summaryrefslogtreecommitdiff
path: root/libavcodec/wavpackenc.c
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>2019-09-20 00:16:58 +0200
committerAndreas Rheinhardt <andreas.rheinhardt@gmail.com>2020-07-01 22:26:04 +0200
commit3497fd2dd7342257efd3f4e1bc60c7d5d657a65a (patch)
tree5fae6367702a20318fe0723abb02bd78fac095ab /libavcodec/wavpackenc.c
parent5dc4b3209f55131e9746954ca6d47f050512ad29 (diff)
downloadffmpeg-3497fd2dd7342257efd3f4e1bc60c7d5d657a65a.tar.gz
avcodec/wavpackenc: Fix undefined shifts
Fixes ticket #8161 and the acodec-wavpack FATE-test. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> (cherry picked from commit 84974c6fb542cf019904016c2165d9a62db9f312) Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Diffstat (limited to 'libavcodec/wavpackenc.c')
-rw-r--r--libavcodec/wavpackenc.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/libavcodec/wavpackenc.c b/libavcodec/wavpackenc.c
index 979b92165b..bc896f15e5 100644
--- a/libavcodec/wavpackenc.c
+++ b/libavcodec/wavpackenc.c
@@ -529,9 +529,9 @@ static int8_t store_weight(int weight)
static int restore_weight(int8_t weight)
{
- int result;
+ int result = 8 * weight;
- if ((result = (int) weight << 3) > 0)
+ if (result > 0)
result += (result + 64) >> 7;
return result;
@@ -2571,7 +2571,7 @@ static int wavpack_encode_block(WavPackEncodeContext *s,
ret = wv_mono(s, samples_l, !s->num_terms, 1);
} else {
for (i = 0; i < nb_samples; i++)
- crc += (crc << 3) + (samples_l[i] << 1) + samples_l[i] + samples_r[i];
+ crc += (crc << 3) + ((uint32_t)samples_l[i] << 1) + samples_l[i] + samples_r[i];
if (s->num_passes)
ret = wv_stereo(s, samples_l, samples_r, !s->num_terms, 1);