[FFmpeg-devel] [PATCH 1/2] avcodec/msmpeg4dec: Don't check for errors for complete VLCs
Andreas Rheinhardt
andreas.rheinhardt at gmail.com
Thu Jan 28 15:16:22 EET 2021
Andreas Rheinhardt:
> This also affected other users of VLCs from msmpeg4dec, namely vc1_block
> and wmv2dec.
>
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at gmail.com>
> ---
> libavcodec/msmpeg4.h | 2 +-
> libavcodec/msmpeg4dec.c | 20 ++------------------
> libavcodec/vc1_block.c | 12 ------------
> libavcodec/wmv2dec.c | 20 +++-----------------
> 4 files changed, 6 insertions(+), 48 deletions(-)
>
> diff --git a/libavcodec/msmpeg4.h b/libavcodec/msmpeg4.h
> index bcdb967401..f9c63b5022 100644
> --- a/libavcodec/msmpeg4.h
> +++ b/libavcodec/msmpeg4.h
> @@ -59,7 +59,7 @@ void ff_msmpeg4_encode_mb(MpegEncContext *s, int16_t block[6][64],
> int ff_msmpeg4_decode_init(AVCodecContext *avctx);
> int ff_msmpeg4_decode_picture_header(MpegEncContext *s);
> int ff_msmpeg4_decode_ext_header(MpegEncContext *s, int buf_size);
> -int ff_msmpeg4_decode_motion(MpegEncContext * s, int *mx_ptr, int *my_ptr);
> +void ff_msmpeg4_decode_motion(MpegEncContext * s, int *mx_ptr, int *my_ptr);
> int ff_msmpeg4_decode_block(MpegEncContext * s, int16_t * block,
> int n, int coded, const uint8_t *scan_table);
> int ff_msmpeg4_pred_dc(MpegEncContext *s, int n,
> diff --git a/libavcodec/msmpeg4dec.c b/libavcodec/msmpeg4dec.c
> index d059e8eecc..9501b101ca 100644
> --- a/libavcodec/msmpeg4dec.c
> +++ b/libavcodec/msmpeg4dec.c
> @@ -228,8 +228,6 @@ static int msmpeg4v34_decode_mb(MpegEncContext *s, int16_t block[6][64])
> }
>
> code = get_vlc2(&s->gb, ff_mb_non_intra_vlc[DEFAULT_INTER_INDEX].table, MB_NON_INTRA_VLC_BITS, 3);
> - if (code < 0)
> - return -1;
> //s->mb_intra = (code & 0x40) ? 0 : 1;
> s->mb_intra = (~code & 0x40) >> 6;
>
> @@ -237,8 +235,6 @@ static int msmpeg4v34_decode_mb(MpegEncContext *s, int16_t block[6][64])
> } else {
> s->mb_intra = 1;
> code = get_vlc2(&s->gb, ff_msmp4_mb_i_vlc.table, MB_INTRA_VLC_BITS, 2);
> - if (code < 0)
> - return -1;
> /* predict coded block pattern */
> cbp = 0;
> for(i=0;i<6;i++) {
> @@ -259,8 +255,7 @@ static int msmpeg4v34_decode_mb(MpegEncContext *s, int16_t block[6][64])
> s->rl_chroma_table_index = s->rl_table_index;
> }
> ff_h263_pred_motion(s, 0, 0, &mx, &my);
> - if (ff_msmpeg4_decode_motion(s, &mx, &my) < 0)
> - return -1;
> + ff_msmpeg4_decode_motion(s, &mx, &my);
> s->mv_dir = MV_DIR_FORWARD;
> s->mv_type = MV_TYPE_16X16;
> s->mv[0][0][0] = mx;
> @@ -612,11 +607,6 @@ static int msmpeg4_decode_dc(MpegEncContext * s, int n, int *dir_ptr)
> } else {
> level = get_vlc2(&s->gb, ff_msmp4_dc_chroma_vlc[s->dc_table_index].table, DC_VLC_BITS, 3);
> }
> - if (level < 0){
> - av_log(s->avctx, AV_LOG_ERROR, "illegal dc vlc\n");
> - *dir_ptr = 0;
> - return -1;
> - }
>
> if (level == DC_MAX) {
> level = get_bits(&s->gb, 8);
> @@ -838,8 +828,7 @@ int ff_msmpeg4_decode_block(MpegEncContext * s, int16_t * block,
> return 0;
> }
>
> -int ff_msmpeg4_decode_motion(MpegEncContext * s,
> - int *mx_ptr, int *my_ptr)
> +void ff_msmpeg4_decode_motion(MpegEncContext *s, int *mx_ptr, int *my_ptr)
> {
> MVTable *mv;
> int code, mx, my;
> @@ -847,10 +836,6 @@ int ff_msmpeg4_decode_motion(MpegEncContext * s,
> mv = &ff_mv_tables[s->mv_table_index];
>
> code = get_vlc2(&s->gb, mv->vlc.table, MV_VLC_BITS, 2);
> - if (code < 0){
> - av_log(s->avctx, AV_LOG_ERROR, "illegal MV code at %d %d\n", s->mb_x, s->mb_y);
> - return -1;
> - }
> if (code == mv->n) {
> mx = get_bits(&s->gb, 6);
> my = get_bits(&s->gb, 6);
> @@ -873,7 +858,6 @@ int ff_msmpeg4_decode_motion(MpegEncContext * s,
> my -= 64;
> *mx_ptr = mx;
> *my_ptr = my;
> - return 0;
> }
>
> AVCodec ff_msmpeg4v1_decoder = {
> diff --git a/libavcodec/vc1_block.c b/libavcodec/vc1_block.c
> index 5c33170933..b6ace37658 100644
> --- a/libavcodec/vc1_block.c
> +++ b/libavcodec/vc1_block.c
> @@ -592,10 +592,6 @@ static int vc1_decode_i_block(VC1Context *v, int16_t block[64], int n,
> } else {
> dcdiff = get_vlc2(&s->gb, ff_msmp4_dc_chroma_vlc[s->dc_table_index].table, DC_VLC_BITS, 3);
> }
> - if (dcdiff < 0) {
> - av_log(s->avctx, AV_LOG_ERROR, "Illegal DC VLC\n");
> - return -1;
> - }
> if (dcdiff) {
> const int m = (v->pq == 1 || v->pq == 2) ? 3 - v->pq : 0;
> if (dcdiff == 119 /* ESC index value */) {
> @@ -740,10 +736,6 @@ static int vc1_decode_i_block_adv(VC1Context *v, int16_t block[64], int n,
> } else {
> dcdiff = get_vlc2(&s->gb, ff_msmp4_dc_chroma_vlc[s->dc_table_index].table, DC_VLC_BITS, 3);
> }
> - if (dcdiff < 0) {
> - av_log(s->avctx, AV_LOG_ERROR, "Illegal DC VLC\n");
> - return -1;
> - }
> if (dcdiff) {
> const int m = (quant == 1 || quant == 2) ? 3 - quant : 0;
> if (dcdiff == 119 /* ESC index value */) {
> @@ -944,10 +936,6 @@ static int vc1_decode_intra_block(VC1Context *v, int16_t block[64], int n,
> } else {
> dcdiff = get_vlc2(&s->gb, ff_msmp4_dc_chroma_vlc[s->dc_table_index].table, DC_VLC_BITS, 3);
> }
> - if (dcdiff < 0) {
> - av_log(s->avctx, AV_LOG_ERROR, "Illegal DC VLC\n");
> - return -1;
> - }
> if (dcdiff) {
> const int m = (quant == 1 || quant == 2) ? 3 - quant : 0;
> if (dcdiff == 119 /* ESC index value */) {
> diff --git a/libavcodec/wmv2dec.c b/libavcodec/wmv2dec.c
> index a16c4465f0..7aae11568c 100644
> --- a/libavcodec/wmv2dec.c
> +++ b/libavcodec/wmv2dec.c
> @@ -278,22 +278,16 @@ int ff_wmv2_decode_secondary_picture_header(MpegEncContext *s)
> return 0;
> }
>
> -static inline int wmv2_decode_motion(Wmv2Context *w, int *mx_ptr, int *my_ptr)
> +static inline void wmv2_decode_motion(Wmv2Context *w, int *mx_ptr, int *my_ptr)
> {
> MpegEncContext *const s = &w->s;
> - int ret;
> -
> - ret = ff_msmpeg4_decode_motion(s, mx_ptr, my_ptr);
>
> - if (ret < 0)
> - return ret;
> + ff_msmpeg4_decode_motion(s, mx_ptr, my_ptr);
>
> if ((((*mx_ptr) | (*my_ptr)) & 1) && s->mspel)
> w->hshift = get_bits1(&s->gb);
> else
> w->hshift = 0;
> -
> - return 0;
> }
>
> static int16_t *wmv2_pred_motion(Wmv2Context *w, int *px, int *py)
> @@ -409,8 +403,6 @@ int ff_wmv2_decode_mb(MpegEncContext *s, int16_t block[6][64])
>
> code = get_vlc2(&s->gb, ff_mb_non_intra_vlc[w->cbp_table_index].table,
> MB_NON_INTRA_VLC_BITS, 3);
> - if (code < 0)
> - return AVERROR_INVALIDDATA;
> s->mb_intra = (~code & 0x40) >> 6;
>
> cbp = code & 0x3f;
> @@ -419,11 +411,6 @@ int ff_wmv2_decode_mb(MpegEncContext *s, int16_t block[6][64])
> if (get_bits_left(&s->gb) <= 0)
> return AVERROR_INVALIDDATA;
> code = get_vlc2(&s->gb, ff_msmp4_mb_i_vlc.table, MB_INTRA_VLC_BITS, 2);
> - if (code < 0) {
> - av_log(s->avctx, AV_LOG_ERROR,
> - "II-cbp illegal at %d %d\n", s->mb_x, s->mb_y);
> - return AVERROR_INVALIDDATA;
> - }
> /* predict coded block pattern */
> cbp = 0;
> for (i = 0; i < 6; i++) {
> @@ -456,8 +443,7 @@ int ff_wmv2_decode_mb(MpegEncContext *s, int16_t block[6][64])
> w->per_block_abt = 0;
> }
>
> - if ((ret = wmv2_decode_motion(w, &mx, &my)) < 0)
> - return ret;
> + wmv2_decode_motion(w, &mx, &my);
>
> s->mv_dir = MV_DIR_FORWARD;
> s->mv_type = MV_TYPE_16X16;
>
Will apply this patchset tomorrow unless there are objections.
- Andreas
More information about the ffmpeg-devel
mailing list