--- a/gst_plugins_base/gst/audioconvert/gstaudioquantize.c Tue Aug 31 15:30:33 2010 +0300
+++ b/gst_plugins_base/gst/audioconvert/gstaudioquantize.c Wed Sep 01 12:16:41 2010 +0100
@@ -37,8 +37,6 @@
#include "audioconvert.h"
#include "gstaudioquantize.h"
-#include "gstfastrandom.h"
-
#define MAKE_QUANTIZE_FUNC_NAME(name) \
gst_audio_quantize_quantize_##name
@@ -146,8 +144,8 @@
gint32 dither = (1<<(scale));
#define ADD_DITHER_RPDF_I() \
- rand = gst_fast_random_int32_range (bias - dither, \
- bias + dither); \
+ rand = g_rand_int_range (ctx->dither_random, bias - dither, \
+ bias + dither); \
if (rand > 0 && tmp > 0 && G_MAXINT32 - tmp <= rand) \
tmp = G_MAXINT32; \
else if (rand < 0 && tmp < 0 && G_MININT32 - tmp >= rand) \
@@ -159,7 +157,8 @@
gdouble dither = 1.0/(1U<<(32 - scale - 1));
#define ADD_DITHER_RPDF_F() \
- tmp += gst_fast_random_double_range (- dither, dither);
+ tmp += g_rand_double_range (ctx->dither_random, - dither, \
+ dither);
#define INIT_DITHER_TPDF_I() \
gint32 rand; \
@@ -167,10 +166,10 @@
bias = bias >> 1;
#define ADD_DITHER_TPDF_I() \
- rand = gst_fast_random_int32_range (bias - dither, \
- bias + dither - 1) \
- + gst_fast_random_int32_range (bias - dither, \
- bias + dither - 1); \
+ rand = g_rand_int_range (ctx->dither_random, bias - dither, \
+ bias + dither - 1) \
+ + g_rand_int_range (ctx->dither_random, bias - dither, \
+ bias + dither - 1); \
if (rand > 0 && tmp > 0 && G_MAXINT32 - tmp <= rand) \
tmp = G_MAXINT32; \
else if (rand < 0 && tmp < 0 && G_MININT32 - tmp >= rand) \
@@ -182,8 +181,10 @@
gdouble dither = 1.0/(1U<<(32 - scale));
#define ADD_DITHER_TPDF_F() \
- tmp += gst_fast_random_double_range (- dither, dither) \
- + gst_fast_random_double_range (- dither, dither);
+ tmp += g_rand_double_range (ctx->dither_random, - dither, \
+ dither) \
+ + g_rand_double_range (ctx->dither_random, - dither, \
+ dither);
#define INIT_DITHER_TPDF_HF_I() \
gint32 rand; \
@@ -192,8 +193,8 @@
bias = bias >> 1;
#define ADD_DITHER_TPDF_HF_I() \
- tmp_rand = gst_fast_random_int32_range (bias - dither, \
- bias + dither); \
+ tmp_rand = g_rand_int_range (ctx->dither_random, bias - dither, \
+ bias + dither); \
rand = tmp_rand - last_random[chan_pos]; \
last_random[chan_pos] = tmp_rand; \
if (rand > 0 && tmp > 0 && G_MAXINT32 - tmp <= rand) \
@@ -212,7 +213,8 @@
gdouble *last_random = (gdouble *) ctx->last_random, tmp_rand;
#define ADD_DITHER_TPDF_HF_F() \
- tmp_rand = gst_fast_random_double_range (- dither, dither); \
+ tmp_rand = g_rand_double_range (ctx->dither_random, - dither, \
+ dither); \
rand = tmp_rand - last_random[chan_pos]; \
last_random[chan_pos] = tmp_rand; \
tmp += rand;
@@ -428,6 +430,7 @@
default:
break;
}
+ return;
g_free (ctx->error_buf);
ctx->error_buf = NULL;
@@ -443,13 +446,16 @@
ctx->last_random = g_new0 (gint32, ctx->out.channels);
else
ctx->last_random = g_new0 (gdouble, ctx->out.channels);
+ ctx->dither_random = g_rand_new ();
break;
case DITHER_RPDF:
case DITHER_TPDF:
+ ctx->dither_random = g_rand_new ();
ctx->last_random = NULL;
break;
case DITHER_NONE:
default:
+ ctx->dither_random = NULL;
ctx->last_random = NULL;
break;
}
@@ -460,6 +466,8 @@
gst_audio_quantize_free_dither (AudioConvertCtx * ctx)
{
g_free (ctx->last_random);
+ if (ctx->dither_random)
+ g_rand_free (ctx->dither_random);
return;
}