diff options
Diffstat (limited to 'libavcodec/ituh263dec.c')
-rw-r--r-- | libavcodec/ituh263dec.c | 40 |
1 files changed, 22 insertions, 18 deletions
diff --git a/libavcodec/ituh263dec.c b/libavcodec/ituh263dec.c index cb26be2..6d43233 100644 --- a/libavcodec/ituh263dec.c +++ b/libavcodec/ituh263dec.c @@ -5,20 +5,20 @@ * Copyright (c) 2001 Juan J. Sierralta P * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at> * - * 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 */ @@ -27,6 +27,8 @@ * h263 decoder. */ +#define UNCHECKED_BITSTREAM_READER 1 + //#define DEBUG #include <limits.h> @@ -40,9 +42,6 @@ #include "flv.h" #include "mpeg4video.h" -//#undef NDEBUG -//#include <assert.h> - // The defines below define the number of bits that are read at once for // reading vlc values. Changing these may improve speed and data cache needs // be aware though that decreasing them may need the number of stages that is @@ -208,16 +207,19 @@ static int h263_decode_gob_header(MpegEncContext *s) * @param end pointer to the end of the buffer * @return pointer to the next resync_marker, or end if none was found */ -const uint8_t *ff_h263_find_resync_marker(const uint8_t *restrict p, const uint8_t * restrict end) +const uint8_t *ff_h263_find_resync_marker(MpegEncContext *s, const uint8_t *av_restrict p, const uint8_t *av_restrict end) { - assert(p < end); + av_assert2(p < end); end-=2; p++; - for(;p<end; p+=2){ - if(!*p){ - if (!p[-1] && p[1]) return p - 1; - else if(!p[ 1] && p[2]) return p; + if(s->resync_marker){ + int prefix_len = ff_mpeg4_get_video_packet_prefix_length(s); + for(;p<end; p+=2){ + if(!*p){ + if (!p[-1] && ((p[1] >> (23-prefix_len)) == 1)) return p - 1; + else if (!p[ 1] && ((p[2] >> (23-prefix_len)) == 1)) return p; + } } } return end+2; @@ -347,7 +349,7 @@ static void preview_obmc(MpegEncContext *s){ s->block_index[i]+= 1; s->mb_x++; - assert(s->pict_type == AV_PICTURE_TYPE_P); + av_assert2(s->pict_type == AV_PICTURE_TYPE_P); do{ if (get_bits1(&s->gb)) { @@ -484,7 +486,7 @@ static int h263_decode_block(MpegEncContext * s, DCTELEM * block, level = get_bits(&s->gb, 8); if((level&0x7F) == 0){ av_log(s->avctx, AV_LOG_ERROR, "illegal dc %d at %d %d\n", level, s->mb_x, s->mb_y); - if(s->err_recognition & AV_EF_BITSTREAM) + if(s->err_recognition & (AV_EF_BITSTREAM|AV_EF_COMPLIANT)) return -1; } if (level == 255) @@ -606,7 +608,7 @@ int ff_h263_decode_mb(MpegEncContext *s, const int xy= s->mb_x + s->mb_y * s->mb_stride; int cbpb = 0, pb_mv_count = 0; - assert(!s->h263_pred); + av_assert2(!s->h263_pred); if (s->pict_type == AV_PICTURE_TYPE_P) { do{ @@ -746,7 +748,7 @@ int ff_h263_decode_mb(MpegEncContext *s, }else cbp=0; - assert(!s->mb_intra); + av_assert2(!s->mb_intra); if(IS_QUANT(mb_type)){ h263_decode_dquant(s); @@ -961,6 +963,8 @@ int ff_h263_decode_picture_header(MpegEncContext *s) s->h263_aic = get_bits1(&s->gb); /* Advanced Intra Coding (AIC) */ s->loop_filter= get_bits1(&s->gb); s->unrestricted_mv = s->umvplus || s->obmc || s->loop_filter; + if(s->avctx->lowres) + s->loop_filter = 0; s->h263_slice_structured= get_bits1(&s->gb); if (get_bits1(&s->gb) != 0) { @@ -1128,7 +1132,7 @@ int ff_h263_decode_picture_header(MpegEncContext *s) } ff_h263_show_pict_info(s); - if (s->pict_type == AV_PICTURE_TYPE_I && s->codec_tag == AV_RL32("ZYGO")){ + if (s->pict_type == AV_PICTURE_TYPE_I && s->codec_tag == AV_RL32("ZYGO") && get_bits_left(&s->gb) >= 85 + 13*3*16 + 50){ int i,j; for(i=0; i<85; i++) av_log(s->avctx, AV_LOG_DEBUG, "%d", get_bits1(&s->gb)); av_log(s->avctx, AV_LOG_DEBUG, "\n"); |