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

                            AVPacket *avpkt)

{

    YopDecContext *s = avctx->priv_data;

    int tag, firstcolor, is_odd_frame;

    int ret, i, x, y;

    uint32_t *palette;



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

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



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

    if (ret < 0) {

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

        return ret;

    }



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

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

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

    s->low_nibble = NULL;



    is_odd_frame = avpkt->data[0];

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



    s->frame.palette_has_changed = 1;



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

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

            if (s->srcptr - avpkt->data >= avpkt->size) {

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

                return AVERROR_INVALIDDATA;

            }



            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;

                }

            }

            s->dstptr += 2;

        }

        s->dstptr += 2*s->frame.linesize[0] - x;

    }



    *got_frame = 1;

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

    return avpkt->size;

}

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

                            AVPacket *avpkt)

{

    YopDecContext *s = avctx->priv_data;

    int tag, firstcolor, is_odd_frame;

    int ret, i, x, y;

    uint32_t *palette;



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

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



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

    if (ret < 0) {

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

        return ret;

    }



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

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

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

    s->low_nibble = NULL;



    is_odd_frame = avpkt->data[0];

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



    s->frame.palette_has_changed = 1;



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

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

            if (s->srcptr - avpkt->data >= avpkt->size) {

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

                return AVERROR_INVALIDDATA;

            }



            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;

                }

            }

            s->dstptr += 2;

        }

        s->dstptr += 2*s->frame.linesize[0] - x;

    }



    *got_frame = 1;

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

    return avpkt->size;

}

                yop_paint_block(s, tag);
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, VAR_9, VAR_10;

    uint32_t *palette;



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

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



    VAR_7 = ff_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->dstbuf     = s->frame.VAR_1[0];

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

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

    s->low_nibble = NULL;



    VAR_6 = VAR_3->VAR_1[0];

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



    s->frame.palette_has_changed = 1;



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

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

            if (s->srcptr - VAR_3->VAR_1 >= VAR_3->size) {

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

                return AVERROR_INVALIDDATA;

            }



            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;

                }

            }

            s->dstptr += 2;

        }

        s->dstptr += 2*s->frame.linesize[0] - VAR_9;

    }



    *VAR_2 = 1;

    *(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, VAR_9, VAR_10; uint32_t *palette; if (s->frame.VAR_1[0])
VAR_0->release_buffer(VAR_0, &s->frame); VAR_7 = ff_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->dstbuf     = s->frame.VAR_1[0]; s->dstptr     = s->frame.VAR_1[0]; s->srcptr     = VAR_3->VAR_1 + 4; s->low_nibble = NULL; VAR_6 = VAR_3->VAR_1[0]; 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); s->frame.palette_has_changed = 1; for (VAR_10 = 0; VAR_10 < VAR_0->height; VAR_10 += 2) { for (VAR_9 = 0; VAR_9 < VAR_0->width; VAR_9 += 2) { if (s->srcptr - VAR_3->VAR_1 >= VAR_3->size) { av_log(VAR_0, AV_LOG_ERROR, "Packet too small.\n"); return AVERROR_INVALIDDATA; } 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; } } s->dstptr += 2; } s->dstptr += 2*s->frame.linesize[0] - VAR_9; } *VAR_2 = 1; *(AVFrame *) VAR_1 = s->frame; return VAR_3->size; }