mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-11 01:45:33 +00:00
Revert the latest change: floating point samples are allowed to have any value, not only values in the range [-1,1]. ...
Original commit message from CVS: * 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.
This commit is contained in:
parent
03992b8779
commit
6fa7788c5d
3 changed files with 16 additions and 49 deletions
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
|||
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:
|
||||
|
|
|
@ -64,8 +64,8 @@
|
|||
#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
|
||||
|
@ -214,12 +214,8 @@ static gboolean volume_set_caps (GstBaseTransform * base, GstCaps * incaps,
|
|||
|
||||
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,
|
||||
|
@ -288,22 +284,10 @@ volume_choose_func (GstVolume * this)
|
|||
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;
|
||||
|
@ -511,20 +495,6 @@ volume_process_double (GstVolume * this, gpointer bytes, guint n_bytes)
|
|||
}
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
|
@ -543,19 +513,6 @@ volume_process_float (GstVolume * this, gpointer bytes, guint n_bytes)
|
|||
oil_scalarmultiply_f32_ns (data, data, &this->real_vol_f, num_samples);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
|
|
|
@ -1006,7 +1006,7 @@ GST_START_TEST (test_double_f32)
|
|||
GstBuffer *outbuffer;
|
||||
GstCaps *caps;
|
||||
gfloat in[2] = { 0.75, -0.25 };
|
||||
gfloat out[2] = { 1.0, -0.5 }; /* notice the clamped sample */
|
||||
gfloat out[2] = { 1.5, -0.5 }; /* nothing is clamped */
|
||||
gfloat *res;
|
||||
|
||||
volume = setup_volume ();
|
||||
|
@ -1190,7 +1190,7 @@ GST_START_TEST (test_double_f64)
|
|||
GstBuffer *outbuffer;
|
||||
GstCaps *caps;
|
||||
gdouble in[2] = { 0.75, -0.25 };
|
||||
gdouble out[2] = { 1.0, -0.5 }; /* notice the clamped sample */
|
||||
gdouble out[2] = { 1.5, -0.5 }; /* nothing is clamped */
|
||||
gdouble *res;
|
||||
|
||||
volume = setup_volume ();
|
||||
|
|
Loading…
Reference in a new issue