[FFmpeg-cvslog] libavcodec/pthread_frame: remove duplicate pointers

Yu Yang git at videolan.org
Mon Jan 3 21:42:38 EET 2022


ffmpeg | branch: master | Yu Yang <yuyang14 at kuaishou.com> | Wed Dec 15 10:17:02 2021 +0800| [5e2a1f1e7db630d547e89988414499ea788bd68e] | committer: Anton Khirnov

libavcodec/pthread_frame: remove duplicate pointers

'*src' and '*avctx' point to the same memory. It is enough to keep one of them.

Signed-off-by: Yu Yang <yuyang14 at kuaishou.com>
Signed-off-by: Anton Khirnov <anton at khirnov.net>

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

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

diff --git a/libavcodec/pthread_frame.c b/libavcodec/pthread_frame.c
index 73b1b7d7d9..85a6bc98c1 100644
--- a/libavcodec/pthread_frame.c
+++ b/libavcodec/pthread_frame.c
@@ -765,14 +765,14 @@ void ff_frame_thread_free(AVCodecContext *avctx, int thread_count)
 
 static av_cold int init_thread(PerThreadContext *p, int *threads_to_free,
                                FrameThreadContext *fctx, AVCodecContext *avctx,
-                               AVCodecContext *src, const AVCodec *codec, int first)
+                               const AVCodec *codec, int first)
 {
     AVCodecContext *copy;
     int err;
 
     atomic_init(&p->state, STATE_INPUT_READY);
 
-    copy = av_memdup(src, sizeof(*src));
+    copy = av_memdup(avctx, sizeof(*avctx));
     if (!copy)
         return AVERROR(ENOMEM);
     copy->priv_data = NULL;
@@ -784,7 +784,7 @@ static av_cold int init_thread(PerThreadContext *p, int *threads_to_free,
     p->parent = fctx;
     p->avctx  = copy;
 
-    copy->internal = av_memdup(src->internal, sizeof(*src->internal));
+    copy->internal = av_memdup(avctx->internal, sizeof(*avctx->internal));
     if (!copy->internal)
         return AVERROR(ENOMEM);
     copy->internal->thread_ctx = p;
@@ -798,7 +798,7 @@ static av_cold int init_thread(PerThreadContext *p, int *threads_to_free,
 
         if (codec->priv_class) {
             *(const AVClass **)copy->priv_data = codec->priv_class;
-            err = av_opt_copy(copy->priv_data, src->priv_data);
+            err = av_opt_copy(copy->priv_data, avctx->priv_data);
             if (err < 0)
                 return err;
         }
@@ -843,7 +843,6 @@ int ff_frame_thread_init(AVCodecContext *avctx)
 {
     int thread_count = avctx->thread_count;
     const AVCodec *codec = avctx->codec;
-    AVCodecContext *src = avctx;
     FrameThreadContext *fctx;
     int err, i = 0;
 
@@ -876,7 +875,7 @@ int ff_frame_thread_init(AVCodecContext *avctx)
     fctx->delaying = 1;
 
     if (codec->type == AVMEDIA_TYPE_VIDEO)
-        avctx->delay = src->thread_count - 1;
+        avctx->delay = avctx->thread_count - 1;
 
     fctx->threads = av_calloc(thread_count, sizeof(*fctx->threads));
     if (!fctx->threads) {
@@ -888,7 +887,7 @@ int ff_frame_thread_init(AVCodecContext *avctx)
         PerThreadContext *p  = &fctx->threads[i];
         int first = !i;
 
-        err = init_thread(p, &i, fctx, avctx, src, codec, first);
+        err = init_thread(p, &i, fctx, avctx, codec, first);
         if (err < 0)
             goto error;
     }



More information about the ffmpeg-cvslog mailing list