Commit 9f890a16 authored by Michael Niedermayer's avatar Michael Niedermayer

Merge commit '2e09096d'

* commit '2e09096d':
  kgv1: use the AVFrame API properly.
  indeo2: use the AVFrame API properly.
  iff: use the AVFrame API properly.
  msrle: use the AVFrame API properly.

Conflicts:
	libavcodec/iff.c
	libavcodec/indeo2.c
	libavcodec/kgv1dec.c
	libavcodec/msrle.c

See: 451b2ca1
See: 80e9e63c
See: 057dce5fMerged-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parents 10ac6f3c 2e09096d
......@@ -318,6 +318,16 @@ static int extract_header(AVCodecContext *const avctx,
return 0;
}
static av_cold int decode_end(AVCodecContext *avctx)
{
IffContext *s = avctx->priv_data;
av_frame_free(&s->frame);
av_freep(&s->planebuf);
av_freep(&s->ham_buf);
av_freep(&s->ham_palbuf);
return 0;
}
static av_cold int decode_init(AVCodecContext *avctx)
{
IffContext *s = avctx->priv_data;
......@@ -360,8 +370,10 @@ static av_cold int decode_init(AVCodecContext *avctx)
s->bpp = avctx->bits_per_coded_sample;
s->frame = av_frame_alloc();
if (!s->frame)
if (!s->frame) {
decode_end(avctx);
return AVERROR(ENOMEM);
}
if ((err = extract_header(avctx, NULL)) < 0)
return err;
......@@ -858,16 +870,6 @@ static int decode_frame(AVCodecContext *avctx,
return buf_size;
}
static av_cold int decode_end(AVCodecContext *avctx)
{
IffContext *s = avctx->priv_data;
av_frame_free(&s->frame);
av_freep(&s->planebuf);
av_freep(&s->ham_buf);
av_freep(&s->ham_palbuf);
return 0;
}
#if CONFIG_IFF_ILBM_DECODER
AVCodec ff_iff_ilbm_decoder = {
.name = "iff",
......
......@@ -171,36 +171,36 @@ static int ir2_decode_frame(AVCodecContext *avctx,
if (s->decode_delta) { /* intraframe */
if ((ret = ir2_decode_plane(s, avctx->width, avctx->height,
s->picture->data[0], s->picture->linesize[0],
p->data[0], p->linesize[0],
ir2_luma_table)) < 0)
return ret;
/* swapped U and V */
if ((ret = ir2_decode_plane(s, avctx->width >> 2, avctx->height >> 2,
s->picture->data[2], s->picture->linesize[2],
p->data[2], p->linesize[2],
ir2_luma_table)) < 0)
return ret;
if ((ret = ir2_decode_plane(s, avctx->width >> 2, avctx->height >> 2,
s->picture->data[1], s->picture->linesize[1],
p->data[1], p->linesize[1],
ir2_luma_table)) < 0)
return ret;
} else { /* interframe */
if ((ret = ir2_decode_plane_inter(s, avctx->width, avctx->height,
s->picture->data[0], s->picture->linesize[0],
p->data[0], p->linesize[0],
ir2_luma_table)) < 0)
return ret;
/* swapped U and V */
if ((ret = ir2_decode_plane_inter(s, avctx->width >> 2, avctx->height >> 2,
s->picture->data[2], s->picture->linesize[2],
p->data[2], p->linesize[2],
ir2_luma_table)) < 0)
return ret;
if ((ret = ir2_decode_plane_inter(s, avctx->width >> 2, avctx->height >> 2,
s->picture->data[1], s->picture->linesize[1],
p->data[1], p->linesize[1],
ir2_luma_table)) < 0)
return ret;
}
if ((ret = av_frame_ref(picture, s->picture)) < 0)
if ((ret = av_frame_ref(picture, p)) < 0)
return ret;
*got_frame = 1;
......
......@@ -38,7 +38,7 @@ static void decode_flush(AVCodecContext *avctx)
{
KgvContext * const c = avctx->priv_data;
av_frame_unref(c->prev);
av_frame_free(&c->prev);
}
static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
......@@ -155,13 +155,13 @@ static av_cold int decode_init(AVCodecContext *avctx)
{
KgvContext * const c = avctx->priv_data;
avctx->pix_fmt = AV_PIX_FMT_RGB555;
avctx->flags |= CODEC_FLAG_EMU_EDGE;
c->prev = av_frame_alloc();
if (!c->prev)
return AVERROR(ENOMEM);
avctx->pix_fmt = AV_PIX_FMT_RGB555;
avctx->flags |= CODEC_FLAG_EMU_EDGE;
return 0;
}
......
......@@ -38,7 +38,7 @@
typedef struct MsrleContext {
AVCodecContext *avctx;
AVFrame frame;
AVFrame *frame;
GetByteContext gb;
const unsigned char *buf;
......@@ -70,7 +70,9 @@ static av_cold int msrle_decode_init(AVCodecContext *avctx)
return AVERROR_INVALIDDATA;
}
avcodec_get_frame_defaults(&s->frame);
s->frame = av_frame_alloc();
if (!s->frame)
return AVERROR(ENOMEM);
if (avctx->extradata_size >= 4)
for (i = 0; i < FFMIN(avctx->extradata_size, AVPALETTE_SIZE)/4; i++)
......@@ -92,24 +94,24 @@ static int msrle_decode_frame(AVCodecContext *avctx,
s->buf = buf;
s->size = buf_size;
if ((ret = ff_reget_buffer(avctx, &s->frame)) < 0)
if ((ret = ff_reget_buffer(avctx, s->frame)) < 0)
return ret;
if (avctx->bits_per_coded_sample > 1 && avctx->bits_per_coded_sample <= 8) {
const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, NULL);
if (pal) {
s->frame.palette_has_changed = 1;
s->frame->palette_has_changed = 1;
memcpy(s->pal, pal, AVPALETTE_SIZE);
}
/* make the palette available */
memcpy(s->frame.data[1], s->pal, AVPALETTE_SIZE);
memcpy(s->frame->data[1], s->pal, AVPALETTE_SIZE);
}
/* FIXME how to correctly detect RLE ??? */
if (avctx->height * istride == avpkt->size) { /* assume uncompressed */
int linesize = (avctx->width * avctx->bits_per_coded_sample + 7) / 8;
uint8_t *ptr = s->frame.data[0];
uint8_t *ptr = s->frame->data[0];
uint8_t *buf = avpkt->data + (avctx->height-1)*istride;
int i, j;
......@@ -125,14 +127,14 @@ static int msrle_decode_frame(AVCodecContext *avctx,
memcpy(ptr, buf, linesize);
}
buf -= istride;
ptr += s->frame.linesize[0];
ptr += s->frame->linesize[0];
}
} else {
bytestream2_init(&s->gb, buf, buf_size);
ff_msrle_decode(avctx, (AVPicture*)&s->frame, avctx->bits_per_coded_sample, &s->gb);
ff_msrle_decode(avctx, (AVPicture*)s->frame, avctx->bits_per_coded_sample, &s->gb);
}
if ((ret = av_frame_ref(data, &s->frame)) < 0)
if ((ret = av_frame_ref(data, s->frame)) < 0)
return ret;
*got_frame = 1;
......@@ -146,7 +148,7 @@ static av_cold int msrle_decode_end(AVCodecContext *avctx)
MsrleContext *s = avctx->priv_data;
/* release the last frame */
av_frame_unref(&s->frame);
av_frame_free(&s->frame);
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