[FFmpeg-devel] [RFC] threading API

Reimar Döffinger Reimar.Doeffinger
Tue Oct 6 09:17:30 CEST 2009

On Tue, Oct 06, 2009 at 09:01:15AM +0200, Reimar D?ffinger wrote:
> The later is only a very minor optimization, and if a API change should
> be avoided by all means, the former can be achieved also by adding to
> AVCodecContext a set_thread_number callback, that if set is executed
> each time before the main worker function with the same void *arg, i.e.
> void (*set_thread_number)(struct AVCodecContext *c, void *arg, int thread)
> So, what are the opinions? Other ideas?

Actually, a better idea: add a
void *(get_worker_arg)(struct AVCodecContext *c, void *arg_array, int arg_size,
int arg_elem_size, int jobnr, int threadnr)
where the arg_ stuff matches with the avctx->execute (arg2, count, size)
The default implementation would then be
return (char*)arg_array + jobnr*arg_elem_size;
whereas dnxhdenc would use something like
DNXHDContext *c = ((DNXHDContext **)arg_array)[threadnr];
c->start_slice = jobnr;
return c;

More information about the ffmpeg-devel mailing list