int ff_thread_get_buffer(AVCodecContext *avctx, AVFrame *f)

{

    PerThreadContext *p = avctx->thread_opaque;

    int *progress, err;



    f->owner = avctx;



    ff_init_buffer_info(avctx, f);



    if (!(avctx->active_thread_type&FF_THREAD_FRAME)) {

        f->thread_opaque = NULL;

        return avctx->get_buffer(avctx, f);

    }



    if (p->state != STATE_SETTING_UP &&

        (avctx->codec->update_thread_context || (!avctx->thread_safe_callbacks &&

                avctx->get_buffer != avcodec_default_get_buffer))) {

        av_log(avctx, AV_LOG_ERROR, "get_buffer() cannot be called after ff_thread_finish_setup()\n");

        return -1;

    }



    pthread_mutex_lock(&p->parent->buffer_mutex);

    f->thread_opaque = progress = allocate_progress(p);



    if (!progress) {

        pthread_mutex_unlock(&p->parent->buffer_mutex);

        return -1;

    }



    progress[0] =

    progress[1] = -1;



    if (avctx->thread_safe_callbacks ||

        avctx->get_buffer == avcodec_default_get_buffer) {

        err = avctx->get_buffer(avctx, f);

    } else {

        p->requested_frame = f;

        p->state = STATE_GET_BUFFER;

        pthread_mutex_lock(&p->progress_mutex);

        pthread_cond_signal(&p->progress_cond);



        while (p->state != STATE_SETTING_UP)

            pthread_cond_wait(&p->progress_cond, &p->progress_mutex);



        err = p->result;



        pthread_mutex_unlock(&p->progress_mutex);



        if (!avctx->codec->update_thread_context)

            ff_thread_finish_setup(avctx);

    }



    pthread_mutex_unlock(&p->parent->buffer_mutex);



    return err;

}

int ff_thread_get_buffer(AVCodecContext *avctx, AVFrame *f)

{

    PerThreadContext *p = avctx->thread_opaque;

    int *progress, err;



    f->owner = avctx;



    ff_init_buffer_info(avctx, f);



    if (!(avctx->active_thread_type&FF_THREAD_FRAME)) {

        f->thread_opaque = NULL;

        return avctx->get_buffer(avctx, f);

    }



    if (p->state != STATE_SETTING_UP &&

        (avctx->codec->update_thread_context || (!avctx->thread_safe_callbacks &&

                avctx->get_buffer != avcodec_default_get_buffer))) {

        av_log(avctx, AV_LOG_ERROR, "get_buffer() cannot be called after ff_thread_finish_setup()\n");

        return -1;

    }



    pthread_mutex_lock(&p->parent->buffer_mutex);

    f->thread_opaque = progress = allocate_progress(p);



    if (!progress) {

        pthread_mutex_unlock(&p->parent->buffer_mutex);

        return -1;

    }



    progress[0] =

    progress[1] = -1;



    if (avctx->thread_safe_callbacks ||

        avctx->get_buffer == avcodec_default_get_buffer) {

        err = avctx->get_buffer(avctx, f);

    } else {

        p->requested_frame = f;

        p->state = STATE_GET_BUFFER;

        pthread_mutex_lock(&p->progress_mutex);

        pthread_cond_signal(&p->progress_cond);



        while (p->state != STATE_SETTING_UP)

            pthread_cond_wait(&p->progress_cond, &p->progress_mutex);



        err = p->result;



        pthread_mutex_unlock(&p->progress_mutex);



        if (!avctx->codec->update_thread_context)

            ff_thread_finish_setup(avctx);

    }



    pthread_mutex_unlock(&p->parent->buffer_mutex);



    return err;

}

        pthread_cond_signal(&p->progress_cond);
int FUNC_0(AVCodecContext *VAR_0, AVFrame *VAR_1)

{

    PerThreadContext *p = VAR_0->thread_opaque;

    int *VAR_2, VAR_3;



    VAR_1->owner = VAR_0;



    ff_init_buffer_info(VAR_0, VAR_1);



    if (!(VAR_0->active_thread_type&FF_THREAD_FRAME)) {

        VAR_1->thread_opaque = NULL;

        return VAR_0->get_buffer(VAR_0, VAR_1);

    }



    if (p->state != STATE_SETTING_UP &&

        (VAR_0->codec->update_thread_context || (!VAR_0->thread_safe_callbacks &&

                VAR_0->get_buffer != avcodec_default_get_buffer))) {

        av_log(VAR_0, AV_LOG_ERROR, "get_buffer() cannot be called after ff_thread_finish_setup()\n");

        return -1;

    }



    pthread_mutex_lock(&p->parent->buffer_mutex);

    VAR_1->thread_opaque = VAR_2 = allocate_progress(p);



    if (!VAR_2) {

        pthread_mutex_unlock(&p->parent->buffer_mutex);

        return -1;

    }



    VAR_2[0] =

    VAR_2[1] = -1;



    if (VAR_0->thread_safe_callbacks ||

        VAR_0->get_buffer == avcodec_default_get_buffer) {

        VAR_3 = VAR_0->get_buffer(VAR_0, VAR_1);

    } else {

        p->requested_frame = VAR_1;

        p->state = STATE_GET_BUFFER;

        pthread_mutex_lock(&p->progress_mutex);

        pthread_cond_signal(&p->progress_cond);



        while (p->state != STATE_SETTING_UP)

            pthread_cond_wait(&p->progress_cond, &p->progress_mutex);



        VAR_3 = p->result;



        pthread_mutex_unlock(&p->progress_mutex);



        if (!VAR_0->codec->update_thread_context)

            ff_thread_finish_setup(VAR_0);

    }



    pthread_mutex_unlock(&p->parent->buffer_mutex);



    return VAR_3;

}

int FUNC_0(AVCodecContext *VAR_0, AVFrame *VAR_1)
{ PerThreadContext *p = VAR_0->thread_opaque; int *VAR_2, VAR_3; VAR_1->owner = VAR_0; ff_init_buffer_info(VAR_0, VAR_1); if (!(VAR_0->active_thread_type&FF_THREAD_FRAME)) { VAR_1->thread_opaque = NULL; return VAR_0->get_buffer(VAR_0, VAR_1); } if (p->state != STATE_SETTING_UP &&
(VAR_0->codec->update_thread_context || (!VAR_0->thread_safe_callbacks &&
VAR_0->get_buffer != avcodec_default_get_buffer))) { av_log(VAR_0, AV_LOG_ERROR, "get_buffer() cannot be called after ff_thread_finish_setup()\n"); return -1; } pthread_mutex_lock(&p->parent->buffer_mutex); VAR_1->thread_opaque = VAR_2 = allocate_progress(p); if (!VAR_2) { pthread_mutex_unlock(&p->parent->buffer_mutex); return -1; } VAR_2[0] =
VAR_2[1] = -1; if (VAR_0->thread_safe_callbacks ||
VAR_0->get_buffer == avcodec_default_get_buffer) { VAR_3 = VAR_0->get_buffer(VAR_0, VAR_1); } else { p->requested_frame = VAR_1; p->state = STATE_GET_BUFFER; pthread_mutex_lock(&p->progress_mutex); pthread_cond_signal(&p->progress_cond); while (p->state != STATE_SETTING_UP)
pthread_cond_wait(&p->progress_cond, &p->progress_mutex); VAR_3 = p->result; pthread_mutex_unlock(&p->progress_mutex); if (!VAR_0->codec->update_thread_context)
ff_thread_finish_setup(VAR_0); } pthread_mutex_unlock(&p->parent->buffer_mutex); return VAR_3; }