mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-24 01:00:37 +00:00
volume: Implement controlled processing for int16/1-2ch and int8/1,2,4ch with orc
This commit is contained in:
parent
0bf4abe581
commit
c11ee1a100
2 changed files with 105 additions and 11 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in a new issue