[FFmpeg-devel] [RFC] execute2/simplify dnxhdenc threading

Reimar Döffinger Reimar.Doeffinger
Mon Oct 12 14:05:17 CEST 2009


On Mon, Oct 12, 2009 at 08:52:29AM +0200, Michael Niedermayer wrote:
> On Sat, Oct 10, 2009 at 05:08:35PM +0200, Reimar D?ffinger wrote:
> > Hello,
> > this is my second try to simplify dnxhdenc and also change the code so
> > that number of jobs/tasks > number of threads, avoiding performance
> > issues if not all threads finish with the same speed.
> > Obviously execute2 must be implemented for the other thread
> > implementations, too, and dnxhdenc can probably be further simplified
> > (in particular, I doubt that setting start_mb_y and end_mb_y is actually
> > necessary), but I wanted to hear if this is on the right track before
> > I take it further.
> > I haven't tested it too well since I just now realized that all the time
> > I had compiled FFmpeg without thread support, if someone volunteers to
> > benchmark the speeds of the different implementations they are more than
> > welcome.
> 
> >  avcodec.h  |   15 ++++++++++++-
> [...]
> >  options.c  |    1 
> >  pthread.c  |   13 ++++++++++-
> >  utils.c    |   10 ++++++++
> >  6 files changed, 72 insertions(+), 37 deletions(-)
> > 1306d5ea93f2e82357f7e328c84a913c2f022ab3  dnxhdthread.diff
> [...]
> >  #define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
> > @@ -2526,6 +2526,18 @@
> >       * - decoding: Set by libavcodec
> >       */
> >      enum AVChromaLocation chroma_sample_location;
> > +
> > +    /**
> > +     * The codec may call this to execute several independent things.
> > +     * It will return only after finishing all tasks.
> > +     * The user may replace this with some multithreaded implementation,
> > +     * the default implementation will execute the parts serially.
> > +     * @param count the number of things to execute
> > +     * @param arg2 argument passed unchanged to func
> > +     * - encoding: Set by libavcodec, user can override.
> > +     * - decoding: Set by libavcodec, user can override.
> > +     */
> > +    int (*execute2)(struct AVCodecContext *c, int (*func)(struct AVCodecContext *c2, void *arg, int jobnr, int threadnr), void *arg2, int *ret, int count);
> 
> doxy is missing a few things, like the arguments of func()

I hope I added all docs necessary.
I also hope you are fine with my vague "future-proof" specification of
the return value.
While it is not _really_ necessary yet I think it is preferable to keep
it at least as an option, that array of return values is not really
comfortable to use and quite wasteful of space.



More information about the ffmpeg-devel mailing list