154 #define MAX_AUTO_THREADS 16
160 unsigned last_execute = 0;
185 c->
func2(avctx, c->
args, our_job, self_id);
241 c->
rets = &dummy_ret;
276 if (thread_count <= 1) {
300 for (i=0; i<thread_count; i++) {
316 #define THREAD_SAFE_CALLBACKS(avctx) \
317 ((avctx)->thread_safe_callbacks || (!(avctx)->get_buffer && (avctx)->get_buffer2 == avcodec_default_get_buffer2))
335 while (p->
state == STATE_INPUT_READY && !fctx->
die)
338 if (fctx->
die)
break;
351 for (i = 0; i < MAX_BUFFERS; i++)
353 p->progress[i][0] = INT_MAX;
354 p->progress[i][1] = INT_MAX;
357 p->
state = STATE_INPUT_READY;
436 #define copy_fields(s, e) memcpy(&dst->s, &src->s, (char*)&dst->e - (char*)&dst->s);
441 #if FF_API_GET_BUFFER
443 dst->get_buffer = src->get_buffer;
444 dst->release_buffer = src->release_buffer;
514 if (prev_thread->
state == STATE_SETTING_UP) {
516 while (prev_thread->
state == STATE_SETTING_UP)
539 p->
state = STATE_SETTING_UP;
553 p->
avctx->get_buffer ||
557 while (p->
state != STATE_SETUP_FINISHED && p->
state != STATE_INPUT_READY) {
560 while (p->
state == STATE_SETTING_UP)
564 case STATE_GET_BUFFER:
567 case STATE_GET_FORMAT:
575 p->
state = STATE_SETTING_UP;
589 AVFrame *picture,
int *got_picture_ptr,
628 p = &fctx->
threads[finished++];
630 if (p->
state != STATE_INPUT_READY) {
632 while (p->
state != STATE_INPUT_READY)
667 if (!progress || progress[field] >= n)
return;
685 if (!progress || progress[field] >= n)
return;
693 while (progress[field] < n)
703 if(p->
state == STATE_SETUP_FINISHED){
708 p->
state = STATE_SETUP_FINISHED;
718 for (i = 0; i < thread_count; i++) {
721 if (p->
state != STATE_INPUT_READY) {
723 while (p->
state != STATE_INPUT_READY)
748 for (i = 0; i < thread_count; i++) {
768 for (i = 0; i < thread_count; i++) {
813 if (thread_count <= 1) {
824 for (i = 0; i < thread_count; i++) {
856 err = codec->
init(copy);
944 if (p->
state != STATE_SETTING_UP &&
946 av_log(avctx,
AV_LOG_ERROR,
"get_buffer() cannot be called after ff_thread_finish_setup()\n");
958 progress[0] = progress[1] = -1;
966 !avctx->get_buffer &&
975 p->
state = STATE_GET_BUFFER;
978 while (p->
state != STATE_SETTING_UP)
1004 if (p->
state != STATE_SETTING_UP) {
1005 av_log(avctx,
AV_LOG_ERROR,
"get_format() cannot be called after ff_thread_finish_setup()\n");
1010 p->
state = STATE_GET_FORMAT;
1013 while (p->
state != STATE_SETTING_UP)
1041 !avctx->get_buffer &&
1055 if (can_direct_free) {
1110 "Application has requested %d threads. Using a thread count greater than %d is not recommended.\n",
1154 if (!entries || !field)
return;
1159 while ((entries[field - 1] - entries[field]) < shift){