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
1771};1771};
1772 1772
1773MVTable ff_mv_tables[2] = {1773MVTable ff_mv_tables[2] = {
1774 { 1099,1774 { table0_mv_code,
1775 table0_mv_code,
1776 table0_mv_bits,1775 table0_mv_bits,
1777 table0_mvx,1776 table0_mvx,
1778 table0_mvy, },1777 table0_mvy, },
1779 { 1099,1778 { table1_mv_code,
1780 table1_mv_code,
1781 table1_mv_bits,1779 table1_mv_bits,
1782 table1_mvx,1780 table1_mvx,
1783 table1_mvy, }1781 table1_mvy, }
libavcodec/msmpeg4data.h+1−1
@@ -37,7 +37,6 @@ · 36 unmodified lines
37 37
38/* motion vector table */38/* motion vector table */
39typedef struct MVTable {39typedef struct MVTable {
40 int n;
41 const uint16_t *table_mv_code;40 const uint16_t *table_mv_code;
42 const uint8_t *table_mv_bits;41 const uint8_t *table_mv_bits;
43 const uint8_t *table_mvx;42 const uint8_t *table_mvx;
@@ -69,6 +68,7 @@ extern const uint8_t ff_wmv1_y_dc_scale_table[32]; · 25 unmodified lines
69extern const uint8_t ff_wmv1_c_dc_scale_table[32];68extern const uint8_t ff_wmv1_c_dc_scale_table[32];
70extern const uint8_t ff_old_ff_y_dc_scale_table[32];69extern const uint8_t ff_old_ff_y_dc_scale_table[32];
71 70
71#define MSMPEG4_MV_TABLES_NB_ELEMS 1099
72extern MVTable ff_mv_tables[2];72extern MVTable ff_mv_tables[2];
73 73
74extern const uint8_t ff_v2_mb_type[8][2];74extern 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
321 memcpy(ff_rl_table[5].rl_vlc, ff_h263_rl_inter.rl_vlc, sizeof(ff_rl_table[5].rl_vlc));321 memcpy(ff_rl_table[5].rl_vlc, ff_h263_rl_inter.rl_vlc, sizeof(ff_rl_table[5].rl_vlc));
322 322
323 mv = &ff_mv_tables[0];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 mv->table_mv_bits, 1, 1,325 mv->table_mv_bits, 1, 1,
326 mv->table_mv_code, 2, 2, 3714);326 mv->table_mv_code, 2, 2, 3714);
327 mv = &ff_mv_tables[1];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 mv->table_mv_bits, 1, 1,329 mv->table_mv_bits, 1, 1,
330 mv->table_mv_code, 2, 2, 2694);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 mv = &ff_mv_tables[s->mv_table_index];836 mv = &ff_mv_tables[s->mv_table_index];
837 837
838 code = get_vlc2(&s->gb, mv->vlc.table, MV_VLC_BITS, 2);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 mx = get_bits(&s->gb, 6);840 mx = get_bits(&s->gb, 6);
841 my = get_bits(&s->gb, 6);841 my = get_bits(&s->gb, 6);
842 } else {842 } else {
libavcodec/msmpeg4enc.c+3−3
@@ -56,9 +56,9 @@ static av_cold int init_mv_table(MVTable *tab) · 55 unmodified lines
56 56
57 /* mark all entries as not used */57 /* mark all entries as not used */
58 for(i=0;i<4096;i++)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 x = tab->table_mvx[i];62 x = tab->table_mvx[i];
63 y = tab->table_mvy[i];63 y = tab->table_mvy[i];
64 tab->table_mv_index[(x << 6) | y] = i;64 tab->table_mv_index[(x << 6) | y] = i;
@@ -320,7 +320,7 @@ void ff_msmpeg4_encode_motion(MpegEncContext * s, · 255 unmodified lines
320 put_bits(&s->pb,320 put_bits(&s->pb,
321 mv->table_mv_bits[code],321 mv->table_mv_bits[code],
322 mv->table_mv_code[code]);322 mv->table_mv_code[code]);
323 if (code == mv->n) {323 if (code == MSMPEG4_MV_TABLES_NB_ELEMS) {
324 /* escape : code literally */324 /* escape : code literally */
325 put_bits(&s->pb, 6, mx);325 put_bits(&s->pb, 6, mx);
326 put_bits(&s->pb, 6, my);326 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