Commit 8d193a24 authored by Michael Niedermayer's avatar Michael Niedermayer

Merge commit '730bac7b'

* commit '730bac7b':
  mss4: use the AVFrame API properly.
  mss3: use the AVFrame API properly.
  mss2: use the AVFrame API properly.
  mss1: use the AVFrame API properly.

Conflicts:
	libavcodec/mss1.c
	libavcodec/mss2.c
	libavcodec/mss3.c
	libavcodec/mss4.c

See: 02fe531a
See: ff1c13b1
See: 310bf283Merged-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parents 72df8708 730bac7b
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
typedef struct MSS1Context { typedef struct MSS1Context {
MSS12Context ctx; MSS12Context ctx;
AVFrame pic; AVFrame *pic;
SliceContext sc; SliceContext sc;
} MSS1Context; } MSS1Context;
...@@ -151,32 +151,32 @@ static int mss1_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, ...@@ -151,32 +151,32 @@ static int mss1_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
arith_init(&acoder, &gb); arith_init(&acoder, &gb);
if ((ret = ff_reget_buffer(avctx, &ctx->pic)) < 0) if ((ret = ff_reget_buffer(avctx, ctx->pic)) < 0)
return ret; return ret;
c->pal_pic = ctx->pic.data[0] + ctx->pic.linesize[0] * (avctx->height - 1); c->pal_pic = ctx->pic->data[0] + ctx->pic->linesize[0] * (avctx->height - 1);
c->pal_stride = -ctx->pic.linesize[0]; c->pal_stride = -ctx->pic->linesize[0];
c->keyframe = !arith_get_bit(&acoder); c->keyframe = !arith_get_bit(&acoder);
if (c->keyframe) { if (c->keyframe) {
c->corrupted = 0; c->corrupted = 0;
ff_mss12_slicecontext_reset(&ctx->sc); ff_mss12_slicecontext_reset(&ctx->sc);
pal_changed = decode_pal(c, &acoder); pal_changed = decode_pal(c, &acoder);
ctx->pic.key_frame = 1; ctx->pic->key_frame = 1;
ctx->pic.pict_type = AV_PICTURE_TYPE_I; ctx->pic->pict_type = AV_PICTURE_TYPE_I;
} else { } else {
if (c->corrupted) if (c->corrupted)
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
ctx->pic.key_frame = 0; ctx->pic->key_frame = 0;
ctx->pic.pict_type = AV_PICTURE_TYPE_P; ctx->pic->pict_type = AV_PICTURE_TYPE_P;
} }
c->corrupted = ff_mss12_decode_rect(&ctx->sc, &acoder, 0, 0, c->corrupted = ff_mss12_decode_rect(&ctx->sc, &acoder, 0, 0,
avctx->width, avctx->height); avctx->width, avctx->height);
if (c->corrupted) if (c->corrupted)
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
memcpy(ctx->pic.data[1], c->pal, AVPALETTE_SIZE); memcpy(ctx->pic->data[1], c->pal, AVPALETTE_SIZE);
ctx->pic.palette_has_changed = pal_changed; 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; return ret;
*got_frame = 1; *got_frame = 1;
...@@ -192,7 +192,9 @@ static av_cold int mss1_decode_init(AVCodecContext *avctx) ...@@ -192,7 +192,9 @@ static av_cold int mss1_decode_init(AVCodecContext *avctx)
c->ctx.avctx = avctx; c->ctx.avctx = avctx;
avcodec_get_frame_defaults(&c->pic); c->pic = av_frame_alloc();
if (!c->pic)
return AVERROR(ENOMEM);
ret = ff_mss12_decode_init(&c->ctx, 0, &c->sc, NULL); ret = ff_mss12_decode_init(&c->ctx, 0, &c->sc, NULL);
...@@ -205,7 +207,7 @@ static av_cold int mss1_decode_end(AVCodecContext *avctx) ...@@ -205,7 +207,7 @@ static av_cold int mss1_decode_end(AVCodecContext *avctx)
{ {
MSS1Context * const ctx = avctx->priv_data; MSS1Context * const ctx = avctx->priv_data;
av_frame_unref(&ctx->pic); av_frame_free(&ctx->pic);
ff_mss12_decode_end(&ctx->ctx); ff_mss12_decode_end(&ctx->ctx);
return 0; return 0;
......
...@@ -840,6 +840,7 @@ static av_cold int mss2_decode_init(AVCodecContext *avctx) ...@@ -840,6 +840,7 @@ static av_cold int mss2_decode_init(AVCodecContext *avctx)
avctx->pix_fmt = c->free_colours == 127 ? AV_PIX_FMT_RGB555 avctx->pix_fmt = c->free_colours == 127 ? AV_PIX_FMT_RGB555
: AV_PIX_FMT_RGB24; : AV_PIX_FMT_RGB24;
return 0; return 0;
} }
......
...@@ -803,15 +803,24 @@ static int mss3_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, ...@@ -803,15 +803,24 @@ static int mss3_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
return buf_size; return buf_size;
} }
static av_cold int mss3_decode_end(AVCodecContext *avctx)
{
MSS3Context * const c = avctx->priv_data;
int i;
av_frame_free(&c->pic);
for (i = 0; i < 3; i++)
av_freep(&c->dct_coder[i].prev_dc);
return 0;
}
static av_cold int mss3_decode_init(AVCodecContext *avctx) static av_cold int mss3_decode_init(AVCodecContext *avctx)
{ {
MSS3Context * const c = avctx->priv_data; MSS3Context * const c = avctx->priv_data;
int i; int i;
c->avctx = avctx; c->avctx = avctx;
c->pic = av_frame_alloc();
if (!c->pic)
return AVERROR(ENOMEM);
if ((avctx->width & 0xF) || (avctx->height & 0xF)) { if ((avctx->width & 0xF) || (avctx->height & 0xF)) {
av_log(avctx, AV_LOG_ERROR, av_log(avctx, AV_LOG_ERROR,
...@@ -838,6 +847,12 @@ static av_cold int mss3_decode_init(AVCodecContext *avctx) ...@@ -838,6 +847,12 @@ static av_cold int mss3_decode_init(AVCodecContext *avctx)
} }
} }
c->pic = av_frame_alloc();
if (!c->pic) {
mss3_decode_end(avctx);
return AVERROR(ENOMEM);
}
avctx->pix_fmt = AV_PIX_FMT_YUV420P; avctx->pix_fmt = AV_PIX_FMT_YUV420P;
init_coders(c); init_coders(c);
...@@ -845,18 +860,6 @@ static av_cold int mss3_decode_init(AVCodecContext *avctx) ...@@ -845,18 +860,6 @@ static av_cold int mss3_decode_init(AVCodecContext *avctx)
return 0; return 0;
} }
static av_cold int mss3_decode_end(AVCodecContext *avctx)
{
MSS3Context * const c = avctx->priv_data;
int i;
av_frame_free(&c->pic);
for (i = 0; i < 3; i++)
av_freep(&c->dct_coder[i].prev_dc);
return 0;
}
AVCodec ff_msa1_decoder = { AVCodec ff_msa1_decoder = {
.name = "msa1", .name = "msa1",
.long_name = NULL_IF_CONFIG_SMALL("MS ATC Screen"), .long_name = NULL_IF_CONFIG_SMALL("MS ATC Screen"),
......
...@@ -626,14 +626,23 @@ static int mss4_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, ...@@ -626,14 +626,23 @@ static int mss4_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
return buf_size; return buf_size;
} }
static av_cold int mss4_decode_init(AVCodecContext *avctx) static av_cold int mss4_decode_end(AVCodecContext *avctx)
{ {
MSS4Context * const c = avctx->priv_data; MSS4Context * const c = avctx->priv_data;
int i; int i;
c->pic = av_frame_alloc(); av_frame_free(&c->pic);
if (!c->pic) for (i = 0; i < 3; i++)
return AVERROR(ENOMEM); av_freep(&c->prev_dc[i]);
mss4_free_vlcs(c);
return 0;
}
static av_cold int mss4_decode_init(AVCodecContext *avctx)
{
MSS4Context * const c = avctx->priv_data;
int i;
if (mss4_init_vlcs(c)) { if (mss4_init_vlcs(c)) {
av_log(avctx, AV_LOG_ERROR, "Cannot initialise VLCs\n"); av_log(avctx, AV_LOG_ERROR, "Cannot initialise VLCs\n");
...@@ -650,21 +659,13 @@ static av_cold int mss4_decode_init(AVCodecContext *avctx) ...@@ -650,21 +659,13 @@ static av_cold int mss4_decode_init(AVCodecContext *avctx)
} }
} }
avctx->pix_fmt = AV_PIX_FMT_YUV444P; c->pic = av_frame_alloc();
if (!c->pic) {
return 0; mss4_decode_end(avctx);
} return AVERROR(ENOMEM);
}
static av_cold int mss4_decode_end(AVCodecContext *avctx)
{
MSS4Context * const c = avctx->priv_data;
int i;
av_frame_free(&c->pic);
for (i = 0; i < 3; i++) avctx->pix_fmt = AV_PIX_FMT_YUV444P;
av_freep(&c->prev_dc[i]);
mss4_free_vlcs(c);
return 0; return 0;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment