-static int gif_encode_frame(AVCodecContext *avctx, unsigned char *outbuf, int buf_size, void *data)
+static int gif_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
+ const AVFrame *pict, int *got_packet)
+{
+ uint8_t *outbuf_ptr, *end;
+ int ret;
+
+ if ((ret = ff_alloc_packet(pkt, avctx->width*avctx->height*7/5 + FF_MIN_BUFFER_SIZE)) < 0) {
+ av_log(avctx, AV_LOG_ERROR, "Error getting output packet.\n");
+ return ret;
+ }
+ outbuf_ptr = pkt->data;
+ end = pkt->data + pkt->size;
+
+ gif_image_write_header(avctx, &outbuf_ptr, (uint32_t *)pict->data[1]);
+ gif_image_write_image(avctx, &outbuf_ptr, end, pict->data[0], pict->linesize[0]);
+
+ pkt->size = outbuf_ptr - pkt->data;
+ pkt->flags |= AV_PKT_FLAG_KEY;
+ *got_packet = 1;
+
+ return 0;
+}
+
+static int gif_encode_close(AVCodecContext *avctx)