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);
+ }
}
}
}
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);
+ }
}
}
}
shrsl t1, t1, 13
convssslw d1, t1
-
.function orc_process_int8
.dest 1 d1 gint8
.param 1 p1
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
+