[FFmpeg-devel] [PATCH] Runtime detection for the number of processors/cores

Stefano Sabatini stefano.sabatini-lala
Wed May 21 12:06:48 CEST 2008


On date Wednesday 2008-05-21 10:51:20 +0200, Philipp Meinen encoded:
> Hello FFmpeg Team
> 
> The attached patch is an attempt to allow runtime detection for the
> number of online processors/cores instead of having to specify the
> number of threads. The idea is to type:
>     ffmpeg -threads 0 ....
> to use as many threads as processors/cores are online.
> 
> I guess cmdutils.c/h is not the right file to place the new
> detection function. To which file should this function belong?

I think a better place could be libavutil/utils.c,
av_get_processor_{num|nb}. 

> 
> Comments welcome :)
> 
> Regards, Philipp

> Index: ffmpeg.c
> ===================================================================
> --- ffmpeg.c	(revision 13199)
> +++ ffmpeg.c	(working copy)
> @@ -2503,10 +2503,13 @@
>      top_field_first= atoi(arg);
>  }
>  
> -static void opt_thread_count(const char *arg)
> +static void opt_thread_count(const char *opt, const char *arg)

static int, return 0, and this change maybe should go into a separate
propedeutic patch.

[...]
> Index: cmdutils.h
> ===================================================================
> --- cmdutils.h	(revision 13199)
> +++ cmdutils.h	(working copy)
> @@ -120,4 +120,11 @@
>   */
>  void show_license(void);
>  
> +/**
> + * Runtime detection for the number of processors/cores.

The first phrase should be a complete sentence describing what the
function does, e.g. in this case:
"Detects at runtime the number of processors/cores."

> + * @return The detected number of processors/cores
> + * or 1 if no runtime detection is available.
> + */
> +long get_num_processors(void);
> +
>  #endif /* FFMPEG_CMDUTILS_H */

Regards.
-- 
FFmpeg = Fantastic and Funny Minimal Picky EniGma




More information about the ffmpeg-devel mailing list