diff options
author | Anton Khirnov <anton@khirnov.net> | 2013-11-09 10:14:46 +0100 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2013-11-16 17:50:51 +0100 |
commit | a6064b12b481072abe0df53e5996cf103994526f (patch) | |
tree | a290b8bcde69d2d470033c4998160a2806ff428b /libavcodec/ffv1dec.c | |
parent | 706a92926ccae390e3f74520a60b4d5790e8ddc4 (diff) | |
download | ffmpeg-a6064b12b481072abe0df53e5996cf103994526f.tar.gz |
ffv1: use the AVFrame API properly.
Diffstat (limited to 'libavcodec/ffv1dec.c')
-rw-r--r-- | libavcodec/ffv1dec.c | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/libavcodec/ffv1dec.c b/libavcodec/ffv1dec.c index f0a409f0a8..5edc667db4 100644 --- a/libavcodec/ffv1dec.c +++ b/libavcodec/ffv1dec.c @@ -784,6 +784,10 @@ static av_cold int ffv1_decode_init(AVCodecContext *avctx) ffv1_common_init(avctx); + f->last_picture = av_frame_alloc(); + if (!f->last_picture) + return AVERROR(ENOMEM); + if (avctx->extradata && (ret = read_extra_header(f)) < 0) return ret; @@ -876,7 +880,7 @@ static int ffv1_decode_frame(AVCodecContext *avctx, void *data, for (i = f->slice_count - 1; i >= 0; i--) { FFV1Context *fs = f->slice_context[i]; int j; - if (fs->slice_damaged && f->last_picture.data[0]) { + if (fs->slice_damaged && f->last_picture->data[0]) { const uint8_t *src[4]; uint8_t *dst[4]; for (j = 0; j < 4; j++) { @@ -884,12 +888,12 @@ static int ffv1_decode_frame(AVCodecContext *avctx, void *data, int sv = (j == 1 || j == 2) ? f->chroma_v_shift : 0; dst[j] = p->data[j] + p->linesize[j] * (fs->slice_y >> sv) + (fs->slice_x >> sh); - src[j] = f->last_picture.data[j] + - f->last_picture.linesize[j] * + src[j] = f->last_picture->data[j] + + f->last_picture->linesize[j] * (fs->slice_y >> sv) + (fs->slice_x >> sh); } av_image_copy(dst, p->linesize, (const uint8_t **)src, - f->last_picture.linesize, + f->last_picture->linesize, avctx->pix_fmt, fs->slice_width, fs->slice_height); } @@ -897,8 +901,8 @@ static int ffv1_decode_frame(AVCodecContext *avctx, void *data, f->picture_number++; - av_frame_unref(&f->last_picture); - if ((ret = av_frame_ref(&f->last_picture, p)) < 0) + av_frame_unref(f->last_picture); + if ((ret = av_frame_ref(f->last_picture, p)) < 0) return ret; f->cur = NULL; @@ -907,6 +911,17 @@ static int ffv1_decode_frame(AVCodecContext *avctx, void *data, return buf_size; } +static av_cold int ffv1_decode_close(AVCodecContext *avctx) +{ + FFV1Context *s = avctx->priv_data;; + + av_frame_free(&s->last_picture); + + ffv1_close(avctx); + + return 0; +} + AVCodec ff_ffv1_decoder = { .name = "ffv1", .long_name = NULL_IF_CONFIG_SMALL("FFmpeg video codec #1"), @@ -914,7 +929,7 @@ AVCodec ff_ffv1_decoder = { .id = AV_CODEC_ID_FFV1, .priv_data_size = sizeof(FFV1Context), .init = ffv1_decode_init, - .close = ffv1_close, + .close = ffv1_decode_close, .decode = ffv1_decode_frame, .capabilities = CODEC_CAP_DR1 /*| CODEC_CAP_DRAW_HORIZ_BAND*/ | CODEC_CAP_SLICE_THREADS, |