History

avcodec/msmpeg4: Inline number of motion vectors

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.

Andreas Rheinhardt committed 5 years ago

Commit d8b2fae1 parent fbb81ea4 files · +9 −11Browse files

Unified · Split

4 files
  1. libavcodec/msmpeg4data.c +2 −4
  2. libavcodec/msmpeg4data.h +1 −1
  3. libavcodec/msmpeg4dec.c +3 −3
  4. libavcodec/msmpeg4enc.c +3 −3
libavcodec/msmpeg4data.c+2−4
@@ -1771,13 +1771,11 @@ static const uint8_t table1_mvy[1099] = { · 1770 unmodified lines
17711771 };
17721772
17731773 MVTable ff_mv_tables[2] = {
1774− { 1099,
1775− table0_mv_code,
1774+ { table0_mv_code,
17761775 table0_mv_bits,
17771776 table0_mvx,
17781777 table0_mvy, },
1779− { 1099,
1780− table1_mv_code,
1778+ { table1_mv_code,
17811779 table1_mv_bits,
17821780 table1_mvx,
17831781 table1_mvy, }
libavcodec/msmpeg4data.h+1−1
@@ -37,7 +37,6 @@ · 36 unmodified lines
3737
3838 /* motion vector table */
3939 typedef struct MVTable {
40− int n;
4140 const uint16_t *table_mv_code;
4241 const uint8_t *table_mv_bits;
4342 const uint8_t *table_mvx;
@@ -69,6 +68,7 @@ extern const uint8_t ff_wmv1_y_dc_scale_table[32]; · 25 unmodified lines
6968 extern const uint8_t ff_wmv1_c_dc_scale_table[32];
7069 extern const uint8_t ff_old_ff_y_dc_scale_table[32];
7170
71+#define MSMPEG4_MV_TABLES_NB_ELEMS 1099
7272 extern MVTable ff_mv_tables[2];
7373
7474 extern const uint8_t ff_v2_mb_type[8][2];
libavcodec/msmpeg4dec.c+3−3
@@ -321,11 +321,11 @@ av_cold int ff_msmpeg4_decode_init(AVCodecContext *avctx) · 320 unmodified lines
321321 memcpy(ff_rl_table[5].rl_vlc, ff_h263_rl_inter.rl_vlc, sizeof(ff_rl_table[5].rl_vlc));
322322
323323 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,
325325 mv->table_mv_bits, 1, 1,
326326 mv->table_mv_code, 2, 2, 3714);
327327 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,
329329 mv->table_mv_bits, 1, 1,
330330 mv->table_mv_code, 2, 2, 2694);
331331
@@ -836,7 +836,7 @@ void ff_msmpeg4_decode_motion(MpegEncContext *s, int *mx_ptr, int *my_ptr) · 504 unmodified lines
836836 mv = &ff_mv_tables[s->mv_table_index];
837837
838838 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) {
840840 mx = get_bits(&s->gb, 6);
841841 my = get_bits(&s->gb, 6);
842842 } else {
libavcodec/msmpeg4enc.c+3−3
@@ -56,9 +56,9 @@ static av_cold int init_mv_table(MVTable *tab) · 55 unmodified lines
5656
5757 /* mark all entries as not used */
5858 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;
6060
61− for(i=0;i<tab->n;i++) {
61+ for (i = 0; i < MSMPEG4_MV_TABLES_NB_ELEMS; i++) {
6262 x = tab->table_mvx[i];
6363 y = tab->table_mvy[i];
6464 tab->table_mv_index[(x << 6) | y] = i;
@@ -320,7 +320,7 @@ void ff_msmpeg4_encode_motion(MpegEncContext * s, · 255 unmodified lines
320320 put_bits(&s->pb,
321321 mv->table_mv_bits[code],
322322 mv->table_mv_code[code]);
323− if (code == mv->n) {
323+ if (code == MSMPEG4_MV_TABLES_NB_ELEMS) {
324324 /* escape : code literally */
325325 put_bits(&s->pb, 6, mx);
326326 put_bits(&s->pb, 6, my);

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