//printf("thread_func %X enter wait\n", (int)v); fflush(stdout);
//av_log(w->avctx, AV_LOG_DEBUG, "thread_func %X enter wait\n", (int)v);
sem_wait(&c->work_sem);
sem_wait(&w->work_sem);
//printf("thread_func %X after wait (func=%X)\n", (int)v, (int)c->func); fflush(stdout);
//av_log(w->avctx, AV_LOG_DEBUG, "thread_func %X after wait\n", (int)v);
if(c->func)
if(c->job_count==0)
c->ret=c->func(c->avctx,c->arg);
break;
else
returnNULL;
for(i=0;i<c->job_count;i++){
//printf("thread_func %X signal complete\n", (int)v); fflush(stdout);
intindex=(i+w->start_index)%c->job_count;
sem_post(&c->done_sem);
JobContext*j=&c->job[index];
//av_log(w->avctx, AV_LOG_DEBUG, "thread_func %X first check of %d\n", (int)v, index);
if(j->assigned)continue;//unsynced check, if != 0 it is already given to another worker, it never becomes available before the next execute() call so this should be safe
//av_log(w->avctx, AV_LOG_DEBUG, "thread_func %X second check of %d\n", (int)v, index);