diff mbox series

[FFmpeg-devel,1/3] avcodec/decode: fetch packets from the pkt_props FIFO on every frame returned

Message ID 20210618220213.52768-1-jamrial@gmail.com
State Accepted
Commit a4fb03563ab918bf9641365d08b4363590ced1eb
Headers show
Series [FFmpeg-devel,1/3] avcodec/decode: fetch packets from the pkt_props FIFO on every frame returned | expand

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate success Make fate finished

Commit Message

James Almer June 18, 2021, 10:02 p.m. UTC
Fixes memleaks on decoders that don't call ff_decode_frame_props().

Signed-off-by: James Almer <jamrial@gmail.com>
---
 libavcodec/decode.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

James Almer June 21, 2021, 1:17 p.m. UTC | #1
On 6/18/2021 7:02 PM, James Almer wrote:
> Fixes memleaks on decoders that don't call ff_decode_frame_props().
> 
> Signed-off-by: James Almer <jamrial@gmail.com>
> ---
>   libavcodec/decode.c | 8 ++++----
>   1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/libavcodec/decode.c b/libavcodec/decode.c
> index 75bc7ad98e..44f0b11546 100644
> --- a/libavcodec/decode.c
> +++ b/libavcodec/decode.c
> @@ -533,6 +533,10 @@ static int decode_receive_frame_internal(AVCodecContext *avctx, AVFrame *frame)
>       if (ret == AVERROR_EOF)
>           avci->draining_done = 1;
>   
> +    if (IS_EMPTY(avci->last_pkt_props) && av_fifo_size(avci->pkt_props) >= sizeof(*avci->last_pkt_props))
> +        av_fifo_generic_read(avci->pkt_props,
> +                             avci->last_pkt_props, sizeof(*avci->last_pkt_props), NULL);
> +
>       if (!ret) {
>           frame->best_effort_timestamp = guess_correct_pts(avctx,
>                                                            frame->pts,
> @@ -1490,10 +1494,6 @@ int ff_decode_frame_props(AVCodecContext *avctx, AVFrame *frame)
>           { AV_PKT_DATA_S12M_TIMECODE,              AV_FRAME_DATA_S12M_TIMECODE },
>       };
>   
> -    if (IS_EMPTY(pkt) && av_fifo_size(avctx->internal->pkt_props) >= sizeof(*pkt))
> -        av_fifo_generic_read(avctx->internal->pkt_props,
> -                             pkt, sizeof(*pkt), NULL);
> -
>       frame->pts = pkt->pts;
>       frame->pkt_pos      = pkt->pos;
>       frame->pkt_duration = pkt->duration;

Will apply set.
diff mbox series

Patch

diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index 75bc7ad98e..44f0b11546 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -533,6 +533,10 @@  static int decode_receive_frame_internal(AVCodecContext *avctx, AVFrame *frame)
     if (ret == AVERROR_EOF)
         avci->draining_done = 1;
 
+    if (IS_EMPTY(avci->last_pkt_props) && av_fifo_size(avci->pkt_props) >= sizeof(*avci->last_pkt_props))
+        av_fifo_generic_read(avci->pkt_props,
+                             avci->last_pkt_props, sizeof(*avci->last_pkt_props), NULL);
+
     if (!ret) {
         frame->best_effort_timestamp = guess_correct_pts(avctx,
                                                          frame->pts,
@@ -1490,10 +1494,6 @@  int ff_decode_frame_props(AVCodecContext *avctx, AVFrame *frame)
         { AV_PKT_DATA_S12M_TIMECODE,              AV_FRAME_DATA_S12M_TIMECODE },
     };
 
-    if (IS_EMPTY(pkt) && av_fifo_size(avctx->internal->pkt_props) >= sizeof(*pkt))
-        av_fifo_generic_read(avctx->internal->pkt_props,
-                             pkt, sizeof(*pkt), NULL);
-
     frame->pts = pkt->pts;
     frame->pkt_pos      = pkt->pos;
     frame->pkt_duration = pkt->duration;