Commit 4ac5b215 authored by bcoudurier's avatar bcoudurier

pass avctx as argument instead of width and height

git-svn-id: file:///var/local/repositories/ffmpeg/trunk@20710 9553f0bf-9b14-0410-a0b8-cfaf0461ba5b
parent 2ef955cd
...@@ -58,17 +58,16 @@ typedef struct { ...@@ -58,17 +58,16 @@ typedef struct {
} GIFContext; } GIFContext;
/* GIF header */ /* GIF header */
static int gif_image_write_header(uint8_t **bytestream, static int gif_image_write_header(AVCodecContext *avctx,
int width, int height, uint8_t **bytestream, uint32_t *palette)
uint32_t *palette)
{ {
int i; int i;
unsigned int v; unsigned int v;
bytestream_put_buffer(bytestream, "GIF", 3); bytestream_put_buffer(bytestream, "GIF", 3);
bytestream_put_buffer(bytestream, "89a", 3); bytestream_put_buffer(bytestream, "89a", 3);
bytestream_put_le16(bytestream, width); bytestream_put_le16(bytestream, avctx->width);
bytestream_put_le16(bytestream, height); bytestream_put_le16(bytestream, avctx->height);
bytestream_put_byte(bytestream, 0xf7); /* flags: global clut, 256 entries */ bytestream_put_byte(bytestream, 0xf7); /* flags: global clut, 256 entries */
bytestream_put_byte(bytestream, 0x1f); /* background color index */ bytestream_put_byte(bytestream, 0x1f); /* background color index */
...@@ -83,8 +82,7 @@ static int gif_image_write_header(uint8_t **bytestream, ...@@ -83,8 +82,7 @@ static int gif_image_write_header(uint8_t **bytestream,
return 0; return 0;
} }
static int gif_image_write_image(uint8_t **bytestream, static int gif_image_write_image(AVCodecContext *avctx, uint8_t **bytestream,
int width, int height,
const uint8_t *buf, int linesize) const uint8_t *buf, int linesize)
{ {
PutBitContext p; PutBitContext p;
...@@ -96,14 +94,14 @@ static int gif_image_write_image(uint8_t **bytestream, ...@@ -96,14 +94,14 @@ static int gif_image_write_image(uint8_t **bytestream,
bytestream_put_byte(bytestream, 0x2c); bytestream_put_byte(bytestream, 0x2c);
bytestream_put_le16(bytestream, 0); bytestream_put_le16(bytestream, 0);
bytestream_put_le16(bytestream, 0); bytestream_put_le16(bytestream, 0);
bytestream_put_le16(bytestream, width); bytestream_put_le16(bytestream, avctx->width);
bytestream_put_le16(bytestream, height); bytestream_put_le16(bytestream, avctx->height);
bytestream_put_byte(bytestream, 0x00); /* flags */ bytestream_put_byte(bytestream, 0x00); /* flags */
/* no local clut */ /* no local clut */
bytestream_put_byte(bytestream, 0x08); bytestream_put_byte(bytestream, 0x08);
left= width * height; left= avctx->width * avctx->height;
init_put_bits(&p, buffer, 130); init_put_bits(&p, buffer, 130);
...@@ -112,7 +110,7 @@ static int gif_image_write_image(uint8_t **bytestream, ...@@ -112,7 +110,7 @@ static int gif_image_write_image(uint8_t **bytestream,
* but it's still the same bitstream between packets (no flush !) * but it's still the same bitstream between packets (no flush !)
*/ */
ptr = buf; ptr = buf;
w = width; w = avctx->width;
while(left>0) { while(left>0) {
put_bits(&p, 9, 0x0100); /* clear code */ put_bits(&p, 9, 0x0100); /* clear code */
...@@ -120,7 +118,7 @@ static int gif_image_write_image(uint8_t **bytestream, ...@@ -120,7 +118,7 @@ static int gif_image_write_image(uint8_t **bytestream,
for(i=(left<GIF_CHUNKS)?left:GIF_CHUNKS;i;i--) { for(i=(left<GIF_CHUNKS)?left:GIF_CHUNKS;i;i--) {
put_bits(&p, 9, *ptr++); put_bits(&p, 9, *ptr++);
if (--w == 0) { if (--w == 0) {
w = width; w = avctx->width;
buf += linesize; buf += linesize;
ptr = buf; ptr = buf;
} }
...@@ -161,8 +159,8 @@ static int gif_encode_frame(AVCodecContext *avctx, unsigned char *outbuf, int bu ...@@ -161,8 +159,8 @@ static int gif_encode_frame(AVCodecContext *avctx, unsigned char *outbuf, int bu
*p = *pict; *p = *pict;
p->pict_type = FF_I_TYPE; p->pict_type = FF_I_TYPE;
p->key_frame = 1; p->key_frame = 1;
gif_image_write_header(&outbuf_ptr, avctx->width, avctx->height, (uint32_t *)pict->data[1]); gif_image_write_header(avctx, &outbuf_ptr, (uint32_t *)pict->data[1]);
gif_image_write_image(&outbuf_ptr, avctx->width, avctx->height, pict->data[0], pict->linesize[0]); gif_image_write_image(avctx, &outbuf_ptr, pict->data[0], pict->linesize[0]);
return outbuf_ptr - outbuf; return outbuf_ptr - outbuf;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment