mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2026-10-24 02:09:03 +03:00
avcodec/wavpackenc: handle INT32_MIN samples
abs() cannot represent the magnitude of INT32_MIN. labs() has the same issue on platforms where long is 32 bits. use FFABSU for the full signed sample range.
Signed-off-by: Ayoub Nabil Boubagrat <237098474+ayoubnabil@users.noreply.github.com>
(cherry picked from commit 4021d0d193)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
committed by
Michael Niedermayer
parent
f5911d012c
commit
6bb0f2ae77
@@ -662,8 +662,9 @@ static uint32_t log2mono(int32_t *samples, int nb_samples, int limit)
|
||||
{
|
||||
uint32_t result = 0;
|
||||
while (nb_samples--) {
|
||||
if (log2sample(abs(*samples++), limit, &result))
|
||||
if (log2sample(FFABSU(samples[0]), limit, &result))
|
||||
return UINT32_MAX;
|
||||
samples++;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -673,9 +674,11 @@ static uint32_t log2stereo(int32_t *samples_l, int32_t *samples_r,
|
||||
{
|
||||
uint32_t result = 0;
|
||||
while (nb_samples--) {
|
||||
if (log2sample(abs(*samples_l++), limit, &result) ||
|
||||
log2sample(abs(*samples_r++), limit, &result))
|
||||
if (log2sample(FFABSU(samples_l[0]), limit, &result) ||
|
||||
log2sample(FFABSU(samples_r[0]), limit, &result))
|
||||
return UINT32_MAX;
|
||||
samples_l++;
|
||||
samples_r++;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -991,7 +994,7 @@ static void scan_word(WavPackEncodeContext *s, WvChannel *c,
|
||||
samples += nb_samples - 1;
|
||||
|
||||
while (nb_samples--) {
|
||||
uint32_t low, value = labs(samples[0]);
|
||||
uint32_t low, value = FFABSU(samples[0]);
|
||||
|
||||
if (value < GET_MED(0)) {
|
||||
DEC_MED(0);
|
||||
|
||||
Reference in New Issue
Block a user