summaryrefslogtreecommitdiff
path: root/libavcodec/truemotion2.c
diff options
context:
space:
mode:
authorPaul B Mahol <onemda@gmail.com>2013-07-26 14:49:12 +0000
committerPaul B Mahol <onemda@gmail.com>2013-07-28 22:42:40 +0000
commite999f2339ab0200039ee7123b75d79a52aaac5d1 (patch)
tree711792718eb2a321e10286ba7feb9df75e43f38e /libavcodec/truemotion2.c
parenta5155294e571bf1861627c7e9c3f4c32c5df32dc (diff)
truemotion2: make code independent of sizeof(AVFrame)
Signed-off-by: Paul B Mahol <onemda@gmail.com>
Diffstat (limited to 'libavcodec/truemotion2.c')
-rw-r--r--libavcodec/truemotion2.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/libavcodec/truemotion2.c b/libavcodec/truemotion2.c
index 7783386d25..6c119aca18 100644
--- a/libavcodec/truemotion2.c
+++ b/libavcodec/truemotion2.c
@@ -58,7 +58,7 @@ enum TM2_BLOCKS {
typedef struct TM2Context {
AVCodecContext *avctx;
- AVFrame pic;
+ AVFrame *pic;
GetBitContext gb;
DSPContext dsp;
@@ -858,7 +858,7 @@ static int decode_frame(AVCodecContext *avctx,
TM2Context * const l = avctx->priv_data;
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size & ~3;
- AVFrame * const p = &l->pic;
+ AVFrame * const p = l->pic;
int offset = TM2_HEADER_SIZE;
int i, t, ret;
@@ -900,7 +900,7 @@ static int decode_frame(AVCodecContext *avctx,
l->cur = !l->cur;
*got_frame = 1;
- ret = av_frame_ref(data, &l->pic);
+ ret = av_frame_ref(data, l->pic);
return (ret < 0) ? ret : buf_size;
}
@@ -916,8 +916,10 @@ static av_cold int decode_init(AVCodecContext *avctx)
}
l->avctx = avctx;
- avcodec_get_frame_defaults(&l->pic);
avctx->pix_fmt = AV_PIX_FMT_BGR24;
+ l->pic = av_frame_alloc();
+ if (!l->pic)
+ return AVERROR(ENOMEM);
ff_dsputil_init(&l->dsp, avctx);
@@ -953,6 +955,7 @@ static av_cold int decode_init(AVCodecContext *avctx)
av_freep(l->V2_base);
av_freep(l->last);
av_freep(l->clast);
+ av_frame_free(&l->pic);
return AVERROR(ENOMEM);
}
l->Y1 = l->Y1_base + l->y_stride * 4 + 4;
@@ -968,7 +971,6 @@ static av_cold int decode_init(AVCodecContext *avctx)
static av_cold int decode_end(AVCodecContext *avctx)
{
TM2Context * const l = avctx->priv_data;
- AVFrame *pic = &l->pic;
int i;
av_free(l->last);
@@ -986,7 +988,7 @@ static av_cold int decode_end(AVCodecContext *avctx)
av_freep(&l->buffer);
l->buffer_size = 0;
- av_frame_unref(pic);
+ av_frame_free(&l->pic);
return 0;
}