diff mbox series

[FFmpeg-devel,4/4] pthread_frame: use av_buffer_replace() to simplify code

Message ID 20200605100219.14930-4-anton@khirnov.net
State New
Headers show
Series [FFmpeg-devel,1/4] lavu/buffer: add a convenience function for replacing buffers
Related show

Checks

Context Check Description
andriy/default pending
andriy/make success Make finished
andriy/make_fate success Make fate finished

Commit Message

Anton Khirnov June 5, 2020, 10:02 a.m. UTC
---
 libavcodec/pthread_frame.c | 13 +++----------
 1 file changed, 3 insertions(+), 10 deletions(-)

Comments

Michael Niedermayer June 5, 2020, 9:36 p.m. UTC | #1
On Fri, Jun 05, 2020 at 12:02:19PM +0200, Anton Khirnov wrote:
> ---
>  libavcodec/pthread_frame.c | 13 +++----------
>  1 file changed, 3 insertions(+), 10 deletions(-)
> 

this changes the output from: (it has fewer frames output)

./ffmpeg -i tickets/5522/progressive_q_mediumhd.avi -f framecrc -

i assume the sample is here:
https://trac.ffmpeg.org/raw-attachment/ticket/5522/progressive_q_mediumhd.avi

thx

[...]
Anton Khirnov June 8, 2020, 10:22 a.m. UTC | #2
Quoting Michael Niedermayer (2020-06-05 23:36:47)
> On Fri, Jun 05, 2020 at 12:02:19PM +0200, Anton Khirnov wrote:
> > ---
> >  libavcodec/pthread_frame.c | 13 +++----------
> >  1 file changed, 3 insertions(+), 10 deletions(-)
> > 
> 
> this changes the output from: (it has fewer frames output)
> 
> ./ffmpeg -i tickets/5522/progressive_q_mediumhd.avi -f framecrc -
> 
> i assume the sample is here:
> https://trac.ffmpeg.org/raw-attachment/ticket/5522/progressive_q_mediumhd.avi

Bug in CFHD, fixed by a patch I just sent.
diff mbox series

Patch

diff --git a/libavcodec/pthread_frame.c b/libavcodec/pthread_frame.c
index 601f170447..3626e745f5 100644
--- a/libavcodec/pthread_frame.c
+++ b/libavcodec/pthread_frame.c
@@ -297,16 +297,9 @@  static int update_context_from_thread(AVCodecContext *dst, AVCodecContext *src,
 
         dst->hwaccel_flags = src->hwaccel_flags;
 
-        if (!!dst->internal->pool != !!src->internal->pool ||
-            (dst->internal->pool && dst->internal->pool->data != src->internal->pool->data)) {
-            av_buffer_unref(&dst->internal->pool);
-
-            if (src->internal->pool) {
-                dst->internal->pool = av_buffer_ref(src->internal->pool);
-                if (!dst->internal->pool)
-                    return AVERROR(ENOMEM);
-            }
-        }
+        err = av_buffer_replace(&dst->internal->pool, src->internal->pool);
+        if (err < 0)
+            return err;
     }
 
     if (for_user) {