int hwaccel_serializing;
int async_serializing;
+
+ atomic_int debug_threads; ///< Set if the FF_DEBUG_THREADS option is set.
} PerThreadContext;
/**
pthread_mutex_unlock(&p->mutex);
return ret;
}
+ atomic_store_explicit(&p->debug_threads,
+ (p->avctx->debug & FF_DEBUG_THREADS) != 0,
+ memory_order_relaxed);
release_delayed_buffers(p);
p = f->owner[field]->internal->thread_ctx;
- pthread_mutex_lock(&p->progress_mutex);
- if (f->owner[field]->debug&FF_DEBUG_THREADS)
+ if (atomic_load_explicit(&p->debug_threads, memory_order_relaxed))
av_log(f->owner[field], AV_LOG_DEBUG,
"%p finished %d field %d\n", progress, n, field);
+ pthread_mutex_lock(&p->progress_mutex);
+
atomic_store_explicit(&progress[field], n, memory_order_release);
pthread_cond_broadcast(&p->progress_cond);
p = f->owner[field]->internal->thread_ctx;
- pthread_mutex_lock(&p->progress_mutex);
- if (f->owner[field]->debug&FF_DEBUG_THREADS)
+ if (atomic_load_explicit(&p->debug_threads, memory_order_relaxed))
av_log(f->owner[field], AV_LOG_DEBUG,
"thread awaiting %d field %d from %p\n", n, field, progress);
+
+ pthread_mutex_lock(&p->progress_mutex);
while (atomic_load_explicit(&progress[field], memory_order_relaxed) < n)
pthread_cond_wait(&p->progress_cond, &p->progress_mutex);
pthread_mutex_unlock(&p->progress_mutex);
if (!thread_count) {
int nb_cpus = av_cpu_count();
+#if FF_API_DEBUG_MV
if ((avctx->debug & (FF_DEBUG_VIS_QP | FF_DEBUG_VIS_MB_TYPE)) || avctx->debug_mv)
nb_cpus = 1;
+#endif
// use number of cores + 1 as thread count if there is more than one
if (nb_cpus > 1)
thread_count = avctx->thread_count = FFMIN(nb_cpus + 1, MAX_AUTO_THREADS);
if (err) goto error;
+ atomic_init(&p->debug_threads, (copy->debug & FF_DEBUG_THREADS) != 0);
+
err = AVERROR(pthread_create(&p->thread, NULL, frame_worker_thread, p));
p->thread_init= !err;
if(!p->thread_init)