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

Paul B Mahol onemda at gmail.com
Sun Feb 17 22:46:53 CET 2013


On 2/17/13, Michael Niedermayer <michaelni at gmx.at> wrote:
> 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

Changed and applied.

>
> thanks
>
> [...]
> --
> Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> Why not whip the teacher when the pupil misbehaves? -- Diogenes of Sinope
>


More information about the ffmpeg-devel mailing list