diff options
author | Anton Khirnov <anton@khirnov.net> | 2012-02-24 13:14:02 +0100 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2012-03-03 06:31:41 +0100 |
commit | 7fb6c9225c309c55b85f6974627e26976817bff5 (patch) | |
tree | 1a4afa03fc8bd6e07674b54e860645147a1e3084 /libavcodec/utils.c | |
parent | e42e9b0e4d3eb8b2c9b5e1791344f211b590040c (diff) | |
download | ffmpeg-7fb6c9225c309c55b85f6974627e26976817bff5.tar.gz |
lavc: free the output packet when encoding failed or produced no output.
Diffstat (limited to 'libavcodec/utils.c')
-rw-r--r-- | libavcodec/utils.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/libavcodec/utils.c b/libavcodec/utils.c index a91eab1ac1..f9927a1383 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -864,6 +864,7 @@ int attribute_align_arg avcodec_encode_audio2(AVCodecContext *avctx, *got_packet_ptr = 0; if (!(avctx->codec->capabilities & CODEC_CAP_DELAY) && !frame) { + av_free_packet(avpkt); av_init_packet(avpkt); avpkt->size = 0; return 0; @@ -962,6 +963,9 @@ int attribute_align_arg avcodec_encode_audio2(AVCodecContext *avctx, if (!ret) avctx->frame_number++; + if (ret < 0 || !*got_packet_ptr) + av_free_packet(avpkt); + /* NOTE: if we add any audio encoders which output non-keyframe packets, this needs to be moved to the encoders, but for now we can do it here to simplify things */ @@ -1095,6 +1099,7 @@ int attribute_align_arg avcodec_encode_video2(AVCodecContext *avctx, *got_packet_ptr = 0; if (!(avctx->codec->capabilities & CODEC_CAP_DELAY) && !frame) { + av_free_packet(avpkt); av_init_packet(avpkt); avpkt->size = 0; return 0; @@ -1121,6 +1126,9 @@ int attribute_align_arg avcodec_encode_video2(AVCodecContext *avctx, avctx->frame_number++; } + if (ret < 0 || !*got_packet_ptr) + av_free_packet(avpkt); + emms_c(); return ret; } |