[FFmpeg-cvslog] avcodec/mpeg12enc: Move high resolution thread check to before initializing threads

Michael Niedermayer git at videolan.org
Mon Feb 1 02:35:24 CET 2016


ffmpeg | branch: release/2.4 | Michael Niedermayer <michael at niedermayer.cc> | Thu Jan 21 00:36:51 2016 +0100| [0732e7b0eab4bbb7af3861fb1630aff3bcdd6082] | committer: Michael Niedermayer

avcodec/mpeg12enc: Move high resolution thread check to before initializing threads

Cleaner solution is welcome!

Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
(cherry picked from commit a53fbda9dc92273054a103db7539d2bb6e9632b2)

Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>

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

 libavcodec/mpeg12enc.c     |    3 ---
 libavcodec/pthread_slice.c |    6 ++++++
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/libavcodec/mpeg12enc.c b/libavcodec/mpeg12enc.c
index b94af14..0e2f2a9 100644
--- a/libavcodec/mpeg12enc.c
+++ b/libavcodec/mpeg12enc.c
@@ -144,9 +144,6 @@ static av_cold int encode_init(AVCodecContext *avctx)
 {
     MpegEncContext *s = avctx->priv_data;
 
-    if (avctx->codec_id == AV_CODEC_ID_MPEG1VIDEO && avctx->height > 2800)
-        avctx->thread_count = 1;
-
     if (ff_mpv_encode_init(avctx) < 0)
         return -1;
 
diff --git a/libavcodec/pthread_slice.c b/libavcodec/pthread_slice.c
index fea989f..4fcbcb1 100644
--- a/libavcodec/pthread_slice.c
+++ b/libavcodec/pthread_slice.c
@@ -181,6 +181,12 @@ int ff_slice_thread_init(AVCodecContext *avctx)
     w32thread_init();
 #endif
 
+    // We cannot do this in the encoder init as the threads are created before
+    if (av_codec_is_encoder(avctx->codec) &&
+        avctx->codec_id == AV_CODEC_ID_MPEG1VIDEO &&
+        avctx->height > 2800)
+        thread_count = avctx->thread_count = 1;
+
     if (!thread_count) {
         int nb_cpus = av_cpu_count();
         if  (avctx->height)



More information about the ffmpeg-cvslog mailing list