diff options
Diffstat (limited to 'libavcodec/h261dec.c')
-rw-r--r-- | libavcodec/h261dec.c | 36 |
1 files changed, 23 insertions, 13 deletions
diff --git a/libavcodec/h261dec.c b/libavcodec/h261dec.c index 0d996eb..95587f2 100644 --- a/libavcodec/h261dec.c +++ b/libavcodec/h261dec.c @@ -3,20 +3,20 @@ * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at> * Copyright (c) 2004 Maarten Daniels * - * 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 */ @@ -25,6 +25,7 @@ * H.261 decoder. */ +#include "libavutil/avassert.h" #include "avcodec.h" #include "mpegutils.h" #include "mpegvideo.h" @@ -126,12 +127,12 @@ static int h261_decode_gob_header(H261Context *h) } /* GEI */ - while (get_bits1(&s->gb) != 0) - skip_bits(&s->gb, 8); + if (skip_1stop_8data_bits(&s->gb) < 0) + return AVERROR_INVALIDDATA; if (s->qscale == 0) { av_log(s->avctx, AV_LOG_ERROR, "qscale has forbidden 0 value\n"); - if (s->avctx->err_recognition & AV_EF_BITSTREAM) + if (s->avctx->err_recognition & (AV_EF_BITSTREAM | AV_EF_COMPLIANT)) return -1; } @@ -378,11 +379,12 @@ static int h261_decode_mb(H261Context *h) // Read mtype h->mtype = get_vlc2(&s->gb, h261_mtype_vlc.table, H261_MTYPE_VLC_BITS, 2); - if (h->mtype < 0 || h->mtype >= FF_ARRAY_ELEMS(ff_h261_mtype_map)) { + if (h->mtype < 0) { av_log(s->avctx, AV_LOG_ERROR, "Invalid mtype index %d\n", h->mtype); return SLICE_ERROR; } + av_assert0(h->mtype < FF_ARRAY_ELEMS(ff_h261_mtype_map)); h->mtype = ff_h261_mtype_map[h->mtype]; // Read mquant @@ -430,6 +432,13 @@ static int h261_decode_mb(H261Context *h) s->mv[0][0][0] = h->current_mv_x * 2; // gets divided by 2 in motion compensation s->mv[0][0][1] = h->current_mv_y * 2; + if (s->current_picture.motion_val[0]) { + int b_stride = 2*s->mb_width + 1; + int b_xy = 2 * s->mb_x + (2 * s->mb_y) * b_stride; + s->current_picture.motion_val[0][b_xy][0] = s->mv[0][0][0]; + s->current_picture.motion_val[0][b_xy][1] = s->mv[0][0][1]; + } + intra: /* decode each block */ if (s->mb_intra || HAS_CBP(h->mtype)) { @@ -505,8 +514,8 @@ static int h261_decode_picture_header(H261Context *h) skip_bits1(&s->gb); /* Reserved */ /* PEI */ - while (get_bits1(&s->gb) != 0) - skip_bits(&s->gb, 8); + if (skip_1stop_8data_bits(&s->gb) < 0) + return AVERROR_INVALIDDATA; /* H.261 has no I-frames, but if we pass AV_PICTURE_TYPE_I for the first * frame, the codec crashes if it does not contain all I-blocks @@ -632,12 +641,12 @@ retry: } ff_MPV_frame_end(s); - assert(s->current_picture.f->pict_type == s->current_picture_ptr->f->pict_type); - assert(s->current_picture.f->pict_type == s->pict_type); + av_assert0(s->current_picture.f->pict_type == s->current_picture_ptr->f->pict_type); + av_assert0(s->current_picture.f->pict_type == s->pict_type); if ((ret = av_frame_ref(pict, s->current_picture_ptr->f)) < 0) return ret; - ff_print_debug_info(s, s->current_picture_ptr); + ff_print_debug_info(s, s->current_picture_ptr, pict); *got_frame = 1; @@ -663,4 +672,5 @@ AVCodec ff_h261_decoder = { .close = h261_decode_end, .decode = h261_decode_frame, .capabilities = CODEC_CAP_DR1, + .max_lowres = 3, }; |