static int clv_decode_frame(AVCodecContext *avctx, void *data,

                            int *got_frame, AVPacket *avpkt)

{

    const uint8_t *buf = avpkt->data;

    int buf_size = avpkt->size;

    CLVContext *c = avctx->priv_data;

    GetByteContext gb;

    uint32_t frame_type;

    int i, j;

    int ret;

    int mb_ret = 0;



    bytestream2_init(&gb, buf, buf_size);

    if (avctx->codec_tag == MKTAG('C','L','V','1')) {

        int skip = bytestream2_get_byte(&gb);

        bytestream2_skip(&gb, (skip + 1) * 8);

    }



    frame_type = bytestream2_get_byte(&gb);

    if ((ret = ff_reget_buffer(avctx, c->pic)) < 0)

        return ret;



    c->pic->key_frame = frame_type & 0x20 ? 1 : 0;

    c->pic->pict_type = frame_type & 0x20 ? AV_PICTURE_TYPE_I : AV_PICTURE_TYPE_P;



    if (frame_type & 0x2) {

        if (buf_size < c->mb_width * c->mb_height) {

            av_log(avctx, AV_LOG_ERROR, "Packet too small\n");

            return AVERROR_INVALIDDATA;

        }



        bytestream2_get_be32(&gb); // frame size;

        c->ac_quant        = bytestream2_get_byte(&gb);

        c->luma_dc_quant   = 32;

        c->chroma_dc_quant = 32;



        if ((ret = init_get_bits8(&c->gb, buf + bytestream2_tell(&gb),

                                  (buf_size - bytestream2_tell(&gb)))) < 0)

            return ret;



        for (i = 0; i < 3; i++)

            c->top_dc[i] = 32;

        for (i = 0; i < 4; i++)

            c->left_dc[i] = 32;



        for (j = 0; j < c->mb_height; j++) {

            for (i = 0; i < c->mb_width; i++) {

                ret = decode_mb(c, i, j);

                if (ret < 0)

                    mb_ret = ret;

            }

        }

    } else {

    }



    if ((ret = av_frame_ref(data, c->pic)) < 0)

        return ret;



    *got_frame = 1;



    return mb_ret < 0 ? mb_ret : buf_size;

}

static int clv_decode_frame(AVCodecContext *avctx, void *data,

                            int *got_frame, AVPacket *avpkt)

{

    const uint8_t *buf = avpkt->data;

    int buf_size = avpkt->size;

    CLVContext *c = avctx->priv_data;

    GetByteContext gb;

    uint32_t frame_type;

    int i, j;

    int ret;

    int mb_ret = 0;



    bytestream2_init(&gb, buf, buf_size);

    if (avctx->codec_tag == MKTAG('C','L','V','1')) {

        int skip = bytestream2_get_byte(&gb);

        bytestream2_skip(&gb, (skip + 1) * 8);

    }



    frame_type = bytestream2_get_byte(&gb);

    if ((ret = ff_reget_buffer(avctx, c->pic)) < 0)

        return ret;



    c->pic->key_frame = frame_type & 0x20 ? 1 : 0;

    c->pic->pict_type = frame_type & 0x20 ? AV_PICTURE_TYPE_I : AV_PICTURE_TYPE_P;



    if (frame_type & 0x2) {

        if (buf_size < c->mb_width * c->mb_height) {

            av_log(avctx, AV_LOG_ERROR, "Packet too small\n");

            return AVERROR_INVALIDDATA;

        }



        bytestream2_get_be32(&gb); 

        c->ac_quant        = bytestream2_get_byte(&gb);

        c->luma_dc_quant   = 32;

        c->chroma_dc_quant = 32;



        if ((ret = init_get_bits8(&c->gb, buf + bytestream2_tell(&gb),

                                  (buf_size - bytestream2_tell(&gb)))) < 0)

            return ret;



        for (i = 0; i < 3; i++)

            c->top_dc[i] = 32;

        for (i = 0; i < 4; i++)

            c->left_dc[i] = 32;



        for (j = 0; j < c->mb_height; j++) {

            for (i = 0; i < c->mb_width; i++) {

                ret = decode_mb(c, i, j);

                if (ret < 0)

                    mb_ret = ret;

            }

        }

    } else {

    }



    if ((ret = av_frame_ref(data, c->pic)) < 0)

        return ret;



    *got_frame = 1;



    return mb_ret < 0 ? mb_ret : buf_size;

}

    if ((ret = ff_reget_buffer(avctx, c->pic)) < 0)         return ret;     c->pic->key_frame = frame_type & 0x20 ? 1 : 0;     c->pic->pict_type = frame_type & 0x20 ? AV_PICTURE_TYPE_I : AV_PICTURE_TYPE_P;     } else {     if ((ret = av_frame_ref(data, c->pic)) < 0)         return ret;     *got_frame = 1;
static int FUNC_0(AVCodecContext *VAR_0, void *VAR_1,

                            int *VAR_2, AVPacket *VAR_3)

{

    const uint8_t *VAR_4 = VAR_3->VAR_1;

    int VAR_5 = VAR_3->size;

    CLVContext *c = VAR_0->priv_data;

    GetByteContext gb;

    uint32_t frame_type;

    int VAR_6, VAR_7;

    int VAR_8;

    int VAR_9 = 0;



    bytestream2_init(&gb, VAR_4, VAR_5);

    if (VAR_0->codec_tag == MKTAG('C','L','V','1')) {

        int VAR_10 = bytestream2_get_byte(&gb);

        bytestream2_skip(&gb, (VAR_10 + 1) * 8);

    }



    frame_type = bytestream2_get_byte(&gb);

    if ((VAR_8 = ff_reget_buffer(VAR_0, c->pic)) < 0)

        return VAR_8;



    c->pic->key_frame = frame_type & 0x20 ? 1 : 0;

    c->pic->pict_type = frame_type & 0x20 ? AV_PICTURE_TYPE_I : AV_PICTURE_TYPE_P;



    if (frame_type & 0x2) {

        if (VAR_5 < c->mb_width * c->mb_height) {

            av_log(VAR_0, AV_LOG_ERROR, "Packet too small\n");

            return AVERROR_INVALIDDATA;

        }



        bytestream2_get_be32(&gb); 

        c->ac_quant        = bytestream2_get_byte(&gb);

        c->luma_dc_quant   = 32;

        c->chroma_dc_quant = 32;



        if ((VAR_8 = init_get_bits8(&c->gb, VAR_4 + bytestream2_tell(&gb),

                                  (VAR_5 - bytestream2_tell(&gb)))) < 0)

            return VAR_8;



        for (VAR_6 = 0; VAR_6 < 3; VAR_6++)

            c->top_dc[VAR_6] = 32;

        for (VAR_6 = 0; VAR_6 < 4; VAR_6++)

            c->left_dc[VAR_6] = 32;



        for (VAR_7 = 0; VAR_7 < c->mb_height; VAR_7++) {

            for (VAR_6 = 0; VAR_6 < c->mb_width; VAR_6++) {

                VAR_8 = decode_mb(c, VAR_6, VAR_7);

                if (VAR_8 < 0)

                    VAR_9 = VAR_8;

            }

        }

    } else {

    }



    if ((VAR_8 = av_frame_ref(VAR_1, c->pic)) < 0)

        return VAR_8;



    *VAR_2 = 1;



    return VAR_9 < 0 ? VAR_9 : VAR_5;

}

static int FUNC_0(AVCodecContext *VAR_0, void *VAR_1,
int *VAR_2, AVPacket *VAR_3)
{ const uint8_t *VAR_4 = VAR_3->VAR_1; int VAR_5 = VAR_3->size; CLVContext *c = VAR_0->priv_data; GetByteContext gb; uint32_t frame_type; int VAR_6, VAR_7; int VAR_8; int VAR_9 = 0; bytestream2_init(&gb, VAR_4, VAR_5); if (VAR_0->codec_tag == MKTAG('C','L','V','1')) { int VAR_10 = bytestream2_get_byte(&gb); bytestream2_skip(&gb, (VAR_10 + 1) * 8); } frame_type = bytestream2_get_byte(&gb); if ((VAR_8 = ff_reget_buffer(VAR_0, c->pic)) < 0)
return VAR_8; c->pic->key_frame = frame_type & 0x20 ? 1 : 0; c->pic->pict_type = frame_type & 0x20 ? AV_PICTURE_TYPE_I : AV_PICTURE_TYPE_P; if (frame_type & 0x2) { if (VAR_5 < c->mb_width * c->mb_height) { av_log(VAR_0, AV_LOG_ERROR, "Packet too small\n"); return AVERROR_INVALIDDATA; } bytestream2_get_be32(&gb); c->ac_quant        = bytestream2_get_byte(&gb); c->luma_dc_quant   = 32; c->chroma_dc_quant = 32; if ((VAR_8 = init_get_bits8(&c->gb, VAR_4 + bytestream2_tell(&gb),
(VAR_5 - bytestream2_tell(&gb)))) < 0)
return VAR_8; for (VAR_6 = 0; VAR_6 < 3; VAR_6++) c->top_dc[VAR_6] = 32; for (VAR_6 = 0; VAR_6 < 4; VAR_6++) c->left_dc[VAR_6] = 32; for (VAR_7 = 0; VAR_7 < c->mb_height; VAR_7++) { for (VAR_6 = 0; VAR_6 < c->mb_width; VAR_6++) { VAR_8 = decode_mb(c, VAR_6, VAR_7); if (VAR_8 < 0)
VAR_9 = VAR_8; } } } else { } if ((VAR_8 = av_frame_ref(VAR_1, c->pic)) < 0)
return VAR_8; *VAR_2 = 1; return VAR_9 < 0 ? VAR_9 : VAR_5; }