From 205d3b1d047ec3ede89e0cd981b940ae12044a59 Mon Sep 17 00:00:00 2001 From: Peter Johnson Date: Fri, 23 Dec 2016 22:21:11 -0800 Subject: [PATCH] Some cameras don't provide the JFIF header, so don't require it. This fixes DHT not being inserted on some images. --- src/JpegUtil.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/JpegUtil.cpp b/src/JpegUtil.cpp index 3f754913fc..0e618e9bfb 100644 --- a/src/JpegUtil.cpp +++ b/src/JpegUtil.cpp @@ -58,9 +58,10 @@ bool IsJpeg(llvm::StringRef data) { return false; // Check for valid JPEG header (null terminated JFIF) - if (bytes[2] != 0xff || bytes[3] != 0xe0 || data.substr(6, 4) != "JFIF" || - bytes[10] != 0x00) + if (bytes[2] == 0xff && bytes[3] == 0xe0) { + if (data.substr(6, 4) != "JFIF" || bytes[10] != 0x00) return false; + } return true; }