mirror of https://git.ffmpeg.org/ffmpeg.git
mss3: make code independent of sizeof(AVFrame)
Signed-off-by: Paul B Mahol <onemda@gmail.com>
This commit is contained in:
parent
02fe531afe
commit
ff1c13b133
|
@ -108,7 +108,7 @@ typedef struct HaarBlockCoder {
|
||||||
|
|
||||||
typedef struct MSS3Context {
|
typedef struct MSS3Context {
|
||||||
AVCodecContext *avctx;
|
AVCodecContext *avctx;
|
||||||
AVFrame pic;
|
AVFrame *pic;
|
||||||
|
|
||||||
int got_error;
|
int got_error;
|
||||||
RangeCoder coder;
|
RangeCoder coder;
|
||||||
|
@ -731,12 +731,12 @@ static int mss3_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
|
||||||
return buf_size;
|
return buf_size;
|
||||||
c->got_error = 0;
|
c->got_error = 0;
|
||||||
|
|
||||||
if ((ret = ff_reget_buffer(avctx, &c->pic)) < 0)
|
if ((ret = ff_reget_buffer(avctx, c->pic)) < 0)
|
||||||
return ret;
|
return ret;
|
||||||
c->pic.key_frame = keyframe;
|
c->pic->key_frame = keyframe;
|
||||||
c->pic.pict_type = keyframe ? AV_PICTURE_TYPE_I : AV_PICTURE_TYPE_P;
|
c->pic->pict_type = keyframe ? AV_PICTURE_TYPE_I : AV_PICTURE_TYPE_P;
|
||||||
if (!bytestream2_get_bytes_left(&gb)) {
|
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;
|
return ret;
|
||||||
*got_frame = 1;
|
*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_width = dec_width >> 4;
|
||||||
mb_height = dec_height >> 4;
|
mb_height = dec_height >> 4;
|
||||||
dst[0] = c->pic.data[0] + dec_x + dec_y * c->pic.linesize[0];
|
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[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[2] = c->pic->data[2] + dec_x / 2 + (dec_y / 2) * c->pic->linesize[2];
|
||||||
for (y = 0; y < mb_height; y++) {
|
for (y = 0; y < mb_height; y++) {
|
||||||
for (x = 0; x < mb_width; x++) {
|
for (x = 0; x < mb_width; x++) {
|
||||||
for (i = 0; i < 3; i++) {
|
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:
|
case FILL_BLOCK:
|
||||||
decode_fill_block(acoder, c->fill_coder + i,
|
decode_fill_block(acoder, c->fill_coder + i,
|
||||||
dst[i] + x * blk_size,
|
dst[i] + x * blk_size,
|
||||||
c->pic.linesize[i], blk_size);
|
c->pic->linesize[i], blk_size);
|
||||||
break;
|
break;
|
||||||
case IMAGE_BLOCK:
|
case IMAGE_BLOCK:
|
||||||
decode_image_block(acoder, c->image_coder + i,
|
decode_image_block(acoder, c->image_coder + i,
|
||||||
dst[i] + x * blk_size,
|
dst[i] + x * blk_size,
|
||||||
c->pic.linesize[i], blk_size);
|
c->pic->linesize[i], blk_size);
|
||||||
break;
|
break;
|
||||||
case DCT_BLOCK:
|
case DCT_BLOCK:
|
||||||
decode_dct_block(acoder, c->dct_coder + i,
|
decode_dct_block(acoder, c->dct_coder + i,
|
||||||
dst[i] + x * blk_size,
|
dst[i] + x * blk_size,
|
||||||
c->pic.linesize[i], blk_size,
|
c->pic->linesize[i], blk_size,
|
||||||
c->dctblock, x, y);
|
c->dctblock, x, y);
|
||||||
break;
|
break;
|
||||||
case HAAR_BLOCK:
|
case HAAR_BLOCK:
|
||||||
decode_haar_block(acoder, c->haar_coder + i,
|
decode_haar_block(acoder, c->haar_coder + i,
|
||||||
dst[i] + x * blk_size,
|
dst[i] + x * blk_size,
|
||||||
c->pic.linesize[i], blk_size,
|
c->pic->linesize[i], blk_size,
|
||||||
c->hblock);
|
c->hblock);
|
||||||
break;
|
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[0] += c->pic->linesize[0] * 16;
|
||||||
dst[1] += c->pic.linesize[1] * 8;
|
dst[1] += c->pic->linesize[1] * 8;
|
||||||
dst[2] += c->pic.linesize[2] * 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;
|
return ret;
|
||||||
|
|
||||||
*got_frame = 1;
|
*got_frame = 1;
|
||||||
|
@ -809,6 +809,9 @@ static av_cold int mss3_decode_init(AVCodecContext *avctx)
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
c->avctx = avctx;
|
c->avctx = avctx;
|
||||||
|
c->pic = av_frame_alloc();
|
||||||
|
if (!c->pic)
|
||||||
|
return AVERROR(ENOMEM);
|
||||||
|
|
||||||
if ((avctx->width & 0xF) || (avctx->height & 0xF)) {
|
if ((avctx->width & 0xF) || (avctx->height & 0xF)) {
|
||||||
av_log(avctx, AV_LOG_ERROR,
|
av_log(avctx, AV_LOG_ERROR,
|
||||||
|
@ -826,6 +829,7 @@ static av_cold int mss3_decode_init(AVCodecContext *avctx)
|
||||||
b_width * b_height);
|
b_width * b_height);
|
||||||
if (!c->dct_coder[i].prev_dc) {
|
if (!c->dct_coder[i].prev_dc) {
|
||||||
av_log(avctx, AV_LOG_ERROR, "Cannot allocate buffer\n");
|
av_log(avctx, AV_LOG_ERROR, "Cannot allocate buffer\n");
|
||||||
|
av_frame_free(&c->pic);
|
||||||
while (i >= 0) {
|
while (i >= 0) {
|
||||||
av_freep(&c->dct_coder[i].prev_dc);
|
av_freep(&c->dct_coder[i].prev_dc);
|
||||||
i--;
|
i--;
|
||||||
|
@ -846,7 +850,7 @@ static av_cold int mss3_decode_end(AVCodecContext *avctx)
|
||||||
MSS3Context * const c = avctx->priv_data;
|
MSS3Context * const c = avctx->priv_data;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
av_frame_unref(&c->pic);
|
av_frame_free(&c->pic);
|
||||||
for (i = 0; i < 3; i++)
|
for (i = 0; i < 3; i++)
|
||||||
av_freep(&c->dct_coder[i].prev_dc);
|
av_freep(&c->dct_coder[i].prev_dc);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue