Browse code

Use FLG pseudo-random number generator in RoQ and ELBG

Originally committed as revision 17881 to svn://svn.ffmpeg.org/ffmpeg/trunk

Vitor Sessak authored on 2009/03/09 02:43:12
Showing 4 changed files
... ...
@@ -25,7 +25,7 @@
25 25
 
26 26
 #include <string.h>
27 27
 
28
-#include "libavutil/random.h"
28
+#include "libavutil/lfg.h"
29 29
 #include "elbg.h"
30 30
 #include "avcodec.h"
31 31
 
... ...
@@ -52,7 +52,7 @@ typedef struct{
52 52
     int *utility_inc;
53 53
     int *nearest_cb;
54 54
     int *points;
55
-    AVRandomState *rand_state;
55
+    AVLFG *rand_state;
56 56
 } elbg_data;
57 57
 
58 58
 static inline int distance_limited(int *a, int *b, int dim, int limit)
... ...
@@ -105,7 +105,7 @@ static int get_high_utility_cell(elbg_data *elbg)
105 105
 {
106 106
     int i=0;
107 107
     /* Using linear search, do binary if it ever turns to be speed critical */
108
-    int r = av_random(elbg->rand_state)%(elbg->utility_inc[elbg->numCB-1]-1) + 1;
108
+    int r = av_lfg_get(elbg->rand_state)%(elbg->utility_inc[elbg->numCB-1]-1) + 1;
109 109
     while (elbg->utility_inc[i] < r)
110 110
         i++;
111 111
 
... ...
@@ -318,7 +318,7 @@ static void do_shiftings(elbg_data *elbg)
318 318
 
319 319
 void ff_init_elbg(int *points, int dim, int numpoints, int *codebook,
320 320
                   int numCB, int max_steps, int *closest_cb,
321
-                  AVRandomState *rand_state)
321
+                  AVLFG *rand_state)
322 322
 {
323 323
     int i, k;
324 324
 
... ...
@@ -345,7 +345,7 @@ void ff_init_elbg(int *points, int dim, int numpoints, int *codebook,
345 345
 
346 346
 void ff_do_elbg(int *points, int dim, int numpoints, int *codebook,
347 347
                 int numCB, int max_steps, int *closest_cb,
348
-                AVRandomState *rand_state)
348
+                AVLFG *rand_state)
349 349
 {
350 350
     int dist;
351 351
     elbg_data elbg_d;
... ...
@@ -39,7 +39,7 @@
39 39
  */
40 40
 void ff_do_elbg(int *points, int dim, int numpoints, int *codebook,
41 41
                 int numCB, int num_steps, int *closest_cb,
42
-                AVRandomState *rand_state);
42
+                AVLFG *rand_state);
43 43
 
44 44
 /**
45 45
  * Initialize the **codebook vector for the elbg algorithm. If you have already
... ...
@@ -50,6 +50,6 @@ void ff_do_elbg(int *points, int dim, int numpoints, int *codebook,
50 50
  */
51 51
 void ff_init_elbg(int *points, int dim, int numpoints, int *codebook,
52 52
                   int numCB, int num_steps, int *closest_cb,
53
-                  AVRandomState *rand_state);
53
+                  AVLFG *rand_state);
54 54
 
55 55
 #endif /* AVCODEC_ELBG_H */
... ...
@@ -22,7 +22,7 @@
22 22
 #ifndef AVCODEC_ROQVIDEO_H
23 23
 #define AVCODEC_ROQVIDEO_H
24 24
 
25
-#include "libavutil/random.h"
25
+#include "libavutil/lfg.h"
26 26
 #include "avcodec.h"
27 27
 #include "dsputil.h"
28 28
 
... ...
@@ -58,7 +58,7 @@ typedef struct RoqContext {
58 58
     int width, height;
59 59
 
60 60
     /* Encoder only data */
61
-    AVRandomState randctx;
61
+    AVLFG randctx;
62 62
     uint64_t lambda;
63 63
 
64 64
     motion_vect *this_motion4;
... ...
@@ -929,7 +929,7 @@ static int roq_encode_init(AVCodecContext *avctx)
929 929
 {
930 930
     RoqContext *enc = avctx->priv_data;
931 931
 
932
-    av_random_init(&enc->randctx, 1);
932
+    av_lfg_init(&enc->randctx, 1);
933 933
 
934 934
     enc->framesSinceKeyframe = 0;
935 935
     if ((avctx->width & 0xf) || (avctx->height & 0xf)) {