summaryrefslogtreecommitdiff
path: root/libavcodec/huffyuvenc.c
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2013-11-09 10:14:46 +0100
committerAnton Khirnov <anton@khirnov.net>2013-11-16 17:50:20 +0100
commit14b35bf065a3df56cccd116a27cae6a772239005 (patch)
tree9eb42b72a7b6d0d95b11c2cc189342a0fdcbac22 /libavcodec/huffyuvenc.c
parentffe04c330335add4c6d70ab0bb98e6b3f4f7abfa (diff)
huffyuv: use the AVFrame API properly.
Diffstat (limited to 'libavcodec/huffyuvenc.c')
-rw-r--r--libavcodec/huffyuvenc.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/libavcodec/huffyuvenc.c b/libavcodec/huffyuvenc.c
index 665d0a68e0..ec07abdcc1 100644
--- a/libavcodec/huffyuvenc.c
+++ b/libavcodec/huffyuvenc.c
@@ -151,7 +151,12 @@ static av_cold int encode_init(AVCodecContext *avctx)
avctx->stats_out = av_mallocz(1024*30); // 21*256*3(%llu ) + 3(\n) + 1(0) = 16132
s->version = 2;
- avctx->coded_frame = &s->picture;
+ 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;
switch (avctx->pix_fmt) {
case AV_PIX_FMT_YUV420P:
@@ -438,7 +443,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
const int fake_ystride = s->interlaced ? pict->linesize[0]*2 : pict->linesize[0];
const int fake_ustride = s->interlaced ? pict->linesize[1]*2 : pict->linesize[1];
const int fake_vstride = s->interlaced ? pict->linesize[2]*2 : pict->linesize[2];
- AVFrame * const p = &s->picture;
+ const AVFrame * const p = pict;
int i, j, size = 0, ret;
if (!pkt->data &&
@@ -447,10 +452,6 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
return ret;
}
- *p = *pict;
- p->pict_type = AV_PICTURE_TYPE_I;
- p->key_frame = 1;
-
if (s->context) {
for (i = 0; i < 3; i++) {
ff_huff_gen_len_table(s->len[i], s->stats[i]);
@@ -676,6 +677,8 @@ static av_cold int encode_end(AVCodecContext *avctx)
av_freep(&avctx->extradata);
av_freep(&avctx->stats_out);
+ av_frame_free(&avctx->coded_frame);
+
return 0;
}