summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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 349136ef9e..a9d0e3f66a 100644
--- a/libavcodec/mpeg12enc.c
+++ b/libavcodec/mpeg12enc.c
@@ -139,9 +139,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 3ba5c665ad..96a7643f6a 100644
--- a/libavcodec/pthread_slice.c
+++ b/libavcodec/pthread_slice.c
@@ -186,6 +186,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)