[FFmpeg-cvslog] avcodec/mlpenc: use ff_ctz()

Paul B Mahol git at videolan.org
Sun Sep 5 01:14:21 EEST 2021


ffmpeg | branch: master | Paul B Mahol <onemda at gmail.com> | Sun Sep  5 00:06:00 2021 +0200| [5b28a5db033b3bb9f476b859791c5a8df039a61b] | committer: Paul B Mahol

avcodec/mlpenc: use ff_ctz()

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

 libavcodec/mlpenc.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/libavcodec/mlpenc.c b/libavcodec/mlpenc.c
index 4af3b1e37f..dd5c69c250 100644
--- a/libavcodec/mlpenc.c
+++ b/libavcodec/mlpenc.c
@@ -28,6 +28,7 @@
 #include "libavutil/channel_layout.h"
 #include "libavutil/crc.h"
 #include "libavutil/avstring.h"
+#include "libavutil/intmath.h"
 #include "libavutil/samplefmt.h"
 #include "libavutil/thread.h"
 #include "mlp.h"
@@ -1303,13 +1304,11 @@ static void input_to_sample_buffer(MLPEncodeContext *ctx)
 /** Counts the number of trailing zeroes in a value */
 static int number_trailing_zeroes(int32_t sample)
 {
-    int bits;
-
-    for (bits = 0; bits < 24 && !(sample & (1<<bits)); bits++);
+    int bits = ff_ctz(sample);
 
     /* All samples are 0. TODO Return previous quant_step_size to avoid
      * writing a new header. */
-    if (bits == 24)
+    if (bits >= 24)
         return 0;
 
     return bits;



More information about the ffmpeg-cvslog mailing list