static int yop_decode_frame(AVCodecContext *avctx, void *data, int *data_size,

                            AVPacket *avpkt)

{

    YopDecContext *s = avctx->priv_data;

    int tag, firstcolor, is_odd_frame;

    int ret, i;

    uint32_t *palette;



    if (s->frame.data[0])

        avctx->release_buffer(avctx, &s->frame);



    if (avpkt->size < 4 + 3*s->num_pal_colors) {

        av_log(avctx, AV_LOG_ERROR, "packet of size %d too small\n", avpkt->size);

        return AVERROR_INVALIDDATA;

    }



    ret = avctx->get_buffer(avctx, &s->frame);

    if (ret < 0) {

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

        return ret;

    }



    s->frame.linesize[0] = avctx->width;



    s->dstbuf     = s->frame.data[0];

    s->dstptr     = s->frame.data[0];

    s->srcptr     = avpkt->data + 4;

    s->row_pos    = 0;

    s->low_nibble = NULL;



    is_odd_frame = avpkt->data[0];

    if(is_odd_frame>1){

        av_log(avctx, AV_LOG_ERROR, "frame is too odd %d\n", is_odd_frame);

        return AVERROR_INVALIDDATA;

    }

    firstcolor   = s->first_color[is_odd_frame];

    palette      = (uint32_t *)s->frame.data[1];



    for (i = 0; i < s->num_pal_colors; i++, s->srcptr += 3) {

        palette[i + firstcolor] = (s->srcptr[0] << 18) |

                                  (s->srcptr[1] << 10) |

                                  (s->srcptr[2] << 2);

        palette[i + firstcolor] |= 0xFF << 24 |

                                   (palette[i + firstcolor] >> 6) & 0x30303;

    }



    s->frame.palette_has_changed = 1;



    while (s->dstptr - s->dstbuf <

           avctx->width * avctx->height &&

           s->srcptr - avpkt->data < avpkt->size) {



        tag = yop_get_next_nibble(s);



        if (tag != 0xf) {

            yop_paint_block(s, tag);

        }else {

            tag = yop_get_next_nibble(s);

            ret = yop_copy_previous_block(s, tag);

            if (ret < 0) {

                avctx->release_buffer(avctx, &s->frame);

                return ret;

            }

        }

        yop_next_macroblock(s);

    }



    *data_size        = sizeof(AVFrame);

    *(AVFrame *) data = s->frame;

    return avpkt->size;

}

static int yop_decode_frame(AVCodecContext *avctx, void *data, int *data_size,

                            AVPacket *avpkt)

{

    YopDecContext *s = avctx->priv_data;

    int tag, firstcolor, is_odd_frame;

    int ret, i;

    uint32_t *palette;



    if (s->frame.data[0])

        avctx->release_buffer(avctx, &s->frame);



    if (avpkt->size < 4 + 3*s->num_pal_colors) {

        av_log(avctx, AV_LOG_ERROR, "packet of size %d too small\n", avpkt->size);

        return AVERROR_INVALIDDATA;

    }



    ret = avctx->get_buffer(avctx, &s->frame);

    if (ret < 0) {

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

        return ret;

    }



    s->frame.linesize[0] = avctx->width;



    s->dstbuf     = s->frame.data[0];

    s->dstptr     = s->frame.data[0];

    s->srcptr     = avpkt->data + 4;

    s->row_pos    = 0;

    s->low_nibble = NULL;



    is_odd_frame = avpkt->data[0];

    if(is_odd_frame>1){

        av_log(avctx, AV_LOG_ERROR, "frame is too odd %d\n", is_odd_frame);

        return AVERROR_INVALIDDATA;

    }

    firstcolor   = s->first_color[is_odd_frame];

    palette      = (uint32_t *)s->frame.data[1];



    for (i = 0; i < s->num_pal_colors; i++, s->srcptr += 3) {

        palette[i + firstcolor] = (s->srcptr[0] << 18) |

                                  (s->srcptr[1] << 10) |

                                  (s->srcptr[2] << 2);

        palette[i + firstcolor] |= 0xFF << 24 |

                                   (palette[i + firstcolor] >> 6) & 0x30303;

    }



    s->frame.palette_has_changed = 1;



    while (s->dstptr - s->dstbuf <

           avctx->width * avctx->height &&

           s->srcptr - avpkt->data < avpkt->size) {



        tag = yop_get_next_nibble(s);



        if (tag != 0xf) {

            yop_paint_block(s, tag);

        }else {

            tag = yop_get_next_nibble(s);

            ret = yop_copy_previous_block(s, tag);

            if (ret < 0) {

                avctx->release_buffer(avctx, &s->frame);

                return ret;

            }

        }

        yop_next_macroblock(s);

    }



    *data_size        = sizeof(AVFrame);

    *(AVFrame *) data = s->frame;

    return avpkt->size;

}

        palette[i + firstcolor] |= 0xFF << 24 |
static int FUNC_0(AVCodecContext *VAR_0, void *VAR_1, int *VAR_2,

                            AVPacket *VAR_3)

{

    YopDecContext *s = VAR_0->priv_data;

    int VAR_4, VAR_5, VAR_6;

    int VAR_7, VAR_8;

    uint32_t *palette;



    if (s->frame.VAR_1[0])

        VAR_0->release_buffer(VAR_0, &s->frame);



    if (VAR_3->size < 4 + 3*s->num_pal_colors) {

        av_log(VAR_0, AV_LOG_ERROR, "packet of size %d too small\n", VAR_3->size);

        return AVERROR_INVALIDDATA;

    }



    VAR_7 = VAR_0->get_buffer(VAR_0, &s->frame);

    if (VAR_7 < 0) {

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

        return VAR_7;

    }



    s->frame.linesize[0] = VAR_0->width;



    s->dstbuf     = s->frame.VAR_1[0];

    s->dstptr     = s->frame.VAR_1[0];

    s->srcptr     = VAR_3->VAR_1 + 4;

    s->row_pos    = 0;

    s->low_nibble = NULL;



    VAR_6 = VAR_3->VAR_1[0];

    if(VAR_6>1){

        av_log(VAR_0, AV_LOG_ERROR, "frame is too odd %d\n", VAR_6);

        return AVERROR_INVALIDDATA;

    }

    VAR_5   = s->first_color[VAR_6];

    palette      = (uint32_t *)s->frame.VAR_1[1];



    for (VAR_8 = 0; VAR_8 < s->num_pal_colors; VAR_8++, s->srcptr += 3) {

        palette[VAR_8 + VAR_5] = (s->srcptr[0] << 18) |

                                  (s->srcptr[1] << 10) |

                                  (s->srcptr[2] << 2);

        palette[VAR_8 + VAR_5] |= 0xFF << 24 |

                                   (palette[VAR_8 + VAR_5] >> 6) & 0x30303;

    }



    s->frame.palette_has_changed = 1;



    while (s->dstptr - s->dstbuf <

           VAR_0->width * VAR_0->height &&

           s->srcptr - VAR_3->VAR_1 < VAR_3->size) {



        VAR_4 = yop_get_next_nibble(s);



        if (VAR_4 != 0xf) {

            yop_paint_block(s, VAR_4);

        }else {

            VAR_4 = yop_get_next_nibble(s);

            VAR_7 = yop_copy_previous_block(s, VAR_4);

            if (VAR_7 < 0) {

                VAR_0->release_buffer(VAR_0, &s->frame);

                return VAR_7;

            }

        }

        yop_next_macroblock(s);

    }



    *VAR_2        = sizeof(AVFrame);

    *(AVFrame *) VAR_1 = s->frame;

    return VAR_3->size;

}

static int FUNC_0(AVCodecContext *VAR_0, void *VAR_1, int *VAR_2,
AVPacket *VAR_3)
{ YopDecContext *s = VAR_0->priv_data; int VAR_4, VAR_5, VAR_6; int VAR_7, VAR_8; uint32_t *palette; if (s->frame.VAR_1[0])
VAR_0->release_buffer(VAR_0, &s->frame); if (VAR_3->size < 4 + 3*s->num_pal_colors) { av_log(VAR_0, AV_LOG_ERROR, "packet of size %d too small\n", VAR_3->size); return AVERROR_INVALIDDATA; } VAR_7 = VAR_0->get_buffer(VAR_0, &s->frame); if (VAR_7 < 0) { av_log(VAR_0, AV_LOG_ERROR, "get_buffer() failed\n"); return VAR_7; } s->frame.linesize[0] = VAR_0->width; s->dstbuf     = s->frame.VAR_1[0]; s->dstptr     = s->frame.VAR_1[0]; s->srcptr     = VAR_3->VAR_1 + 4; s->row_pos    = 0; s->low_nibble = NULL; VAR_6 = VAR_3->VAR_1[0]; if(VAR_6>1){ av_log(VAR_0, AV_LOG_ERROR, "frame is too odd %d\n", VAR_6); return AVERROR_INVALIDDATA; } VAR_5   = s->first_color[VAR_6]; palette      = (uint32_t *)s->frame.VAR_1[1]; for (VAR_8 = 0; VAR_8 < s->num_pal_colors; VAR_8++, s->srcptr += 3) { palette[VAR_8 + VAR_5] = (s->srcptr[0] << 18) |
(s->srcptr[1] << 10) |
(s->srcptr[2] << 2); palette[VAR_8 + VAR_5] |= 0xFF << 24 |
(palette[VAR_8 + VAR_5] >> 6) & 0x30303; } s->frame.palette_has_changed = 1; while (s->dstptr - s->dstbuf <
VAR_0->width * VAR_0->height &&
s->srcptr - VAR_3->VAR_1 < VAR_3->size) { VAR_4 = yop_get_next_nibble(s); if (VAR_4 != 0xf) { yop_paint_block(s, VAR_4); }else { VAR_4 = yop_get_next_nibble(s); VAR_7 = yop_copy_previous_block(s, VAR_4); if (VAR_7 < 0) { VAR_0->release_buffer(VAR_0, &s->frame); return VAR_7; } } yop_next_macroblock(s); } *VAR_2        = sizeof(AVFrame); *(AVFrame *) VAR_1 = s->frame; return VAR_3->size; }