1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2025-08-10 06:10:52 +02:00

random_seed: Reorder if clauses for gathering entropy

Make it easier to add more cases.

This should be a pure refactoring, with no functional changes.

Signed-off-by: Martin Storsjö <martin@martin.st>
This commit is contained in:
Martin Storsjö
2025-02-05 23:59:34 +02:00
parent dc7964a862
commit b053f1173d

View File

@@ -98,17 +98,20 @@ static uint32_t get_generic_seed(void)
for (;;) { for (;;) {
clock_t t = clock(); clock_t t = clock();
if (last_t + 2*last_td + (CLOCKS_PER_SEC > 1000) >= t) { int incremented_i = 0;
last_td = t - last_t; int cur_td = t - last_t;
buffer[i & 511] = 1664525*buffer[i & 511] + 1013904223 + (last_td % 3294638521U); if (last_t + 2*last_td + (CLOCKS_PER_SEC > 1000) < t) {
buffer[++i & 511] += cur_td % 3294638521U;
incremented_i = 1;
} else { } else {
last_td = t - last_t; buffer[i & 511] = 1664525*buffer[i & 511] + 1013904223 + (cur_td % 3294638521U);
buffer[++i & 511] += last_td % 3294638521U; }
if ((t - init_t) >= CLOCKS_PER_SEC>>5) if (incremented_i && (t - init_t) >= CLOCKS_PER_SEC>>5) {
if (last_i && i - last_i > 4 || i - last_i > 64 || TEST && i - last_i > 8) if (last_i && i - last_i > 4 || i - last_i > 64 || TEST && i - last_i > 8)
break; break;
} }
last_t = t; last_t = t;
last_td = cur_td;
if (!init_t) if (!init_t)
init_t = t; init_t = t;
} }