- pthread_mutex_lock(&c->current_job_lock);
- c->done = 1;
- pthread_cond_broadcast(&c->current_job_cond);
- pthread_mutex_unlock(&c->current_job_lock);
-
- for (i=0; i<avctx->thread_count; i++)
- pthread_join(c->workers[i], NULL);
-
- pthread_mutex_destroy(&c->current_job_lock);
- pthread_cond_destroy(&c->current_job_cond);
- pthread_cond_destroy(&c->last_job_cond);
- av_free(c->workers);
- av_freep(&avctx->thread_opaque);
-}
-
-int avcodec_thread_execute(AVCodecContext *avctx, action_func* func, void *arg, int *ret, int job_count, int job_size)
-{
- ThreadContext *c= avctx->thread_opaque;
- int dummy_ret;
-
- if (job_count <= 0)
- return 0;
-
- pthread_mutex_lock(&c->current_job_lock);
-
- c->current_job = avctx->thread_count;
- c->job_count = job_count;
- c->job_size = job_size;
- c->args = arg;
- c->func = func;
- if (ret) {
- c->rets = ret;
- c->rets_count = job_count;
- } else {
- c->rets = &dummy_ret;
- c->rets_count = 1;
- }
- pthread_cond_broadcast(&c->current_job_cond);
-
- avcodec_thread_park_workers(c, avctx->thread_count);
+ if (avctx->active_thread_type&FF_THREAD_SLICE)
+ return ff_slice_thread_init(avctx);
+ else if (avctx->active_thread_type&FF_THREAD_FRAME)
+ return ff_frame_thread_init(avctx);