[FFmpeg-cvslog] avcodec/mlpenc: increase compression ratio when input is of lower bit depth

Paul B Mahol git at videolan.org
Mon Oct 2 21:32:59 EEST 2023


ffmpeg | branch: master | Paul B Mahol <onemda at gmail.com> | Mon Oct  2 18:52:35 2023 +0200| [0be5da9cfa745ca734c50d75491fd2d79c374789] | committer: Paul B Mahol

avcodec/mlpenc: increase compression ratio when input is of lower bit depth

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

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

diff --git a/libavcodec/mlpenc.c b/libavcodec/mlpenc.c
index ce7ad2d5ea..cb4eabbae2 100644
--- a/libavcodec/mlpenc.c
+++ b/libavcodec/mlpenc.c
@@ -1259,16 +1259,9 @@ 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, const int wordlength)
+static int number_trailing_zeroes(int32_t sample)
 {
-    int bits = ff_ctz(sample);
-
-    /* All samples are 0. TODO Return previous quant_step_size to avoid
-     * writing a new header. */
-    if (bits >= wordlength)
-        return 0;
-
-    return bits;
+    return FFMIN(15, ff_ctz(sample));
 }
 
 /** Determines how many bits are zero at the end of all samples so they can be
@@ -1279,7 +1272,6 @@ static void determine_quant_step_size(MLPEncodeContext *ctx)
     DecodingParams *dp = ctx->cur_decoding_params;
     RestartHeader  *rh = ctx->cur_restart_header;
     MatrixParams *mp = &dp->matrix_params;
-    const int wordlength = ctx->wordlength;
     int32_t *sample_buffer = ctx->sample_buffer;
     int32_t sample_mask[MAX_CHANNELS];
 
@@ -1293,7 +1285,7 @@ static void determine_quant_step_size(MLPEncodeContext *ctx)
     }
 
     for (unsigned int channel = 0; channel <= rh->max_channel; channel++)
-        dp->quant_step_size[channel] = number_trailing_zeroes(sample_mask[channel], wordlength) - mp->shift[channel];
+        dp->quant_step_size[channel] = number_trailing_zeroes(sample_mask[channel]) - mp->shift[channel];
 }
 
 /** Determines the smallest number of bits needed to encode the filter



More information about the ffmpeg-cvslog mailing list