History

gifenc: switch to encode2().

Anton Khirnov committed 14 years ago

Commit 577fed31 parent d8f33651 file · +19 −6Browse files

Unified · Split

libavcodec/gif.c+19−6
@@ -43,6 +43,7 @@ · 42 unmodified lines
4343
4444 #include "avcodec.h"
4545 #include "bytestream.h"
46+#include "internal.h"
4647 #include "lzw.h"
4748
4849 /* The GIF format uses reversed order for bitstreams... */
@@ -141,20 +142,32 @@ static av_cold int gif_encode_init(AVCodecContext *avctx) · 92 unmodified lines
141142 }
142143
143144 /* better than nothing gif encoder */
144−static int gif_encode_frame(AVCodecContext *avctx, unsigned char *outbuf, int buf_size, void *data)
145+static int gif_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
146+ const AVFrame *pict, int *got_packet)
145147 {
146148 GIFContext *s = avctx->priv_data;
147− AVFrame *pict = data;
148149 AVFrame *const p = (AVFrame *)&s->picture;
149− uint8_t *outbuf_ptr = outbuf;
150− uint8_t *end = outbuf + buf_size;
150+ uint8_t *outbuf_ptr, *end;
151+ int ret;
152+
153+ if ((ret = ff_alloc_packet(pkt, avctx->width*avctx->height*7/5 + FF_MIN_BUFFER_SIZE)) < 0) {
154+ av_log(avctx, AV_LOG_ERROR, "Error getting output packet.\n");
155+ return ret;
156+ }
157+ outbuf_ptr = pkt->data;
158+ end = pkt->data + pkt->size;
151159
152160 *p = *pict;
153161 p->pict_type = AV_PICTURE_TYPE_I;
154162 p->key_frame = 1;
155163 gif_image_write_header(avctx, &outbuf_ptr, (uint32_t *)pict->data[1]);
156164 gif_image_write_image(avctx, &outbuf_ptr, end, pict->data[0], pict->linesize[0]);
157− return outbuf_ptr - outbuf;
165+
166+ pkt->size = outbuf_ptr - pkt->data;
167+ pkt->flags |= AV_PKT_FLAG_KEY;
168+ *got_packet = 1;
169+
170+ return 0;
158171 }
159172
160173 static int gif_encode_close(AVCodecContext *avctx)
@@ -172,7 +185,7 @@ AVCodec ff_gif_encoder = { · 11 unmodified lines
172185 .id = CODEC_ID_GIF,
173186 .priv_data_size = sizeof(GIFContext),
174187 .init = gif_encode_init,
175− .encode = gif_encode_frame,
188+ .encode2 = gif_encode_frame,
176189 .close = gif_encode_close,
177190 .pix_fmts= (const enum PixelFormat[]){PIX_FMT_RGB8, PIX_FMT_BGR8, PIX_FMT_RGB4_BYTE, PIX_FMT_BGR4_BYTE, PIX_FMT_GRAY8, PIX_FMT_PAL8, PIX_FMT_NONE},
178191 .long_name= NULL_IF_CONFIG_SMALL("GIF (Graphics Interchange Format)"),

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t