Fix for libjpeg API changes 68/60168/4
authorminho.sun <minho.sun@samsung.com>
Wed, 24 Feb 2016 02:24:43 +0000 (11:24 +0900)
committerTom Robinson <tom.robinson@samsung.com>
Wed, 23 Mar 2016 10:50:20 +0000 (03:50 -0700)
TurboJPEG API functions will now return an error code if a warning is triggered in the underlying libjpeg API.

For instance, if a JPEG file is corrupt, the TurboJPEG decompression functions will attempt to decompress as much of the image as possible, but those functions will now return -1 to indicate that the decompression was not entirely successful.

For this reason, we need to distinguish return of tjGetErrorStr() is warning or error.

If the return string has 'Corrupt JPEG data' prefix, it means warning.
Then, do not return false.

Change-Id: Ib542f2365c0e35c14187e3daa7e32008296c26bb

platform-abstractions/tizen/image-loaders/loader-jpeg-turbo.cpp

index b567b6a..33826b8 100755 (executable)
@@ -332,8 +332,21 @@ bool LoadBitmapFromJpeg( const ResourceLoadingClient& client, const ImageLoader:
 
   if( tjDecompress2( autoJpg.GetHandle(), jpegBufferPtr, jpegBufferSize, bitmapPixelBuffer, scaledPreXformWidth, 0, scaledPreXformHeight, DECODED_PIXEL_LIBJPEG_TYPE, flags ) == -1 )
   {
-    DALI_LOG_ERROR("%s\n", tjGetErrorStr());
-    return false;
+    std::string errorString = tjGetErrorStr();
+
+    if( errorString.find("Corrupt JPEG data") == std::string::npos )
+    {
+        DALI_LOG_ERROR("%s\n", errorString.c_str());
+        return false;
+    }
+    else
+    {
+        DALI_LOG_WARNING("%s\n", errorString.c_str());
+    }
+
+    //TurboJPEG API functions will now return an error code if a warning is triggered in the underlying libjpeg API.
+    //So, we need to distinguish return of tjGetErrorStr() is warning or error.
+    //If the return string has 'Corrupt JPEG data' prefix, it means warning.
   }
 
   const unsigned int  bufferWidth  = GetTextureDimension( scaledPreXformWidth );