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

Richard Buteau rbuteau
Tue Sep 21 21:08:53 CEST 2010



-----Original Message-----
From: ffmpeg-devel-bounces at mplayerhq.hu [mailto:ffmpeg-devel-bounces at mplayerhq.hu] On Behalf Of M?ns Rullg?rd
Sent: Tuesday, September 21, 2010 12:22 PM
To: FFmpeg development discussions and patches
Subject: Re: [FFmpeg-devel] [PATCH 1/3] thread 0 not working for mpeg4

"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?
--------------
RB: The number of threads is limited by the height in macro block. L449 in MPV_common_init.c

> +       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.
--------------
RB: Thread 0 is not working at all for these codec. If the user want to stick to 4 cores he can always specify -thread 4. Running 16 threads on a 2/4 core system will be faster than the default of 1. Isn't partial support is better than none?
Is there cpu/core count detection in ffmpeg other than the one for x264?

-- 
M?ns Rullg?rd
mans at mansr.com
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel at mplayerhq.hu
https://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-devel



More information about the ffmpeg-devel mailing list