1
mirror of https://git.videolan.org/git/ffmpeg.git synced 2024-10-02 17:12:49 +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:
Niklas Haas 2023-09-27 15:16:51 +02:00
parent 7a24d794f6
commit 338a5fcdbe

View File

@ -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);
}