void ff_frame_thread_free(AVCodecContext *avctx, int thread_count)

{

    FrameThreadContext *fctx = avctx->internal->thread_ctx;

    const AVCodec *codec = avctx->codec;

    int i;



    park_frame_worker_threads(fctx, thread_count);



    if (fctx->prev_thread && fctx->prev_thread != fctx->threads)

        if (update_context_from_thread(fctx->threads->avctx, fctx->prev_thread->avctx, 0) < 0) {

            av_log(avctx, AV_LOG_ERROR, "Final thread update failed\n");

            fctx->prev_thread->avctx->internal->is_copy = fctx->threads->avctx->internal->is_copy;

            fctx->threads->avctx->internal->is_copy = 1;

        }



    fctx->die = 1;



    for (i = 0; i < thread_count; i++) {

        PerThreadContext *p = &fctx->threads[i];



        pthread_mutex_lock(&p->mutex);

        pthread_cond_signal(&p->input_cond);

        pthread_mutex_unlock(&p->mutex);



        if (p->thread_init)

            pthread_join(p->thread, NULL);

        p->thread_init=0;



        if (codec->close)

            codec->close(p->avctx);



        release_delayed_buffers(p);

        av_frame_free(&p->frame);

    }



    for (i = 0; i < thread_count; i++) {

        PerThreadContext *p = &fctx->threads[i];



        pthread_mutex_destroy(&p->mutex);

        pthread_mutex_destroy(&p->progress_mutex);

        pthread_cond_destroy(&p->input_cond);

        pthread_cond_destroy(&p->progress_cond);

        pthread_cond_destroy(&p->output_cond);

        av_packet_unref(&p->avpkt);

        av_freep(&p->released_buffers);



        if (i) {

            av_freep(&p->avctx->priv_data);

            av_freep(&p->avctx->slice_offset);

        }



        av_freep(&p->avctx->internal);

        av_freep(&p->avctx);

    }



    av_freep(&fctx->threads);

    pthread_mutex_destroy(&fctx->buffer_mutex);

    av_freep(&avctx->internal->thread_ctx);



    if (avctx->priv_data && avctx->codec && avctx->codec->priv_class)

        av_opt_free(avctx->priv_data);

    avctx->codec = NULL;

}

void ff_frame_thread_free(AVCodecContext *avctx, int thread_count)

{

    FrameThreadContext *fctx = avctx->internal->thread_ctx;

    const AVCodec *codec = avctx->codec;

    int i;



    park_frame_worker_threads(fctx, thread_count);



    if (fctx->prev_thread && fctx->prev_thread != fctx->threads)

        if (update_context_from_thread(fctx->threads->avctx, fctx->prev_thread->avctx, 0) < 0) {

            av_log(avctx, AV_LOG_ERROR, "Final thread update failed\n");

            fctx->prev_thread->avctx->internal->is_copy = fctx->threads->avctx->internal->is_copy;

            fctx->threads->avctx->internal->is_copy = 1;

        }



    fctx->die = 1;



    for (i = 0; i < thread_count; i++) {

        PerThreadContext *p = &fctx->threads[i];



        pthread_mutex_lock(&p->mutex);

        pthread_cond_signal(&p->input_cond);

        pthread_mutex_unlock(&p->mutex);



        if (p->thread_init)

            pthread_join(p->thread, NULL);

        p->thread_init=0;



        if (codec->close)

            codec->close(p->avctx);



        release_delayed_buffers(p);

        av_frame_free(&p->frame);

    }



    for (i = 0; i < thread_count; i++) {

        PerThreadContext *p = &fctx->threads[i];



        pthread_mutex_destroy(&p->mutex);

        pthread_mutex_destroy(&p->progress_mutex);

        pthread_cond_destroy(&p->input_cond);

        pthread_cond_destroy(&p->progress_cond);

        pthread_cond_destroy(&p->output_cond);

        av_packet_unref(&p->avpkt);

        av_freep(&p->released_buffers);



        if (i) {

            av_freep(&p->avctx->priv_data);

            av_freep(&p->avctx->slice_offset);

        }



        av_freep(&p->avctx->internal);

        av_freep(&p->avctx);

    }



    av_freep(&fctx->threads);

    pthread_mutex_destroy(&fctx->buffer_mutex);

    av_freep(&avctx->internal->thread_ctx);



    if (avctx->priv_data && avctx->codec && avctx->codec->priv_class)

        av_opt_free(avctx->priv_data);

    avctx->codec = NULL;

}

        if (codec->close)         if (i) {         av_freep(&p->avctx->internal);
void FUNC_0(AVCodecContext *VAR_0, int VAR_1)

{

    FrameThreadContext *fctx = VAR_0->internal->thread_ctx;

    const AVCodec *VAR_2 = VAR_0->VAR_2;

    int VAR_3;



    park_frame_worker_threads(fctx, VAR_1);



    if (fctx->prev_thread && fctx->prev_thread != fctx->threads)

        if (update_context_from_thread(fctx->threads->VAR_0, fctx->prev_thread->VAR_0, 0) < 0) {

            av_log(VAR_0, AV_LOG_ERROR, "Final thread update failed\n");

            fctx->prev_thread->VAR_0->internal->is_copy = fctx->threads->VAR_0->internal->is_copy;

            fctx->threads->VAR_0->internal->is_copy = 1;

        }



    fctx->die = 1;



    for (VAR_3 = 0; VAR_3 < VAR_1; VAR_3++) {

        PerThreadContext *p = &fctx->threads[VAR_3];



        pthread_mutex_lock(&p->mutex);

        pthread_cond_signal(&p->input_cond);

        pthread_mutex_unlock(&p->mutex);



        if (p->thread_init)

            pthread_join(p->thread, NULL);

        p->thread_init=0;



        if (VAR_2->close)

            VAR_2->close(p->VAR_0);



        release_delayed_buffers(p);

        av_frame_free(&p->frame);

    }



    for (VAR_3 = 0; VAR_3 < VAR_1; VAR_3++) {

        PerThreadContext *p = &fctx->threads[VAR_3];



        pthread_mutex_destroy(&p->mutex);

        pthread_mutex_destroy(&p->progress_mutex);

        pthread_cond_destroy(&p->input_cond);

        pthread_cond_destroy(&p->progress_cond);

        pthread_cond_destroy(&p->output_cond);

        av_packet_unref(&p->avpkt);

        av_freep(&p->released_buffers);



        if (VAR_3) {

            av_freep(&p->VAR_0->priv_data);

            av_freep(&p->VAR_0->slice_offset);

        }



        av_freep(&p->VAR_0->internal);

        av_freep(&p->VAR_0);

    }



    av_freep(&fctx->threads);

    pthread_mutex_destroy(&fctx->buffer_mutex);

    av_freep(&VAR_0->internal->thread_ctx);



    if (VAR_0->priv_data && VAR_0->VAR_2 && VAR_0->VAR_2->priv_class)

        av_opt_free(VAR_0->priv_data);

    VAR_0->VAR_2 = NULL;

}

void FUNC_0(AVCodecContext *VAR_0, int VAR_1)
{ FrameThreadContext *fctx = VAR_0->internal->thread_ctx; const AVCodec *VAR_2 = VAR_0->VAR_2; int VAR_3; park_frame_worker_threads(fctx, VAR_1); if (fctx->prev_thread && fctx->prev_thread != fctx->threads)
if (update_context_from_thread(fctx->threads->VAR_0, fctx->prev_thread->VAR_0, 0) < 0) { av_log(VAR_0, AV_LOG_ERROR, "Final thread update failed\n"); fctx->prev_thread->VAR_0->internal->is_copy = fctx->threads->VAR_0->internal->is_copy; fctx->threads->VAR_0->internal->is_copy = 1; } fctx->die = 1; for (VAR_3 = 0; VAR_3 < VAR_1; VAR_3++) { PerThreadContext *p = &fctx->threads[VAR_3]; pthread_mutex_lock(&p->mutex); pthread_cond_signal(&p->input_cond); pthread_mutex_unlock(&p->mutex); if (p->thread_init)
pthread_join(p->thread, NULL); p->thread_init=0; if (VAR_2->close)
VAR_2->close(p->VAR_0); release_delayed_buffers(p); av_frame_free(&p->frame); } for (VAR_3 = 0; VAR_3 < VAR_1; VAR_3++) { PerThreadContext *p = &fctx->threads[VAR_3]; pthread_mutex_destroy(&p->mutex); pthread_mutex_destroy(&p->progress_mutex); pthread_cond_destroy(&p->input_cond); pthread_cond_destroy(&p->progress_cond); pthread_cond_destroy(&p->output_cond); av_packet_unref(&p->avpkt); av_freep(&p->released_buffers); if (VAR_3) { av_freep(&p->VAR_0->priv_data); av_freep(&p->VAR_0->slice_offset); } av_freep(&p->VAR_0->internal); av_freep(&p->VAR_0); } av_freep(&fctx->threads); pthread_mutex_destroy(&fctx->buffer_mutex); av_freep(&VAR_0->internal->thread_ctx); if (VAR_0->priv_data && VAR_0->VAR_2 && VAR_0->VAR_2->priv_class)
av_opt_free(VAR_0->priv_data); VAR_0->VAR_2 = NULL; }