audiopanorama: move invariant check out of the inner loop

Improves performance for simple method.
This commit is contained in:
Stefan Kost 2010-03-11 10:33:00 +02:00
parent cf6d4cd94e
commit f405f9c775

View file

@ -537,23 +537,28 @@ gst_audio_panorama_transform_m2s_int_simple (GstAudioPanorama * filter,
gint16 * idata, gint16 * odata, guint num_samples) gint16 * idata, gint16 * odata, guint num_samples)
{ {
guint i; guint i;
gdouble val; gdouble pan;
glong lval, rval; glong lval, rval;
for (i = 0; i < num_samples; i++) {
val = (gdouble) * idata++;
if (filter->panorama > 0.0) { if (filter->panorama > 0.0) {
lval = (glong) (val * (1.0 - filter->panorama)); pan = 1.0 - filter->panorama;
rval = (glong) val; for (i = 0; i < num_samples; i++) {
} else { rval = *idata++;
lval = (glong) val; lval = (glong) ((gdouble) rval * pan);
rval = (glong) (val * (1.0 + filter->panorama));
}
*odata++ = (gint16) CLAMP (lval, G_MININT16, G_MAXINT16); *odata++ = (gint16) CLAMP (lval, G_MININT16, G_MAXINT16);
*odata++ = (gint16) rval;
}
} else {
pan = 1.0 + filter->panorama;
for (i = 0; i < num_samples; i++) {
lval = *idata++;
rval = (glong) ((gdouble) lval * pan);
*odata++ = (gint16) lval;
*odata++ = (gint16) CLAMP (rval, G_MININT16, G_MAXINT16); *odata++ = (gint16) CLAMP (rval, G_MININT16, G_MAXINT16);
} }
}
} }
static void static void
@ -562,23 +567,33 @@ gst_audio_panorama_transform_s2s_int_simple (GstAudioPanorama * filter,
{ {
guint i; guint i;
glong lval, rval; glong lval, rval;
gdouble lival, rival; gdouble lival, rival, pan;
if (filter->panorama > 0.0) {
pan = 1.0 - filter->panorama;
for (i = 0; i < num_samples; i++) { for (i = 0; i < num_samples; i++) {
lival = (gdouble) * idata++; lival = (gdouble) * idata++;
rival = (gdouble) * idata++; rival = (gdouble) * idata++;
if (filter->panorama > 0.0) { lval = (glong) (lival * pan);
lval = (glong) (lival * (1.0 - filter->panorama));
rval = (glong) rival; rval = (glong) rival;
} else {
lval = (glong) lival;
rval = (glong) (rival * (1.0 + filter->panorama));
}
*odata++ = (gint16) CLAMP (lval, G_MININT16, G_MAXINT16); *odata++ = (gint16) CLAMP (lval, G_MININT16, G_MAXINT16);
*odata++ = (gint16) rval;
}
} else {
pan = 1.0 + filter->panorama;
for (i = 0; i < num_samples; i++) {
lival = (gdouble) * idata++;
rival = (gdouble) * idata++;
lval = (glong) lival;
rval = (glong) (rival * pan);
*odata++ = (gint16) lval;
*odata++ = (gint16) CLAMP (rval, G_MININT16, G_MAXINT16); *odata++ = (gint16) CLAMP (rval, G_MININT16, G_MAXINT16);
} }
}
} }
static void static void
@ -586,18 +601,23 @@ gst_audio_panorama_transform_m2s_float_simple (GstAudioPanorama * filter,
gfloat * idata, gfloat * odata, guint num_samples) gfloat * idata, gfloat * odata, guint num_samples)
{ {
guint i; guint i;
gfloat val; gfloat val, pan;
if (filter->panorama > 0.0) {
pan = 1.0 - filter->panorama;
for (i = 0; i < num_samples; i++) { for (i = 0; i < num_samples; i++) {
val = *idata++; val = *idata++;
if (filter->panorama > 0.0) { *odata++ = val * pan;
*odata++ = val * (1.0 - filter->panorama);
*odata++ = val; *odata++ = val;
}
} else { } else {
pan = 1.0 + filter->panorama;
for (i = 0; i < num_samples; i++) {
val = *idata++;
*odata++ = val; *odata++ = val;
*odata++ = val * (1.0 + filter->panorama); *odata++ = val * pan;
} }
} }
} }
@ -607,18 +627,25 @@ gst_audio_panorama_transform_s2s_float_simple (GstAudioPanorama * filter,
gfloat * idata, gfloat * odata, guint num_samples) gfloat * idata, gfloat * odata, guint num_samples)
{ {
guint i; guint i;
gfloat lival, rival; gfloat lival, rival, pan;
if (filter->panorama > 0.0) {
pan = 1.0 - filter->panorama;
for (i = 0; i < num_samples; i++) { for (i = 0; i < num_samples; i++) {
lival = *idata++; lival = *idata++;
rival = *idata++; rival = *idata++;
if (filter->panorama > 0.0) { *odata++ = lival * pan;
*odata++ = lival * (1.0 - filter->panorama);
*odata++ = rival; *odata++ = rival;
}
} else { } else {
pan = 1.0 + filter->panorama;
for (i = 0; i < num_samples; i++) {
lival = *idata++;
rival = *idata++;
*odata++ = lival; *odata++ = lival;
*odata++ = rival * (1.0 + filter->panorama); *odata++ = rival * pan;
} }
} }
} }