jpeg pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=755b290404fa8936c421dc972cf60dc419f5500c

commit 755b290404fa8936c421dc972cf60dc419f5500c
Author: Jean-Philippe Andre <jp.an...@samsung.com>
Date:   Wed Apr 15 10:44:02 2015 +0900

    Emile: Reduce ERR logs on invalid JPEG images
    
    When reading the head of a file, we may get the error that it is
    not a JPEG image (which is normal), so we should not print any ERR.
    
    The JPEG header read function can indeed be called to test whether a
    file can be opened by the JPEG loader or not (any file).
    
    Note that JPEG files don't have reliable magic numbers, so we
    don't check them, but rely on libjpeg instead.
    
    Fixes T2290
---
 src/lib/emile/emile_image.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/src/lib/emile/emile_image.c b/src/lib/emile/emile_image.c
index 9ea4539..dc8af2c 100644
--- a/src/lib/emile/emile_image.c
+++ b/src/lib/emile/emile_image.c
@@ -23,6 +23,7 @@
 #include <stdio.h>
 #include <setjmp.h>
 #include <jpeglib.h>
+#include <jerror.h>
 
 #ifdef HAVE_EVIL
 #include <Evil.h>
@@ -673,8 +674,12 @@ _emile_image_jpeg_error_exit_cb(j_common_ptr cinfo)
    char buffer[JMSG_LENGTH_MAX];
    emptr errmgr;
 
-   (*cinfo->err->format_message)(cinfo, buffer);
-   ERR("%s", buffer);
+   // Avoid message "Not a JPEG file: starts with 0x%02x 0x%02x"
+   if (cinfo->client_data || (cinfo->err->msg_code != JERR_NO_SOI))
+     {
+        (*cinfo->err->format_message)(cinfo, buffer);
+        ERR("%s", buffer);
+     }
    errmgr = (emptr)cinfo->err;
    longjmp(errmgr->setjmp_buffer, 1);
 }
@@ -1352,6 +1357,7 @@ _emile_jpeg_head(Emile_Image *image,
 
    memset(&cinfo, 0, sizeof(cinfo));
    cinfo.err = jpeg_std_error(&(jerr.pub));
+   cinfo.client_data = NULL;
    jerr.pub.error_exit = _emile_image_jpeg_error_exit_cb;
    jerr.pub.emit_message = _emile_image_jpeg_emit_message_cb;
    jerr.pub.output_message = _emile_image_jpeg_output_message_cb;
@@ -1610,6 +1616,7 @@ _emile_jpeg_data(Emile_Image *image,
      }
 
    cinfo.err = jpeg_std_error(&(jerr.pub));
+   cinfo.client_data = (void *)(intptr_t) 0x1;
    jerr.pub.error_exit = _emile_image_jpeg_error_exit_cb;
    jerr.pub.emit_message = _emile_image_jpeg_emit_message_cb;
    jerr.pub.output_message = _emile_image_jpeg_output_message_cb;

-- 


Reply via email to