Added bypass routine(JpegDecoder) when failed to get subsampling in JpegTurboDecoder
[framework/osp/image-core.git] / src / FMedia_ImageDecoder.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