1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-11-21 10:55:51 +02:00

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.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
This commit is contained in:
Andreas Rheinhardt 2021-01-26 22:19:19 +01:00
parent fbb81ea2c6
commit d8b2fae3c7
4 changed files with 9 additions and 11 deletions

View File

@ -1771,13 +1771,11 @@ static const uint8_t table1_mvy[1099] = {
};
MVTable ff_mv_tables[2] = {
{ 1099,
table0_mv_code,
{ table0_mv_code,
table0_mv_bits,
table0_mvx,
table0_mvy, },
{ 1099,
table1_mv_code,
{ table1_mv_code,
table1_mv_bits,
table1_mvx,
table1_mvy, }

View File

@ -37,7 +37,6 @@
/* motion vector table */
typedef struct MVTable {
int n;
const uint16_t *table_mv_code;
const uint8_t *table_mv_bits;
const uint8_t *table_mvx;
@ -69,6 +68,7 @@ extern const uint8_t ff_wmv1_y_dc_scale_table[32];
extern const uint8_t ff_wmv1_c_dc_scale_table[32];
extern const uint8_t ff_old_ff_y_dc_scale_table[32];
#define MSMPEG4_MV_TABLES_NB_ELEMS 1099
extern MVTable ff_mv_tables[2];
extern const uint8_t ff_v2_mb_type[8][2];

View File

@ -321,11 +321,11 @@ av_cold int ff_msmpeg4_decode_init(AVCodecContext *avctx)
memcpy(ff_rl_table[5].rl_vlc, ff_h263_rl_inter.rl_vlc, sizeof(ff_rl_table[5].rl_vlc));
mv = &ff_mv_tables[0];
INIT_VLC_STATIC(&mv->vlc, MV_VLC_BITS, mv->n + 1,
INIT_VLC_STATIC(&mv->vlc, MV_VLC_BITS, MSMPEG4_MV_TABLES_NB_ELEMS + 1,
mv->table_mv_bits, 1, 1,
mv->table_mv_code, 2, 2, 3714);
mv = &ff_mv_tables[1];
INIT_VLC_STATIC(&mv->vlc, MV_VLC_BITS, mv->n + 1,
INIT_VLC_STATIC(&mv->vlc, MV_VLC_BITS, MSMPEG4_MV_TABLES_NB_ELEMS + 1,
mv->table_mv_bits, 1, 1,
mv->table_mv_code, 2, 2, 2694);
@ -836,7 +836,7 @@ void ff_msmpeg4_decode_motion(MpegEncContext *s, int *mx_ptr, int *my_ptr)
mv = &ff_mv_tables[s->mv_table_index];
code = get_vlc2(&s->gb, mv->vlc.table, MV_VLC_BITS, 2);
if (code == mv->n) {
if (code == MSMPEG4_MV_TABLES_NB_ELEMS) {
mx = get_bits(&s->gb, 6);
my = get_bits(&s->gb, 6);
} else {

View File

@ -56,9 +56,9 @@ static av_cold int init_mv_table(MVTable *tab)
/* mark all entries as not used */
for(i=0;i<4096;i++)
tab->table_mv_index[i] = tab->n;
tab->table_mv_index[i] = MSMPEG4_MV_TABLES_NB_ELEMS;
for(i=0;i<tab->n;i++) {
for (i = 0; i < MSMPEG4_MV_TABLES_NB_ELEMS; i++) {
x = tab->table_mvx[i];
y = tab->table_mvy[i];
tab->table_mv_index[(x << 6) | y] = i;
@ -320,7 +320,7 @@ void ff_msmpeg4_encode_motion(MpegEncContext * s,
put_bits(&s->pb,
mv->table_mv_bits[code],
mv->table_mv_code[code]);
if (code == mv->n) {
if (code == MSMPEG4_MV_TABLES_NB_ELEMS) {
/* escape : code literally */
put_bits(&s->pb, 6, mx);
put_bits(&s->pb, 6, my);