merge with master
[framework/osp/image-core.git] / src / FMedia_BmpDecoder.cpp
old mode 100644 (file)
new mode 100755 (executable)
index d671d32..b40cea0
@@ -65,18 +65,15 @@ _BmpDecoder::OpenCodec(void)
        result r = E_SUCCESS;
        int res = 0;
 
-       //avcodec_init();
        avcodec_register_all();
 
-       __pCodecCtx = avcodec_alloc_context();
-       SysTryCatch(NID_MEDIA, __pCodecCtx != null, r = E_SYSTEM, E_SYSTEM,
-                          "[E_SYSTEM] avcodec context allocation failed.");
-
        __pCodec = avcodec_find_decoder(CODEC_ID_BMP);
-       SysTryCatch(NID_MEDIA, __pCodec != null, r = E_SYSTEM, E_SYSTEM,
-                          "[E_SYSTEM] Failed to find bmp decoder.");
+       SysTryReturnResult(NID_MEDIA, __pCodec != null, E_UNSUPPORTED_CODEC, "Failed to find bmp decoder.");
+
+       __pCodecCtx = avcodec_alloc_context3(__pCodec);
+       SysTryReturnResult(NID_MEDIA, __pCodecCtx != null, E_OUT_OF_MEMORY, "context allocation failed.");
 
-       res = avcodec_open(__pCodecCtx, __pCodec);
+       res = avcodec_open2(__pCodecCtx, __pCodec, null);
        SysTryCatch(NID_MEDIA, res >= 0, r = E_SYSTEM, E_SYSTEM,
                           "[E_SYSTEM] Failed to open bmp decoder.");
 
@@ -223,28 +220,20 @@ _BmpDecoder::SetDecodingRegion(int x, int y, int width, int height)
 result
 _BmpDecoder::GetDimension(int& width, int& height)
 {
-       result r = E_SUCCESS;
+       SysTryReturnResult(NID_MEDIA, __pCodecCtx, E_INVALID_STATE, "Not Constructed.");
 
-       SysTryCatch(NID_MEDIA, __pCodecCtx, r = E_INVALID_STATE,
-                          E_INVALID_STATE, "[E_INVALID_STATE] Not Constructed.");
+       SysTryReturnResult(NID_MEDIA, __pCodecCtx->width > 0 && __pCodecCtx->height > 0, E_INVALID_STATE,
+                       "Invalid dimensions : (%d x %d)", __pCodecCtx->width, __pCodecCtx->height);
 
        width = __pCodecCtx->width;
        height = __pCodecCtx->height;
 
-       if ((width <= 0) || (height <= 0))
-       {
-               SysLog(NID_MEDIA, "Invalid dimensions! Should be greater than zero : (%d x %d)", width, height);
-               r = E_SYSTEM;
-       }
-
-CATCH:
-       return r;
+       return E_SUCCESS;
 }
 
 MediaPixelFormat
 _BmpDecoder::GetPixelFormat(void)
 {
-       result r = E_SUCCESS;
        MediaPixelFormat pixel_format = MEDIA_PIXEL_FORMAT_NONE;
 
        SysTryReturn(NID_MEDIA, __pCodecCtx, pixel_format, E_INVALID_STATE,