diff options
author | Paul B Mahol <onemda@gmail.com> | 2013-07-29 15:27:05 +0000 |
---|---|---|
committer | Paul B Mahol <onemda@gmail.com> | 2013-07-31 20:01:42 +0000 |
commit | ff1c13b133d548b3ce103f91999b6cc1bb7e65cc (patch) | |
tree | 93bc238ddaf81e3fca15aa35f080e87f14e17f1d /libavcodec/mss3.c | |
parent | 02fe531afefa7ac3fcc552f8e83461a4bfa7f868 (diff) | |
download | ffmpeg-ff1c13b133d548b3ce103f91999b6cc1bb7e65cc.tar.gz |
mss3: make code independent of sizeof(AVFrame)
Signed-off-by: Paul B Mahol <onemda@gmail.com>
Diffstat (limited to 'libavcodec/mss3.c')
-rw-r--r-- | libavcodec/mss3.c | 38 |
1 files changed, 21 insertions, 17 deletions
diff --git a/libavcodec/mss3.c b/libavcodec/mss3.c index 3cc484f7b7..15bf77a5b1 100644 --- a/libavcodec/mss3.c +++ b/libavcodec/mss3.c @@ -108,7 +108,7 @@ typedef struct HaarBlockCoder { typedef struct MSS3Context { AVCodecContext *avctx; - AVFrame pic; + AVFrame *pic; int got_error; RangeCoder coder; @@ -731,12 +731,12 @@ static int mss3_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, return buf_size; c->got_error = 0; - if ((ret = ff_reget_buffer(avctx, &c->pic)) < 0) + if ((ret = ff_reget_buffer(avctx, c->pic)) < 0) return ret; - c->pic.key_frame = keyframe; - c->pic.pict_type = keyframe ? AV_PICTURE_TYPE_I : AV_PICTURE_TYPE_P; + c->pic->key_frame = keyframe; + c->pic->pict_type = keyframe ? AV_PICTURE_TYPE_I : AV_PICTURE_TYPE_P; if (!bytestream2_get_bytes_left(&gb)) { - if ((ret = av_frame_ref(data, &c->pic)) < 0) + if ((ret = av_frame_ref(data, c->pic)) < 0) return ret; *got_frame = 1; @@ -749,9 +749,9 @@ static int mss3_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, mb_width = dec_width >> 4; mb_height = dec_height >> 4; - dst[0] = c->pic.data[0] + dec_x + dec_y * c->pic.linesize[0]; - dst[1] = c->pic.data[1] + dec_x / 2 + (dec_y / 2) * c->pic.linesize[1]; - dst[2] = c->pic.data[2] + dec_x / 2 + (dec_y / 2) * c->pic.linesize[2]; + dst[0] = c->pic->data[0] + dec_x + dec_y * c->pic->linesize[0]; + dst[1] = c->pic->data[1] + dec_x / 2 + (dec_y / 2) * c->pic->linesize[1]; + dst[2] = c->pic->data[2] + dec_x / 2 + (dec_y / 2) * c->pic->linesize[2]; for (y = 0; y < mb_height; y++) { for (x = 0; x < mb_width; x++) { for (i = 0; i < 3; i++) { @@ -762,23 +762,23 @@ static int mss3_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, case FILL_BLOCK: decode_fill_block(acoder, c->fill_coder + i, dst[i] + x * blk_size, - c->pic.linesize[i], blk_size); + c->pic->linesize[i], blk_size); break; case IMAGE_BLOCK: decode_image_block(acoder, c->image_coder + i, dst[i] + x * blk_size, - c->pic.linesize[i], blk_size); + c->pic->linesize[i], blk_size); break; case DCT_BLOCK: decode_dct_block(acoder, c->dct_coder + i, dst[i] + x * blk_size, - c->pic.linesize[i], blk_size, + c->pic->linesize[i], blk_size, c->dctblock, x, y); break; case HAAR_BLOCK: decode_haar_block(acoder, c->haar_coder + i, dst[i] + x * blk_size, - c->pic.linesize[i], blk_size, + c->pic->linesize[i], blk_size, c->hblock); break; } @@ -790,12 +790,12 @@ static int mss3_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, } } } - dst[0] += c->pic.linesize[0] * 16; - dst[1] += c->pic.linesize[1] * 8; - dst[2] += c->pic.linesize[2] * 8; + dst[0] += c->pic->linesize[0] * 16; + dst[1] += c->pic->linesize[1] * 8; + dst[2] += c->pic->linesize[2] * 8; } - if ((ret = av_frame_ref(data, &c->pic)) < 0) + if ((ret = av_frame_ref(data, c->pic)) < 0) return ret; *got_frame = 1; @@ -809,6 +809,9 @@ static av_cold int mss3_decode_init(AVCodecContext *avctx) int i; c->avctx = avctx; + c->pic = av_frame_alloc(); + if (!c->pic) + return AVERROR(ENOMEM); if ((avctx->width & 0xF) || (avctx->height & 0xF)) { av_log(avctx, AV_LOG_ERROR, @@ -826,6 +829,7 @@ static av_cold int mss3_decode_init(AVCodecContext *avctx) b_width * b_height); if (!c->dct_coder[i].prev_dc) { av_log(avctx, AV_LOG_ERROR, "Cannot allocate buffer\n"); + av_frame_free(&c->pic); while (i >= 0) { av_freep(&c->dct_coder[i].prev_dc); i--; @@ -846,7 +850,7 @@ static av_cold int mss3_decode_end(AVCodecContext *avctx) MSS3Context * const c = avctx->priv_data; int i; - av_frame_unref(&c->pic); + av_frame_free(&c->pic); for (i = 0; i < 3; i++) av_freep(&c->dct_coder[i].prev_dc); |