static int cinepak_decode (CinepakContext *s)
{
    const uint8_t  *eod = (s->data + s->size);
    int           i, result, strip_size, frame_flags, num_strips;
    int           y0 = 0;
    int           encoded_buf_size;
    if (s->size < 10)
        return -1;
    frame_flags = s->data[0];
    num_strips  = AV_RB16 (&s->data[8]);
    encoded_buf_size = ((s->data[1] << 16) | AV_RB16 (&s->data[2]));
    if (s->sega_film_skip_bytes == -1) {
        if (encoded_buf_size != s->size) {
            if ((s->data[10] == 0xFE) &&
                (s->data[11] == 0x00) &&
                (s->data[12] == 0x00) &&
                (s->data[13] == 0x06) &&
                (s->data[14] == 0x00) &&
                (s->data[15] == 0x00))
                s->sega_film_skip_bytes = 6;
            else
                s->sega_film_skip_bytes = 2;
        } else
            s->sega_film_skip_bytes = 0;
    }
    s->data += 10 + s->sega_film_skip_bytes;
    if (num_strips > MAX_STRIPS)
        num_strips = MAX_STRIPS;
    for (i=0; i < num_strips; i++) {
        if ((s->data + 12) > eod)
            return -1;
        s->strips[i].id = AV_RB16 (s->data);
        s->strips[i].y1 = y0;
        s->strips[i].x1 = 0;
        s->strips[i].y2 = y0 + AV_RB16 (&s->data[8]);
        s->strips[i].x2 = s->avctx->width;
        strip_size = AV_RB16 (&s->data[2]) - 12;
        s->data   += 12;
        strip_size = ((s->data + strip_size) > eod) ? (eod - s->data) : strip_size;
        if ((i > 0) && !(frame_flags & 0x01)) {
            memcpy (s->strips[i].v4_codebook, s->strips[i-1].v4_codebook,
                sizeof(s->strips[i].v4_codebook));
            memcpy (s->strips[i].v1_codebook, s->strips[i-1].v1_codebook,
                sizeof(s->strips[i].v1_codebook));
        }
        result = cinepak_decode_strip (s, &s->strips[i], s->data, strip_size);
        if (result != 0)
            return result;
        s->data += strip_size;
        y0    = s->strips[i].y2;
    }
    return 0;
}
['static int cinepak_decode (CinepakContext *s)\n{\n    const uint8_t  *eod = (s->data + s->size);\n    int           i, result, strip_size, frame_flags, num_strips;\n    int           y0 = 0;\n    int           encoded_buf_size;\n    if (s->size < 10)\n        return -1;\n    frame_flags = s->data[0];\n    num_strips  = AV_RB16 (&s->data[8]);\n    encoded_buf_size = ((s->data[1] << 16) | AV_RB16 (&s->data[2]));\n    if (s->sega_film_skip_bytes == -1) {\n        if (encoded_buf_size != s->size) {\n            if ((s->data[10] == 0xFE) &&\n                (s->data[11] == 0x00) &&\n                (s->data[12] == 0x00) &&\n                (s->data[13] == 0x06) &&\n                (s->data[14] == 0x00) &&\n                (s->data[15] == 0x00))\n                s->sega_film_skip_bytes = 6;\n            else\n                s->sega_film_skip_bytes = 2;\n        } else\n            s->sega_film_skip_bytes = 0;\n    }\n    s->data += 10 + s->sega_film_skip_bytes;\n    if (num_strips > MAX_STRIPS)\n        num_strips = MAX_STRIPS;\n    for (i=0; i < num_strips; i++) {\n        if ((s->data + 12) > eod)\n            return -1;\n        s->strips[i].id = AV_RB16 (s->data);\n        s->strips[i].y1 = y0;\n        s->strips[i].x1 = 0;\n        s->strips[i].y2 = y0 + AV_RB16 (&s->data[8]);\n        s->strips[i].x2 = s->avctx->width;\n        strip_size = AV_RB16 (&s->data[2]) - 12;\n        s->data   += 12;\n        strip_size = ((s->data + strip_size) > eod) ? (eod - s->data) : strip_size;\n        if ((i > 0) && !(frame_flags & 0x01)) {\n            memcpy (s->strips[i].v4_codebook, s->strips[i-1].v4_codebook,\n                sizeof(s->strips[i].v4_codebook));\n            memcpy (s->strips[i].v1_codebook, s->strips[i-1].v1_codebook,\n                sizeof(s->strips[i].v1_codebook));\n        }\n        result = cinepak_decode_strip (s, &s->strips[i], s->data, strip_size);\n        if (result != 0)\n            return result;\n        s->data += strip_size;\n        y0    = s->strips[i].y2;\n    }\n    return 0;\n}']