[vlc-commits] commit: Use vlc_mrand48() instead of rand() ( Rémi Denis-Courmont )
git at videolan.org
git at videolan.org
Sat Mar 6 11:30:22 CET 2010
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sat Mar 6 12:29:29 2010 +0200| [4d6247fdd024fcf4511eb40cf62d01e12c825e7d] | committer: Rémi Denis-Courmont
Use vlc_mrand48() instead of rand()
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=4d6247fdd024fcf4511eb40cf62d01e12c825e7d
---
modules/access/vcdx/vcdplayer.c | 3 ++-
modules/video_filter/grain.c | 3 ++-
modules/video_filter/noise.c | 9 +++++----
modules/video_filter/puzzle.c | 11 ++++++-----
4 files changed, 15 insertions(+), 11 deletions(-)
diff --git a/modules/access/vcdx/vcdplayer.c b/modules/access/vcdx/vcdplayer.c
index 317e9bd..e955fb1 100644
--- a/modules/access/vcdx/vcdplayer.c
+++ b/modules/access/vcdx/vcdplayer.c
@@ -36,6 +36,7 @@
#include <vlc_common.h>
#include <vlc_input.h>
#include <vlc_interface.h>
+#include <vlc_rand.h>
#include "vcd.h"
#include "vcdplayer.h"
@@ -538,7 +539,7 @@ vcdplayer_pbc_nav ( access_t * p_access, uint8_t *wait_time )
/* Pick a random selection. */
unsigned int bsn=vcdinf_get_bsn(p_vcdplayer->pxd.psd);
int rand_selection=bsn +
- (int) ((i_selections+0.0)*rand()/(RAND_MAX+1.0));
+ ((unsigned)vlc_lrand48() % (unsigned)i_selections);
lid_t rand_lid=vcdinfo_selection_get_lid (p_vcdplayer->vcd,
p_vcdplayer->i_lid,
rand_selection);
diff --git a/modules/video_filter/grain.c b/modules/video_filter/grain.c
index 1ad5372..8aff4cd 100644
--- a/modules/video_filter/grain.c
+++ b/modules/video_filter/grain.c
@@ -31,6 +31,7 @@
#include <vlc_common.h>
#include <vlc_plugin.h>
+#include <vlc_rand.h>
#include <vlc_filter.h>
#include "filter_picture.h"
@@ -135,7 +136,7 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic )
{
for( i_col = 0; i_col < i_num_cols; i_col++ )
{
- p_noise[i_line*i_pitch+i_col] = ((rand()&0x1f)-0x0f);
+ p_noise[i_line*i_pitch+i_col] = ((vlc_mrand48()&0x1f)-0x0f);
}
}
diff --git a/modules/video_filter/noise.c b/modules/video_filter/noise.c
index e1858ca..e95d0f7 100644
--- a/modules/video_filter/noise.c
+++ b/modules/video_filter/noise.c
@@ -31,6 +31,7 @@
#include <vlc_common.h>
#include <vlc_plugin.h>
+#include <vlc_rand.h>
#include <vlc_filter.h>
#include "filter_picture.h"
@@ -105,7 +106,7 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic )
for( i_line = 0 ; i_line < i_num_lines ; i_line++ )
{
- if( rand()%8 )
+ if( vlc_mrand48()&7 )
{
/* line isn't noisy */
vlc_memcpy( p_out+i_line*i_pitch, p_in+i_line*i_pitch,
@@ -114,17 +115,17 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic )
else
{
/* this line is noisy */
- int noise_level = rand()%8+2;
+ unsigned noise_level = (vlc_mrand48()&7)+2;
for( i_col = 0; i_col < i_num_cols ; i_col++ )
{
- if( rand()%noise_level )
+ if( ((unsigned)vlc_mrand48())%noise_level )
{
p_out[i_line*i_pitch+i_col] =
p_in[i_line*i_pitch+i_col];
}
else
{
- p_out[i_line*i_pitch+i_col] = (rand()%3)*0x7f;
+ p_out[i_line*i_pitch+i_col] = (vlc_mrand48()&3)*0x7f;
}
}
}
diff --git a/modules/video_filter/puzzle.c b/modules/video_filter/puzzle.c
index 2c92270..33dba29 100644
--- a/modules/video_filter/puzzle.c
+++ b/modules/video_filter/puzzle.c
@@ -33,6 +33,7 @@
#include <vlc_common.h>
#include <vlc_plugin.h>
#include <vlc_filter.h>
+#include <vlc_rand.h>
#include "filter_picture.h"
@@ -429,19 +430,19 @@ static bool IsValid( filter_sys_t *p_sys )
static void Shuffle( filter_sys_t *p_sys )
{
- const int i_count = p_sys->i_cols * p_sys->i_rows;
+ const unsigned i_count = p_sys->i_cols * p_sys->i_rows;
free( p_sys->pi_order );
p_sys->pi_order = calloc( i_count, sizeof(*p_sys->pi_order) );
do
{
- for( int i = 0; i < i_count; i++ )
+ for( unsigned i = 0; i < i_count; i++ )
p_sys->pi_order[i] = -1;
- for( int c = 0; c < i_count; )
+ for( unsigned c = 0; c < i_count; )
{
- int i = rand() % i_count;
+ unsigned i = ((unsigned)vlc_mrand48()) % i_count;
if( p_sys->pi_order[i] == -1 )
p_sys->pi_order[i] = c++;
}
@@ -451,7 +452,7 @@ static void Shuffle( filter_sys_t *p_sys )
if( p_sys->b_blackslot )
{
- for( int i = 0; i < i_count; i++ )
+ for( unsigned i = 0; i < i_count; i++ )
{
if( p_sys->pi_order[i] == i_count - 1 )
{
More information about the vlc-commits
mailing list