diff mbox series

[FFmpeg-devel,20/35] avcodec/proresenc_anatoliy: compute sign only once

Message ID 20231211014429.1841681-21-u@pkh.me
State Accepted
Commit 9258f4eaf9e8d8afbd98ae1e0c34a3bee8bec067
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
This makes the function closer to encode_dcs() in proresenc_kostya.
---
 libavcodec/proresenc_anatoliy.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

Stefano Sabatini Dec. 18, 2023, 12:37 a.m. UTC | #1
On date Monday 2023-12-11 02:35:21 +0100, Clément Bœsch wrote:
> This makes the function closer to encode_dcs() in proresenc_kostya.
> ---
>  libavcodec/proresenc_anatoliy.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)

Should be good.
diff mbox series

Patch

diff --git a/libavcodec/proresenc_anatoliy.c b/libavcodec/proresenc_anatoliy.c
index 0de262c9c5..0d8ca5515f 100644
--- a/libavcodec/proresenc_anatoliy.c
+++ b/libavcodec/proresenc_anatoliy.c
@@ -257,7 +257,6 @@  static void encode_vlc_codeword(PutBitContext *pb, unsigned codebook, int val)
 
 #define GET_SIGN(x)  ((x) >> 31)
 #define TO_GOLOMB(val) (((val) * 2) ^ GET_SIGN(val))
-#define DIFF_SIGN(val, sign) (GET_SIGN(val) ^ (sign))
 #define IS_NEGATIVE(val) ((GET_SIGN(val) ^ -1) + 1)
 #define TO_GOLOMB2(val,sign) ((val)==0 ? 0 : ((val) << 1) + (sign))
 
@@ -272,7 +271,7 @@  static void encode_dcs(PutBitContext *pb, int16_t *blocks,
                        int blocks_per_slice, int *qmat)
 {
     int prev_dc, codebook;
-    int i, sign;
+    int i, sign, new_sign;
     int new_dc, delta, diff_sign, code;
 
     prev_dc = (blocks[0] - 0x4000) / qmat[0];
@@ -284,13 +283,14 @@  static void encode_dcs(PutBitContext *pb, int16_t *blocks,
     for (i = 1; i < blocks_per_slice; i++, blocks += 64) {
         new_dc    = (blocks[0] - 0x4000) / qmat[0];
         delta     = new_dc - prev_dc;
-        diff_sign = DIFF_SIGN(delta, sign);
+        new_sign  = GET_SIGN(delta);
+        diff_sign = new_sign ^ sign;
         code      = TO_GOLOMB2(get_level(delta), diff_sign);
 
         encode_vlc_codeword(pb, ff_prores_dc_codebook[codebook], code);
 
         codebook  = FFMIN(code, 6);
-        sign      = delta >> 31;
+        sign      = new_sign;
         prev_dc   = new_dc;
     }
 }