Mercurial > libavcodec.hg
comparison rangecoder.c @ 9199:ea0e5e9a520f libavcodec
Replace random() usage in test programs by av_lfg_*().
author | diego |
---|---|
date | Fri, 20 Mar 2009 11:48:27 +0000 |
parents | e9d9d946f213 |
children | 2313bf51945b |
comparison
equal
deleted
inserted
replaced
9198:342e95d4784b | 9199:ea0e5e9a520f |
---|---|
109 return c->bytestream - c->bytestream_start; | 109 return c->bytestream - c->bytestream_start; |
110 } | 110 } |
111 | 111 |
112 #ifdef TEST | 112 #ifdef TEST |
113 #define SIZE 10240 | 113 #define SIZE 10240 |
114 #undef random | 114 |
115 #include "libavutil/lfg.h" | |
116 | |
115 int main(void){ | 117 int main(void){ |
116 RangeCoder c; | 118 RangeCoder c; |
117 uint8_t b[9*SIZE]; | 119 uint8_t b[9*SIZE]; |
118 uint8_t r[9*SIZE]; | 120 uint8_t r[9*SIZE]; |
119 int i; | 121 int i; |
120 uint8_t state[10]= {0}; | 122 uint8_t state[10]= {0}; |
123 AVLFG prn; | |
124 | |
125 av_lfg_init(&prn, 1); | |
121 | 126 |
122 ff_init_range_encoder(&c, b, SIZE); | 127 ff_init_range_encoder(&c, b, SIZE); |
123 ff_build_rac_states(&c, 0.05*(1LL<<32), 128+64+32+16); | 128 ff_build_rac_states(&c, 0.05*(1LL<<32), 128+64+32+16); |
124 | 129 |
125 memset(state, 128, sizeof(state)); | 130 memset(state, 128, sizeof(state)); |
126 | 131 |
127 for(i=0; i<SIZE; i++){ | 132 for(i=0; i<SIZE; i++){ |
128 r[i]= random()%7; | 133 r[i] = av_lfg_get(&prn) % 7; |
129 } | 134 } |
130 | 135 |
131 for(i=0; i<SIZE; i++){ | 136 for(i=0; i<SIZE; i++){ |
132 START_TIMER | 137 START_TIMER |
133 put_rac(&c, state, r[i]&1); | 138 put_rac(&c, state, r[i]&1); |