Added bypass routine(JpegDecoder) when failed to get subsampling in JpegTurboDecoder
authorJungYumin <y_m.jung@samsung.com>
Fri, 12 Apr 2013 03:43:35 +0000 (12:43 +0900)
committerJungYumin <y_m.jung@samsung.com>
Fri, 12 Apr 2013 03:44:34 +0000 (12:44 +0900)
Change-Id: Ifa95feb3fd501774d763a1220a8c8dcd9bf56c34
Signed-off-by: JungYumin <y_m.jung@samsung.com>
CMakeLists.txt
src/FMedia_ImageDecoder.cpp
src/FMedia_JpegDecoder.cpp
src/FMedia_JpegDecoder.h

index 5abb7b6..79f5199 100755 (executable)
@@ -27,6 +27,7 @@ SET (${this_target}_SOURCE_FILES
        src/FMedia_BmpDecoder.cpp
        src/FMedia_PngDecoder.cpp
        src/FMedia_GifDecoder.cpp
+       src/FMedia_JpegDecoder.cpp
        src/FMedia_JpegTurboDecoder.cpp
        src/FMedia_TiffDecoder.cpp
        src/FMedia_WbmpDecoder.cpp
index 7b8b6d4..fd976e4 100644 (file)
@@ -31,6 +31,7 @@
 #include "FMedia_ColorConverter.h"
 #include "FMedia_ImageDecoder.h"
 #include "FMedia_PngDecoder.h"
+#include "FMedia_JpegDecoder.h"
 #include "FMedia_JpegTurboDecoder.h"
 #include "FMedia_GifDecoder.h"
 #include "FMedia_BmpDecoder.h"
@@ -346,6 +347,17 @@ _ImageDecoder::Construct(const Tizen::Base::ByteBuffer& srcBuf,
 
        // Decoder construction
        r = __pDec->Construct((byte*) __pSrcBuf->GetPointer(), __pSrcBuf->GetCapacity(), pixelFormat);
+       // TODO: enhance me. turbo jpeg construction failed.
+       if (IsFailed(r) && __imgFormat == IMG_FORMAT_JPG)
+       {
+               __pDec.reset(new (std::nothrow) _JpegDecoder());
+               SysTryCatch(NID_MEDIA, __pDec.get() != null, r = GetLastResult(), r,
+                       "[%s] Could not create decoder for image format %d.",
+                       GetErrorMessage(r), __imgFormat);
+
+               // Decoder construction
+               r = __pDec->Construct((byte*) __pSrcBuf->GetPointer(), __pSrcBuf->GetCapacity(), pixelFormat);
+       }
        SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagated.", GetErrorMessage(r));
 
        // Get original dimension
index fa9da1f..6474f19 100644 (file)
@@ -23,7 +23,7 @@
 #include <setjmp.h>
 #include <jpeglib.h>
 #include <stdlib.h>
-#include <FMediaTypes.h>
+#include <FMediaImageTypes.h>
 #include <FBaseSysLog.h>
 #include "FMedia_JpegDecoder.h"
 
@@ -147,8 +147,8 @@ CATCH:
        return r;
 }
 
-result
-_JpegDecoder::DecodeN(byte*& outBuf, int& length)
+byte*
+_JpegDecoder::DecodeN(int& length)
 {
        int buffSize = 0;
        int planarSize = 0;
@@ -156,7 +156,7 @@ _JpegDecoder::DecodeN(byte*& outBuf, int& length)
        byte* pReturnBuf = null;
        int outY = 0;
        int outX = 0;
-
+       byte* outBuf = null;
        result r = E_SUCCESS;
 
        // Set decoding option
@@ -312,9 +312,9 @@ _JpegDecoder::DecodeN(byte*& outBuf, int& length)
        }
 
        pReturnBuf = null;
-
+       SetLastResult(E_SUCCESS);
 CATCH:
-       return r;
+       return outBuf;
 }
 
 result
index 45cf227..78945db 100644 (file)
@@ -71,7 +71,7 @@ public:
         * @exception   E_OUT_OF_MEMORY   Memory is insufficient.
         * @exception   E_INVALID_DATA     The data is invalid.
         */
-       virtual result DecodeN(byte*& outBuf, int& length);
+       virtual byte* DecodeN(int& length);
 
        /**
         * Sets the decoding region. @n