aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2016-01-21 00:36:51 +0100
committerMichael Niedermayer <michael@niedermayer.cc>2016-01-31 00:23:45 +0100
commit302f11e719cc7fc59960f145b99b1f54a4ba0374 (patch)
tree80c5594db518fcae6b058662ebfaa632e46460e4
parent8c2f006d10c7e8df42d6ee57060bd1ce6ff3298f (diff)
downloadffmpeg-302f11e719cc7fc59960f145b99b1f54a4ba0374.tar.gz
avcodec/mpeg12enc: Move high resolution thread check to before initializing threads
Cleaner solution is welcome! Signed-off-by: Michael Niedermayer <michael@niedermayer.cc> (cherry picked from commit a53fbda9dc92273054a103db7539d2bb6e9632b2) Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
-rw-r--r--libavcodec/mpeg12enc.c3
-rw-r--r--libavcodec/pthread_slice.c6
2 files changed, 6 insertions, 3 deletions
diff --git a/libavcodec/mpeg12enc.c b/libavcodec/mpeg12enc.c
index 5b8c4ecf33..ea3c7843b9 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 c8e69f0a9a..f9fc8042fe 100644
--- a/libavcodec/pthread_slice.c
+++ b/libavcodec/pthread_slice.c
@@ -193,6 +193,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)