On Thu, Aug 31, 2017 at 05:30:44AM +0700, Ilia Valiakhmetov wrote:
{...]
> @@ -1481,6 +1661,68 @@ static int
vp9_decode_update_thread_context(AVCodecContext *dst, const AVCodecCo
>
> return 0;
> }
> +
> +void vp9_free_entries(VP9Context *s) {
> + pthread_mutex_destroy(&s->progress_mutex);
> + pthread_cond_destroy(&s->progress_cond);
> + av_freep(&s->entries);
> +}
> +
> +int vp9_alloc_entries(AVCodecContext *avctx, int n) {
> + VP9Context *s = avctx->priv_data;
> + int i;
> +
> + if (avctx->active_thread_type & FF_THREAD_SLICE) {
> + if (s->entries)
> + av_freep(&s->entries);
> +
> + s->entries = av_malloc_array(n, sizeof(atomic_int));
> +
> + if (!s->entries) {
> + av_freep(&s->entries);
> + return AVERROR(ENOMEM);
> + }
> +
> + for (i = 0; i < n; i++)
> + atomic_init(&s->entries[i], 0);
> +
> + pthread_mutex_init(&s->progress_mutex, NULL);
> + pthread_cond_init(&s->progress_cond, NULL);
> + }
> + return 0;
> +}
> +
> +void vp9_report_tile_progress(VP9Context *s, int field, int n) {
> + atomic_fetch_add_explicit(&s->entries[field], n, memory_order_relaxed);
> + pthread_cond_signal(&s->progress_cond);
> +}
> +
> +void vp9_await_tile_progress(VP9Context *s, int field, int n) {
> + if (atomic_load_explicit(&s->entries[field], memory_order_acquire) >= n)
> + return;
> +
> + pthread_mutex_lock(&s->progress_mutex);
> + while (atomic_load_explicit(&s->entries[field], memory_order_relaxed) !=
> n)
> + pthread_cond_wait(&s->progress_cond, &s->progress_mutex);
> + pthread_mutex_unlock(&s->progress_mutex);
> +}
> +#else
> +void vp9_free_entries(VP9Context *s)
> +{
> +}
> +
> +int vp9_alloc_entries(AVCodecContext *avctx, int n)
> +{
> + return 0;
> +}
> +
> +void vp9_report_tile_progress(VP9Context *s, int field, int n)
> +{
> +}
> +
> +void vp9_await_tile_progress(VP9Context *s, int field, int n)
> +{
> +}
> #endifnon static functions need a ff_ or av* prefix no more comments from me, review left to others [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Into a blind darkness they enter who follow after the Ignorance, they as if into a greater darkness enter who devote themselves to the Knowledge alone. -- Isha Upanishad
signature.asc
Description: Digital signature
_______________________________________________ ffmpeg-devel mailing list [email protected] http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
