aboutsummaryrefslogtreecommitdiffstats
path: root/libavutil
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2014-01-06 22:09:14 +0100
committerMichael Niedermayer <michaelni@gmx.at>2014-01-06 22:12:29 +0100
commit00f25e0a990f9200806fc23d9054a47169db69a2 (patch)
treecb5b741af2c07b3dd66385bbbe2c3dcae9d99c57 /libavutil
parent13f3092b387fb1e0f9b281e94ae725b537304af6 (diff)
parent01d245ef4392152dbdc78a6ba4dfa0a6e8b08e6f (diff)
downloadffmpeg-00f25e0a990f9200806fc23d9054a47169db69a2.tar.gz
Merge commit '01d245ef4392152dbdc78a6ba4dfa0a6e8b08e6f'
* commit '01d245ef4392152dbdc78a6ba4dfa0a6e8b08e6f': random_seed: Rewrite the generic clock() based seed code Conflicts: libavutil/random_seed.c See: 66531c75d3bfd8a013acd8bd3c04a131dae2a1a0 Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavutil')
-rw-r--r--libavutil/random_seed.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/libavutil/random_seed.c b/libavutil/random_seed.c
index aa8902472e..e3ffaff014 100644
--- a/libavutil/random_seed.c
+++ b/libavutil/random_seed.c
@@ -33,10 +33,10 @@
#include <string.h>
#include "avassert.h"
#include "internal.h"
+#include "intreadwrite.h"
#include "timer.h"
#include "random_seed.h"
#include "sha.h"
-#include "intreadwrite.h"
#ifndef TEST
#define TEST 0
@@ -65,7 +65,7 @@ static uint32_t get_generic_seed(void)
struct AVSHA *sha = (void*)tmp;
clock_t last_t = 0;
static uint64_t i = 0;
- static uint32_t buffer[512] = {0};
+ static uint32_t buffer[512] = { 0 };
unsigned char digest[20];
uint64_t last_i = i;
@@ -84,11 +84,11 @@ static uint32_t get_generic_seed(void)
for (;;) {
clock_t t = clock();
- if(last_t == t){
- buffer[i&511]++;
- }else{
- buffer[++i&511]+= (t-last_t) % 3294638521U;
- if(last_i && i-last_i > 4 || i-last_i > 64 || TEST && i-last_i > 8)
+ if (last_t == t) {
+ buffer[i & 511]++;
+ } else {
+ buffer[++i & 511] += (t - last_t) % 3294638521U;
+ if (last_i && i - last_i > 4 || i - last_i > 64 || TEST && i - last_i > 8)
break;
}
last_t = t;
@@ -98,9 +98,9 @@ static uint32_t get_generic_seed(void)
buffer[0] = buffer[1] = 0;
av_sha_init(sha, 160);
- av_sha_update(sha, (uint8_t*)buffer, sizeof(buffer));
+ av_sha_update(sha, (const uint8_t *)buffer, sizeof(buffer));
av_sha_final(sha, digest);
- return AV_RB32(digest) + AV_RB32(digest+16);
+ return AV_RB32(digest) + AV_RB32(digest + 16);
}
uint32_t av_get_random_seed(void)