[FFmpeg-devel] [PATCH v4] vvcdec: add thread executor
Nuo Mi
nuomi2021 at gmail.com
Tue Aug 22 15:20:34 EEST 2023
>
>
>
> > +
> > +#if !HAVE_THREADS
> > +#define pthread_create(t, a, s, ar) 0
> > +#define pthread_join(t, r) do {} while(0)
> > +
> > +#define pthread_cond_init(c, a) 0
> > +#define pthread_cond_broadcast(c) do {} while(0)
> > +#define pthread_cond_signal(c) do {} while(0)
> > +#define pthread_cond_wait(c, m) do {} while(0)
> > +#define pthread_cond_destroy(c) do {} while(0)
> > +
> > +#define pthread_mutex_init(m, a) 0
> > +#define pthread_mutex_lock(l) do {} while(0)
> > +#define pthread_mutex_unlock(l) do {} while(0)
> > +#define pthread_mutex_destroy(l) do {} while(0)
>
> You have ff_mutex_* and AVMutex for this. I sent a patch adding
> ff_cond_* and AVCond, as well as ff_thread_create/join and AVThread to
> thread.h to simplify things.
Will do it for AVMutex and AVCond.
But it's hard to add a wrapper for pthread_t. Because we do not have a way
to detect typedef and I do not want to add "#ifdef
_BITS_PTHREADTYPES_COMMON_H"
>
> > +#endif
> > +
> > +typedef struct ThreadInfo {
> > + AVExecutor *e;
> > + pthread_t thread;
> > +AVExecutor* av_executor_alloc(const AVTaskCallbacks *cb, int
> thread_count)
> > +{
> > + AVExecutor *e;
> > + int has_lock = 0, has_cond = 0;
> > + if (!cb || !cb->user_data || !cb->ready || !cb->run ||
> !cb->priority_higher)
> > + return NULL;
> > +
> > + e = av_calloc(1, sizeof(*e));
>
> av_mallocz()
>
will do
>
> > + if (!e)
> > + return NULL;
> > + e->cb = *cb;
> > +
> > + e->local_contexts = av_calloc(thread_count,
> e->cb.local_context_size);
> > + if (!e->local_contexts)
>
>
More information about the ffmpeg-devel
mailing list