mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-03-03 14:32:16 +02:00
lavc/h274: fix PRNG definition
The spec specifies x^31 + x^3 + 1 as the polynomial, but the diagram in Figure 1-1 omits the +1 offset. The initial implementation was based on the diagram, but this is wrong (produces subtly incorrect results).
This commit is contained in:
parent
7a24d794f6
commit
338a5fcdbe
@ -38,7 +38,7 @@ static void prng_shift(uint32_t *state)
|
||||
{
|
||||
// Primitive polynomial x^31 + x^3 + 1 (modulo 2)
|
||||
uint32_t x = *state;
|
||||
uint8_t feedback = (x >> 2) ^ (x >> 30);
|
||||
uint8_t feedback = 1u ^ (x >> 2) ^ (x >> 30);
|
||||
*state = (x << 1) | (feedback & 1u);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user