diff options
author | Sebastian Dröge <slomo@circular-chaos.org> | 2007-09-09 04:08:48 +0000 |
---|---|---|
committer | Sebastian Dröge <slomo@circular-chaos.org> | 2007-09-09 04:08:48 +0000 |
commit | 6fa7788c5d7ca3ac781cd3e13595cf8ef7ae351c (patch) | |
tree | f66ada16b0d3ad9313681cca5d65b1da2e9d4a10 | |
parent | 03992b877955b247b93c7b5d1b49233cc5f926d8 (diff) |
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.
-rw-r--r-- | ChangeLog | 10 | ||||
-rw-r--r-- | gst/volume/gstvolume.c | 51 | ||||
-rw-r--r-- | tests/check/elements/volume.c | 4 |
3 files changed, 16 insertions, 49 deletions
@@ -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: diff --git a/gst/volume/gstvolume.c b/gst/volume/gstvolume.c index 4747581f..942cda95 100644 --- a/gst/volume/gstvolume.c +++ b/gst/volume/gstvolume.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; @@ -512,20 +496,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) { gfloat *data = (gfloat *) bytes; @@ -544,19 +514,6 @@ volume_process_float (GstVolume * this, gpointer bytes, guint n_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; diff --git a/tests/check/elements/volume.c b/tests/check/elements/volume.c index c0ca64cb..0bb12f49 100644 --- a/tests/check/elements/volume.c +++ b/tests/check/elements/volume.c @@ -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 (); |