summaryrefslogtreecommitdiff
path: root/libavcodec
diff options
context:
space:
mode:
authorPaul B Mahol <onemda@gmail.com>2021-03-03 12:37:02 +0100
committerPaul B Mahol <onemda@gmail.com>2021-03-03 12:41:44 +0100
commit3be33703c6e588c4df003340b37c89206afa4f2e (patch)
treec069c0b5530a314f18183ac070e4af98827c272f /libavcodec
parent4dc039b4c7c74567af4a31ab1d212139f5225b69 (diff)
avcodec/half2float: fix integer overflows in convertmantissa()
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/half2float.h12
1 files changed, 6 insertions, 6 deletions
diff --git a/libavcodec/half2float.h b/libavcodec/half2float.h
index 9cff12a309..fd11caffdf 100644
--- a/libavcodec/half2float.h
+++ b/libavcodec/half2float.h
@@ -23,16 +23,16 @@
static uint32_t convertmantissa(uint32_t i)
{
- uint32_t m = i << 13; // Zero pad mantissa bits
- uint32_t e = 0; // Zero exponent
+ int32_t m = i << 13; // Zero pad mantissa bits
+ int32_t e = 0; // Zero exponent
- while (!(m & 0x00800000UL)){ // While not normalized
- e -= 0x00800000UL; // Decrement exponent (1<<23)
+ while (!(m & 0x00800000)) { // While not normalized
+ e -= 0x00800000; // Decrement exponent (1<<23)
m <<= 1; // Shift mantissa
}
- m &= ~0x00800000UL; // Clear leading 1 bit
- e += 0x38800000UL; // Adjust bias ((127-14)<<23)
+ m &= ~0x00800000; // Clear leading 1 bit
+ e += 0x38800000; // Adjust bias ((127-14)<<23)
return m | e; // Return combined number
}