[FFmpeg-cvslog] avcodec/cbs: Use put_bits63()

Andreas Rheinhardt git at videolan.org
Sat Apr 26 01:15:05 EEST 2025


ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt at outlook.com> | Fri Apr 18 13:02:47 2025 +0200| [6676038b23bd8272b9d6b9bb94f64b55f5dfd954] | committer: Andreas Rheinhardt

avcodec/cbs: Use put_bits63()

It is better when BUF_BITS == 64 (i.e. on x64), because
the underlying put_bits can then handle 0..63 bits naturally.
It does not worsen the code when BUF_BITS != 64, because
the compiler can optimize this to the same code as now
(due to the assert).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=6676038b23bd8272b9d6b9bb94f64b55f5dfd954
---

 libavcodec/cbs.c | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/libavcodec/cbs.c b/libavcodec/cbs.c
index ba1034a72e..398d286a92 100644
--- a/libavcodec/cbs.c
+++ b/libavcodec/cbs.c
@@ -674,10 +674,7 @@ int CBS_FUNC(write_unsigned)(CodedBitstreamContext *ctx, PutBitContext *pbc,
     if (put_bits_left(pbc) < width)
         return AVERROR(ENOSPC);
 
-    if (width < 32)
-        put_bits(pbc, width, value);
-    else
-        put_bits32(pbc, value);
+    put_bits63(pbc, width, value);
 
     CBS_TRACE_WRITE_END();
 
@@ -746,10 +743,7 @@ int CBS_FUNC(write_signed)(CodedBitstreamContext *ctx, PutBitContext *pbc,
     if (put_bits_left(pbc) < width)
         return AVERROR(ENOSPC);
 
-    if (width < 32)
-        put_sbits(pbc, width, value);
-    else
-        put_bits32(pbc, value);
+    put_bits63(pbc, width, zero_extend(value, width));
 
     CBS_TRACE_WRITE_END();
 



More information about the ffmpeg-cvslog mailing list