[FFmpeg-devel] [PATCH]JPEG two-pass encoding does not work for threads > 1

Carl Eugen Hoyos cehoyos at ag.or.at
Tue Dec 17 11:57:07 CET 2013


Hi!

Two-pass jpeg encoding does not work with threads > 1, attached patch shows an 
error if this is tried.

Please comment, Carl Eugen
-------------- next part --------------
diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index fb9f451..bd2f0e1 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -267,6 +267,12 @@ av_cold int ff_MPV_encode_init(AVCodecContext *avctx)
             av_log(avctx, AV_LOG_ERROR, "colorspace not supported in jpeg\n");
             return -1;
         }
+        if (avctx->thread_count != 1 &&
+            (avctx->flags & CODEC_FLAG_PASS1 ||
+             avctx->flags & CODEC_FLAG_PASS2)) {
+                av_log(avctx, AV_LOG_ERROR, "Jpeg two-pass encoding needs -threads 1\n");
+            return -1;
+        }
         break;
     default:
         if (avctx->pix_fmt != AV_PIX_FMT_YUV420P) {


More information about the ffmpeg-devel mailing list