diff options
Diffstat (limited to 'libavcodec/indeo3.c')
-rw-r--r-- | libavcodec/indeo3.c | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/libavcodec/indeo3.c b/libavcodec/indeo3.c index 4f3cb36606..1bb73fe790 100644 --- a/libavcodec/indeo3.c +++ b/libavcodec/indeo3.c @@ -2,20 +2,20 @@ * Indeo Video v3 compatible decoder * Copyright (c) 2009 - 2011 Maxim Poliakovski * - * 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 */ @@ -226,8 +226,11 @@ static void copy_cell(Indeo3DecodeContext *ctx, Plane *plane, Cell *cell) /* setup output and reference pointers */ offset_dst = (cell->ypos << 2) * plane->pitch + (cell->xpos << 2); dst = plane->pixels[ctx->buf_sel] + offset_dst; + if(cell->mv_ptr){ mv_y = cell->mv_ptr[0]; mv_x = cell->mv_ptr[1]; + }else + mv_x= mv_y= 0; offset = offset_dst + mv_y * plane->pitch + mv_x; src = plane->pixels[ctx->buf_sel ^ 1] + offset; @@ -733,7 +736,7 @@ static int parse_bintree(Indeo3DecodeContext *ctx, AVCodecContext *avctx, ref_cell->width -= curr_cell.width; } - while (1) { /* loop until return */ + while (get_bits_left(&ctx->gb) >= 2) { /* loop until return */ RESYNC_BITSTREAM; switch (code = get_bits(&ctx->gb, 2)) { case H_SPLIT: @@ -788,7 +791,7 @@ static int parse_bintree(Indeo3DecodeContext *ctx, AVCodecContext *avctx, } }//while - return 0; + return AVERROR_INVALIDDATA; } @@ -797,15 +800,19 @@ static int decode_plane(Indeo3DecodeContext *ctx, AVCodecContext *avctx, int32_t strip_width) { Cell curr_cell; - int num_vectors; + uint32_t num_vectors; /* each plane data starts with mc_vector_count field, */ /* an optional array of motion vectors followed by the vq data */ num_vectors = bytestream_get_le32(&data); + if(num_vectors >= data_size/2) + return AVERROR_INVALIDDATA; ctx->mc_vectors = num_vectors ? data : 0; + data += num_vectors * 2; + data_size-= num_vectors * 2; /* init the bitreader */ - init_get_bits(&ctx->gb, &data[num_vectors * 2], data_size << 3); + init_get_bits(&ctx->gb, data, data_size << 3); ctx->skip_bits = 0; ctx->need_resync = 0; @@ -971,6 +978,7 @@ static av_cold int decode_init(AVCodecContext *avctx) ctx->width = avctx->width; ctx->height = avctx->height; avctx->pix_fmt = PIX_FMT_YUV410P; + avcodec_get_frame_defaults(&ctx->frame); build_requant_tab(); |