diff mbox series

[FFmpeg-devel,14/35] avcodec/proresenc_anatoliy: inline QSCALE()

Message ID 20231211014429.1841681-15-u@pkh.me
State Accepted
Commit c44cd371ca8269065876874326c6c5c7ef1c8e5f
Headers show
Series [FFmpeg-devel,01/35] avcodec/proresenc_kostya: remove an unnecessary parenthesis level in MAKE_CODE() macro | expand

Commit Message

Clément Bœsch Dec. 11, 2023, 1:35 a.m. UTC
Also replaces 16384 with 0x4000.

This makes the function slightly closer to same function in proresenc_kostya.
---
 libavcodec/proresenc_anatoliy.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

Comments

Stefano Sabatini Dec. 18, 2023, 12:13 a.m. UTC | #1
On date Monday 2023-12-11 02:35:15 +0100, Clément Bœsch wrote:
> Also replaces 16384 with 0x4000.
> 
> This makes the function slightly closer to same function in proresenc_kostya.

LGTM (and possibly improves readability by removing an unnecessary indirection).
diff mbox series

Patch

diff --git a/libavcodec/proresenc_anatoliy.c b/libavcodec/proresenc_anatoliy.c
index 86e436615c..b8433ee872 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);