Commit 4d6247fd authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Use vlc_mrand48() instead of rand()

parent ac824333
......@@ -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);
......
......@@ -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);
}
}
......
......@@ -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;
}
}
}
......
......@@ -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 )
{
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment