+2007-09-09 Sebastian Dröge <slomo@circular-chaos.org>
+
+ * gst/volume/gstvolume.c: (volume_choose_func):
+ * tests/check/elements/volume.c: (GST_START_TEST):
+ Revert the latest change: floating point samples are allowed to
+ have any value, not only values in the range [-1,1]. Thanks to Andy
+ Wingo for noticing.
+ Also fix processing of int32 samples with volumes > 4 by making the
+ unity value smaller which prevents overflows.
+
2007-09-07 Tim-Philipp Müller <tim at centricular dot net>
* gst-libs/gst/rtp/gstrtpbuffer.c:
#define VOLUME_UNITY_INT16_BIT_SHIFT 13 /* number of bits to shift for unity */
#define VOLUME_UNITY_INT24 2097152 /* internal int for unity 2^(24-3) */
#define VOLUME_UNITY_INT24_BIT_SHIFT 21 /* number of bits to shift for unity */
-#define VOLUME_UNITY_INT32 536870912 /* internal int for unity 2^(32-3) */
-#define VOLUME_UNITY_INT32_BIT_SHIFT 29
+#define VOLUME_UNITY_INT32 134217728 /* internal int for unity 2^(32-5) */
+#define VOLUME_UNITY_INT32_BIT_SHIFT 27
#define VOLUME_MAX_DOUBLE 10.0
#define VOLUME_MAX_INT8 G_MAXINT8
#define VOLUME_MIN_INT8 G_MININT8
static void volume_process_double (GstVolume * this, gpointer bytes,
guint n_bytes);
-static void volume_process_double_clamp (GstVolume * this, gpointer bytes,
- guint n_bytes);
static void volume_process_float (GstVolume * this, gpointer bytes,
guint n_bytes);
-static void volume_process_float_clamp (GstVolume * this, gpointer bytes,
- guint n_bytes);
static void volume_process_int32 (GstVolume * this, gpointer bytes,
guint n_bytes);
static void volume_process_int32_clamp (GstVolume * this, gpointer bytes,
case GST_VOLUME_FORMAT_FLOAT:
switch (this->width) {
case 32:
- /* only clamp if the gain is greater than 1.0
- * FIXME: real_vol_f can change while processing the buffer!
- */
- if (this->real_vol_f > 1.0)
- this->process = volume_process_float_clamp;
- else
- this->process = volume_process_float;
+ this->process = volume_process_float;
break;
case 64:
- /* only clamp if the gain is greater than 1.0
- * FIXME: real_vol_f can change while processing the buffer!
- */
- if (this->real_vol_f > 1.0)
- this->process = volume_process_double_clamp;
- else
- this->process = volume_process_double;
+ this->process = volume_process_double;
break;
}
break;
}
static void
-volume_process_double_clamp (GstVolume * this, gpointer bytes, guint n_bytes)
-{
- gdouble *data = (gdouble *) bytes;
- guint i, num_samples = n_bytes / sizeof (gdouble);
- gdouble tmp;
-
- for (i = 0; i < num_samples; i++) {
- tmp = *data * this->real_vol_f;
- *data++ = CLAMP (tmp, -1.0, 1.0);
- }
-
-}
-
-static void
volume_process_float (GstVolume * this, gpointer bytes, guint n_bytes)
{
gfloat *data = (gfloat *) bytes;
}
static void
-volume_process_float_clamp (GstVolume * this, gpointer bytes, guint n_bytes)
-{
- gfloat *data = (gfloat *) bytes;
- guint i, num_samples = n_bytes / sizeof (gfloat);
- gfloat tmp;
-
- for (i = 0; i < num_samples; i++) {
- tmp = *data * this->real_vol_f;
- *data++ = CLAMP (tmp, -1.0, 1.0);
- }
-}
-
-static void
volume_process_int32 (GstVolume * this, gpointer bytes, guint n_bytes)
{
gint *data = (gint *) bytes;