This is needed so we can stop using the main context for decoding threads.
---
 libavcodec/pthread.c |    6 ++++++
 libavcodec/utils.c   |    4 ++--
 2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/libavcodec/pthread.c b/libavcodec/pthread.c
index 1f601d1..b44065e 100644
--- a/libavcodec/pthread.c
+++ b/libavcodec/pthread.c
@@ -273,6 +273,9 @@ static int ff_frame_thread_init(AVCodecContext *avctx)
         if (!i) {
             p->context = avctx;
             avctx->thread_opaque = p;
+
+            if (avctx->codec->init)
+                avctx->codec->init(p->context);
         } else {
             AVCodecContext *copy = av_malloc(sizeof(AVCodecContext));
 
@@ -460,6 +463,9 @@ static void ff_frame_thread_free(AVCodecContext *avctx)
         }
     }
 
+    if (codec->close)
+        codec->close(fctx->threads->context);
+
     av_freep(&fctx->threads);
     av_free(fctx);
 
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index 466764a..bbee69b 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -856,7 +856,7 @@ int attribute_align_arg avcodec_open(AVCodecContext *avctx, AVCodec *codec)
         }
     }
 
-    if(avctx->codec->init){
+    if(avctx->codec->init && !USE_FRAME_THREADING(avctx)){
         ret = avctx->codec->init(avctx);
         if (ret < 0) {
             av_freep(&avctx->priv_data);
@@ -1002,7 +1002,7 @@ int avcodec_close(AVCodecContext *avctx)
 
     if (ENABLE_THREADS && avctx->thread_opaque)
         avcodec_thread_free(avctx);
-    if (avctx->codec->close)
+    if (avctx->codec->close && !USE_FRAME_THREADING(avctx))
         avctx->codec->close(avctx);
     avcodec_default_free_buffers(avctx);
     av_freep(&avctx->priv_data);
_______________________________________________
FFmpeg-soc mailing list
[email protected]
https://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-soc

Reply via email to