diff options
Diffstat (limited to 'libavcodec/mss2.c')
-rw-r--r-- | libavcodec/mss2.c | 41 |
1 files changed, 18 insertions, 23 deletions
diff --git a/libavcodec/mss2.c b/libavcodec/mss2.c index ffbba6d0fd..35c5d2722d 100644 --- a/libavcodec/mss2.c +++ b/libavcodec/mss2.c @@ -1,20 +1,20 @@ /* * Microsoft Screen 2 (aka Windows Media Video V9 Screen) decoder * - * 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 */ @@ -57,7 +57,7 @@ static void arith2_normalise(ArithCoder *c) } } -ARITH_GET_BIT(2) +ARITH_GET_BIT(arith2) /* L. Stuiver and A. Moffat: "Piecewise Integer Mapping for Arithmetic Coding." * In Proc. 8th Data Compression Conference (DCC '98), pp. 3-12, Mar. 1998 */ @@ -130,7 +130,7 @@ static int arith2_get_prob(ArithCoder *c, int16_t *probs) return i; } -ARITH_GET_MODEL_SYM(2) +ARITH_GET_MODEL_SYM(arith2) static int arith2_get_consumed_bytes(ArithCoder *c) { @@ -380,7 +380,8 @@ static int decode_wmv9(AVCodecContext *avctx, const uint8_t *buf, int buf_size, ff_mpeg_flush(avctx); - init_get_bits(&s->gb, buf, buf_size * 8); + if ((ret = init_get_bits8(&s->gb, buf, buf_size)) < 0) + return ret; s->loop_filter = avctx->skip_loop_filter < AVDISCARD_ALL; @@ -423,8 +424,8 @@ static int decode_wmv9(AVCodecContext *avctx, const uint8_t *buf, int buf_size, if (v->respic == 3) { ctx->dsp.upsample_plane(f->data[0], f->linesize[0], w, h); - ctx->dsp.upsample_plane(f->data[1], f->linesize[1], w >> 1, h >> 1); - ctx->dsp.upsample_plane(f->data[2], f->linesize[2], w >> 1, h >> 1); + ctx->dsp.upsample_plane(f->data[1], f->linesize[1], w+1 >> 1, h+1 >> 1); + ctx->dsp.upsample_plane(f->data[2], f->linesize[2], w+1 >> 1, h+1 >> 1); } else if (v->respic) avpriv_request_sample(v->s.avctx, "Asymmetric WMV9 rectangle subsampling"); @@ -478,7 +479,8 @@ static int mss2_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, av_assert0(FF_INPUT_BUFFER_PADDING_SIZE >= ARITH2_PADDING + (MIN_CACHE_BITS + 7) / 8); - init_get_bits(&gb, buf, buf_size * 8); + if ((ret = init_get_bits8(&gb, buf, buf_size)) < 0) + return ret; if (keyframe = get_bits1(&gb)) skip_bits(&gb, 7); @@ -594,10 +596,8 @@ static int mss2_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, if (c->mvX < 0 || c->mvY < 0) { FFSWAP(uint8_t *, c->pal_pic, c->last_pal_pic); - if ((ret = ff_get_buffer(avctx, frame, AV_GET_BUFFER_FLAG_REF)) < 0) { - av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); + if ((ret = ff_get_buffer(avctx, frame, AV_GET_BUFFER_FLAG_REF)) < 0) return ret; - } if (ctx->last_pic->data[0]) { av_assert0(frame->linesize[0] == ctx->last_pic->linesize[0]); @@ -608,10 +608,8 @@ static int mss2_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, return AVERROR_INVALIDDATA; } } else { - if ((ret = ff_reget_buffer(avctx, ctx->last_pic)) < 0) { - av_log(avctx, AV_LOG_ERROR, "reget_buffer() failed\n"); + if ((ret = ff_reget_buffer(avctx, ctx->last_pic)) < 0) return ret; - } if ((ret = av_frame_ref(frame, ctx->last_pic)) < 0) return ret; @@ -640,7 +638,8 @@ static int mss2_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, ff_mss12_slicecontext_reset(&ctx->sc[1]); } if (is_rle) { - init_get_bits(&gb, buf, buf_size * 8); + if ((ret = init_get_bits8(&gb, buf, buf_size)) < 0) + return ret; if (ret = decode_rle(&gb, c->pal_pic, c->pal_stride, c->rgb_pic, c->rgb_stride, c->pal, keyframe, ctx->split_position, 0, @@ -818,10 +817,11 @@ static av_cold int mss2_decode_init(AVCodecContext *avctx) c->avctx = avctx; if (ret = ff_mss12_decode_init(c, 1, &ctx->sc[0], &ctx->sc[1])) return ret; + ctx->last_pic = av_frame_alloc(); c->pal_stride = c->mask_stride; c->pal_pic = av_mallocz(c->pal_stride * avctx->height); c->last_pal_pic = av_mallocz(c->pal_stride * avctx->height); - if (!c->pal_pic || !c->last_pal_pic) { + if (!c->pal_pic || !c->last_pal_pic || !ctx->last_pic) { mss2_decode_end(avctx); return AVERROR(ENOMEM); } @@ -835,11 +835,6 @@ static av_cold int mss2_decode_init(AVCodecContext *avctx) avctx->pix_fmt = c->free_colours == 127 ? AV_PIX_FMT_RGB555 : AV_PIX_FMT_RGB24; - ctx->last_pic = av_frame_alloc(); - if (!ctx->last_pic) { - mss2_decode_end(avctx); - return AVERROR(ENOMEM); - } return 0; } |