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:41:32 +0100 |
commit | acaffdca21f63b3b465892e8e9d85fd8ca0022bd (patch) | |
tree | f7fcc207e5b9bee7d543c714eaa181f07134e472 /libavcodec | |
parent | 508b37557bf36eae83c18e64d42f27b44a321d81 (diff) | |
download | ffmpeg-acaffdca21f63b3b465892e8e9d85fd8ca0022bd.tar.gz |
mss1: use the AVFrame API properly.
Diffstat (limited to 'libavcodec')
-rw-r--r-- | libavcodec/mss1.c | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/libavcodec/mss1.c b/libavcodec/mss1.c index b5e016b378..a67a942ac2 100644 --- a/libavcodec/mss1.c +++ b/libavcodec/mss1.c @@ -30,7 +30,7 @@ typedef struct MSS1Context { MSS12Context ctx; - AVFrame pic; + AVFrame *pic; SliceContext sc; } MSS1Context; @@ -151,34 +151,34 @@ static int mss1_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, init_get_bits(&gb, buf, buf_size * 8); arith_init(&acoder, &gb); - if ((ret = ff_reget_buffer(avctx, &ctx->pic)) < 0) { + if ((ret = ff_reget_buffer(avctx, ctx->pic)) < 0) { av_log(avctx, AV_LOG_ERROR, "reget_buffer() failed\n"); return ret; } - c->pal_pic = ctx->pic.data[0] + ctx->pic.linesize[0] * (avctx->height - 1); - c->pal_stride = -ctx->pic.linesize[0]; + c->pal_pic = ctx->pic->data[0] + ctx->pic->linesize[0] * (avctx->height - 1); + c->pal_stride = -ctx->pic->linesize[0]; c->keyframe = !arith_get_bit(&acoder); if (c->keyframe) { c->corrupted = 0; ff_mss12_slicecontext_reset(&ctx->sc); pal_changed = decode_pal(c, &acoder); - ctx->pic.key_frame = 1; - ctx->pic.pict_type = AV_PICTURE_TYPE_I; + ctx->pic->key_frame = 1; + ctx->pic->pict_type = AV_PICTURE_TYPE_I; } else { if (c->corrupted) return AVERROR_INVALIDDATA; - ctx->pic.key_frame = 0; - ctx->pic.pict_type = AV_PICTURE_TYPE_P; + ctx->pic->key_frame = 0; + ctx->pic->pict_type = AV_PICTURE_TYPE_P; } c->corrupted = ff_mss12_decode_rect(&ctx->sc, &acoder, 0, 0, avctx->width, avctx->height); if (c->corrupted) return AVERROR_INVALIDDATA; - memcpy(ctx->pic.data[1], c->pal, AVPALETTE_SIZE); - ctx->pic.palette_has_changed = pal_changed; + memcpy(ctx->pic->data[1], c->pal, AVPALETTE_SIZE); + ctx->pic->palette_has_changed = pal_changed; - if ((ret = av_frame_ref(data, &ctx->pic)) < 0) + if ((ret = av_frame_ref(data, ctx->pic)) < 0) return ret; *got_frame = 1; @@ -193,7 +193,10 @@ static av_cold int mss1_decode_init(AVCodecContext *avctx) int ret; c->ctx.avctx = avctx; - avctx->coded_frame = &c->pic; + + c->pic = av_frame_alloc(); + if (!c->pic) + return AVERROR(ENOMEM); ret = ff_mss12_decode_init(&c->ctx, 0, &c->sc, NULL); @@ -206,7 +209,7 @@ static av_cold int mss1_decode_end(AVCodecContext *avctx) { MSS1Context * const ctx = avctx->priv_data; - av_frame_unref(&ctx->pic); + av_frame_free(&ctx->pic); ff_mss12_decode_end(&ctx->ctx); return 0; |