[3.0]Fix for libjpeg API changes 84/62384/3 accepted/tizen/common/20160323.184854 accepted/tizen/ivi/20160323.140643 accepted/tizen/mobile/20160323.135032 accepted/tizen/tv/20160323.135447 accepted/tizen/wearable/20160323.135146 submit/tizen/20160323.065919
authorminho.sun <minho.sun@samsung.com>
Wed, 24 Feb 2016 02:24:43 +0000 (11:24 +0900)
committerminho.sun <minho.sun@samsung.com>
Wed, 23 Mar 2016 05:13:32 +0000 (14:13 +0900)
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..7e81375 100755 (executable)
@@ -332,8 +332,20 @@ 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();
+
+    //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.
+    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());
+    }
   }
 
   const unsigned int  bufferWidth  = GetTextureDimension( scaledPreXformWidth );