diff mbox series

[FFmpeg-devel,37/39] avcodec/mpeg12enc: Also inline chroma subsampling

Message ID DBAPR03MB6664F7A11213ED7416E1E6298F409@DBAPR03MB6664.eurprd03.prod.outlook.com
State Accepted
Commit d91b5020ec4b9b8d356e0dd7b1bee2438c948b0e
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
ff_mpeg1_encode_mb() contains two inlined calls to
mpeg1_encode_mb_internal(); these calls are supposed
to inline the properties depending upon the color space
used. Yet inlining vertical chroma subsampling (which
allows to remove complete branches and blocks depending
upon them) has been forgotten.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
Looking at this code makes me wonder whether inlining was ever
worth it here.

 libavcodec/mpeg12enc.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)
diff mbox series

Patch

diff --git a/libavcodec/mpeg12enc.c b/libavcodec/mpeg12enc.c
index 3692494713..1437ac421c 100644
--- a/libavcodec/mpeg12enc.c
+++ b/libavcodec/mpeg12enc.c
@@ -773,7 +773,8 @@  next_coef:
 static av_always_inline void mpeg1_encode_mb_internal(MpegEncContext *s,
                                                       int16_t block[8][64],
                                                       int motion_x, int motion_y,
-                                                      int mb_block_count)
+                                                      int mb_block_count,
+                                                      int chroma_y_shift)
 {
     int i, cbp;
     const int mb_x     = s->mb_x;
@@ -918,7 +919,7 @@  static av_always_inline void mpeg1_encode_mb_internal(MpegEncContext *s,
                 s->mv_bits += get_bits_diff(s);
             }
             if (cbp) {
-                if (s->chroma_y_shift) {
+                if (chroma_y_shift) {
                     put_bits(&s->pb,
                              ff_mpeg12_mbPatTable[cbp][1],
                              ff_mpeg12_mbPatTable[cbp][0]);
@@ -1025,7 +1026,7 @@  static av_always_inline void mpeg1_encode_mb_internal(MpegEncContext *s,
             }
             s->mv_bits += get_bits_diff(s);
             if (cbp) {
-                if (s->chroma_y_shift) {
+                if (chroma_y_shift) {
                     put_bits(&s->pb,
                              ff_mpeg12_mbPatTable[cbp][1],
                              ff_mpeg12_mbPatTable[cbp][0]);
@@ -1052,9 +1053,9 @@  void ff_mpeg1_encode_mb(MpegEncContext *s, int16_t block[8][64],
                         int motion_x, int motion_y)
 {
     if (s->chroma_format == CHROMA_420)
-        mpeg1_encode_mb_internal(s, block, motion_x, motion_y, 6);
+        mpeg1_encode_mb_internal(s, block, motion_x, motion_y, 6, 1);
     else
-        mpeg1_encode_mb_internal(s, block, motion_x, motion_y, 8);
+        mpeg1_encode_mb_internal(s, block, motion_x, motion_y, 8, 0);
 }
 
 static av_cold void mpeg12_encode_init_static(void)