MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / ff_thread_finish_setup

Function ff_thread_finish_setup

libavcodec/pthread_frame.c:673–716  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

671}
672
673void ff_thread_finish_setup(AVCodecContext *avctx) {
674 PerThreadContext *p;
675
676 if (!(avctx->active_thread_type&FF_THREAD_FRAME)) return;
677
678 p = avctx->internal->thread_ctx;
679
680 p->hwaccel_threadsafe = avctx->hwaccel &&
681 (ffhwaccel(avctx->hwaccel)->caps_internal & HWACCEL_CAP_THREAD_SAFE);
682
683 if (hwaccel_serial(avctx) && !p->hwaccel_serializing) {
684 pthread_mutex_lock(&p->parent->hwaccel_mutex);
685 p->hwaccel_serializing = 1;
686 }
687
688 /* this assumes that no hwaccel calls happen before ff_thread_finish_setup() */
689 if (avctx->hwaccel &&
690 !(ffhwaccel(avctx->hwaccel)->caps_internal & HWACCEL_CAP_ASYNC_SAFE)) {
691 p->async_serializing = 1;
692
693 async_lock(p->parent);
694 }
695
696 /* thread-unsafe hwaccels share a single private data instance, so we
697 * save hwaccel state for passing to the next thread;
698 * this is done here so that this worker thread can wipe its own hwaccel
699 * state after decoding, without requiring synchronization */
700 av_assert0(!p->parent->stash_hwaccel);
701 if (hwaccel_serial(avctx)) {
702 p->parent->stash_hwaccel = avctx->hwaccel;
703 p->parent->stash_hwaccel_context = avctx->hwaccel_context;
704 p->parent->stash_hwaccel_priv = avctx->internal->hwaccel_priv_data;
705 }
706
707 pthread_mutex_lock(&p->progress_mutex);
708 if(atomic_load(&p->state) == STATE_SETUP_FINISHED){
709 av_log(avctx, AV_LOG_WARNING, "Multiple ff_thread_finish_setup() calls\n");
710 }
711
712 atomic_store(&p->state, STATE_SETUP_FINISHED);
713
714 pthread_cond_broadcast(&p->progress_cond);
715 pthread_mutex_unlock(&p->progress_mutex);
716}
717
718/// Waits for all threads to finish.
719static av_cold void park_frame_worker_threads(FrameThreadContext *fctx, int thread_count)

Callers 1

frame_worker_threadFunction · 0.70

Calls 7

ffhwaccelFunction · 0.85
hwaccel_serialFunction · 0.85
async_lockFunction · 0.85
av_logFunction · 0.85
pthread_mutex_lockFunction · 0.50
pthread_cond_broadcastFunction · 0.50
pthread_mutex_unlockFunction · 0.50

Tested by

no test coverage detected