[FFmpeg-cvslog] avcodec/proresenc_anatoliy: inline QSCALE()

Clément Bœsch git at videolan.org
Wed Jan 10 15:22:10 EET 2024


ffmpeg | branch: master | Clément Bœsch <u at pkh.me> | Mon Dec 11 01:43:33 2023 +0100| [c44cd371ca8269065876874326c6c5c7ef1c8e5f] | committer: Clément Bœsch

avcodec/proresenc_anatoliy: inline QSCALE()

Also replaces 16384 with 0x4000.

This makes the function slightly closer to same function in proresenc_kostya.

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

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

diff --git a/libavcodec/proresenc_anatoliy.c b/libavcodec/proresenc_anatoliy.c
index 71d5ad2771..d037efd837 100644
--- a/libavcodec/proresenc_anatoliy.c
+++ b/libavcodec/proresenc_anatoliy.c
@@ -255,7 +255,6 @@ static void encode_vlc_codeword(PutBitContext *pb, unsigned codebook, int val)
     }
 }
 
-#define QSCALE(qmat,ind,val) ((val) / ((qmat)[ind]))
 #define TO_GOLOMB(val) (((val) * 2) ^ ((val) >> 31))
 #define DIFF_SIGN(val, sign) (((val) >> 31) ^ (sign))
 #define IS_NEGATIVE(val) ((((val) >> 31) ^ -1) + 1)
@@ -275,13 +274,13 @@ static void encode_dc_coeffs(PutBitContext *pb, int16_t *in,
     int i, sign, idx;
     int new_dc, delta, diff_sign, new_code;
 
-    prev_dc = QSCALE(qmat, 0, in[0] - 16384);
+    prev_dc = (in[0] - 0x4000) / qmat[0];
     code = TO_GOLOMB(prev_dc);
     encode_vlc_codeword(pb, FIRST_DC_CB, code);
 
     code = 5; sign = 0; idx = 64;
     for (i = 1; i < blocks_per_slice; i++, idx += 64) {
-        new_dc    = QSCALE(qmat, 0, in[idx] - 16384);
+        new_dc    = (in[idx] - 0x4000) / qmat[0];
         delta     = new_dc - prev_dc;
         diff_sign = DIFF_SIGN(delta, sign);
         new_code  = TO_GOLOMB2(get_level(delta), diff_sign);
@@ -304,7 +303,7 @@ static void encode_ac_coeffs(PutBitContext *pb,
     for (i = 1; i < 64; i++) {
         int indp = ff_prores_scan[i];
         for (j = 0; j < blocks_per_slice; j++) {
-            int val = QSCALE(qmat, indp, in[(j << 6) + indp]);
+            int val = (in[(j << 6) + indp]) / qmat[indp];
             if (val) {
                 encode_vlc_codeword(pb, ff_prores_run_to_cb[FFMIN(prev_run, 15)], run);
 



More information about the ffmpeg-cvslog mailing list