static int cinepak_decode_strip (CinepakContext *s,
                                 cvid_strip_t *strip, uint8_t *data, int size)
{
    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)
    while ((data + 4) <= eod) {
        chunk_id   = BE_16 (&data[0]);
        chunk_size = BE_16 (&data[2]) - 4;
        data      += 4;
        chunk_size = ((data + chunk_size) > eod) ? (eod - data) : chunk_size;
        switch (chunk_id) {
        case 0x2000:
        case 0x2100:
        case 0x2400:
        case 0x2500:
            cinepak_decode_codebook (strip->v4_codebook, chunk_id, 
                chunk_size, data);
            break;
        case 0x2200:
        case 0x2300:
        case 0x2600:
        case 0x2700:
            cinepak_decode_codebook (strip->v1_codebook, chunk_id, 
                chunk_size, data);
            break;
        case 0x3000:
        case 0x3100:
        case 0x3200:
            return cinepak_decode_vectors (s, strip, chunk_id, 
                chunk_size, data);
        }
        data += chunk_size;
    }
}
static int cinepak_decode_strip (CinepakContext *s,
                                 cvid_strip_t *strip, uint8_t *data, int size)
{
    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)
    while ((data + 4) <= eod) {
        chunk_id   = BE_16 (&data[0]);
        chunk_size = BE_16 (&data[2]) - 4;
        data      += 4;
        chunk_size = ((data + chunk_size) > eod) ? (eod - data) : chunk_size;
        switch (chunk_id) {
        case 0x2000:
        case 0x2100:
        case 0x2400:
        case 0x2500:
            cinepak_decode_codebook (strip->v4_codebook, chunk_id, 
                chunk_size, data);
            break;
        case 0x2200:
        case 0x2300:
        case 0x2600:
        case 0x2700:
            cinepak_decode_codebook (strip->v1_codebook, chunk_id, 
                chunk_size, data);
            break;
        case 0x3000:
        case 0x3100:
        case 0x3200:
            return cinepak_decode_vectors (s, strip, chunk_id, 
                chunk_size, data);
        }
        data += chunk_size;
    }
}
static int FUNC_0 (CinepakContext *VAR_0,
                                 cvid_strip_t *VAR_1, uint8_t *VAR_2, int VAR_3)
{
    uint8_t *eod = (VAR_2 + VAR_3);
    int      VAR_4, VAR_5;
    
    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)
    while ((VAR_2 + 4) <= eod) {
        VAR_4   = BE_16 (&VAR_2[0]);
        VAR_5 = BE_16 (&VAR_2[2]) - 4;
        VAR_2      += 4;
        VAR_5 = ((VAR_2 + VAR_5) > eod) ? (eod - VAR_2) : VAR_5;
        switch (VAR_4) {
        case 0x2000:
        case 0x2100:
        case 0x2400:
        case 0x2500:
            cinepak_decode_codebook (VAR_1->v4_codebook, VAR_4, 
                VAR_5, VAR_2);
            break;
        case 0x2200:
        case 0x2300:
        case 0x2600:
        case 0x2700:
            cinepak_decode_codebook (VAR_1->v1_codebook, VAR_4, 
                VAR_5, VAR_2);
            break;
        case 0x3000:
        case 0x3100:
        case 0x3200:
            return cinepak_decode_vectors (VAR_0, VAR_1, VAR_4, 
                VAR_5, VAR_2);
        }
        VAR_2 += VAR_5;
    }
}
static int FUNC_0 (CinepakContext *VAR_0,
cvid_strip_t *VAR_1, uint8_t *VAR_2, int VAR_3)
{ uint8_t *eod = (VAR_2 + VAR_3); int      VAR_4, VAR_5; 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)
while ((VAR_2 + 4) <= eod) { VAR_4   = BE_16 (&VAR_2[0]); VAR_5 = BE_16 (&VAR_2[2]) - 4; VAR_2      += 4; VAR_5 = ((VAR_2 + VAR_5) > eod) ? (eod - VAR_2) : VAR_5; switch (VAR_4) { case 0x2000:
case 0x2100:
case 0x2400:
case 0x2500:
cinepak_decode_codebook (VAR_1->v4_codebook, VAR_4,
VAR_5, VAR_2); break; case 0x2200:
case 0x2300:
case 0x2600:
case 0x2700:
cinepak_decode_codebook (VAR_1->v1_codebook, VAR_4,
VAR_5, VAR_2); break; case 0x3000:
case 0x3100:
case 0x3200:
return cinepak_decode_vectors (VAR_0, VAR_1, VAR_4,
VAR_5, VAR_2); } VAR_2 += VAR_5; } }