mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2025-12-12 18:10:13 +01:00
lavc: free the output packet when encoding failed or produced no output.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user