diff mbox series

[FFmpeg-devel,2/5] avcodec/scpr3: unify adding 127

Message ID 20240516231932.6950-2-michael@niedermayer.cc
State New
Headers show
Series [FFmpeg-devel,1/5] avcodec/rv34: assert that size is not 0 in rv34_gen_vlc_ext() | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Michael Niedermayer May 16, 2024, 11:19 p.m. UTC
Untested, i have no testcase nor does fate

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 libavcodec/scpr3.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
diff mbox series

Patch

diff --git a/libavcodec/scpr3.c b/libavcodec/scpr3.c
index 5271717ac79..79106ddcff8 100644
--- a/libavcodec/scpr3.c
+++ b/libavcodec/scpr3.c
@@ -42,7 +42,7 @@  static void renew_table3(uint32_t nsym, uint32_t *cntsum,
         freqs[d] = b;
         freqs1[d] = a;
         cnts[d] = c;
-        for (int q = a + 128 - 1 >> 7, f = (a + b - 1 >> 7) + 1; q < f; q++)
+        for (int q = a + 127 >> 7, f = a + b + 127 >> 7; q < f; q++)
             dectab[q] = d;
 
         a += b;
@@ -232,7 +232,7 @@  static int update_model6_to_7(PixelModel3 *m)
             cnts[j] = d;
         }
         p = (e + 127) >> 7;
-        k = ((f + e - 1) >> 7) + 1;
+        k = f + e + 127 >> 7;
         if (k > FF_ARRAY_ELEMS(n.dectab))
             return AVERROR_INVALIDDATA;
         for (i = 0; i < k - p; i++)
@@ -688,10 +688,10 @@  static int update_model3_to_7(PixelModel3 *m, uint8_t value)
         n.cntsum += n.cnts[e];
         n.freqs1[e] = c;
         g = n.freqs[e];
-        f = (c + g - 1 >> 7) + 1;
+        f = c + g + 127 >> 7;
         if (f > FF_ARRAY_ELEMS(n.dectab))
             return AVERROR_INVALIDDATA;
-        for (q = c + 128 - 1 >> 7; q < f; q++) {
+        for (q = c + 127 >> 7; q < f; q++) {
             n.dectab[q] = e;
         }
         c += g;
@@ -760,7 +760,7 @@  static int decode_value3(SCPRContext *s, uint32_t max, uint32_t *cntsum,
             freqs1[i] = e;
             g = (c + 127) >> 7;
             c += e;
-            q = ((c - 1) >> 7) + 1;
+            q = c + 127 >> 7;
             if (q > g) {
                 for (int j = 0; j < q - g; j++)
                     dectable[j + g] = i;