[FFmpeg-devel] [PATCH 40/57] avcodec/h263enc: Remove no-output code

Andreas Rheinhardt andreas.rheinhardt at outlook.com
Wed Jun 12 16:48:36 EEST 2024


The no-output mode (guarded by AV_CODEC_FLAG2_NO_OUTPUT)
does not provide a noteworthy speedup; in fact, it even
turned out to be slower than the code with the no-output
code removed (ordinary encode: 153259721 decicycles,
noout encode: 153259721; encode with this patch applied:
152451581 decicycles; timings are for encode_frame callbacks
when encoding a 1080p sample to MPEG-4).

(Furthermore, this code was broken for most of its existence
(since 9207dc3b0db368bb9cf5eb295cbc1129c2975e31) and no one
noticed, so the no-output mode is probably not used at all.)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>
---
 libavcodec/h263enc.h | 29 ++---------------------------
 1 file changed, 2 insertions(+), 27 deletions(-)

diff --git a/libavcodec/h263enc.h b/libavcodec/h263enc.h
index 6e07440b30..784500ca7a 100644
--- a/libavcodec/h263enc.h
+++ b/libavcodec/h263enc.h
@@ -37,36 +37,11 @@ void ff_clean_h263_qscales(MpegEncContext *s);
 void ff_h263_encode_motion(PutBitContext *pb, int val, int f_code);
 void ff_h263_update_mb(MpegEncContext *s);
 
-static inline int h263_get_motion_length(int val, int f_code)
-{
-    int bit_size, code, sign;
-
-    if (val == 0) {
-        return 1; /* ff_mvtab[0][1] */
-    } else {
-        bit_size = f_code - 1;
-        /* modulo encoding */
-        val  = sign_extend(val, 6 + bit_size);
-        sign = val >> 31;
-        val  = (val ^ sign) - sign; /* val = FFABS(val) */
-        val--;
-        code = (val >> bit_size) + 1;
-
-        return ff_mvtab[code][1] + 1 + bit_size;
-    }
-}
-
 static inline void ff_h263_encode_motion_vector(MpegEncContext * s,
                                                 int x, int y, int f_code)
 {
-    if (s->avctx->flags2 & AV_CODEC_FLAG2_NO_OUTPUT) {
-        skip_put_bits(&s->pb,
-                      h263_get_motion_length(x, f_code) +
-                      h263_get_motion_length(y, f_code));
-    } else {
-        ff_h263_encode_motion(&s->pb, x, f_code);
-        ff_h263_encode_motion(&s->pb, y, f_code);
-    }
+    ff_h263_encode_motion(&s->pb, x, f_code);
+    ff_h263_encode_motion(&s->pb, y, f_code);
 }
 
 static inline int get_p_cbp(MpegEncContext * s,
-- 
2.40.1



More information about the ffmpeg-devel mailing list