Lines Matching defs:fctx
163 static void async_lock(FrameThreadContext *fctx)
165 pthread_mutex_lock(&fctx->async_mutex);
166 while (fctx->async_lock)
167 pthread_cond_wait(&fctx->async_cond, &fctx->async_mutex);
168 fctx->async_lock = 1;
169 pthread_mutex_unlock(&fctx->async_mutex);
172 static void async_unlock(FrameThreadContext *fctx)
174 pthread_mutex_lock(&fctx->async_mutex);
175 av_assert0(fctx->async_lock);
176 fctx->async_lock = 0;
177 pthread_cond_broadcast(&fctx->async_cond);
178 pthread_mutex_unlock(&fctx->async_mutex);
402 FrameThreadContext *fctx = p->parent;
407 pthread_mutex_lock(&fctx->buffer_mutex);
416 pthread_mutex_unlock(&fctx->buffer_mutex);
424 FrameThreadContext *fctx = p->parent;
425 PerThreadContext *prev_thread = fctx->prev_thread;
465 FFSWAP(const AVHWAccel*, p->avctx->hwaccel, fctx->stash_hwaccel);
466 FFSWAP(void*, p->avctx->hwaccel_context, fctx->stash_hwaccel_context);
467 FFSWAP(void*, p->avctx->internal->hwaccel_priv_data, fctx->stash_hwaccel_priv);
519 fctx->prev_thread = p;
520 fctx->next_decoding++;
529 FrameThreadContext *fctx = avctx->internal->thread_ctx;
530 int finished = fctx->next_finished;
536 async_unlock(fctx);
542 p = &fctx->threads[fctx->next_decoding];
551 if (fctx->next_decoding > (avctx->thread_count-1-(avctx->codec_id == AV_CODEC_ID_FFV1)))
552 fctx->delaying = 0;
554 if (fctx->delaying) {
570 p = &fctx->threads[finished++];
587 * stopped by the "finished != fctx->next_finished" condition.
594 } while (!avpkt->size && !*got_picture_ptr && err >= 0 && finished != fctx->next_finished);
598 if (fctx->next_decoding >= avctx->thread_count) fctx->next_decoding = 0;
600 fctx->next_finished = finished;
606 async_lock(fctx);
692 static void park_frame_worker_threads(FrameThreadContext *fctx, int thread_count)
696 async_unlock(fctx);
699 PerThreadContext *p = &fctx->threads[i];
710 async_lock(fctx);
727 FrameThreadContext *fctx = avctx->internal->thread_ctx;
731 park_frame_worker_threads(fctx, thread_count);
734 PerThreadContext *p = &fctx->threads[i];
776 av_freep(&fctx->threads);
777 ff_pthread_free(fctx, thread_ctx_offsets);
782 FFSWAP(const AVHWAccel*, avctx->hwaccel, fctx->stash_hwaccel);
783 FFSWAP(void*, avctx->hwaccel_context, fctx->stash_hwaccel_context);
784 FFSWAP(void*, avctx->internal->hwaccel_priv_data, fctx->stash_hwaccel_priv);
790 FrameThreadContext *fctx, AVCodecContext *avctx,
807 p->parent = fctx;
869 FrameThreadContext *fctx;
886 avctx->internal->thread_ctx = fctx = av_mallocz(sizeof(FrameThreadContext));
887 if (!fctx)
890 err = ff_pthread_init(fctx, thread_ctx_offsets);
892 ff_pthread_free(fctx, thread_ctx_offsets);
897 fctx->async_lock = 1;
898 fctx->delaying = 1;
903 fctx->threads = av_calloc(thread_count, sizeof(*fctx->threads));
904 if (!fctx->threads) {
910 PerThreadContext *p = &fctx->threads[i];
913 err = init_thread(p, &i, fctx, avctx, codec, first);
928 FrameThreadContext *fctx = avctx->internal->thread_ctx;
930 if (!fctx) return;
932 park_frame_worker_threads(fctx, avctx->thread_count);
933 if (fctx->prev_thread) {
934 if (fctx->prev_thread != &fctx->threads[0])
935 update_context_from_thread(fctx->threads[0].avctx, fctx->prev_thread->avctx, 0);
938 fctx->next_decoding = fctx->next_finished = 0;
939 fctx->delaying = 1;
940 fctx->prev_thread = NULL;
942 PerThreadContext *p = &fctx->threads[i];
1102 FrameThreadContext *fctx;
1126 fctx = p->parent;
1127 pthread_mutex_lock(&fctx->buffer_mutex);
1150 pthread_mutex_unlock(&fctx->buffer_mutex);