static int compat_decode(AVCodecContext *avctx, AVFrame *frame,

                         int *got_frame, AVPacket *pkt)

{

    AVCodecInternal *avci = avctx->internal;

    int ret;



    av_assert0(avci->compat_decode_consumed == 0);



    *got_frame = 0;

    avci->compat_decode = 1;



    if (avci->compat_decode_partial_size > 0 &&

        avci->compat_decode_partial_size != pkt->size) {

        av_log(avctx, AV_LOG_ERROR,

               "Got unexpected packet size after a partial decode\n");

        ret = AVERROR(EINVAL);

        goto finish;

    }



    if (!avci->compat_decode_partial_size) {

        ret = avcodec_send_packet(avctx, pkt);

        if (ret == AVERROR_EOF)

            ret = 0;

        else if (ret == AVERROR(EAGAIN)) {

            /* we fully drain all the output in each decode call, so this should not

             * ever happen */

            ret = AVERROR_BUG;

            goto finish;

        } else if (ret < 0)

            goto finish;

    }



    while (ret >= 0) {

        ret = avcodec_receive_frame(avctx, frame);

        if (ret < 0) {

            if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF)

                ret = 0;

            goto finish;

        }



        if (frame != avci->compat_decode_frame) {

            if (!avctx->refcounted_frames) {

                ret = unrefcount_frame(avci, frame);

                if (ret < 0)

                    goto finish;

            }



            *got_frame = 1;

            frame = avci->compat_decode_frame;

        } else {

            if (!avci->compat_decode_warned) {

                av_log(avctx, AV_LOG_WARNING, "The deprecated avcodec_decode_* "

                       "API cannot return all the frames for this decoder. "

                       "Some frames will be dropped. Update your code to the "

                       "new decoding API to fix this.\n");

                avci->compat_decode_warned = 1;

            }

        }



        if (avci->draining || (!avctx->codec->bsfs && avci->compat_decode_consumed < pkt->size))

            break;

    }



finish:

    if (ret == 0) {

        /* if there are any bsfs then assume full packet is always consumed */

        if (avctx->codec->bsfs)

            ret = pkt->size;

        else

            ret = FFMIN(avci->compat_decode_consumed, pkt->size);

    }

    avci->compat_decode_consumed = 0;

    avci->compat_decode_partial_size = (ret >= 0) ? pkt->size - ret : 0;



    return ret;

}

static int compat_decode(AVCodecContext *avctx, AVFrame *frame,

                         int *got_frame, AVPacket *pkt)

{

    AVCodecInternal *avci = avctx->internal;

    int ret;



    av_assert0(avci->compat_decode_consumed == 0);



    *got_frame = 0;

    avci->compat_decode = 1;



    if (avci->compat_decode_partial_size > 0 &&

        avci->compat_decode_partial_size != pkt->size) {

        av_log(avctx, AV_LOG_ERROR,

               "Got unexpected packet size after a partial decode\n");

        ret = AVERROR(EINVAL);

        goto finish;

    }



    if (!avci->compat_decode_partial_size) {

        ret = avcodec_send_packet(avctx, pkt);

        if (ret == AVERROR_EOF)

            ret = 0;

        else if (ret == AVERROR(EAGAIN)) {

            



            ret = AVERROR_BUG;

            goto finish;

        } else if (ret < 0)

            goto finish;

    }



    while (ret >= 0) {

        ret = avcodec_receive_frame(avctx, frame);

        if (ret < 0) {

            if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF)

                ret = 0;

            goto finish;

        }



        if (frame != avci->compat_decode_frame) {

            if (!avctx->refcounted_frames) {

                ret = unrefcount_frame(avci, frame);

                if (ret < 0)

                    goto finish;

            }



            *got_frame = 1;

            frame = avci->compat_decode_frame;

        } else {

            if (!avci->compat_decode_warned) {

                av_log(avctx, AV_LOG_WARNING, "The deprecated avcodec_decode_* "

                       "API cannot return all the frames for this decoder. "

                       "Some frames will be dropped. Update your code to the "

                       "new decoding API to fix this.\n");

                avci->compat_decode_warned = 1;

            }

        }



        if (avci->draining || (!avctx->codec->bsfs && avci->compat_decode_consumed < pkt->size))

            break;

    }



finish:

    if (ret == 0) {

        

        if (avctx->codec->bsfs)

            ret = pkt->size;

        else

            ret = FFMIN(avci->compat_decode_consumed, pkt->size);

    }

    avci->compat_decode_consumed = 0;

    avci->compat_decode_partial_size = (ret >= 0) ? pkt->size - ret : 0;



    return ret;

}

    int ret;
static int FUNC_0(AVCodecContext *VAR_0, AVFrame *VAR_1,

                         int *VAR_2, AVPacket *VAR_3)

{

    AVCodecInternal *avci = VAR_0->internal;

    int VAR_4;



    av_assert0(avci->compat_decode_consumed == 0);



    *VAR_2 = 0;

    avci->FUNC_0 = 1;



    if (avci->compat_decode_partial_size > 0 &&

        avci->compat_decode_partial_size != VAR_3->size) {

        av_log(VAR_0, AV_LOG_ERROR,

               "Got unexpected packet size after a partial decode\n");

        VAR_4 = AVERROR(EINVAL);

        goto finish;

    }



    if (!avci->compat_decode_partial_size) {

        VAR_4 = avcodec_send_packet(VAR_0, VAR_3);

        if (VAR_4 == AVERROR_EOF)

            VAR_4 = 0;

        else if (VAR_4 == AVERROR(EAGAIN)) {

            



            VAR_4 = AVERROR_BUG;

            goto finish;

        } else if (VAR_4 < 0)

            goto finish;

    }



    while (VAR_4 >= 0) {

        VAR_4 = avcodec_receive_frame(VAR_0, VAR_1);

        if (VAR_4 < 0) {

            if (VAR_4 == AVERROR(EAGAIN) || VAR_4 == AVERROR_EOF)

                VAR_4 = 0;

            goto finish;

        }



        if (VAR_1 != avci->compat_decode_frame) {

            if (!VAR_0->refcounted_frames) {

                VAR_4 = unrefcount_frame(avci, VAR_1);

                if (VAR_4 < 0)

                    goto finish;

            }



            *VAR_2 = 1;

            VAR_1 = avci->compat_decode_frame;

        } else {

            if (!avci->compat_decode_warned) {

                av_log(VAR_0, AV_LOG_WARNING, "The deprecated avcodec_decode_* "

                       "API cannot return all the frames for this decoder. "

                       "Some frames will be dropped. Update your code to the "

                       "new decoding API to fix this.\n");

                avci->compat_decode_warned = 1;

            }

        }



        if (avci->draining || (!VAR_0->codec->bsfs && avci->compat_decode_consumed < VAR_3->size))

            break;

    }



finish:

    if (VAR_4 == 0) {

        

        if (VAR_0->codec->bsfs)

            VAR_4 = VAR_3->size;

        else

            VAR_4 = FFMIN(avci->compat_decode_consumed, VAR_3->size);

    }

    avci->compat_decode_consumed = 0;

    avci->compat_decode_partial_size = (VAR_4 >= 0) ? VAR_3->size - VAR_4 : 0;



    return VAR_4;

}

static int FUNC_0(AVCodecContext *VAR_0, AVFrame *VAR_1,
int *VAR_2, AVPacket *VAR_3)
{ AVCodecInternal *avci = VAR_0->internal; int VAR_4; av_assert0(avci->compat_decode_consumed == 0); *VAR_2 = 0; avci->FUNC_0 = 1; if (avci->compat_decode_partial_size > 0 &&
avci->compat_decode_partial_size != VAR_3->size) { av_log(VAR_0, AV_LOG_ERROR,
"Got unexpected packet size after a partial decode\n"); VAR_4 = AVERROR(EINVAL); goto finish; } if (!avci->compat_decode_partial_size) { VAR_4 = avcodec_send_packet(VAR_0, VAR_3); if (VAR_4 == AVERROR_EOF)
VAR_4 = 0; else if (VAR_4 == AVERROR(EAGAIN)) { VAR_4 = AVERROR_BUG; goto finish; } else if (VAR_4 < 0) goto finish; } while (VAR_4 >= 0) { VAR_4 = avcodec_receive_frame(VAR_0, VAR_1); if (VAR_4 < 0) { if (VAR_4 == AVERROR(EAGAIN) || VAR_4 == AVERROR_EOF)
VAR_4 = 0; goto finish; } if (VAR_1 != avci->compat_decode_frame) { if (!VAR_0->refcounted_frames) { VAR_4 = unrefcount_frame(avci, VAR_1); if (VAR_4 < 0)
goto finish; } *VAR_2 = 1; VAR_1 = avci->compat_decode_frame; } else { if (!avci->compat_decode_warned) { av_log(VAR_0, AV_LOG_WARNING, "The deprecated avcodec_decode_* "
"API cannot return all the frames for this decoder. "
"Some frames will be dropped. Update your code to the "
"new decoding API to fix this.\n"); avci->compat_decode_warned = 1; } } if (avci->draining || (!VAR_0->codec->bsfs && avci->compat_decode_consumed < VAR_3->size))
break; } finish:
if (VAR_4 == 0) { if (VAR_0->codec->bsfs)
VAR_4 = VAR_3->size; else
VAR_4 = FFMIN(avci->compat_decode_consumed, VAR_3->size); } avci->compat_decode_consumed = 0; avci->compat_decode_partial_size = (VAR_4 >= 0) ? VAR_3->size - VAR_4 : 0; return VAR_4; }