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

                             int *got_frame, AVPacket *avpkt)

{

    const uint8_t *buf        = avpkt->data;

    int buf_size              = avpkt->size;

    VCR1Context *const a      = avctx->priv_data;

    AVFrame *const p          = data;

    const uint8_t *bytestream = buf;

    int i, x, y, ret;



    if ((ret = ff_get_buffer(avctx, p, 0)) < 0) {

        av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");

        return ret;

    }

    p->pict_type = AV_PICTURE_TYPE_I;

    p->key_frame = 1;



    if (buf_size < 32)

        goto packet_small;



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

        a->delta[i] = *bytestream++;

        bytestream++;

        buf_size--;

    }



    for (y = 0; y < avctx->height; y++) {

        int offset;

        uint8_t *luma = &p->data[0][y * p->linesize[0]];



        if ((y & 3) == 0) {

            uint8_t *cb = &p->data[1][(y >> 2) * p->linesize[1]];

            uint8_t *cr = &p->data[2][(y >> 2) * p->linesize[2]];



            if (buf_size < 4 + avctx->width)

                goto packet_small;



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

                a->offset[i] = *bytestream++;

            buf_size -= 4;



            offset = a->offset[0] - a->delta[bytestream[2] & 0xF];

            for (x = 0; x < avctx->width; x += 4) {

                luma[0]     = offset += a->delta[bytestream[2] & 0xF];

                luma[1]     = offset += a->delta[bytestream[2] >>  4];

                luma[2]     = offset += a->delta[bytestream[0] & 0xF];

                luma[3]     = offset += a->delta[bytestream[0] >>  4];

                luma       += 4;



                *cb++       = bytestream[3];

                *cr++       = bytestream[1];



                bytestream += 4;


            }

        } else {

            if (buf_size < avctx->width / 2)

                goto packet_small;



            offset = a->offset[y & 3] - a->delta[bytestream[2] & 0xF];



            for (x = 0; x < avctx->width; x += 8) {

                luma[0]     = offset += a->delta[bytestream[2] & 0xF];

                luma[1]     = offset += a->delta[bytestream[2] >>  4];

                luma[2]     = offset += a->delta[bytestream[3] & 0xF];

                luma[3]     = offset += a->delta[bytestream[3] >>  4];

                luma[4]     = offset += a->delta[bytestream[0] & 0xF];

                luma[5]     = offset += a->delta[bytestream[0] >>  4];

                luma[6]     = offset += a->delta[bytestream[1] & 0xF];

                luma[7]     = offset += a->delta[bytestream[1] >>  4];

                luma       += 8;

                bytestream += 4;


            }

        }

    }



    *got_frame = 1;



    return buf_size;

packet_small:

    av_log(avctx, AV_LOG_ERROR, "Input packet too small.\n");

    return AVERROR_INVALIDDATA;

}
static int vcr1_decode_frame(AVCodecContext *avctx, void *data,

                             int *got_frame, AVPacket *avpkt)

{

    const uint8_t *buf        = avpkt->data;

    int buf_size              = avpkt->size;

    VCR1Context *const a      = avctx->priv_data;

    AVFrame *const p          = data;

    const uint8_t *bytestream = buf;

    int i, x, y, ret;



    if ((ret = ff_get_buffer(avctx, p, 0)) < 0) {

        av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");

        return ret;

    }

    p->pict_type = AV_PICTURE_TYPE_I;

    p->key_frame = 1;



    if (buf_size < 32)

        goto packet_small;



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

        a->delta[i] = *bytestream++;

        bytestream++;

        buf_size--;

    }



    for (y = 0; y < avctx->height; y++) {

        int offset;

        uint8_t *luma = &p->data[0][y * p->linesize[0]];



        if ((y & 3) == 0) {

            uint8_t *cb = &p->data[1][(y >> 2) * p->linesize[1]];

            uint8_t *cr = &p->data[2][(y >> 2) * p->linesize[2]];



            if (buf_size < 4 + avctx->width)

                goto packet_small;



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

                a->offset[i] = *bytestream++;

            buf_size -= 4;



            offset = a->offset[0] - a->delta[bytestream[2] & 0xF];

            for (x = 0; x < avctx->width; x += 4) {

                luma[0]     = offset += a->delta[bytestream[2] & 0xF];

                luma[1]     = offset += a->delta[bytestream[2] >>  4];

                luma[2]     = offset += a->delta[bytestream[0] & 0xF];

                luma[3]     = offset += a->delta[bytestream[0] >>  4];

                luma       += 4;



                *cb++       = bytestream[3];

                *cr++       = bytestream[1];



                bytestream += 4;


            }

        } else {

            if (buf_size < avctx->width / 2)

                goto packet_small;



            offset = a->offset[y & 3] - a->delta[bytestream[2] & 0xF];



            for (x = 0; x < avctx->width; x += 8) {

                luma[0]     = offset += a->delta[bytestream[2] & 0xF];

                luma[1]     = offset += a->delta[bytestream[2] >>  4];

                luma[2]     = offset += a->delta[bytestream[3] & 0xF];

                luma[3]     = offset += a->delta[bytestream[3] >>  4];

                luma[4]     = offset += a->delta[bytestream[0] & 0xF];

                luma[5]     = offset += a->delta[bytestream[0] >>  4];

                luma[6]     = offset += a->delta[bytestream[1] & 0xF];

                luma[7]     = offset += a->delta[bytestream[1] >>  4];

                luma       += 8;

                bytestream += 4;


            }

        }

    }



    *got_frame = 1;



    return buf_size;

packet_small:

    av_log(avctx, AV_LOG_ERROR, "Input packet too small.\n");

    return AVERROR_INVALIDDATA;

}
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;

    VCR1Context *const a      = VAR_0->priv_data;

    AVFrame *const p          = VAR_1;

    const uint8_t *VAR_6 = VAR_4;

    int VAR_7, VAR_8, VAR_9, VAR_10;



    if ((VAR_10 = ff_get_buffer(VAR_0, p, 0)) < 0) {

        av_log(VAR_0, AV_LOG_ERROR, "get_buffer() failed\n");

        return VAR_10;

    }

    p->pict_type = AV_PICTURE_TYPE_I;

    p->key_frame = 1;



    if (VAR_5 < 32)

        goto packet_small;



    for (VAR_7 = 0; VAR_7 < 16; VAR_7++) {

        a->delta[VAR_7] = *VAR_6++;

        VAR_6++;

        VAR_5--;

    }



    for (VAR_9 = 0; VAR_9 < VAR_0->height; VAR_9++) {

        int offset;

        uint8_t *luma = &p->VAR_1[0][VAR_9 * p->linesize[0]];



        if ((VAR_9 & 3) == 0) {

            uint8_t *cb = &p->VAR_1[1][(VAR_9 >> 2) * p->linesize[1]];

            uint8_t *cr = &p->VAR_1[2][(VAR_9 >> 2) * p->linesize[2]];



            if (VAR_5 < 4 + VAR_0->width)

                goto packet_small;



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

                a->offset[VAR_7] = *VAR_6++;

            VAR_5 -= 4;



            offset = a->offset[0] - a->delta[VAR_6[2] & 0xF];

            for (VAR_8 = 0; VAR_8 < VAR_0->width; VAR_8 += 4) {

                luma[0]     = offset += a->delta[VAR_6[2] & 0xF];

                luma[1]     = offset += a->delta[VAR_6[2] >>  4];

                luma[2]     = offset += a->delta[VAR_6[0] & 0xF];

                luma[3]     = offset += a->delta[VAR_6[0] >>  4];

                luma       += 4;



                *cb++       = VAR_6[3];

                *cr++       = VAR_6[1];



                VAR_6 += 4;


            }

        } else {

            if (VAR_5 < VAR_0->width / 2)

                goto packet_small;



            offset = a->offset[VAR_9 & 3] - a->delta[VAR_6[2] & 0xF];



            for (VAR_8 = 0; VAR_8 < VAR_0->width; VAR_8 += 8) {

                luma[0]     = offset += a->delta[VAR_6[2] & 0xF];

                luma[1]     = offset += a->delta[VAR_6[2] >>  4];

                luma[2]     = offset += a->delta[VAR_6[3] & 0xF];

                luma[3]     = offset += a->delta[VAR_6[3] >>  4];

                luma[4]     = offset += a->delta[VAR_6[0] & 0xF];

                luma[5]     = offset += a->delta[VAR_6[0] >>  4];

                luma[6]     = offset += a->delta[VAR_6[1] & 0xF];

                luma[7]     = offset += a->delta[VAR_6[1] >>  4];

                luma       += 8;

                VAR_6 += 4;


            }

        }

    }



    *VAR_2 = 1;



    return VAR_5;

packet_small:

    av_log(VAR_0, AV_LOG_ERROR, "Input packet too small.\n");

    return AVERROR_INVALIDDATA;

}
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; VCR1Context *const a      = VAR_0->priv_data; AVFrame *const p          = VAR_1; const uint8_t *VAR_6 = VAR_4; int VAR_7, VAR_8, VAR_9, VAR_10; if ((VAR_10 = ff_get_buffer(VAR_0, p, 0)) < 0) { av_log(VAR_0, AV_LOG_ERROR, "get_buffer() failed\n"); return VAR_10; } p->pict_type = AV_PICTURE_TYPE_I; p->key_frame = 1; if (VAR_5 < 32)
goto packet_small; for (VAR_7 = 0; VAR_7 < 16; VAR_7++) { a->delta[VAR_7] = *VAR_6++; VAR_6++; VAR_5--; } for (VAR_9 = 0; VAR_9 < VAR_0->height; VAR_9++) { int offset; uint8_t *luma = &p->VAR_1[0][VAR_9 * p->linesize[0]]; if ((VAR_9 & 3) == 0) { uint8_t *cb = &p->VAR_1[1][(VAR_9 >> 2) * p->linesize[1]]; uint8_t *cr = &p->VAR_1[2][(VAR_9 >> 2) * p->linesize[2]]; if (VAR_5 < 4 + VAR_0->width)
goto packet_small; for (VAR_7 = 0; VAR_7 < 4; VAR_7++) a->offset[VAR_7] = *VAR_6++; VAR_5 -= 4; offset = a->offset[0] - a->delta[VAR_6[2] & 0xF]; for (VAR_8 = 0; VAR_8 < VAR_0->width; VAR_8 += 4) { luma[0]     = offset += a->delta[VAR_6[2] & 0xF]; luma[1]     = offset += a->delta[VAR_6[2] >>  4]; luma[2]     = offset += a->delta[VAR_6[0] & 0xF]; luma[3]     = offset += a->delta[VAR_6[0] >>  4]; luma       += 4; *cb++       = VAR_6[3]; *cr++       = VAR_6[1]; VAR_6 += 4; } } else { if (VAR_5 < VAR_0->width / 2)
goto packet_small; offset = a->offset[VAR_9 & 3] - a->delta[VAR_6[2] & 0xF]; for (VAR_8 = 0; VAR_8 < VAR_0->width; VAR_8 += 8) { luma[0]     = offset += a->delta[VAR_6[2] & 0xF]; luma[1]     = offset += a->delta[VAR_6[2] >>  4]; luma[2]     = offset += a->delta[VAR_6[3] & 0xF]; luma[3]     = offset += a->delta[VAR_6[3] >>  4]; luma[4]     = offset += a->delta[VAR_6[0] & 0xF]; luma[5]     = offset += a->delta[VAR_6[0] >>  4]; luma[6]     = offset += a->delta[VAR_6[1] & 0xF]; luma[7]     = offset += a->delta[VAR_6[1] >>  4]; luma       += 8; VAR_6 += 4; } } } *VAR_2 = 1; return VAR_5; packet_small:
av_log(VAR_0, AV_LOG_ERROR, "Input packet too small.\n"); return AVERROR_INVALIDDATA; }