summaryrefslogtreecommitdiff
path: root/libavcodec/gif.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2013-11-17 12:17:05 +0100
committerMichael Niedermayer <michaelni@gmx.at>2013-11-17 12:19:55 +0100
commit5b0c70c2499e20529d517b712910d6f4f72e9485 (patch)
tree620207093db182a6b54129a2a166b2f721685378 /libavcodec/gif.c
parent3ea168edeb7a20eae1fccf7da66ac7b8c8c791ba (diff)
parent57e7b3a89f5a0879ad039e8f04273b48649799a8 (diff)
Merge commit '57e7b3a89f5a0879ad039e8f04273b48649799a8'
* commit '57e7b3a89f5a0879ad039e8f04273b48649799a8': dnxhdenc: use the AVFrame API properly. libx264: use the AVFrame API properly. svq1enc: use the AVFrame API properly. gif: use the AVFrame API properly. Conflicts: libavcodec/gif.c libavcodec/svq1enc.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/gif.c')
-rw-r--r--libavcodec/gif.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/libavcodec/gif.c b/libavcodec/gif.c
index 8b9d95fe09..27d054e512 100644
--- a/libavcodec/gif.c
+++ b/libavcodec/gif.c
@@ -216,6 +216,13 @@ static av_cold int gif_encode_init(AVCodecContext *avctx)
return AVERROR(EINVAL);
}
+ avctx->coded_frame = av_frame_alloc();
+ if (!avctx->coded_frame)
+ return AVERROR(ENOMEM);
+
+ avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
+ avctx->coded_frame->key_frame = 1;
+
s->lzw = av_mallocz(ff_lzw_encode_state_size);
s->buf = av_malloc(avctx->width*avctx->height*2);
s->tmpl = av_malloc(avctx->width);
@@ -232,7 +239,6 @@ static int gif_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
const AVFrame *pict, int *got_packet)
{
GIFContext *s = avctx->priv_data;
- AVFrame *const p = (AVFrame *)pict;
uint8_t *outbuf_ptr, *end;
const uint32_t *palette = NULL;
int ret;
@@ -242,15 +248,12 @@ static int gif_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
outbuf_ptr = pkt->data;
end = pkt->data + pkt->size;
- p->pict_type = AV_PICTURE_TYPE_I;
- p->key_frame = 1;
-
if (avctx->pix_fmt == AV_PIX_FMT_PAL8) {
uint8_t *pal_exdata = av_packet_new_side_data(pkt, AV_PKT_DATA_PALETTE, AVPALETTE_SIZE);
if (!pal_exdata)
return AVERROR(ENOMEM);
- memcpy(pal_exdata, p->data[1], AVPALETTE_SIZE);
- palette = (uint32_t*)p->data[1];
+ memcpy(pal_exdata, pict->data[1], AVPALETTE_SIZE);
+ palette = (uint32_t*)pict->data[1];
}
gif_image_write_image(avctx, &outbuf_ptr, end, palette,
@@ -276,6 +279,8 @@ static int gif_encode_close(AVCodecContext *avctx)
{
GIFContext *s = avctx->priv_data;
+ av_frame_free(&avctx->coded_frame);
+
av_freep(&s->lzw);
av_freep(&s->buf);
av_frame_free(&s->last_frame);