summaryrefslogtreecommitdiff
path: root/libavcodec/mss3.c
diff options
context:
space:
mode:
Diffstat (limited to 'libavcodec/mss3.c')
-rw-r--r--libavcodec/mss3.c50
1 files changed, 26 insertions, 24 deletions
diff --git a/libavcodec/mss3.c b/libavcodec/mss3.c
index fa5b99c454..15bf77a5b1 100644
--- a/libavcodec/mss3.c
+++ b/libavcodec/mss3.c
@@ -2,20 +2,20 @@
* Microsoft Screen 3 (aka Microsoft ATC Screen) decoder
* Copyright (c) 2012 Konstantin Shishkov
*
- * This file is part of Libav.
+ * This file is part of FFmpeg.
*
- * Libav is free software; you can redistribute it and/or
+ * FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
- * Libav is distributed in the hope that it will be useful,
+ * FFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
- * License along with Libav; if not, write to the Free Software
+ * License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
@@ -108,7 +108,7 @@ typedef struct HaarBlockCoder {
typedef struct MSS3Context {
AVCodecContext *avctx;
- AVFrame pic;
+ AVFrame *pic;
int got_error;
RangeCoder coder;
@@ -296,7 +296,7 @@ static void rac_normalise(RangeCoder *c)
c->low |= *c->src++;
} else if (!c->low) {
c->got_error = 1;
- return;
+ c->low = 1;
}
if (c->range >= RAC_BOTTOM)
return;
@@ -731,14 +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) {
- av_log(avctx, AV_LOG_ERROR, "reget_buffer() failed\n");
+ 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;
@@ -751,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++) {
@@ -764,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;
}
@@ -792,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;
@@ -811,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,
@@ -828,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--;
@@ -848,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);