]> rtime.felk.cvut.cz Git - frescor/ffmpeg.git/commitdiff
Use FLG pseudo-random number generator in RoQ and ELBG
authorvitor <vitor@9553f0bf-9b14-0410-a0b8-cfaf0461ba5b>
Sun, 8 Mar 2009 17:43:12 +0000 (17:43 +0000)
committervitor <vitor@9553f0bf-9b14-0410-a0b8-cfaf0461ba5b>
Sun, 8 Mar 2009 17:43:12 +0000 (17:43 +0000)
git-svn-id: file:///var/local/repositories/ffmpeg/trunk@17881 9553f0bf-9b14-0410-a0b8-cfaf0461ba5b

libavcodec/elbg.c
libavcodec/elbg.h
libavcodec/roqvideo.h
libavcodec/roqvideoenc.c

index 712c927cec6e0f24667fd17ff6a06d0a8aa5649c..35f068825f1c3450e588ec8884044b6a2aa379e8 100644 (file)
@@ -25,7 +25,7 @@
 
 #include <string.h>
 
-#include "libavutil/random.h"
+#include "libavutil/lfg.h"
 #include "elbg.h"
 #include "avcodec.h"
 
@@ -52,7 +52,7 @@ typedef struct{
     int *utility_inc;
     int *nearest_cb;
     int *points;
-    AVRandomState *rand_state;
+    AVLFG *rand_state;
 } elbg_data;
 
 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)
 {
     int i=0;
     /* Using linear search, do binary if it ever turns to be speed critical */
-    int r = av_random(elbg->rand_state)%(elbg->utility_inc[elbg->numCB-1]-1) + 1;
+    int r = av_lfg_get(elbg->rand_state)%(elbg->utility_inc[elbg->numCB-1]-1) + 1;
     while (elbg->utility_inc[i] < r)
         i++;
 
@@ -318,7 +318,7 @@ static void do_shiftings(elbg_data *elbg)
 
 void ff_init_elbg(int *points, int dim, int numpoints, int *codebook,
                   int numCB, int max_steps, int *closest_cb,
-                  AVRandomState *rand_state)
+                  AVLFG *rand_state)
 {
     int i, k;
 
@@ -345,7 +345,7 @@ void ff_init_elbg(int *points, int dim, int numpoints, int *codebook,
 
 void ff_do_elbg(int *points, int dim, int numpoints, int *codebook,
                 int numCB, int max_steps, int *closest_cb,
-                AVRandomState *rand_state)
+                AVLFG *rand_state)
 {
     int dist;
     elbg_data elbg_d;
index cbc1f98c1f34051b127ab529262dc181431478c6..5eb33ecb28ebd58bbf123c7d4803cef48838ebe2 100644 (file)
@@ -39,7 +39,7 @@
  */
 void ff_do_elbg(int *points, int dim, int numpoints, int *codebook,
                 int numCB, int num_steps, int *closest_cb,
-                AVRandomState *rand_state);
+                AVLFG *rand_state);
 
 /**
  * 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,
  */
 void ff_init_elbg(int *points, int dim, int numpoints, int *codebook,
                   int numCB, int num_steps, int *closest_cb,
-                  AVRandomState *rand_state);
+                  AVLFG *rand_state);
 
 #endif /* AVCODEC_ELBG_H */
index 2b69838757de24e95c885ae8ea600f80e0e47afa..3fe11c670bd23913ae74be8c345c98334f36a4ee 100644 (file)
@@ -22,7 +22,7 @@
 #ifndef AVCODEC_ROQVIDEO_H
 #define AVCODEC_ROQVIDEO_H
 
-#include "libavutil/random.h"
+#include "libavutil/lfg.h"
 #include "avcodec.h"
 #include "dsputil.h"
 
@@ -58,7 +58,7 @@ typedef struct RoqContext {
     int width, height;
 
     /* Encoder only data */
-    AVRandomState randctx;
+    AVLFG randctx;
     uint64_t lambda;
 
     motion_vect *this_motion4;
index b9ab912564bccb77892f7ced2320e1ac12ea537b..8cca312f22ed60da6a0ce5308501d63a66efee54 100644 (file)
@@ -929,7 +929,7 @@ static int roq_encode_init(AVCodecContext *avctx)
 {
     RoqContext *enc = avctx->priv_data;
 
-    av_random_init(&enc->randctx, 1);
+    av_lfg_init(&enc->randctx, 1);
 
     enc->framesSinceKeyframe = 0;
     if ((avctx->width & 0xf) || (avctx->height & 0xf)) {