mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2024-12-17 21:14:47 +00:00
compat: Fix the fallback definition of stdc_trailing_zeros
While shifting "value" to left, we would iterate through all bits of an unsigned long long, while we only expect to count through "size * CHAR_BIT" bits; instead shift bits to the right and just count the trailing zeros. This fixes fate with MSVC. Signed-off-by: Martin Storsjö <martin@martin.st>
This commit is contained in:
parent
e18b46d95f
commit
b4d9fa6cb9
@ -178,11 +178,14 @@ static inline unsigned int stdc_trailing_zeros_uc(unsigned char value)
|
|||||||
static inline unsigned int __stdc_trailing_zeros(unsigned long long value,
|
static inline unsigned int __stdc_trailing_zeros(unsigned long long value,
|
||||||
unsigned int size)
|
unsigned int size)
|
||||||
{
|
{
|
||||||
unsigned int zeros = size * CHAR_BIT;
|
unsigned int zeros = 0;
|
||||||
|
|
||||||
while (value != 0) {
|
if (!value)
|
||||||
value <<= 1;
|
return size * CHAR_BIT;
|
||||||
zeros--;
|
|
||||||
|
while ((value & 1) == 0) {
|
||||||
|
value >>= 1;
|
||||||
|
zeros++;
|
||||||
}
|
}
|
||||||
|
|
||||||
return zeros;
|
return zeros;
|
||||||
|
Loading…
Reference in New Issue
Block a user