[FFmpeg-devel] [PATCH] lavfi/noise: switch to AVLFG noise generator

Michael Niedermayer michaelni at gmx.at
Sun Feb 17 22:14:22 CET 2013


On Sun, Feb 17, 2013 at 09:07:25PM +0000, Paul B Mahol wrote:
> Signed-off-by: Paul B Mahol <onemda at gmail.com>
> ---
>  libavfilter/vf_noise.c | 18 +++++++++++-------
>  1 file changed, 11 insertions(+), 7 deletions(-)
> 
> diff --git a/libavfilter/vf_noise.c b/libavfilter/vf_noise.c
> index 59748b1..fd231ea 100644
> --- a/libavfilter/vf_noise.c
> +++ b/libavfilter/vf_noise.c
> @@ -26,6 +26,7 @@
>  
>  #include "libavutil/opt.h"
>  #include "libavutil/imgutils.h"
> +#include "libavutil/lfg.h"
>  #include "libavutil/parseutils.h"
>  #include "libavutil/pixdesc.h"
>  #include "avfilter.h"
> @@ -47,6 +48,7 @@ typedef struct {
>      int strength;
>      unsigned flags;
>      int shiftptr;
> +    AVLFG lfg;
>      int seed;
>      int8_t *noise;
>      int8_t *prev_shift[MAX_RES][3];
> @@ -91,11 +93,12 @@ AVFILTER_DEFINE_CLASS(noise);
>  
>  static const int8_t patt[4] = { -1, 0, 1, 0 };
>  
> -#define RAND_N(range) ((int) ((double) range * rand() / (RAND_MAX + 1.0)))
> +#define RAND_N(range) ((int) ((double) range * av_lfg_get(lfg) / (RAND_MAX + 1.0)))

RAND_MAX is rand() specific

otherwise LGTM

thanks

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Why not whip the teacher when the pupil misbehaves? -- Diogenes of Sinope
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20130217/e288e374/attachment.asc>


More information about the ffmpeg-devel mailing list