static int try_decode_video_frame(AVCodecContext *codec_ctx, AVPacket *pkt, int decode)

{

    int ret = 0;

    int got_frame = 0;

    AVFrame *frame = NULL;

    int skip_frame = codec_ctx->skip_frame;



    if (!avcodec_is_open(codec_ctx)) {

        const AVCodec *codec = avcodec_find_decoder(codec_ctx->codec_id);



        ret = avcodec_open2(codec_ctx, codec, NULL);

        if (ret < 0) {

            av_log(codec_ctx, AV_LOG_ERROR, "Failed to open codec\n");

            goto end;

        }

    }



    frame = av_frame_alloc();

    if (!frame) {

        av_log(NULL, AV_LOG_ERROR, "Failed to allocate frame\n");

        goto end;

    }



    if (!decode && codec_ctx->codec->caps_internal & FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM) {

        codec_ctx->skip_frame = AVDISCARD_ALL;

    }



    do {

        ret = avcodec_decode_video2(codec_ctx, frame, &got_frame, pkt);

        av_assert0(decode || (!decode && !got_frame));

        if (ret < 0)

            break;

        pkt->data += ret;

        pkt->size -= ret;



        if (got_frame) {

            break;

        }

    } while (pkt->size > 0);



end:

    codec_ctx->skip_frame = skip_frame;



    av_frame_free(&frame);

    return ret;

}

static int try_decode_video_frame(AVCodecContext *codec_ctx, AVPacket *pkt, int decode)

{

    int ret = 0;

    int got_frame = 0;

    AVFrame *frame = NULL;

    int skip_frame = codec_ctx->skip_frame;



    if (!avcodec_is_open(codec_ctx)) {

        const AVCodec *codec = avcodec_find_decoder(codec_ctx->codec_id);



        ret = avcodec_open2(codec_ctx, codec, NULL);

        if (ret < 0) {

            av_log(codec_ctx, AV_LOG_ERROR, "Failed to open codec\n");

            goto end;

        }

    }



    frame = av_frame_alloc();

    if (!frame) {

        av_log(NULL, AV_LOG_ERROR, "Failed to allocate frame\n");

        goto end;

    }



    if (!decode && codec_ctx->codec->caps_internal & FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM) {

        codec_ctx->skip_frame = AVDISCARD_ALL;

    }



    do {

        ret = avcodec_decode_video2(codec_ctx, frame, &got_frame, pkt);

        av_assert0(decode || (!decode && !got_frame));

        if (ret < 0)

            break;

        pkt->data += ret;

        pkt->size -= ret;



        if (got_frame) {

            break;

        }

    } while (pkt->size > 0);



end:

    codec_ctx->skip_frame = skip_frame;



    av_frame_free(&frame);

    return ret;

}

    if (!decode && codec_ctx->codec->caps_internal & FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM) {
static int FUNC_0(AVCodecContext *VAR_0, AVPacket *VAR_1, int VAR_2)

{

    int VAR_3 = 0;

    int VAR_4 = 0;

    AVFrame *frame = NULL;

    int VAR_5 = VAR_0->VAR_5;



    if (!avcodec_is_open(VAR_0)) {

        const AVCodec *VAR_6 = avcodec_find_decoder(VAR_0->codec_id);



        VAR_3 = avcodec_open2(VAR_0, VAR_6, NULL);

        if (VAR_3 < 0) {

            av_log(VAR_0, AV_LOG_ERROR, "Failed to open VAR_6\n");

            goto end;

        }

    }



    frame = av_frame_alloc();

    if (!frame) {

        av_log(NULL, AV_LOG_ERROR, "Failed to allocate frame\n");

        goto end;

    }



    if (!VAR_2 && VAR_0->VAR_6->caps_internal & FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM) {

        VAR_0->VAR_5 = AVDISCARD_ALL;

    }



    do {

        VAR_3 = avcodec_decode_video2(VAR_0, frame, &VAR_4, VAR_1);

        av_assert0(VAR_2 || (!VAR_2 && !VAR_4));

        if (VAR_3 < 0)

            break;

        VAR_1->data += VAR_3;

        VAR_1->size -= VAR_3;



        if (VAR_4) {

            break;

        }

    } while (VAR_1->size > 0);



end:

    VAR_0->VAR_5 = VAR_5;



    av_frame_free(&frame);

    return VAR_3;

}

static int FUNC_0(AVCodecContext *VAR_0, AVPacket *VAR_1, int VAR_2)
{ int VAR_3 = 0; int VAR_4 = 0; AVFrame *frame = NULL; int VAR_5 = VAR_0->VAR_5; if (!avcodec_is_open(VAR_0)) { const AVCodec *VAR_6 = avcodec_find_decoder(VAR_0->codec_id); VAR_3 = avcodec_open2(VAR_0, VAR_6, NULL); if (VAR_3 < 0) { av_log(VAR_0, AV_LOG_ERROR, "Failed to open VAR_6\n"); goto end; } } frame = av_frame_alloc(); if (!frame) { av_log(NULL, AV_LOG_ERROR, "Failed to allocate frame\n"); goto end; } if (!VAR_2 && VAR_0->VAR_6->caps_internal & FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM) { VAR_0->VAR_5 = AVDISCARD_ALL; } do { VAR_3 = avcodec_decode_video2(VAR_0, frame, &VAR_4, VAR_1); av_assert0(VAR_2 || (!VAR_2 && !VAR_4)); if (VAR_3 < 0)
break; VAR_1->data += VAR_3; VAR_1->size -= VAR_3; if (VAR_4) { break; } } while (VAR_1->size > 0); end:
VAR_0->VAR_5 = VAR_5; av_frame_free(&frame); return VAR_3; }