Both motion vector tables have the same number of elements, hence one can inline said number and remove the field containing the number of elements from the structure.
Unified · Split
| @@ -1771,13 +1771,11 @@ static const uint8_t table1_mvy[1099] = { · 1770 unmodified lines | ||
| 1771 | 1771 | }; |
| 1772 | 1772 | |
| 1773 | 1773 | MVTable ff_mv_tables[2] = { |
| 1774 | − { 1099, | |
| 1775 | − table0_mv_code, | |
| 1774 | + { table0_mv_code, | |
| 1776 | 1775 | table0_mv_bits, |
| 1777 | 1776 | table0_mvx, |
| 1778 | 1777 | table0_mvy, }, |
| 1779 | − { 1099, | |
| 1780 | − table1_mv_code, | |
| 1778 | + { table1_mv_code, | |
| 1781 | 1779 | table1_mv_bits, |
| 1782 | 1780 | table1_mvx, |
| 1783 | 1781 | table1_mvy, } |
| @@ -37,7 +37,6 @@ · 36 unmodified lines | ||
| 37 | 37 | |
| 38 | 38 | /* motion vector table */ |
| 39 | 39 | typedef struct MVTable { |
| 40 | − int n; | |
| 41 | 40 | const uint16_t *table_mv_code; |
| 42 | 41 | const uint8_t *table_mv_bits; |
| 43 | 42 | const uint8_t *table_mvx; |
| @@ -69,6 +68,7 @@ extern const uint8_t ff_wmv1_y_dc_scale_table[32]; · 25 unmodified lines | ||
| 69 | 68 | extern const uint8_t ff_wmv1_c_dc_scale_table[32]; |
| 70 | 69 | extern const uint8_t ff_old_ff_y_dc_scale_table[32]; |
| 71 | 70 | |
| 71 | +#define MSMPEG4_MV_TABLES_NB_ELEMS 1099 | |
| 72 | 72 | extern MVTable ff_mv_tables[2]; |
| 73 | 73 | |
| 74 | 74 | extern const uint8_t ff_v2_mb_type[8][2]; |
| @@ -321,11 +321,11 @@ av_cold int ff_msmpeg4_decode_init(AVCodecContext *avctx) · 320 unmodified lines | ||
| 321 | 321 | memcpy(ff_rl_table[5].rl_vlc, ff_h263_rl_inter.rl_vlc, sizeof(ff_rl_table[5].rl_vlc)); |
| 322 | 322 | |
| 323 | 323 | mv = &ff_mv_tables[0]; |
| 324 | − INIT_VLC_STATIC(&mv->vlc, MV_VLC_BITS, mv->n + 1, | |
| 324 | + INIT_VLC_STATIC(&mv->vlc, MV_VLC_BITS, MSMPEG4_MV_TABLES_NB_ELEMS + 1, | |
| 325 | 325 | mv->table_mv_bits, 1, 1, |
| 326 | 326 | mv->table_mv_code, 2, 2, 3714); |
| 327 | 327 | mv = &ff_mv_tables[1]; |
| 328 | − INIT_VLC_STATIC(&mv->vlc, MV_VLC_BITS, mv->n + 1, | |
| 328 | + INIT_VLC_STATIC(&mv->vlc, MV_VLC_BITS, MSMPEG4_MV_TABLES_NB_ELEMS + 1, | |
| 329 | 329 | mv->table_mv_bits, 1, 1, |
| 330 | 330 | mv->table_mv_code, 2, 2, 2694); |
| 331 | 331 | |
| @@ -836,7 +836,7 @@ void ff_msmpeg4_decode_motion(MpegEncContext *s, int *mx_ptr, int *my_ptr) · 504 unmodified lines | ||
| 836 | 836 | mv = &ff_mv_tables[s->mv_table_index]; |
| 837 | 837 | |
| 838 | 838 | code = get_vlc2(&s->gb, mv->vlc.table, MV_VLC_BITS, 2); |
| 839 | − if (code == mv->n) { | |
| 839 | + if (code == MSMPEG4_MV_TABLES_NB_ELEMS) { | |
| 840 | 840 | mx = get_bits(&s->gb, 6); |
| 841 | 841 | my = get_bits(&s->gb, 6); |
| 842 | 842 | } else { |
| @@ -56,9 +56,9 @@ static av_cold int init_mv_table(MVTable *tab) · 55 unmodified lines | ||
| 56 | 56 | |
| 57 | 57 | /* mark all entries as not used */ |
| 58 | 58 | for(i=0;i<4096;i++) |
| 59 | − tab->table_mv_index[i] = tab->n; | |
| 59 | + tab->table_mv_index[i] = MSMPEG4_MV_TABLES_NB_ELEMS; | |
| 60 | 60 | |
| 61 | − for(i=0;i<tab->n;i++) { | |
| 61 | + for (i = 0; i < MSMPEG4_MV_TABLES_NB_ELEMS; i++) { | |
| 62 | 62 | x = tab->table_mvx[i]; |
| 63 | 63 | y = tab->table_mvy[i]; |
| 64 | 64 | tab->table_mv_index[(x << 6) | y] = i; |
| @@ -320,7 +320,7 @@ void ff_msmpeg4_encode_motion(MpegEncContext * s, · 255 unmodified lines | ||
| 320 | 320 | put_bits(&s->pb, |
| 321 | 321 | mv->table_mv_bits[code], |
| 322 | 322 | mv->table_mv_code[code]); |
| 323 | − if (code == mv->n) { | |
| 323 | + if (code == MSMPEG4_MV_TABLES_NB_ELEMS) { | |
| 324 | 324 | /* escape : code literally */ |
| 325 | 325 | put_bits(&s->pb, 6, mx); |
| 326 | 326 | put_bits(&s->pb, 6, my); |