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
43 43
44#include "avcodec.h"44#include "avcodec.h"
45#include "bytestream.h"45#include "bytestream.h"
46#include "internal.h"
46#include "lzw.h"47#include "lzw.h"
47 48
48/* The GIF format uses reversed order for bitstreams... */49/* The GIF format uses reversed order for bitstreams... */
@@ -141,20 +142,32 @@ static av_cold int gif_encode_init(AVCodecContext *avctx) · 92 unmodified lines
141}142}
142 143
143/* better than nothing gif encoder */144/* better than nothing gif encoder */
144static int gif_encode_frame(AVCodecContext *avctx, unsigned char *outbuf, int buf_size, void *data)145static int gif_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
146 const AVFrame *pict, int *got_packet)
145{147{
146 GIFContext *s = avctx->priv_data;148 GIFContext *s = avctx->priv_data;
147 AVFrame *pict = data;
148 AVFrame *const p = (AVFrame *)&s->picture;149 AVFrame *const p = (AVFrame *)&s->picture;
149 uint8_t *outbuf_ptr = outbuf;150 uint8_t *outbuf_ptr, *end;
150 uint8_t *end = outbuf + buf_size;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;
151 159
152 *p = *pict;160 *p = *pict;
153 p->pict_type = AV_PICTURE_TYPE_I;161 p->pict_type = AV_PICTURE_TYPE_I;
154 p->key_frame = 1;162 p->key_frame = 1;
155 gif_image_write_header(avctx, &outbuf_ptr, (uint32_t *)pict->data[1]);163 gif_image_write_header(avctx, &outbuf_ptr, (uint32_t *)pict->data[1]);
156 gif_image_write_image(avctx, &outbuf_ptr, end, pict->data[0], pict->linesize[0]);164 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;
158}171}
159 172
160static int gif_encode_close(AVCodecContext *avctx)173static int gif_encode_close(AVCodecContext *avctx)
@@ -172,7 +185,7 @@ AVCodec ff_gif_encoder = { · 11 unmodified lines
172 .id = CODEC_ID_GIF,185 .id = CODEC_ID_GIF,
173 .priv_data_size = sizeof(GIFContext),186 .priv_data_size = sizeof(GIFContext),
174 .init = gif_encode_init,187 .init = gif_encode_init,
175 .encode = gif_encode_frame,188 .encode2 = gif_encode_frame,
176 .close = gif_encode_close,189 .close = gif_encode_close,
177 .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},190 .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},
178 .long_name= NULL_IF_CONFIG_SMALL("GIF (Graphics Interchange Format)"),191 .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