aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/qpeg.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2013-11-17 01:07:37 +0100
committerMichael Niedermayer <michaelni@gmx.at>2013-11-17 01:07:37 +0100
commit5219afc09d8e97e18917738cbc052f903df9a619 (patch)
tree324177cb47f114fb5dabb34f96833ee54b269c6d /libavcodec/qpeg.c
parentbfb1f44d246f4ed97d5cad9c1eace8a20951ff76 (diff)
parent2d2a92f72199823a92e4e226c32e42a27ec801c0 (diff)
downloadffmpeg-5219afc09d8e97e18917738cbc052f903df9a619.tar.gz
Merge commit '2d2a92f72199823a92e4e226c32e42a27ec801c0'
* commit '2d2a92f72199823a92e4e226c32e42a27ec801c0': dxa: use the AVFrame API properly. qpeg: use the AVFrame API properly. cin video: use the AVFrame API properly. msvideo1: use the AVFrame API properly. Conflicts: libavcodec/dsicinav.c libavcodec/dxa.c libavcodec/msvideo1.c libavcodec/qpeg.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/qpeg.c')
-rw-r--r--libavcodec/qpeg.c46
1 files changed, 25 insertions, 21 deletions
diff --git a/libavcodec/qpeg.c b/libavcodec/qpeg.c
index edde937b15..da2d3b9d16 100644
--- a/libavcodec/qpeg.c
+++ b/libavcodec/qpeg.c
@@ -30,7 +30,7 @@
typedef struct QpegContext{
AVCodecContext *avctx;
- AVFrame pic, ref;
+ AVFrame *pic, *ref;
uint32_t pal[256];
GetByteContext buffer;
} QpegContext;
@@ -255,8 +255,8 @@ static int decode_frame(AVCodecContext *avctx,
{
uint8_t ctable[128];
QpegContext * const a = avctx->priv_data;
- AVFrame * p = &a->pic;
- AVFrame * ref= &a->ref;
+ AVFrame * const p = a->pic;
+ AVFrame * const ref = a->ref;
uint8_t* outdata;
int delta, ret;
const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, NULL);
@@ -273,26 +273,26 @@ static int decode_frame(AVCodecContext *avctx,
if ((ret = ff_get_buffer(avctx, p, AV_GET_BUFFER_FLAG_REF)) < 0)
return ret;
- outdata = a->pic.data[0];
+ outdata = p->data[0];
bytestream2_skip(&a->buffer, 4);
bytestream2_get_buffer(&a->buffer, ctable, 128);
bytestream2_skip(&a->buffer, 1);
delta = bytestream2_get_byte(&a->buffer);
if(delta == 0x10) {
- qpeg_decode_intra(a, outdata, a->pic.linesize[0], avctx->width, avctx->height);
+ qpeg_decode_intra(a, outdata, p->linesize[0], avctx->width, avctx->height);
} else {
- qpeg_decode_inter(a, outdata, a->pic.linesize[0], avctx->width, avctx->height, delta, ctable, a->ref.data[0]);
+ qpeg_decode_inter(a, outdata, p->linesize[0], avctx->width, avctx->height, delta, ctable, ref->data[0]);
}
/* make the palette available on the way out */
if (pal) {
- a->pic.palette_has_changed = 1;
+ p->palette_has_changed = 1;
memcpy(a->pal, pal, AVPALETTE_SIZE);
}
- memcpy(a->pic.data[1], a->pal, AVPALETTE_SIZE);
+ memcpy(p->data[1], a->pal, AVPALETTE_SIZE);
- if ((ret = av_frame_ref(data, &a->pic)) < 0)
+ if ((ret = av_frame_ref(data, p)) < 0)
return ret;
*got_frame = 1;
@@ -312,6 +312,16 @@ static void decode_flush(AVCodecContext *avctx){
a->pal[i] = 0xFFU<<24 | AV_RL32(pal_src+4*i);
}
+static av_cold int decode_end(AVCodecContext *avctx)
+{
+ QpegContext * const a = avctx->priv_data;
+
+ av_frame_free(&a->pic);
+ av_frame_free(&a->ref);
+
+ return 0;
+}
+
static av_cold int decode_init(AVCodecContext *avctx){
QpegContext * const a = avctx->priv_data;
@@ -322,18 +332,12 @@ static av_cold int decode_init(AVCodecContext *avctx){
decode_flush(avctx);
- avcodec_get_frame_defaults(&a->pic);
-
- return 0;
-}
-
-static av_cold int decode_end(AVCodecContext *avctx){
- QpegContext * const a = avctx->priv_data;
- AVFrame * const p = &a->pic;
- AVFrame * const ref= &a->ref;
-
- av_frame_unref(p);
- av_frame_unref(ref);
+ a->pic = av_frame_alloc();
+ a->ref = av_frame_alloc();
+ if (!a->pic || !a->ref) {
+ decode_end(avctx);
+ return AVERROR(ENOMEM);
+ }
return 0;
}