diff options
author | Sebastian Dröge <sebastian.droege@collabora.co.uk> | 2010-10-01 12:21:52 +0200 |
---|---|---|
committer | Sebastian Dröge <sebastian.droege@collabora.co.uk> | 2010-10-08 00:01:15 +0200 |
commit | c11ee1a100f5f620ea50916b07f555993c501acb (patch) | |
tree | 09eabbc85b74d3b63cd140fdea40fbcf63258012 /gst/volume | |
parent | 0bf4abe5815f8920dc4995506c1882b07fa6ae32 (diff) |
volume: Implement controlled processing for int16/1-2ch and int8/1,2,4ch with orc
Diffstat (limited to 'gst/volume')
-rw-r--r-- | gst/volume/gstvolume.c | 34 | ||||
-rw-r--r-- | gst/volume/gstvolumeorc.orc | 82 |
2 files changed, 105 insertions, 11 deletions
diff --git a/gst/volume/gstvolume.c b/gst/volume/gstvolume.c index 43fa3409e..9ce5c5f6d 100644 --- a/gst/volume/gstvolume.c +++ b/gst/volume/gstvolume.c @@ -769,11 +769,17 @@ volume_process_controlled_int16_clamp (GstVolume * self, gpointer bytes, guint num_samples = n_bytes / (sizeof (gint16) * channels); gdouble vol, val; - for (i = 0; i < num_samples; i++) { - vol = *volume++; - for (j = 0; j < channels; j++) { - val = *data * vol; - *data++ = (gint16) CLAMP (val, VOLUME_MIN_INT16, VOLUME_MAX_INT16); + if (channels == 1) { + orc_process_controlled_int16_1ch (data, volume, num_samples); + } else if (channels == 2) { + orc_process_controlled_int16_2ch (data, volume, num_samples); + } else { + for (i = 0; i < num_samples; i++) { + vol = *volume++; + for (j = 0; j < channels; j++) { + val = *data * vol; + *data++ = (gint16) CLAMP (val, VOLUME_MIN_INT16, VOLUME_MAX_INT16); + } } } } @@ -837,11 +843,19 @@ volume_process_controlled_int8_clamp (GstVolume * self, gpointer bytes, guint num_samples = n_bytes / (sizeof (gint8) * channels); gdouble val, vol; - for (i = 0; i < num_samples; i++) { - vol = *volume++; - for (j = 0; j < channels; j++) { - val = *data * vol; - *data++ = (gint8) CLAMP (val, VOLUME_MIN_INT8, VOLUME_MAX_INT8); + if (channels == 1) { + orc_process_controlled_int8_1ch (data, volume, num_samples); + } else if (channels == 2) { + orc_process_controlled_int8_2ch (data, volume, num_samples); + } else if (channels == 4) { + orc_process_controlled_int8_4ch (data, volume, num_samples); + } else { + for (i = 0; i < num_samples; i++) { + vol = *volume++; + for (j = 0; j < channels; j++) { + val = *data * vol; + *data++ = (gint8) CLAMP (val, VOLUME_MIN_INT8, VOLUME_MAX_INT8); + } } } } diff --git a/gst/volume/gstvolumeorc.orc b/gst/volume/gstvolumeorc.orc index bd2b6e46b..31c0c8aba 100644 --- a/gst/volume/gstvolumeorc.orc +++ b/gst/volume/gstvolumeorc.orc @@ -33,7 +33,6 @@ mulswl t1, d1, p1 shrsl t1, t1, 13 convssslw d1, t1 - .function orc_process_int8 .dest 1 d1 gint8 .param 1 p1 @@ -91,3 +90,84 @@ mulf d1, d1, t1 convdf t1, s1 mergelq t2, t1, t1 x2 mulf d1, d1, t2 + +.function orc_process_controlled_int16_1ch +.dest 2 d1 gint16 +.source 8 s1 gdouble +.temp 8 t1 +.temp 4 t2 +.temp 2 t3 + +muld t1, s1, 0x40DFFFC000000000L +convdl t2, t1 +convssslw t3, t2 +mulswl t2, t3, d1 +shrsl t2, t2, 16 +convlw d1, t2 + +.function orc_process_controlled_int16_2ch +.dest 4 d1 gint16 +.source 8 s1 gdouble +.temp 8 t1 +.temp 4 t2 +.temp 2 t3 + +muld t1, s1, 0x40DFFFC000000000L +convdl t2, t1 +convssslw t3, t2 +mergewl t2, t3, t3 +x2 mulswl t1, t2, d1 +x2 shrsl t1, t1, 16 +x2 convlw d1, t1 + +.function orc_process_controlled_int8_1ch +.dest 1 d1 gint8 +.source 8 s1 gdouble +.temp 8 t1 +.temp 4 t2 +.temp 2 t3 +.temp 1 t4 + +muld t1, s1, 0x405FC00000000000L +convdl t2, t1 +convlw t3, t2 +convssswb t4, t3 +mulsbw t3, t4, d1 +shrsw t3, t3, 8 +convwb d1, t3 + +.function orc_process_controlled_int8_2ch +.dest 2 d1 gint8 +.source 8 s1 gdouble +.temp 8 t1 +.temp 4 t2 +.temp 2 t3 +.temp 1 t4 + +muld t1, s1, 0x405FC00000000000L +convdl t2, t1 +convlw t3, t2 +convssswb t4, t3 +mergebw t3, t4, t4 +x2 mulsbw t2, t3, d1 +x2 shrsw t2, t2, 8 +x2 convwb d1, t2 + +.function orc_process_controlled_int8_4ch +.dest 4 d1 gint8 +.source 8 s1 gdouble +.temp 8 t1 +.temp 4 t2 +.temp 2 t3 +.temp 1 t4 + +muld t1, s1, 0x405FC00000000000L +convdl t2, t1 +convlw t3, t2 +convssswb t4, t3 +mergebw t3, t4, t4 +mergewl t2, t3, t3 +x4 mulsbw t1, t2, d1 +x4 shrsw t1, t1, 8 +x4 convwb d1, t1 + |