[FFmpeg-devel] [PATCH 43/57] avcodec/mpeg4videoenc: Avoid branch for writing stuffing

Andreas Rheinhardt andreas.rheinhardt at outlook.com
Tue Apr 30 00:14:24 EEST 2024


Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>
---
 libavcodec/mpeg4videoenc.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/libavcodec/mpeg4videoenc.c b/libavcodec/mpeg4videoenc.c
index e853282b4b..31307cc8dd 100644
--- a/libavcodec/mpeg4videoenc.c
+++ b/libavcodec/mpeg4videoenc.c
@@ -865,11 +865,9 @@ void ff_mpeg4_encode_mb(MpegEncContext *s, int16_t block[6][64],
  */
 void ff_mpeg4_stuffing(PutBitContext *pbc)
 {
-    int length;
-    put_bits(pbc, 1, 0);
-    length = (-put_bits_count(pbc)) & 7;
-    if (length)
-        put_bits(pbc, length, (1 << length) - 1);
+    int length = 8 - (put_bits_count(pbc) & 7);
+
+    put_bits(pbc, length, (1 << (length - 1)) - 1);
 }
 
 /* must be called before writing the header */
-- 
2.40.1



More information about the ffmpeg-devel mailing list