volume: Implement int32 processing with orc
This commit is contained in:
parent
c11ee1a100
commit
39ef36b32c
@ -569,10 +569,13 @@ static void
|
|||||||
volume_process_int32 (GstVolume * self, gpointer bytes, guint n_bytes)
|
volume_process_int32 (GstVolume * self, gpointer bytes, guint n_bytes)
|
||||||
{
|
{
|
||||||
gint32 *data = (gint32 *) bytes;
|
gint32 *data = (gint32 *) bytes;
|
||||||
guint i, num_samples;
|
guint num_samples = n_bytes / sizeof (gint);
|
||||||
|
#ifndef USE_ORC
|
||||||
|
guint i;
|
||||||
gint64 val;
|
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++) {
|
for (i = 0; i < num_samples; i++) {
|
||||||
/* we use bitshifting instead of dividing by UNITY_INT for speed */
|
/* we use bitshifting instead of dividing by UNITY_INT for speed */
|
||||||
val = (gint64) * data;
|
val = (gint64) * data;
|
||||||
@ -581,16 +584,22 @@ volume_process_int32 (GstVolume * self, gpointer bytes, guint n_bytes)
|
|||||||
val) >> VOLUME_UNITY_INT32_BIT_SHIFT);
|
val) >> VOLUME_UNITY_INT32_BIT_SHIFT);
|
||||||
*data++ = (gint32) val;
|
*data++ = (gint32) val;
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
orc_process_int32 (data, self->current_vol_i32, num_samples);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
volume_process_int32_clamp (GstVolume * self, gpointer bytes, guint n_bytes)
|
volume_process_int32_clamp (GstVolume * self, gpointer bytes, guint n_bytes)
|
||||||
{
|
{
|
||||||
gint32 *data = (gint32 *) bytes;
|
gint32 *data = (gint32 *) bytes;
|
||||||
guint i, num_samples;
|
guint num_samples = n_bytes / sizeof (gint);
|
||||||
|
#ifndef USE_ORC
|
||||||
|
guint i;
|
||||||
gint64 val;
|
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++) {
|
for (i = 0; i < num_samples; i++) {
|
||||||
/* we use bitshifting instead of dividing by UNITY_INT for speed */
|
/* 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);
|
val) >> VOLUME_UNITY_INT32_BIT_SHIFT);
|
||||||
*data++ = (gint32) CLAMP (val, VOLUME_MIN_INT32, VOLUME_MAX_INT32);
|
*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
|
static void
|
||||||
@ -611,11 +623,15 @@ volume_process_controlled_int32_clamp (GstVolume * self, gpointer bytes,
|
|||||||
guint num_samples = n_bytes / (sizeof (gint32) * channels);
|
guint num_samples = n_bytes / (sizeof (gint32) * channels);
|
||||||
gdouble vol, val;
|
gdouble vol, val;
|
||||||
|
|
||||||
for (i = 0; i < num_samples; i++) {
|
if (channels == 1) {
|
||||||
vol = *volume++;
|
orc_process_controlled_int32_1ch (data, volume, num_samples);
|
||||||
for (j = 0; j < channels; j++) {
|
} else {
|
||||||
val = *data * vol;
|
for (i = 0; i < num_samples; i++) {
|
||||||
*data++ = (gint32) CLAMP (val, VOLUME_MIN_INT32, VOLUME_MAX_INT32);
|
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
|
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
|
.function orc_process_int16
|
||||||
.dest 2 d1 gint16
|
.dest 2 d1 gint16
|
||||||
@ -91,6 +108,18 @@ convdf t1, s1
|
|||||||
mergelq t2, t1, t1
|
mergelq t2, t1, t1
|
||||||
x2 mulf d1, d1, t2
|
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
|
.function orc_process_controlled_int16_1ch
|
||||||
.dest 2 d1 gint16
|
.dest 2 d1 gint16
|
||||||
.source 8 s1 gdouble
|
.source 8 s1 gdouble
|
||||||
|
Loading…
x
Reference in New Issue
Block a user