OSDN Git Service

stagefright-plugins: Fix memory leak
authorKeith Mok <kmok@cyngn.com>
Mon, 14 Mar 2016 18:20:03 +0000 (11:20 -0700)
committerEthan Chen <intervigil@gmail.com>
Tue, 15 Mar 2016 00:05:58 +0000 (16:05 -0800)
AVPacket needs to be unreference after
calling avcodec_decode_video2.
Reference: "ffmpeg/tests/api/api-band-test.c"

CYNGNOS-2239

Change-Id: I0ffb7c95addc32cb49c070d95a8d7cc950646360

omx/SoftFFmpegAudio.cpp
omx/SoftFFmpegVideo.cpp

index b43fd81..11c6bd9 100644 (file)
@@ -1096,6 +1096,8 @@ int32_t SoftFFmpegAudio::decodeAudio() {
     av_frame_unref(mFrame);
 
     len = avcodec_decode_audio4(mCtx, mFrame, &gotFrm, &pkt);
+    av_packet_unref(&pkt);
+
     //a negative error code is returned if an error occurred during decoding
     if (len < 0) {
         ALOGW("ffmpeg audio decoder err, we skip the frame and play silence instead");
index dca4e14..4e1d348 100644 (file)
@@ -475,6 +475,7 @@ int32_t SoftFFmpegVideo::decodeVideo() {
     av_frame_unref(mFrame);
 
     err = avcodec_decode_video2(mCtx, mFrame, &gotPic, &pkt);
+    av_packet_unref(&pkt);
 
     if (err < 0) {
         ALOGE("ffmpeg video decoder failed to decode frame. (%d)", err);