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;
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 */
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
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);
+ }
}
}
}
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
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