static int gif_image_write_image(AVCodecContext *avctx,

                                 uint8_t **bytestream, uint8_t *end,

                                 const uint8_t *buf, int linesize)

{

    GIFContext *s = avctx->priv_data;

    int len, height;

    const uint8_t *ptr;

    /* image block */



    bytestream_put_byte(bytestream, 0x2c);

    bytestream_put_le16(bytestream, 0);

    bytestream_put_le16(bytestream, 0);

    bytestream_put_le16(bytestream, avctx->width);

    bytestream_put_le16(bytestream, avctx->height);

    bytestream_put_byte(bytestream, 0x00); /* flags */

    /* no local clut */



    bytestream_put_byte(bytestream, 0x08);



    ff_lzw_encode_init(s->lzw, s->buf, avctx->width*avctx->height,

                       12, FF_LZW_GIF, put_bits);



    ptr = buf;

    for (height = avctx->height; height--;) {

        len += ff_lzw_encode(s->lzw, ptr, avctx->width);

        ptr += linesize;

    }

    len += ff_lzw_encode_flush(s->lzw, flush_put_bits);



    ptr = s->buf;

    while (len > 0) {

        int size = FFMIN(255, len);

        bytestream_put_byte(bytestream, size);

        if (end - *bytestream < size)

            return -1;

        bytestream_put_buffer(bytestream, ptr, size);

        ptr += size;

        len -= size;

    }

    bytestream_put_byte(bytestream, 0x00); /* end of image block */

    bytestream_put_byte(bytestream, 0x3b);

    return 0;

}

static int gif_image_write_image(AVCodecContext *avctx,

                                 uint8_t **bytestream, uint8_t *end,

                                 const uint8_t *buf, int linesize)

{

    GIFContext *s = avctx->priv_data;

    int len, height;

    const uint8_t *ptr;

    



    bytestream_put_byte(bytestream, 0x2c);

    bytestream_put_le16(bytestream, 0);

    bytestream_put_le16(bytestream, 0);

    bytestream_put_le16(bytestream, avctx->width);

    bytestream_put_le16(bytestream, avctx->height);

    bytestream_put_byte(bytestream, 0x00); 

    



    bytestream_put_byte(bytestream, 0x08);



    ff_lzw_encode_init(s->lzw, s->buf, avctx->width*avctx->height,

                       12, FF_LZW_GIF, put_bits);



    ptr = buf;

    for (height = avctx->height; height--;) {

        len += ff_lzw_encode(s->lzw, ptr, avctx->width);

        ptr += linesize;

    }

    len += ff_lzw_encode_flush(s->lzw, flush_put_bits);



    ptr = s->buf;

    while (len > 0) {

        int size = FFMIN(255, len);

        bytestream_put_byte(bytestream, size);

        if (end - *bytestream < size)

            return -1;

        bytestream_put_buffer(bytestream, ptr, size);

        ptr += size;

        len -= size;

    }

    bytestream_put_byte(bytestream, 0x00); 

    bytestream_put_byte(bytestream, 0x3b);

    return 0;

}

    int len, height;
static int FUNC_0(AVCodecContext *VAR_0,

                                 uint8_t **VAR_1, uint8_t *VAR_2,

                                 const uint8_t *VAR_3, int VAR_4)

{

    GIFContext *s = VAR_0->priv_data;

    int VAR_5, VAR_6;

    const uint8_t *VAR_7;

    



    bytestream_put_byte(VAR_1, 0x2c);

    bytestream_put_le16(VAR_1, 0);

    bytestream_put_le16(VAR_1, 0);

    bytestream_put_le16(VAR_1, VAR_0->width);

    bytestream_put_le16(VAR_1, VAR_0->VAR_6);

    bytestream_put_byte(VAR_1, 0x00); 

    



    bytestream_put_byte(VAR_1, 0x08);



    ff_lzw_encode_init(s->lzw, s->VAR_3, VAR_0->width*VAR_0->VAR_6,

                       12, FF_LZW_GIF, put_bits);



    VAR_7 = VAR_3;

    for (VAR_6 = VAR_0->VAR_6; VAR_6--;) {

        VAR_5 += ff_lzw_encode(s->lzw, VAR_7, VAR_0->width);

        VAR_7 += VAR_4;

    }

    VAR_5 += ff_lzw_encode_flush(s->lzw, flush_put_bits);



    VAR_7 = s->VAR_3;

    while (VAR_5 > 0) {

        int VAR_8 = FFMIN(255, VAR_5);

        bytestream_put_byte(VAR_1, VAR_8);

        if (VAR_2 - *VAR_1 < VAR_8)

            return -1;

        bytestream_put_buffer(VAR_1, VAR_7, VAR_8);

        VAR_7 += VAR_8;

        VAR_5 -= VAR_8;

    }

    bytestream_put_byte(VAR_1, 0x00); 

    bytestream_put_byte(VAR_1, 0x3b);

    return 0;

}

static int FUNC_0(AVCodecContext *VAR_0,
uint8_t **VAR_1, uint8_t *VAR_2,
const uint8_t *VAR_3, int VAR_4)
{ GIFContext *s = VAR_0->priv_data; int VAR_5, VAR_6; const uint8_t *VAR_7; bytestream_put_byte(VAR_1, 0x2c); bytestream_put_le16(VAR_1, 0); bytestream_put_le16(VAR_1, 0); bytestream_put_le16(VAR_1, VAR_0->width); bytestream_put_le16(VAR_1, VAR_0->VAR_6); bytestream_put_byte(VAR_1, 0x00); bytestream_put_byte(VAR_1, 0x08); ff_lzw_encode_init(s->lzw, s->VAR_3, VAR_0->width*VAR_0->VAR_6,
12, FF_LZW_GIF, put_bits); VAR_7 = VAR_3; for (VAR_6 = VAR_0->VAR_6; VAR_6--;) { VAR_5 += ff_lzw_encode(s->lzw, VAR_7, VAR_0->width); VAR_7 += VAR_4; } VAR_5 += ff_lzw_encode_flush(s->lzw, flush_put_bits); VAR_7 = s->VAR_3; while (VAR_5 > 0) { int VAR_8 = FFMIN(255, VAR_5); bytestream_put_byte(VAR_1, VAR_8); if (VAR_2 - *VAR_1 < VAR_8)
return -1; bytestream_put_buffer(VAR_1, VAR_7, VAR_8); VAR_7 += VAR_8; VAR_5 -= VAR_8; } bytestream_put_byte(VAR_1, 0x00); bytestream_put_byte(VAR_1, 0x3b); return 0; }