summaryrefslogtreecommitdiff
path: root/libavcodec/tscc2.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2013-03-23 12:24:05 +0100
committerMichael Niedermayer <michaelni@gmx.at>2013-03-23 12:26:08 +0100
commit8b63eeb6b1c2f9e7d762f32dbd42dae124591314 (patch)
tree22c4f47fceef730a0f193cd168514ea65baeee66 /libavcodec/tscc2.c
parent9bb6504e3bff2e00610f52cc41938aa8c2a3ad4c (diff)
parent3f15b301fa61547f59f1452b14edf14e5673fdd2 (diff)
Merge remote-tracking branch 'qatar/master'
* qatar/master: fate: add test for cropping h264 to container dimensions FATE: add a tscc2 test. tscc2: allocate AVFrame properly. Conflicts: libavcodec/tscc2.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/tscc2.c')
-rw-r--r--libavcodec/tscc2.c39
1 files changed, 23 insertions, 16 deletions
diff --git a/libavcodec/tscc2.c b/libavcodec/tscc2.c
index f275ff9d8d..291693af3d 100644
--- a/libavcodec/tscc2.c
+++ b/libavcodec/tscc2.c
@@ -33,7 +33,7 @@
typedef struct TSCC2Context {
AVCodecContext *avctx;
- AVFrame pic;
+ AVFrame *pic;
int mb_width, mb_height;
uint8_t *slice_quants;
int quant[2];
@@ -200,9 +200,9 @@ static int tscc2_decode_slice(TSCC2Context *c, int mb_y,
if (q == 0 || q == 3) // skip block
continue;
for (i = 0; i < 3; i++) {
- off = mb_x * 16 + mb_y * 8 * c->pic.linesize[i];
+ off = mb_x * 16 + mb_y * 8 * c->pic->linesize[i];
ret = tscc2_decode_mb(c, c->q[q - 1], c->quant[q - 1] - 2,
- c->pic.data[i] + off, c->pic.linesize[i], i);
+ c->pic->data[i] + off, c->pic->linesize[i], i);
if (ret)
return ret;
}
@@ -230,12 +230,13 @@ static int tscc2_decode_frame(AVCodecContext *avctx, void *data,
return AVERROR_INVALIDDATA;
}
- if ((ret = ff_reget_buffer(avctx, &c->pic)) < 0)
+ if ((ret = ff_reget_buffer(avctx, c->pic)) < 0) {
return ret;
+ }
if (frame_type == 0) {
*got_frame = 1;
- if ((ret = av_frame_ref(data, &c->pic)) < 0)
+ if ((ret = av_frame_ref(data, c->pic)) < 0)
return ret;
return buf_size;
@@ -320,13 +321,24 @@ static int tscc2_decode_frame(AVCodecContext *avctx, void *data,
}
*got_frame = 1;
- if ((ret = av_frame_ref(data, &c->pic)) < 0)
+ if ((ret = av_frame_ref(data, c->pic)) < 0)
return ret;
/* always report that the buffer was completely consumed */
return buf_size;
}
+static av_cold int tscc2_decode_end(AVCodecContext *avctx)
+{
+ TSCC2Context * const c = avctx->priv_data;
+
+ av_frame_free(&c->pic);
+ av_freep(&c->slice_quants);
+ free_vlcs(c);
+
+ return 0;
+}
+
static av_cold int tscc2_decode_init(AVCodecContext *avctx)
{
TSCC2Context * const c = avctx->priv_data;
@@ -350,16 +362,11 @@ static av_cold int tscc2_decode_init(AVCodecContext *avctx)
return AVERROR(ENOMEM);
}
- return 0;
-}
-
-static av_cold int tscc2_decode_end(AVCodecContext *avctx)
-{
- TSCC2Context * const c = avctx->priv_data;
-
- av_frame_unref(&c->pic);
- av_freep(&c->slice_quants);
- free_vlcs(c);
+ c->pic = av_frame_alloc();
+ if (!c->pic) {
+ tscc2_decode_end(avctx);
+ return AVERROR(ENOMEM);
+ }
return 0;
}