diff mbox series

[FFmpeg-devel,4/4] fftools/ffmpeg: Remove unnecessary av_packet_unref()

Message ID AM7PR03MB66601D1B66CD11AC4ACEEDC58FB29@AM7PR03MB6660.eurprd03.prod.outlook.com
State Accepted
Commit f1df856fb632c2d14a29cfb1f4a11c4dbb027f89
Headers show
Series [FFmpeg-devel,1/4] avfilter/avfiltergraph: Fix use-after-free when inserting auto-converter | expand

Checks

Context Check Description
andriy/configurex86 warning Failed to apply patch
andriy/configureppc warning Failed to apply patch

Commit Message

Andreas Rheinhardt Oct. 8, 2021, 8:14 a.m. UTC
avcodec_receive_packet() already unreferences the packet on its own.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 fftools/ffmpeg.c | 3 ---
 1 file changed, 3 deletions(-)

Comments

James Almer Oct. 8, 2021, 12:28 p.m. UTC | #1
On 10/8/2021 5:14 AM, Andreas Rheinhardt wrote:
> avcodec_receive_packet() already unreferences the packet on its own.
> 
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> ---
>   fftools/ffmpeg.c | 3 ---
>   1 file changed, 3 deletions(-)
> 
> diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
> index 0e38d6d185..14611480f1 100644
> --- a/fftools/ffmpeg.c
> +++ b/fftools/ffmpeg.c
> @@ -1033,7 +1033,6 @@ static void do_audio_out(OutputFile *of, OutputStream *ost,
>           goto error;
>   
>       while (1) {
> -        av_packet_unref(pkt);
>           ret = avcodec_receive_packet(enc, pkt);
>           if (ret == AVERROR(EAGAIN))
>               break;
> @@ -1378,7 +1377,6 @@ static void do_video_out(OutputFile *of,
>           av_frame_remove_side_data(in_picture, AV_FRAME_DATA_A53_CC);
>   
>           while (1) {
> -            av_packet_unref(pkt);
>               ret = avcodec_receive_packet(enc, pkt);
>               update_benchmark("encode_video %d.%d", ost->file_index, ost->index);
>               if (ret == AVERROR(EAGAIN))
> @@ -1997,7 +1995,6 @@ static void flush_encoders(void)
>   
>               update_benchmark(NULL);
>   
> -            av_packet_unref(pkt);
>               while ((ret = avcodec_receive_packet(enc, pkt)) == AVERROR(EAGAIN)) {
>                   ret = avcodec_send_frame(enc, NULL);
>                   if (ret < 0) {

Should be ok.
diff mbox series

Patch

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 0e38d6d185..14611480f1 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -1033,7 +1033,6 @@  static void do_audio_out(OutputFile *of, OutputStream *ost,
         goto error;
 
     while (1) {
-        av_packet_unref(pkt);
         ret = avcodec_receive_packet(enc, pkt);
         if (ret == AVERROR(EAGAIN))
             break;
@@ -1378,7 +1377,6 @@  static void do_video_out(OutputFile *of,
         av_frame_remove_side_data(in_picture, AV_FRAME_DATA_A53_CC);
 
         while (1) {
-            av_packet_unref(pkt);
             ret = avcodec_receive_packet(enc, pkt);
             update_benchmark("encode_video %d.%d", ost->file_index, ost->index);
             if (ret == AVERROR(EAGAIN))
@@ -1997,7 +1995,6 @@  static void flush_encoders(void)
 
             update_benchmark(NULL);
 
-            av_packet_unref(pkt);
             while ((ret = avcodec_receive_packet(enc, pkt)) == AVERROR(EAGAIN)) {
                 ret = avcodec_send_frame(enc, NULL);
                 if (ret < 0) {