diff mbox series

[FFmpeg-devel,39/39] avcodec/mpeg12enc: Inline constants

Message ID DBAPR03MB66645F595CE544FC02751E298F409@DBAPR03MB6664.eurprd03.prod.outlook.com
State Accepted
Commit 8abc192236a5afe764e4fc76dcae9874fb3bedaa
Headers show
Series [FFmpeg-devel,01/14] avcodec/mjpegenc: Use custom close function directly | expand

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished
andriy/make_ppc success Make finished
andriy/make_fate_ppc fail Make fate failed

Commit Message

Andreas Rheinhardt Dec. 25, 2021, 6:06 a.m. UTC
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
For a long time, ff_mpeg1_init_uni_ac_vlc() has only been used
to create MPEG-1/2 tables and therefore some values (namely
the number of elements) have been inlined; yet nowadays this function
is also used for speedhq whose number of elements differs.
So it seems to me that one should uninline this value
in ff_mpeg1_init_uni_ac_vlc.

 libavcodec/mpeg12enc.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
diff mbox series

Patch

diff --git a/libavcodec/mpeg12enc.c b/libavcodec/mpeg12enc.c
index 97d497d619..e28aa809d2 100644
--- a/libavcodec/mpeg12enc.c
+++ b/libavcodec/mpeg12enc.c
@@ -621,10 +621,8 @@  static inline void put_mb_modes(MpegEncContext *s, int n, int bits,
 static void mpeg1_encode_motion(MpegEncContext *s, int val, int f_or_b_code)
 {
     if (val == 0) {
-        /* zero vector */
-        put_bits(&s->pb,
-                 ff_mpeg12_mbMotionVectorTable[0][1],
-                 ff_mpeg12_mbMotionVectorTable[0][0]);
+        /* zero vector, corresponds to ff_mpeg12_mbMotionVectorTable[0] */
+        put_bits(&s->pb, 1, 0x01);
     } else {
         int code, sign, bits;
         int bit_size = f_or_b_code - 1;
@@ -746,8 +744,10 @@  next_coef:
                 put_bits(&s->pb, table_vlc[code][1] + 1,
                          (table_vlc[code][0] << 1) + sign);
             } else {
-                /* escape seems to be pretty rare <5% so I do not optimize it */
-                put_bits(&s->pb, table_vlc[111][1], table_vlc[111][0]);
+                /* Escape seems to be pretty rare <5% so I do not optimize it;
+                 * the following value is the common escape value for both
+                 * possible tables (i.e. table_vlc[111]). */
+                put_bits(&s->pb, 6, 0x01);
                 /* escape: only clip in this case */
                 put_bits(&s->pb, 6, run);
                 if (s->codec_id == AV_CODEC_ID_MPEG1VIDEO) {
@@ -1097,7 +1097,7 @@  static av_cold void mpeg12_encode_init_static(void)
             int len;
 
             if (mv == 0) {
-                len = ff_mpeg12_mbMotionVectorTable[0][1];
+                len = 1; /* ff_mpeg12_mbMotionVectorTable[0][1] */
             } else {
                 int val, bit_size, code;
 
@@ -1112,7 +1112,7 @@  static av_cold void mpeg12_encode_init_static(void)
                     len = ff_mpeg12_mbMotionVectorTable[code][1] +
                           1 + bit_size;
                 else
-                    len = ff_mpeg12_mbMotionVectorTable[16][1] +
+                    len = 10 /* ff_mpeg12_mbMotionVectorTable[16][1] */ +
                           2 + bit_size;
             }