From: Sebastian Dröge Date: Sun, 3 Oct 2010 09:20:37 +0000 (+0200) Subject: volume: Implement int32 processing with orc X-Git-Tag: 1.19.3~511^2~7962 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=39ef36b32c13456dc6cc65d2f832d54c68b43fc3;p=platform%2Fupstream%2Fgstreamer.git volume: Implement int32 processing with orc --- diff --git a/gst/volume/gstvolume.c b/gst/volume/gstvolume.c index 9ce5c5f..7645a57 100644 --- a/gst/volume/gstvolume.c +++ b/gst/volume/gstvolume.c @@ -569,10 +569,13 @@ static void volume_process_int32 (GstVolume * self, gpointer bytes, guint n_bytes) { gint32 *data = (gint32 *) bytes; - guint i, num_samples; + guint num_samples = n_bytes / sizeof (gint); +#ifndef USE_ORC + guint i; gint64 val; - num_samples = n_bytes / sizeof (gint); + /* hard coded in volume.orc */ + g_assert (VOLUME_UNITY_INT16_BIT_SHIFT == 27); for (i = 0; i < num_samples; i++) { /* we use bitshifting instead of dividing by UNITY_INT for speed */ val = (gint64) * data; @@ -581,16 +584,22 @@ volume_process_int32 (GstVolume * self, gpointer bytes, guint n_bytes) val) >> VOLUME_UNITY_INT32_BIT_SHIFT); *data++ = (gint32) val; } +#else + orc_process_int32 (data, self->current_vol_i32, num_samples); +#endif } static void volume_process_int32_clamp (GstVolume * self, gpointer bytes, guint n_bytes) { gint32 *data = (gint32 *) bytes; - guint i, num_samples; + guint num_samples = n_bytes / sizeof (gint); +#ifndef USE_ORC + guint i; gint64 val; - num_samples = n_bytes / sizeof (gint32); + /* hard coded in volume.orc */ + g_assert (VOLUME_UNITY_INT16_BIT_SHIFT == 27); for (i = 0; i < num_samples; i++) { /* we use bitshifting instead of dividing by UNITY_INT for speed */ @@ -600,6 +609,9 @@ volume_process_int32_clamp (GstVolume * self, gpointer bytes, guint n_bytes) val) >> VOLUME_UNITY_INT32_BIT_SHIFT); *data++ = (gint32) CLAMP (val, VOLUME_MIN_INT32, VOLUME_MAX_INT32); } +#else + orc_process_int32_clamp (data, self->current_vol_i32, num_samples); +#endif } static void @@ -611,11 +623,15 @@ volume_process_controlled_int32_clamp (GstVolume * self, gpointer bytes, guint num_samples = n_bytes / (sizeof (gint32) * channels); gdouble vol, val; - for (i = 0; i < num_samples; i++) { - vol = *volume++; - for (j = 0; j < channels; j++) { - val = *data * vol; - *data++ = (gint32) CLAMP (val, VOLUME_MIN_INT32, VOLUME_MAX_INT32); + if (channels == 1) { + orc_process_controlled_int32_1ch (data, volume, num_samples); + } else { + for (i = 0; i < num_samples; i++) { + vol = *volume++; + for (j = 0; j < channels; j++) { + val = *data * vol; + *data++ = (gint32) CLAMP (val, VOLUME_MIN_INT32, VOLUME_MAX_INT32); + } } } } diff --git a/gst/volume/gstvolumeorc.orc b/gst/volume/gstvolumeorc.orc index 31c0c8a..2153735 100644 --- a/gst/volume/gstvolumeorc.orc +++ b/gst/volume/gstvolumeorc.orc @@ -13,6 +13,23 @@ muld d1, d1, p1 mulf d1, d1, p1 +.function orc_process_int32 +.dest 4 d1 gint32 +.param 4 p1 +.temp 8 t1 + +mulslq t1, d1, p1 +shrsq t1, t1, 27 +convql d1, t1 + +.function orc_process_int32_clamp +.dest 4 d1 gint32 +.param 4 p1 +.temp 8 t1 + +mulslq t1, d1, p1 +shrsq t1, t1, 27 +convsssql d1, t1 .function orc_process_int16 .dest 2 d1 gint16 @@ -91,6 +108,18 @@ convdf t1, s1 mergelq t2, t1, t1 x2 mulf d1, d1, t2 +.function orc_process_controlled_int32_1ch +.dest 4 d1 gint32 +.source 8 s1 gdouble +.temp 8 t1 +.temp 4 t2 + +muld t1, s1, 0x41DFFFFFFFC00000L +convdl t2, t1 +mulslq t1, d1, t2 +shrsq t1, t1, 32 +convql d1, t1 + .function orc_process_controlled_int16_1ch .dest 2 d1 gint16 .source 8 s1 gdouble