diff options
Diffstat (limited to 'libavcodec/pthread.c')
-rw-r--r-- | libavcodec/pthread.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/libavcodec/pthread.c b/libavcodec/pthread.c index 82eba38786..556e546188 100644 --- a/libavcodec/pthread.c +++ b/libavcodec/pthread.c @@ -26,10 +26,12 @@ #include "avcodec.h" typedef int (action_func)(AVCodecContext *c, void *arg); +typedef int (action_func2)(AVCodecContext *c, void *arg, int jobnr, int threadnr); typedef struct ThreadContext { pthread_t *workers; action_func *func; + action_func2 *func2; void *args; int *rets; int rets_count; @@ -68,7 +70,8 @@ static void* attribute_align_arg worker(void *v) } pthread_mutex_unlock(&c->current_job_lock); - c->rets[our_job%c->rets_count] = c->func(avctx, (char*)c->args + our_job*c->job_size); + c->rets[our_job%c->rets_count] = c->func ? c->func(avctx, (char*)c->args + our_job*c->job_size): + c->func2(avctx, c->args, our_job, self_id); pthread_mutex_lock(&c->current_job_lock); our_job = c->current_job++; @@ -130,6 +133,13 @@ int avcodec_thread_execute(AVCodecContext *avctx, action_func* func, void *arg, return 0; } +int avcodec_thread_execute2(AVCodecContext *avctx, action_func2* func2, void *arg, int *ret, int job_count) +{ + ThreadContext *c= avctx->thread_opaque; + c->func2 = func2; + return avcodec_thread_execute(avctx, NULL, arg, ret, job_count, 0); +} + int avcodec_thread_init(AVCodecContext *avctx, int thread_count) { int i; @@ -167,5 +177,6 @@ int avcodec_thread_init(AVCodecContext *avctx, int thread_count) avcodec_thread_park_workers(c, thread_count); avctx->execute = avcodec_thread_execute; + avctx->execute2 = avcodec_thread_execute2; return 0; } |