]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/frame_thread_encoder.c
Merge commit '91be8df20b57a18307e90f1c4886a35ea7b28880'
[ffmpeg] / libavcodec / frame_thread_encoder.c
index b9acefc1101bd89b29a32f6fb2cbadeea41bda72..786599679decaaf4eb0cd1e1468655b8decf82d7 100644 (file)
@@ -125,6 +125,20 @@ int ff_frame_thread_encoder_init(AVCodecContext *avctx, AVDictionary *options){
        || !(avctx->codec->capabilities & CODEC_CAP_INTRA_ONLY))
         return 0;
 
+    if(   !avctx->thread_count
+       && avctx->codec_id == AV_CODEC_ID_MJPEG
+       && !(avctx->flags & CODEC_FLAG_QSCALE)) {
+        av_log(avctx, AV_LOG_DEBUG,
+               "Forcing thread count to 1 for MJPEG encoding, use -thread_type slice "
+               "or a constant quantizer if you want to use multiple cpu cores\n");
+        avctx->thread_count = 1;
+    }
+    if(   avctx->thread_count > 1
+       && avctx->codec_id == AV_CODEC_ID_MJPEG
+       && !(avctx->flags & CODEC_FLAG_QSCALE))
+        av_log(avctx, AV_LOG_WARNING,
+               "MJPEG CBR encoding works badly with frame multi-threading, consider "
+               "using -threads 1, -thread_type slice or a constant quantizer.\n");
     if(!avctx->thread_count) {
         avctx->thread_count = av_cpu_count();
         avctx->thread_count = FFMIN(avctx->thread_count, MAX_THREADS);
@@ -133,6 +147,13 @@ int ff_frame_thread_encoder_init(AVCodecContext *avctx, AVDictionary *options){
     if(avctx->thread_count <= 1)
         return 0;
 
+    if (avctx->codec_id == AV_CODEC_ID_HUFFYUV ||
+        avctx->codec_id == AV_CODEC_ID_FFVHUFF) {
+        // huffyuv doesnt support these with multiple frame threads currently
+        if (avctx->context_model > 0 || (avctx->flags & CODEC_FLAG_PASS1))
+            return 0;
+    }
+
     if(avctx->thread_count > MAX_THREADS)
         return AVERROR(EINVAL);