Commit 39ef36b3 authored by Sebastian Dröge's avatar Sebastian Dröge
Browse files

volume: Implement int32 processing with orc

parent c11ee1a1
......@@ -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);
}
}
}
}
......
......@@ -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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment