[FFmpeg-devel] [PATCH 1/3] thread 0 not working for mpeg4
Richard Buteau
rbuteau
Tue Sep 21 19:15:30 CEST 2010
Hi all,
Here is a patch to get -thread 0 to work for mpeg4 and other mpeg codec.
Let me know if this acceptable.
Richard
diff -uNr -x .svn -x '*.d' ffmpeg/libavcodec/mpegvideo_enc.c
ffmpeg.thread0/libavcodec/mpegvideo_enc.c
--- ffmpeg/libavcodec/mpegvideo_enc.c 2010-09-14 13:04:02.000000000
-0500
+++ ffmpeg.thread0/libavcodec/mpegvideo_enc.c 2010-09-21
10:25:19.000000000 -0500
@@ -466,10 +466,23 @@
av_log(avctx, AV_LOG_ERROR, "multi threaded encoding not
supported by codec\n");
return -1;
}
-
- if(s->avctx->thread_count < 1){
- av_log(avctx, AV_LOG_ERROR, "automatic thread number detection
not supported by codec, patch welcome\n");
- return -1;
+ if(s->avctx->thread_count < 1)
+ {
+ if (!s->mb_height)
+ {
+ //from MPV_common_init
+ if(s->codec_id == CODEC_ID_MPEG2VIDEO &&
!s->progressive_sequence)
+ s->mb_height = (s->height + 31) / 32 * 2;
+ else
+ s->mb_height = (s->height + 15) / 16;
+ }
+ s->avctx->thread_count=s->mb_height;
+ // assuming most system are multi-core core by now running 16
threads on a 6-12 cores overhead should be minimal anyway (better than
running 1 )
+ if (s->avctx->thread_count>MAX_THREADS)
+ {
+ s->avctx->thread_count=MAX_THREADS;
+ }
+ av_log(s->avctx, AV_LOG_INFO, "Started %d thread(s)
(s->mb_height:%d) s->height:%d :s->avctx->height%d\n",
s->avctx->thread_count, s->mb_height, s->height, s->avctx->height);
}
if(s->avctx->thread_count > 1)
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: thread0.patch.txt
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20100921/04d960d9/attachment.txt>
More information about the ffmpeg-devel
mailing list