[FFmpeg-cvslog] pthread_frame: use av_buffer_replace() to simplify code

Anton Khirnov git at videolan.org
Mon Sep 28 12:48:49 EEST 2020


ffmpeg | branch: master | Anton Khirnov <anton at khirnov.net> | Fri Jun  5 11:24:19 2020 +0200| [56ff01e6ec915963b467d3d2d488e400f67f46a3] | committer: Anton Khirnov

pthread_frame: use av_buffer_replace() to simplify code

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=56ff01e6ec915963b467d3d2d488e400f67f46a3
---

 libavcodec/pthread_frame.c | 13 +++----------
 1 file changed, 3 insertions(+), 10 deletions(-)

diff --git a/libavcodec/pthread_frame.c b/libavcodec/pthread_frame.c
index 3255aa9337..f8a01ad8cd 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) {



More information about the ffmpeg-cvslog mailing list