[FFmpeg-cvslog] avcodec/msmpeg4: Inline number of motion vectors
Andreas Rheinhardt
git at videolan.org
Fri Jan 29 07:45:08 EET 2021
ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt at gmail.com> | Tue Jan 26 22:19:19 2021 +0100| [d8b2fae3c73d92608abeaa04402fd05266e29bb2] | committer: 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: Andreas Rheinhardt <andreas.rheinhardt at gmail.com>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=d8b2fae3c73d92608abeaa04402fd05266e29bb2
---
libavcodec/msmpeg4data.c | 6 ++----
libavcodec/msmpeg4data.h | 2 +-
libavcodec/msmpeg4dec.c | 6 +++---
libavcodec/msmpeg4enc.c | 6 +++---
4 files changed, 9 insertions(+), 11 deletions(-)
diff --git a/libavcodec/msmpeg4data.c b/libavcodec/msmpeg4data.c
index b9c1d8ec0b..fb0c6185bf 100644
--- a/libavcodec/msmpeg4data.c
+++ b/libavcodec/msmpeg4data.c
@@ -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, }
diff --git a/libavcodec/msmpeg4data.h b/libavcodec/msmpeg4data.h
index 02199d0123..68a1d14f55 100644
--- a/libavcodec/msmpeg4data.h
+++ b/libavcodec/msmpeg4data.h
@@ -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];
diff --git a/libavcodec/msmpeg4dec.c b/libavcodec/msmpeg4dec.c
index 9501b101ca..405fda4b83 100644
--- a/libavcodec/msmpeg4dec.c
+++ b/libavcodec/msmpeg4dec.c
@@ -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 {
diff --git a/libavcodec/msmpeg4enc.c b/libavcodec/msmpeg4enc.c
index 2c61735d9d..5f809c2aeb 100644
--- a/libavcodec/msmpeg4enc.c
+++ b/libavcodec/msmpeg4enc.c
@@ -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);
More information about the ffmpeg-cvslog
mailing list