提交 d8b2fae3 编写于 作者: A Andreas Rheinhardt

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: NAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
上级 fbb81ea2
...@@ -1771,13 +1771,11 @@ static const uint8_t table1_mvy[1099] = { ...@@ -1771,13 +1771,11 @@ static const uint8_t table1_mvy[1099] = {
}; };
MVTable ff_mv_tables[2] = { MVTable ff_mv_tables[2] = {
{ 1099, { table0_mv_code,
table0_mv_code,
table0_mv_bits, table0_mv_bits,
table0_mvx, table0_mvx,
table0_mvy, }, table0_mvy, },
{ 1099, { table1_mv_code,
table1_mv_code,
table1_mv_bits, table1_mv_bits,
table1_mvx, table1_mvx,
table1_mvy, } table1_mvy, }
......
...@@ -37,7 +37,6 @@ ...@@ -37,7 +37,6 @@
/* motion vector table */ /* motion vector table */
typedef struct MVTable { typedef struct MVTable {
int n;
const uint16_t *table_mv_code; const uint16_t *table_mv_code;
const uint8_t *table_mv_bits; const uint8_t *table_mv_bits;
const uint8_t *table_mvx; const uint8_t *table_mvx;
...@@ -69,6 +68,7 @@ extern const uint8_t ff_wmv1_y_dc_scale_table[32]; ...@@ -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_wmv1_c_dc_scale_table[32];
extern const uint8_t ff_old_ff_y_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 MVTable ff_mv_tables[2];
extern const uint8_t ff_v2_mb_type[8][2]; extern const uint8_t ff_v2_mb_type[8][2];
......
...@@ -321,11 +321,11 @@ av_cold int ff_msmpeg4_decode_init(AVCodecContext *avctx) ...@@ -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)); 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]; 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_bits, 1, 1,
mv->table_mv_code, 2, 2, 3714); mv->table_mv_code, 2, 2, 3714);
mv = &ff_mv_tables[1]; 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_bits, 1, 1,
mv->table_mv_code, 2, 2, 2694); mv->table_mv_code, 2, 2, 2694);
...@@ -836,7 +836,7 @@ void ff_msmpeg4_decode_motion(MpegEncContext *s, int *mx_ptr, int *my_ptr) ...@@ -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]; mv = &ff_mv_tables[s->mv_table_index];
code = get_vlc2(&s->gb, mv->vlc.table, MV_VLC_BITS, 2); 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); mx = get_bits(&s->gb, 6);
my = get_bits(&s->gb, 6); my = get_bits(&s->gb, 6);
} else { } else {
......
...@@ -56,9 +56,9 @@ static av_cold int init_mv_table(MVTable *tab) ...@@ -56,9 +56,9 @@ static av_cold int init_mv_table(MVTable *tab)
/* mark all entries as not used */ /* mark all entries as not used */
for(i=0;i<4096;i++) 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]; x = tab->table_mvx[i];
y = tab->table_mvy[i]; y = tab->table_mvy[i];
tab->table_mv_index[(x << 6) | y] = i; tab->table_mv_index[(x << 6) | y] = i;
...@@ -320,7 +320,7 @@ void ff_msmpeg4_encode_motion(MpegEncContext * s, ...@@ -320,7 +320,7 @@ void ff_msmpeg4_encode_motion(MpegEncContext * s,
put_bits(&s->pb, put_bits(&s->pb,
mv->table_mv_bits[code], mv->table_mv_bits[code],
mv->table_mv_code[code]); mv->table_mv_code[code]);
if (code == mv->n) { if (code == MSMPEG4_MV_TABLES_NB_ELEMS) {
/* escape : code literally */ /* escape : code literally */
put_bits(&s->pb, 6, mx); put_bits(&s->pb, 6, mx);
put_bits(&s->pb, 6, my); put_bits(&s->pb, 6, my);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册