Revision ab3faa8b

View differences:

libavcodec/gif.c
58 58
} GIFContext;
59 59

  
60 60
/* GIF header */
61
static int gif_image_write_header(uint8_t **bytestream,
62
                                  int width, int height,
63
                                  uint32_t *palette)
61
static int gif_image_write_header(AVCodecContext *avctx,
62
                                  uint8_t **bytestream, uint32_t *palette)
64 63
{
65 64
    int i;
66 65
    unsigned int v;
67 66

  
68 67
    bytestream_put_buffer(bytestream, "GIF", 3);
69 68
    bytestream_put_buffer(bytestream, "89a", 3);
70
    bytestream_put_le16(bytestream, width);
71
    bytestream_put_le16(bytestream, height);
69
    bytestream_put_le16(bytestream, avctx->width);
70
    bytestream_put_le16(bytestream, avctx->height);
72 71

  
73 72
    bytestream_put_byte(bytestream, 0xf7); /* flags: global clut, 256 entries */
74 73
    bytestream_put_byte(bytestream, 0x1f); /* background color index */
......
83 82
    return 0;
84 83
}
85 84

  
86
static int gif_image_write_image(uint8_t **bytestream,
87
                                 int width, int height,
85
static int gif_image_write_image(AVCodecContext *avctx, uint8_t **bytestream,
88 86
                                 const uint8_t *buf, int linesize)
89 87
{
90 88
    PutBitContext p;
......
96 94
    bytestream_put_byte(bytestream, 0x2c);
97 95
    bytestream_put_le16(bytestream, 0);
98 96
    bytestream_put_le16(bytestream, 0);
99
    bytestream_put_le16(bytestream, width);
100
    bytestream_put_le16(bytestream, height);
97
    bytestream_put_le16(bytestream, avctx->width);
98
    bytestream_put_le16(bytestream, avctx->height);
101 99
    bytestream_put_byte(bytestream, 0x00); /* flags */
102 100
    /* no local clut */
103 101

  
104 102
    bytestream_put_byte(bytestream, 0x08);
105 103

  
106
    left= width * height;
104
    left= avctx->width * avctx->height;
107 105

  
108 106
    init_put_bits(&p, buffer, 130);
109 107

  
......
112 110
 * but it's still the same bitstream between packets (no flush !)
113 111
 */
114 112
    ptr = buf;
115
    w = width;
113
    w = avctx->width;
116 114
    while(left>0) {
117 115

  
118 116
        put_bits(&p, 9, 0x0100); /* clear code */
......
120 118
        for(i=(left<GIF_CHUNKS)?left:GIF_CHUNKS;i;i--) {
121 119
            put_bits(&p, 9, *ptr++);
122 120
            if (--w == 0) {
123
                w = width;
121
                w = avctx->width;
124 122
                buf += linesize;
125 123
                ptr = buf;
126 124
            }
......
161 159
    *p = *pict;
162 160
    p->pict_type = FF_I_TYPE;
163 161
    p->key_frame = 1;
164
    gif_image_write_header(&outbuf_ptr, avctx->width, avctx->height, (uint32_t *)pict->data[1]);
165
    gif_image_write_image(&outbuf_ptr, avctx->width, avctx->height, pict->data[0], pict->linesize[0]);
162
    gif_image_write_header(avctx, &outbuf_ptr, (uint32_t *)pict->data[1]);
163
    gif_image_write_image(avctx, &outbuf_ptr, pict->data[0], pict->linesize[0]);
166 164
    return outbuf_ptr - outbuf;
167 165
}
168 166

  

Also available in: Unified diff