[FFmpeg-devel] [PATCH 1/3] thread 0 not working for mpeg4

Måns Rullgård mans
Tue Sep 21 19:21:54 CEST 2010


"Richard Buteau" <rbuteau at rgbnetworks.com> writes:

> 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;
> +       }

Eh what?

> +       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 )

Most desktop systems have 2 or 4 real cores with hyperthreading
doubling the number of virtual cores.  Running 16 threads on these
systems is not a good idea.

-- 
M?ns Rullg?rd
mans at mansr.com



More information about the ffmpeg-devel mailing list