static int cinepak_decode_strip (CinepakContext *s,

                                 cvid_strip *strip, const uint8_t *data, int size)

{

    const uint8_t *eod = (data + size);

    int      chunk_id, chunk_size;



    /* coordinate sanity checks */

    if (strip->x1 >= s->width  || strip->x2 > s->width  ||

        strip->y1 >= s->height || strip->y2 > s->height ||

        strip->x1 >= strip->x2 || strip->y1 >= strip->y2)

        return -1;



    while ((data + 4) <= eod) {

        chunk_id   = data[0];

        chunk_size = AV_RB24 (&data[1]) - 4;

        if(chunk_size < 0)

            return -1;



        data      += 4;

        chunk_size = ((data + chunk_size) > eod) ? (eod - data) : chunk_size;



        switch (chunk_id) {



        case 0x20:

        case 0x21:

        case 0x24:

        case 0x25:

            cinepak_decode_codebook (strip->v4_codebook, chunk_id,

                chunk_size, data);

            break;



        case 0x22:

        case 0x23:

        case 0x26:

        case 0x27:

            cinepak_decode_codebook (strip->v1_codebook, chunk_id,

                chunk_size, data);

            break;



        case 0x30:

        case 0x31:

        case 0x32:

            return cinepak_decode_vectors (s, strip, chunk_id,

                chunk_size, data);

        }



        data += chunk_size;

    }



    return -1;

}

static int cinepak_decode_strip (CinepakContext *s,

                                 cvid_strip *strip, const uint8_t *data, int size)

{

    const uint8_t *eod = (data + size);

    int      chunk_id, chunk_size;



    

    if (strip->x1 >= s->width  || strip->x2 > s->width  ||

        strip->y1 >= s->height || strip->y2 > s->height ||

        strip->x1 >= strip->x2 || strip->y1 >= strip->y2)

        return -1;



    while ((data + 4) <= eod) {

        chunk_id   = data[0];

        chunk_size = AV_RB24 (&data[1]) - 4;

        if(chunk_size < 0)

            return -1;



        data      += 4;

        chunk_size = ((data + chunk_size) > eod) ? (eod - data) : chunk_size;



        switch (chunk_id) {



        case 0x20:

        case 0x21:

        case 0x24:

        case 0x25:

            cinepak_decode_codebook (strip->v4_codebook, chunk_id,

                chunk_size, data);

            break;



        case 0x22:

        case 0x23:

        case 0x26:

        case 0x27:

            cinepak_decode_codebook (strip->v1_codebook, chunk_id,

                chunk_size, data);

            break;



        case 0x30:

        case 0x31:

        case 0x32:

            return cinepak_decode_vectors (s, strip, chunk_id,

                chunk_size, data);

        }



        data += chunk_size;

    }



    return -1;

}

static int FUNC_0 (CinepakContext *VAR_0,

                                 cvid_strip *VAR_1, const uint8_t *VAR_2, int VAR_3)

{

    const uint8_t *VAR_4 = (VAR_2 + VAR_3);

    int      VAR_5, VAR_6;



    

    if (VAR_1->x1 >= VAR_0->width  || VAR_1->x2 > VAR_0->width  ||

        VAR_1->y1 >= VAR_0->height || VAR_1->y2 > VAR_0->height ||

        VAR_1->x1 >= VAR_1->x2 || VAR_1->y1 >= VAR_1->y2)

        return -1;



    while ((VAR_2 + 4) <= VAR_4) {

        VAR_5   = VAR_2[0];

        VAR_6 = AV_RB24 (&VAR_2[1]) - 4;

        if(VAR_6 < 0)

            return -1;



        VAR_2      += 4;

        VAR_6 = ((VAR_2 + VAR_6) > VAR_4) ? (VAR_4 - VAR_2) : VAR_6;



        switch (VAR_5) {



        case 0x20:

        case 0x21:

        case 0x24:

        case 0x25:

            cinepak_decode_codebook (VAR_1->v4_codebook, VAR_5,

                VAR_6, VAR_2);

            break;



        case 0x22:

        case 0x23:

        case 0x26:

        case 0x27:

            cinepak_decode_codebook (VAR_1->v1_codebook, VAR_5,

                VAR_6, VAR_2);

            break;



        case 0x30:

        case 0x31:

        case 0x32:

            return cinepak_decode_vectors (VAR_0, VAR_1, VAR_5,

                VAR_6, VAR_2);

        }



        VAR_2 += VAR_6;

    }



    return -1;

}

static int FUNC_0 (CinepakContext *VAR_0,
cvid_strip *VAR_1, const uint8_t *VAR_2, int VAR_3)
{ const uint8_t *VAR_4 = (VAR_2 + VAR_3); int      VAR_5, VAR_6; if (VAR_1->x1 >= VAR_0->width  || VAR_1->x2 > VAR_0->width  ||
VAR_1->y1 >= VAR_0->height || VAR_1->y2 > VAR_0->height ||
VAR_1->x1 >= VAR_1->x2 || VAR_1->y1 >= VAR_1->y2)
return -1; while ((VAR_2 + 4) <= VAR_4) { VAR_5   = VAR_2[0]; VAR_6 = AV_RB24 (&VAR_2[1]) - 4; if(VAR_6 < 0)
return -1; VAR_2      += 4; VAR_6 = ((VAR_2 + VAR_6) > VAR_4) ? (VAR_4 - VAR_2) : VAR_6; switch (VAR_5) { case 0x20:
case 0x21:
case 0x24:
case 0x25:
cinepak_decode_codebook (VAR_1->v4_codebook, VAR_5,
VAR_6, VAR_2); break; case 0x22:
case 0x23:
case 0x26:
case 0x27:
cinepak_decode_codebook (VAR_1->v1_codebook, VAR_5,
VAR_6, VAR_2); break; case 0x30:
case 0x31:
case 0x32:
return cinepak_decode_vectors (VAR_0, VAR_1, VAR_5,
VAR_6, VAR_2); } VAR_2 += VAR_6; } return -1; }