History

avcodec/msmpeg4dec: Don't check for errors for complete VLCs

This also affected other users of VLCs from msmpeg4dec, namely vc1_block and wmv2dec.

Andreas Rheinhardt committed 5 years ago

Commit fbb81ea1 parent a899d6c4 files · +6 −48Browse files

Unified · Split

4 files
  1. libavcodec/msmpeg4.h +1 −1
  2. libavcodec/msmpeg4dec.c +2 −18
  3. libavcodec/vc1_block.c +0 −12
  4. libavcodec/wmv2dec.c +3 −17
libavcodec/msmpeg4.h+1−1
@@ -59,7 +59,7 @@ void ff_msmpeg4_encode_mb(MpegEncContext *s, int16_t block[6][64], · 58 unmodified lines
5959 int ff_msmpeg4_decode_init(AVCodecContext *avctx);
6060 int ff_msmpeg4_decode_picture_header(MpegEncContext *s);
6161 int ff_msmpeg4_decode_ext_header(MpegEncContext *s, int buf_size);
62−int ff_msmpeg4_decode_motion(MpegEncContext * s, int *mx_ptr, int *my_ptr);
62+void ff_msmpeg4_decode_motion(MpegEncContext * s, int *mx_ptr, int *my_ptr);
6363 int ff_msmpeg4_decode_block(MpegEncContext * s, int16_t * block,
6464 int n, int coded, const uint8_t *scan_table);
6565 int ff_msmpeg4_pred_dc(MpegEncContext *s, int n,
libavcodec/msmpeg4dec.c+2−18
@@ -228,8 +228,6 @@ static int msmpeg4v34_decode_mb(MpegEncContext *s, int16_t block[6][64]) · 227 unmodified lines
228228 }
229229
230230 code = get_vlc2(&s->gb, ff_mb_non_intra_vlc[DEFAULT_INTER_INDEX].table, MB_NON_INTRA_VLC_BITS, 3);
231− if (code < 0)
232− return -1;
233231 //s->mb_intra = (code & 0x40) ? 0 : 1;
234232 s->mb_intra = (~code & 0x40) >> 6;
235233
@@ -237,8 +235,6 @@ static int msmpeg4v34_decode_mb(MpegEncContext *s, int16_t block[6][64]) · 1 unmodified line
237235 } else {
238236 s->mb_intra = 1;
239237 code = get_vlc2(&s->gb, ff_msmp4_mb_i_vlc.table, MB_INTRA_VLC_BITS, 2);
240− if (code < 0)
241− return -1;
242238 /* predict coded block pattern */
243239 cbp = 0;
244240 for(i=0;i<6;i++) {
@@ -259,8 +255,7 @@ static int msmpeg4v34_decode_mb(MpegEncContext *s, int16_t block[6][64]) · 14 unmodified lines
259255 s->rl_chroma_table_index = s->rl_table_index;
260256 }
261257 ff_h263_pred_motion(s, 0, 0, &mx, &my);
262− if (ff_msmpeg4_decode_motion(s, &mx, &my) < 0)
263− return -1;
258+ ff_msmpeg4_decode_motion(s, &mx, &my);
264259 s->mv_dir = MV_DIR_FORWARD;
265260 s->mv_type = MV_TYPE_16X16;
266261 s->mv[0][0][0] = mx;
@@ -612,11 +607,6 @@ static int msmpeg4_decode_dc(MpegEncContext * s, int n, int *dir_ptr) · 345 unmodified lines
612607 } else {
613608 level = get_vlc2(&s->gb, ff_msmp4_dc_chroma_vlc[s->dc_table_index].table, DC_VLC_BITS, 3);
614609 }
615− if (level < 0){
616− av_log(s->avctx, AV_LOG_ERROR, "illegal dc vlc\n");
617− *dir_ptr = 0;
618− return -1;
619− }
620610
621611 if (level == DC_MAX) {
622612 level = get_bits(&s->gb, 8);
@@ -838,8 +828,7 @@ int ff_msmpeg4_decode_block(MpegEncContext * s, int16_t * block, · 215 unmodified lines
838828 return 0;
839829 }
840830
841−int ff_msmpeg4_decode_motion(MpegEncContext * s,
842− int *mx_ptr, int *my_ptr)
831+void ff_msmpeg4_decode_motion(MpegEncContext *s, int *mx_ptr, int *my_ptr)
843832 {
844833 MVTable *mv;
845834 int code, mx, my;
@@ -847,10 +836,6 @@ int ff_msmpeg4_decode_motion(MpegEncContext * s, · 1 unmodified line
847836 mv = &ff_mv_tables[s->mv_table_index];
848837
849838 code = get_vlc2(&s->gb, mv->vlc.table, MV_VLC_BITS, 2);
850− if (code < 0){
851− av_log(s->avctx, AV_LOG_ERROR, "illegal MV code at %d %d\n", s->mb_x, s->mb_y);
852− return -1;
853− }
854839 if (code == mv->n) {
855840 mx = get_bits(&s->gb, 6);
856841 my = get_bits(&s->gb, 6);
@@ -873,7 +858,6 @@ int ff_msmpeg4_decode_motion(MpegEncContext * s, · 16 unmodified lines
873858 my -= 64;
874859 *mx_ptr = mx;
875860 *my_ptr = my;
876− return 0;
877861 }
878862
879863 AVCodec ff_msmpeg4v1_decoder = {
libavcodec/vc1_block.c+0−12
@@ -592,10 +592,6 @@ static int vc1_decode_i_block(VC1Context *v, int16_t block[64], int n, · 591 unmodified lines
592592 } else {
593593 dcdiff = get_vlc2(&s->gb, ff_msmp4_dc_chroma_vlc[s->dc_table_index].table, DC_VLC_BITS, 3);
594594 }
595− if (dcdiff < 0) {
596− av_log(s->avctx, AV_LOG_ERROR, "Illegal DC VLC\n");
597− return -1;
598− }
599595 if (dcdiff) {
600596 const int m = (v->pq == 1 || v->pq == 2) ? 3 - v->pq : 0;
601597 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, · 138 unmodified lines
740736 } else {
741737 dcdiff = get_vlc2(&s->gb, ff_msmp4_dc_chroma_vlc[s->dc_table_index].table, DC_VLC_BITS, 3);
742738 }
743− if (dcdiff < 0) {
744− av_log(s->avctx, AV_LOG_ERROR, "Illegal DC VLC\n");
745− return -1;
746− }
747739 if (dcdiff) {
748740 const int m = (quant == 1 || quant == 2) ? 3 - quant : 0;
749741 if (dcdiff == 119 /* ESC index value */) {
@@ -944,10 +936,6 @@ static int vc1_decode_intra_block(VC1Context *v, int16_t block[64], int n, · 194 unmodified lines
944936 } else {
945937 dcdiff = get_vlc2(&s->gb, ff_msmp4_dc_chroma_vlc[s->dc_table_index].table, DC_VLC_BITS, 3);
946938 }
947− if (dcdiff < 0) {
948− av_log(s->avctx, AV_LOG_ERROR, "Illegal DC VLC\n");
949− return -1;
950− }
951939 if (dcdiff) {
952940 const int m = (quant == 1 || quant == 2) ? 3 - quant : 0;
953941 if (dcdiff == 119 /* ESC index value */) {
libavcodec/wmv2dec.c+3−17
@@ -278,22 +278,16 @@ int ff_wmv2_decode_secondary_picture_header(MpegEncContext *s) · 277 unmodified lines
278278 return 0;
279279 }
280280
281−static inline int wmv2_decode_motion(Wmv2Context *w, int *mx_ptr, int *my_ptr)
281+static inline void wmv2_decode_motion(Wmv2Context *w, int *mx_ptr, int *my_ptr)
282282 {
283283 MpegEncContext *const s = &w->s;
284− int ret;
285−
286− ret = ff_msmpeg4_decode_motion(s, mx_ptr, my_ptr);
287284
288− if (ret < 0)
289− return ret;
285+ ff_msmpeg4_decode_motion(s, mx_ptr, my_ptr);
290286
291287 if ((((*mx_ptr) | (*my_ptr)) & 1) && s->mspel)
292288 w->hshift = get_bits1(&s->gb);
293289 else
294290 w->hshift = 0;
295−
296− return 0;
297291 }
298292
299293 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]) · 109 unmodified lines
409403
410404 code = get_vlc2(&s->gb, ff_mb_non_intra_vlc[w->cbp_table_index].table,
411405 MB_NON_INTRA_VLC_BITS, 3);
412− if (code < 0)
413− return AVERROR_INVALIDDATA;
414406 s->mb_intra = (~code & 0x40) >> 6;
415407
416408 cbp = code & 0x3f;
@@ -419,11 +411,6 @@ int ff_wmv2_decode_mb(MpegEncContext *s, int16_t block[6][64]) · 2 unmodified lines
419411 if (get_bits_left(&s->gb) <= 0)
420412 return AVERROR_INVALIDDATA;
421413 code = get_vlc2(&s->gb, ff_msmp4_mb_i_vlc.table, MB_INTRA_VLC_BITS, 2);
422− if (code < 0) {
423− av_log(s->avctx, AV_LOG_ERROR,
424− "II-cbp illegal at %d %d\n", s->mb_x, s->mb_y);
425− return AVERROR_INVALIDDATA;
426− }
427414 /* predict coded block pattern */
428415 cbp = 0;
429416 for (i = 0; i < 6; i++) {
@@ -456,8 +443,7 @@ int ff_wmv2_decode_mb(MpegEncContext *s, int16_t block[6][64]) · 26 unmodified lines
456443 w->per_block_abt = 0;
457444 }
458445
459− if ((ret = wmv2_decode_motion(w, &mx, &my)) < 0)
460− return ret;
446+ wmv2_decode_motion(w, &mx, &my);
461447
462448 s->mv_dir = MV_DIR_FORWARD;
463449 s->mv_type = MV_TYPE_16X16;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t