Fixed prevent defect
authorJungYumin <y_m.jung@samsung.com>
Tue, 2 Apr 2013 04:42:58 +0000 (13:42 +0900)
committerJungYumin <y_m.jung@samsung.com>
Tue, 2 Apr 2013 04:53:36 +0000 (13:53 +0900)
Change-Id: Ic25674980249dc4dd668f59026ee1694c8083424
Signed-off-by: JungYumin <y_m.jung@samsung.com>
src/FMedia_AacDecoder.cpp
src/FMedia_AacEncoder.cpp

index d821fa1..b1c3d03 100644 (file)
@@ -150,8 +150,7 @@ _AacDecoder::Construct(const Tizen::Base::Collection::HashMap* pOption)
 
        __pOutBuf = new (std::nothrow) byte[DEFAULT_BUFFER_SIZE];
        SysTryCatch(NID_MEDIA, __pOutBuf != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
-                          "[%s] Memory Allocation  Failed ",GetErrorMessage(E_OUT_OF_MEMORY)); 
-
+                          "[%s] Memory Allocation  Failed ",GetErrorMessage(E_OUT_OF_MEMORY));
 
        return r;
 
@@ -267,21 +266,15 @@ _AacDecoder::Decode(const byte* pSrcBuf, int srcBufSize, int& srcBufUsed,
                srcBufUsed = res; //Input bytes used            
        }
 
-       if (gotFrame)
-       {
-               outBufSize = av_samples_get_buffer_size(NULL, __pCodecCtx->channels, pOutFrame->nb_samples, __pCodecCtx->sample_fmt, 1);
+       outBufSize = av_samples_get_buffer_size(NULL, __pCodecCtx->channels, pOutFrame->nb_samples, __pCodecCtx->sample_fmt, 1);
 
-               SysTryReturnResult(NID_MEDIA, dstBufSize >= outBufSize, E_OUT_OF_MEMORY, "pDstBuf(%d) is smaller than decoded data(%d)", dstBufSize, outBufSize);
+       SysTryReturnResult(NID_MEDIA, dstBufSize >= outBufSize, E_OUT_OF_MEMORY, "pDstBuf(%d) is smaller than decoded data(%d)", dstBufSize, outBufSize);
 
-               dstBufUsed = outBufSize; // The decoded audio data size
-               memcpy(pDstBuf, pOutFrame->data[0], outBufSize);
-       }
-       else
-       {
-               dstBufUsed = 0;
-       }
+       dstBufUsed = outBufSize; // The decoded audio data size
+       memcpy(pDstBuf, pOutFrame->data[0], outBufSize);
 
        __decodeCalled = true;
+
        return E_SUCCESS;
 }
 
index 058b48f..6ba3e9b 100644 (file)
@@ -199,9 +199,8 @@ _AacEncoder::Encode(const byte* srcBuf, int srcBufSize, int &srcBufUsed, byte* d
        int samples = 0;
        int minSrcBufLength = 0;
        int minDstBufLength = FF_MIN_BUFFER_SIZE;
-       AVPacket outPacket;
-       outPacket.data = null;
        int gotOutput = 0;
+       AVPacket outPacket;
 
        SysTryReturnResult(NID_MEDIA, __pCodecCtx, E_INVALID_STATE, "not constructed");
 
@@ -253,6 +252,7 @@ _AacEncoder::Encode(const byte* srcBuf, int srcBufSize, int &srcBufUsed, byte* d
                av_init_packet(&outPacket);
                outPacket.data = NULL;
                outPacket.size = 0;
+               outPacket.priv = NULL;
 
                res = avcodec_encode_audio2(__pCodecCtx, &outPacket, __pInputFrame, &gotOutput);