-
Notifications
You must be signed in to change notification settings - Fork 239
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug: bs_read_ue compiler-dependent behavior when i==32 #52
Comments
The minimal fix could be like:
But it looks quite ugly. And things go deeper, if we look closer on other implementations. There's a bit different implementation in VLC project. They increment VLC also have different realization of Our implementation is quite strange -- for instance, we decrement the |
I was wrong about the minimal fix. This function implements the Exponential-Golomb decoding algorithm: static inline uint32_t bs_read_ue(bs_t* b)
{
int32_t r = 0;
int i = 0;
while( (bs_read_u1(b) == 0) && (i < 32) && (!bs_eof(b)) )
{
i++;
}
r = bs_read_u(b, i);
r += (1 << i) - 1;
return r;
} The Exp-Golomb coded integer number looks like: First the function reads N zero bits. It stops either reading non-zero bit or reaching some limits. That's the while-loop code. Then it reads next N bits and represents them as an unsigned value (according to the ue-suffix). Thus we have Finally we add So the As for the failing tests -- there's a byte sequence:
which in binary is:
Moreover, the
There are 47 leading zero bits before the first 1-bit. So our coded number should contain 47 informational bits. That's neither However, if it's true and we really need 47 bits, we don't have them. After bytes given above the |
This line has compiler-dependent behavior
h264bitstream/bs.h
Line 203 in d8e53fd
Found by @LostInKadath #51 (comment)
(Probably gcc does what is intended here and clang on 64bit platforms is bugged)
The text was updated successfully, but these errors were encountered: