[FFmpeg-devel] [PATCH 2/5] avcodec/scpr3: unify adding 127
Michael Niedermayer
michael at niedermayer.cc
Fri May 17 02:19:29 EEST 2024
Untested, i have no testcase nor does fate
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
---
libavcodec/scpr3.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
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;
--
2.43.2
More information about the ffmpeg-devel
mailing list