[FFmpeg-devel] [PATCH] simplify dnxhd threading

Baptiste Coudurier baptiste.coudurier
Fri Sep 25 19:51:36 CEST 2009


On 09/25/2009 09:30 AM, Reimar D?ffinger wrote:
> Hello,
> attached patch changes dnxhd encoder to create one task per slice
> instead of one per thread.
> Since the overhead of having more tasks (max is 64 or so anyway) is
> minimal, this causes no slowdown, but allows removing of the outer loops
> of several functions and more simplifications (and also gets rid of the
> error of -threads is>  than number of slices).
> It also means that e.g. on a system with two very differently loaded
> CPUs and using only two threads, each thread will dynamically process as
> much as it can, instead of one thread being idle while the other one has
> barely started processing.
> I have tested it to not be slower as the original code, but that test
> was probably useless since with the options I used encoding did not get
> any faster using threads...
>
> [...]
>
>       ctx->thread[0] = ctx;
> -    for (i = 1; i<  avctx->thread_count; i++) {
> +    for (i = 1; i<  ctx->m.mb_height; i++) {
>           ctx->thread[i] =  av_malloc(sizeof(DNXHDEncContext));
>           memcpy(ctx->thread[i], ctx, sizeof(DNXHDEncContext));
>       }
>
> [...]
 >
>       return 0;
> Index: libavcodec/dnxhdenc.h
> ===================================================================
> --- libavcodec/dnxhdenc.h	(revision 20013)
> +++ libavcodec/dnxhdenc.h	(working copy)
> @@ -38,6 +38,8 @@
>       int bits;
>   } RCEntry;
>
> +#define MAX_SLICES (1088 / 16)
> +
>   typedef struct DNXHDEncContext {
>       MpegEncContext m; ///<  Used for quantization dsp functions
>
> @@ -47,7 +49,7 @@
>       uint8_t *msip; ///<  Macroblock Scan Indexes Payload
>       uint32_t *slice_size;
>
> -    struct DNXHDEncContext *thread[MAX_THREADS];
> +    struct DNXHDEncContext *thread[MAX_SLICES];
>

68 contexts, even when not using threads ? I'm concerned about memory.

I'd like to see extended benchmarks with 8+ threads before considering 
it, if it's not faster, I don't really see the point.

-- 
Baptiste COUDURIER
Key fingerprint                 8D77134D20CC9220201FC5DB0AC9325C5C1ABAAA
FFmpeg maintainer                                  http://www.ffmpeg.org



More information about the ffmpeg-devel mailing list