@@ -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;
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(-)