mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-03-01 17:31:10 +00:00
audiopanorama: use orc to speedup processing
Use special variants for the case when we don't change the panorama (pan=0.0). Simplify the processing functions by passing the panorama value directy instead of the instance. Use orc for clearing buffers too.
This commit is contained in:
parent
6e23f1fec4
commit
1dc06932a2
4 changed files with 382 additions and 233 deletions
|
@ -5,6 +5,9 @@ plugin_LTLIBRARIES = libgstaudiofx.la
|
||||||
# FIXME 0.11: ignore GValueArray warnings for now until this is sorted
|
# FIXME 0.11: ignore GValueArray warnings for now until this is sorted
|
||||||
ERROR_CFLAGS=
|
ERROR_CFLAGS=
|
||||||
|
|
||||||
|
ORC_SOURCE=audiopanoramaorc
|
||||||
|
include $(top_srcdir)/common/orc.mak
|
||||||
|
|
||||||
# sources used to compile this plug-in
|
# sources used to compile this plug-in
|
||||||
libgstaudiofx_la_SOURCES = audiofx.c\
|
libgstaudiofx_la_SOURCES = audiofx.c\
|
||||||
audiopanorama.c \
|
audiopanorama.c \
|
||||||
|
@ -22,16 +25,19 @@ libgstaudiofx_la_SOURCES = audiofx.c\
|
||||||
audiofirfilter.c \
|
audiofirfilter.c \
|
||||||
audioecho.c \
|
audioecho.c \
|
||||||
gstscaletempo.c
|
gstscaletempo.c
|
||||||
|
nodist_libgstaudiofx_la_SOURCES = $(ORC_NODIST_SOURCES)
|
||||||
|
|
||||||
# flags used to compile this plugin
|
# flags used to compile this plugin
|
||||||
libgstaudiofx_la_CFLAGS = $(GST_CFLAGS) \
|
libgstaudiofx_la_CFLAGS = $(GST_CFLAGS) \
|
||||||
$(GST_BASE_CFLAGS) \
|
$(GST_BASE_CFLAGS) \
|
||||||
$(GST_PLUGINS_BASE_CFLAGS)
|
$(GST_PLUGINS_BASE_CFLAGS) \
|
||||||
|
$(ORC_CFLAGS)
|
||||||
libgstaudiofx_la_LIBADD = $(GST_LIBS) \
|
libgstaudiofx_la_LIBADD = $(GST_LIBS) \
|
||||||
$(GST_BASE_LIBS) \
|
$(GST_BASE_LIBS) \
|
||||||
$(GST_PLUGINS_BASE_LIBS) \
|
$(GST_PLUGINS_BASE_LIBS) \
|
||||||
-lgstaudio-$(GST_API_VERSION) \
|
-lgstaudio-$(GST_API_VERSION) \
|
||||||
-lgstfft-$(GST_API_VERSION) \
|
-lgstfft-$(GST_API_VERSION) \
|
||||||
|
$(ORC_LIBS) \
|
||||||
$(LIBM)
|
$(LIBM)
|
||||||
libgstaudiofx_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
|
libgstaudiofx_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
|
||||||
libgstaudiofx_la_LIBTOOLFLAGS = $(GST_PLUGIN_LIBTOOLFLAGS)
|
libgstaudiofx_la_LIBTOOLFLAGS = $(GST_PLUGIN_LIBTOOLFLAGS)
|
||||||
|
|
|
@ -45,7 +45,14 @@
|
||||||
#include <gst/gst.h>
|
#include <gst/gst.h>
|
||||||
#include <gst/base/gstbasetransform.h>
|
#include <gst/base/gstbasetransform.h>
|
||||||
|
|
||||||
|
#ifdef HAVE_ORC
|
||||||
|
#include <orc/orcfunctions.h>
|
||||||
|
#else
|
||||||
|
#define orc_memset memset
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "audiopanorama.h"
|
#include "audiopanorama.h"
|
||||||
|
#include "audiopanoramaorc.h"
|
||||||
|
|
||||||
#define GST_CAT_DEFAULT gst_audio_panorama_debug
|
#define GST_CAT_DEFAULT gst_audio_panorama_debug
|
||||||
GST_DEBUG_CATEGORY_STATIC (GST_CAT_DEFAULT);
|
GST_DEBUG_CATEGORY_STATIC (GST_CAT_DEFAULT);
|
||||||
|
@ -109,23 +116,23 @@ static GstCaps *gst_audio_panorama_transform_caps (GstBaseTransform * base,
|
||||||
static gboolean gst_audio_panorama_set_caps (GstBaseTransform * base,
|
static gboolean gst_audio_panorama_set_caps (GstBaseTransform * base,
|
||||||
GstCaps * incaps, GstCaps * outcaps);
|
GstCaps * incaps, GstCaps * outcaps);
|
||||||
|
|
||||||
static void gst_audio_panorama_transform_m2s_int (GstAudioPanorama * filter,
|
static void gst_audio_panorama_m2s_int (gfloat pan,
|
||||||
gint16 * idata, gint16 * odata, guint num_samples);
|
gint16 * idata, gint16 * odata, guint num_samples);
|
||||||
static void gst_audio_panorama_transform_s2s_int (GstAudioPanorama * filter,
|
static void gst_audio_panorama_s2s_int (gfloat pan,
|
||||||
gint16 * idata, gint16 * odata, guint num_samples);
|
gint16 * idata, gint16 * odata, guint num_samples);
|
||||||
static void gst_audio_panorama_transform_m2s_float (GstAudioPanorama * filter,
|
static void gst_audio_panorama_m2s_float (gfloat pan,
|
||||||
gfloat * idata, gfloat * odata, guint num_samples);
|
gfloat * idata, gfloat * odata, guint num_samples);
|
||||||
static void gst_audio_panorama_transform_s2s_float (GstAudioPanorama * filter,
|
static void gst_audio_panorama_s2s_float (gfloat pan,
|
||||||
gfloat * idata, gfloat * odata, guint num_samples);
|
gfloat * idata, gfloat * odata, guint num_samples);
|
||||||
|
|
||||||
static void gst_audio_panorama_transform_m2s_int_simple (GstAudioPanorama *
|
static void gst_audio_panorama_m2s_int_simple (gfloat pan,
|
||||||
filter, gint16 * idata, gint16 * odata, guint num_samples);
|
gint16 * idata, gint16 * odata, guint num_samples);
|
||||||
static void gst_audio_panorama_transform_s2s_int_simple (GstAudioPanorama *
|
static void gst_audio_panorama_s2s_int_simple (gfloat pan,
|
||||||
filter, gint16 * idata, gint16 * odata, guint num_samples);
|
gint16 * idata, gint16 * odata, guint num_samples);
|
||||||
static void gst_audio_panorama_transform_m2s_float_simple (GstAudioPanorama *
|
static void gst_audio_panorama_m2s_float_simple (gfloat pan,
|
||||||
filter, gfloat * idata, gfloat * odata, guint num_samples);
|
gfloat * idata, gfloat * odata, guint num_samples);
|
||||||
static void gst_audio_panorama_transform_s2s_float_simple (GstAudioPanorama *
|
static void gst_audio_panorama_s2s_float_simple (gfloat pan,
|
||||||
filter, gfloat * idata, gfloat * odata, guint num_samples);
|
gfloat * idata, gfloat * odata, guint num_samples);
|
||||||
|
|
||||||
static GstFlowReturn gst_audio_panorama_transform (GstBaseTransform * base,
|
static GstFlowReturn gst_audio_panorama_transform (GstBaseTransform * base,
|
||||||
GstBuffer * inbuf, GstBuffer * outbuf);
|
GstBuffer * inbuf, GstBuffer * outbuf);
|
||||||
|
@ -134,20 +141,20 @@ static GstFlowReturn gst_audio_panorama_transform (GstBaseTransform * base,
|
||||||
/* Table with processing functions: [channels][format][method] */
|
/* Table with processing functions: [channels][format][method] */
|
||||||
static GstAudioPanoramaProcessFunc panorama_process_functions[2][2][2] = {
|
static GstAudioPanoramaProcessFunc panorama_process_functions[2][2][2] = {
|
||||||
{
|
{
|
||||||
{(GstAudioPanoramaProcessFunc) gst_audio_panorama_transform_m2s_int,
|
{
|
||||||
(GstAudioPanoramaProcessFunc)
|
(GstAudioPanoramaProcessFunc) gst_audio_panorama_m2s_int,
|
||||||
gst_audio_panorama_transform_m2s_int_simple},
|
(GstAudioPanoramaProcessFunc) gst_audio_panorama_m2s_int_simple},
|
||||||
{(GstAudioPanoramaProcessFunc) gst_audio_panorama_transform_m2s_float,
|
{
|
||||||
(GstAudioPanoramaProcessFunc)
|
(GstAudioPanoramaProcessFunc) gst_audio_panorama_m2s_float,
|
||||||
gst_audio_panorama_transform_m2s_float_simple}
|
(GstAudioPanoramaProcessFunc) gst_audio_panorama_m2s_float_simple}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
{(GstAudioPanoramaProcessFunc) gst_audio_panorama_transform_s2s_int,
|
{
|
||||||
(GstAudioPanoramaProcessFunc)
|
(GstAudioPanoramaProcessFunc) gst_audio_panorama_s2s_int,
|
||||||
gst_audio_panorama_transform_s2s_int_simple},
|
(GstAudioPanoramaProcessFunc) gst_audio_panorama_s2s_int_simple},
|
||||||
{(GstAudioPanoramaProcessFunc) gst_audio_panorama_transform_s2s_float,
|
{
|
||||||
(GstAudioPanoramaProcessFunc)
|
(GstAudioPanoramaProcessFunc) gst_audio_panorama_s2s_float,
|
||||||
gst_audio_panorama_transform_s2s_float_simple}
|
(GstAudioPanoramaProcessFunc) gst_audio_panorama_s2s_float_simple}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -366,250 +373,128 @@ no_format:
|
||||||
}
|
}
|
||||||
|
|
||||||
/* psychoacoustic processing functions */
|
/* psychoacoustic processing functions */
|
||||||
|
|
||||||
|
/* mono to stereo panning
|
||||||
|
* pan: -1.0 0.0 1.0
|
||||||
|
* l: 1.0 0.5 0.0
|
||||||
|
* r: 0.0 0.5 1.0
|
||||||
|
*
|
||||||
|
* FIXME: we should use -3db (1/sqtr(2)) for 50:50
|
||||||
|
*/
|
||||||
static void
|
static void
|
||||||
gst_audio_panorama_transform_m2s_int (GstAudioPanorama * filter, gint16 * idata,
|
gst_audio_panorama_m2s_int (gfloat pan, gint16 * idata, gint16 * odata, guint n)
|
||||||
gint16 * odata, guint num_samples)
|
|
||||||
{
|
{
|
||||||
guint i;
|
gfloat r = (pan + 1.0) / 2.0;
|
||||||
gdouble val;
|
audiopanoramam_orc_process_s16_ch1_psy (odata, idata, 1.0 - r, r, n);
|
||||||
glong lval, rval;
|
|
||||||
gdouble rpan, lpan;
|
|
||||||
|
|
||||||
/* pan: -1.0 0.0 1.0
|
|
||||||
* lpan: 1.0 0.5 0.0
|
|
||||||
* rpan: 0.0 0.5 1.0
|
|
||||||
*
|
|
||||||
* FIXME: we should use -3db (1/sqtr(2)) for 50:50
|
|
||||||
*/
|
|
||||||
rpan = (gdouble) (filter->panorama + 1.0) / 2.0;
|
|
||||||
lpan = 1.0 - rpan;
|
|
||||||
|
|
||||||
for (i = 0; i < num_samples; i++) {
|
|
||||||
val = (gdouble) * idata++;
|
|
||||||
|
|
||||||
lval = (glong) (val * lpan);
|
|
||||||
rval = (glong) (val * rpan);
|
|
||||||
|
|
||||||
*odata++ = (gint16) CLAMP (lval, G_MININT16, G_MAXINT16);
|
|
||||||
*odata++ = (gint16) CLAMP (rval, G_MININT16, G_MAXINT16);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_audio_panorama_transform_s2s_int (GstAudioPanorama * filter, gint16 * idata,
|
gst_audio_panorama_m2s_float (gfloat pan, gfloat * idata,
|
||||||
gint16 * odata, guint num_samples)
|
gfloat * odata, guint n)
|
||||||
{
|
{
|
||||||
guint i;
|
gfloat r = (pan + 1.0) / 2.0;
|
||||||
glong lval, rval;
|
audiopanoramam_orc_process_f32_ch1_psy (odata, idata, 1.0 - r, r, n);
|
||||||
gdouble lival, rival;
|
}
|
||||||
gdouble lrpan, llpan, rrpan, rlpan;
|
|
||||||
|
|
||||||
/* pan: -1.0 0.0 1.0
|
/* stereo balance
|
||||||
* llpan: 1.0 1.0 0.0
|
* pan: -1.0 0.0 1.0
|
||||||
* lrpan: 1.0 0.0 0.0
|
* ll: 1.0 1.0 0.0
|
||||||
* rrpan: 0.0 1.0 1.0
|
* lr: 1.0 0.0 0.0
|
||||||
* rlpan: 0.0 0.0 1.0
|
* rr: 0.0 1.0 1.0
|
||||||
*/
|
* rl: 0.0 0.0 1.0
|
||||||
if (filter->panorama > 0) {
|
*/
|
||||||
rlpan = (gdouble) filter->panorama;
|
static void
|
||||||
llpan = 1.0 - rlpan;
|
gst_audio_panorama_s2s_int (gfloat pan, gint16 * idata, gint16 * odata, guint n)
|
||||||
lrpan = 0.0;
|
{
|
||||||
rrpan = 1.0;
|
if (pan == 0.0) {
|
||||||
|
audiopanoramam_orc_process_s16_ch2_none (odata, idata, n);
|
||||||
|
} else if (pan > 0.0) {
|
||||||
|
gfloat rl = pan;
|
||||||
|
gfloat ll = 1.0 - rl;
|
||||||
|
audiopanoramam_orc_process_s16_ch2_psy_right (odata, idata, ll, rl, n);
|
||||||
} else {
|
} else {
|
||||||
rrpan = (gdouble) (1.0 + filter->panorama);
|
gfloat rr = 1.0 + pan;
|
||||||
lrpan = 1.0 - rrpan;
|
gfloat lr = 1.0 - rr;
|
||||||
rlpan = 0.0;
|
audiopanoramam_orc_process_s16_ch2_psy_left (odata, idata, lr, rr, n);
|
||||||
llpan = 1.0;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < num_samples; i++) {
|
|
||||||
lival = (gdouble) * idata++;
|
|
||||||
rival = (gdouble) * idata++;
|
|
||||||
|
|
||||||
lval = lival * llpan + rival * lrpan;
|
|
||||||
rval = lival * rlpan + rival * rrpan;
|
|
||||||
|
|
||||||
*odata++ = (gint16) CLAMP (lval, G_MININT16, G_MAXINT16);
|
|
||||||
*odata++ = (gint16) CLAMP (rval, G_MININT16, G_MAXINT16);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_audio_panorama_transform_m2s_float (GstAudioPanorama * filter,
|
gst_audio_panorama_s2s_float (gfloat pan, gfloat * idata,
|
||||||
gfloat * idata, gfloat * odata, guint num_samples)
|
gfloat * odata, guint n)
|
||||||
{
|
{
|
||||||
guint i;
|
if (pan == 0.0) {
|
||||||
gfloat val;
|
audiopanoramam_orc_process_f32_ch2_none (odata, idata, n);
|
||||||
gdouble rpan, lpan;
|
} else if (pan > 0.0) {
|
||||||
|
gfloat rl = pan;
|
||||||
/* pan: -1.0 0.0 1.0
|
gfloat ll = 1.0 - rl;
|
||||||
* lpan: 1.0 0.5 0.0
|
audiopanoramam_orc_process_f32_ch2_psy_right (odata, idata, ll, rl, n);
|
||||||
* rpan: 0.0 0.5 1.0
|
|
||||||
*
|
|
||||||
* FIXME: we should use -3db (1/sqtr(2)) for 50:50
|
|
||||||
*/
|
|
||||||
rpan = (gdouble) (filter->panorama + 1.0) / 2.0;
|
|
||||||
lpan = 1.0 - rpan;
|
|
||||||
|
|
||||||
for (i = 0; i < num_samples; i++) {
|
|
||||||
val = *idata++;
|
|
||||||
|
|
||||||
*odata++ = val * lpan;
|
|
||||||
*odata++ = val * rpan;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
gst_audio_panorama_transform_s2s_float (GstAudioPanorama * filter,
|
|
||||||
gfloat * idata, gfloat * odata, guint num_samples)
|
|
||||||
{
|
|
||||||
guint i;
|
|
||||||
gfloat lival, rival;
|
|
||||||
gdouble lrpan, llpan, rrpan, rlpan;
|
|
||||||
|
|
||||||
/* pan: -1.0 0.0 1.0
|
|
||||||
* llpan: 1.0 1.0 0.0
|
|
||||||
* lrpan: 1.0 0.0 0.0
|
|
||||||
* rrpan: 0.0 1.0 1.0
|
|
||||||
* rlpan: 0.0 0.0 1.0
|
|
||||||
*/
|
|
||||||
if (filter->panorama > 0) {
|
|
||||||
rlpan = (gdouble) filter->panorama;
|
|
||||||
llpan = 1.0 - rlpan;
|
|
||||||
lrpan = 0.0;
|
|
||||||
rrpan = 1.0;
|
|
||||||
} else {
|
} else {
|
||||||
rrpan = (gdouble) (1.0 + filter->panorama);
|
gfloat rr = 1.0 + pan;
|
||||||
lrpan = 1.0 - rrpan;
|
gfloat lr = 1.0 - rr;
|
||||||
rlpan = 0.0;
|
audiopanoramam_orc_process_f32_ch2_psy_left (odata, idata, lr, rr, n);
|
||||||
llpan = 1.0;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < num_samples; i++) {
|
|
||||||
lival = *idata++;
|
|
||||||
rival = *idata++;
|
|
||||||
|
|
||||||
*odata++ = lival * llpan + rival * lrpan;
|
|
||||||
*odata++ = lival * rlpan + rival * rrpan;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* simple processing functions */
|
/* simple processing functions */
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_audio_panorama_transform_m2s_int_simple (GstAudioPanorama * filter,
|
gst_audio_panorama_m2s_int_simple (gfloat pan, gint16 * idata,
|
||||||
gint16 * idata, gint16 * odata, guint num_samples)
|
gint16 * odata, guint n)
|
||||||
{
|
{
|
||||||
guint i;
|
if (pan == 0.0) {
|
||||||
gdouble pan;
|
audiopanoramam_orc_process_s16_ch1_none (odata, idata, n);
|
||||||
glong lval, rval;
|
} else if (pan > 0.0) {
|
||||||
|
gfloat lpan = 1.0 - pan;
|
||||||
if (filter->panorama > 0.0) {
|
audiopanoramam_orc_process_s16_ch1_sim_left (odata, idata, lpan, n);
|
||||||
pan = 1.0 - filter->panorama;
|
|
||||||
for (i = 0; i < num_samples; i++) {
|
|
||||||
rval = *idata++;
|
|
||||||
lval = (glong) ((gdouble) rval * pan);
|
|
||||||
|
|
||||||
*odata++ = (gint16) CLAMP (lval, G_MININT16, G_MAXINT16);
|
|
||||||
*odata++ = (gint16) rval;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
pan = 1.0 + filter->panorama;
|
gfloat rpan = 1.0 + pan;
|
||||||
for (i = 0; i < num_samples; i++) {
|
audiopanoramam_orc_process_s16_ch1_sim_right (odata, idata, rpan, n);
|
||||||
lval = *idata++;
|
|
||||||
rval = (glong) ((gdouble) lval * pan);
|
|
||||||
|
|
||||||
*odata++ = (gint16) lval;
|
|
||||||
*odata++ = (gint16) CLAMP (rval, G_MININT16, G_MAXINT16);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_audio_panorama_transform_s2s_int_simple (GstAudioPanorama * filter,
|
gst_audio_panorama_s2s_int_simple (gfloat pan, gint16 * idata,
|
||||||
gint16 * idata, gint16 * odata, guint num_samples)
|
gint16 * odata, guint n)
|
||||||
{
|
{
|
||||||
guint i;
|
if (pan == 0.0) {
|
||||||
glong lval, rval;
|
audiopanoramam_orc_process_s16_ch2_none (odata, idata, n);
|
||||||
gdouble lival, rival, pan;
|
} else if (pan > 0.0) {
|
||||||
|
gfloat lpan = 1.0 - pan;
|
||||||
if (filter->panorama > 0.0) {
|
audiopanoramam_orc_process_s16_ch2_sim_left (odata, idata, lpan, n);
|
||||||
pan = 1.0 - filter->panorama;
|
|
||||||
for (i = 0; i < num_samples; i++) {
|
|
||||||
lival = (gdouble) * idata++;
|
|
||||||
rival = (gdouble) * idata++;
|
|
||||||
|
|
||||||
lval = (glong) (lival * pan);
|
|
||||||
rval = (glong) rival;
|
|
||||||
|
|
||||||
*odata++ = (gint16) CLAMP (lval, G_MININT16, G_MAXINT16);
|
|
||||||
*odata++ = (gint16) rval;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
pan = 1.0 + filter->panorama;
|
gfloat rpan = 1.0 + pan;
|
||||||
for (i = 0; i < num_samples; i++) {
|
audiopanoramam_orc_process_s16_ch2_sim_right (odata, idata, rpan, n);
|
||||||
lival = (gdouble) * idata++;
|
|
||||||
rival = (gdouble) * idata++;
|
|
||||||
|
|
||||||
lval = (glong) lival;
|
|
||||||
rval = (glong) (rival * pan);
|
|
||||||
|
|
||||||
*odata++ = (gint16) lval;
|
|
||||||
*odata++ = (gint16) CLAMP (rval, G_MININT16, G_MAXINT16);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_audio_panorama_transform_m2s_float_simple (GstAudioPanorama * filter,
|
gst_audio_panorama_m2s_float_simple (gfloat pan, gfloat * idata,
|
||||||
gfloat * idata, gfloat * odata, guint num_samples)
|
gfloat * odata, guint n)
|
||||||
{
|
{
|
||||||
guint i;
|
if (pan == 0.0) {
|
||||||
gfloat val, pan;
|
audiopanoramam_orc_process_f32_ch1_none (odata, idata, n);
|
||||||
|
} else if (pan > 0.0) {
|
||||||
if (filter->panorama > 0.0) {
|
gfloat lpan = 1.0 - pan;
|
||||||
pan = 1.0 - filter->panorama;
|
audiopanoramam_orc_process_f32_ch1_sim_left (odata, idata, lpan, n);
|
||||||
for (i = 0; i < num_samples; i++) {
|
|
||||||
val = *idata++;
|
|
||||||
|
|
||||||
*odata++ = val * pan;
|
|
||||||
*odata++ = val;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
pan = 1.0 + filter->panorama;
|
gfloat rpan = 1.0 + pan;
|
||||||
for (i = 0; i < num_samples; i++) {
|
audiopanoramam_orc_process_f32_ch1_sim_right (odata, idata, rpan, n);
|
||||||
val = *idata++;
|
|
||||||
|
|
||||||
*odata++ = val;
|
|
||||||
*odata++ = val * pan;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_audio_panorama_transform_s2s_float_simple (GstAudioPanorama * filter,
|
gst_audio_panorama_s2s_float_simple (gfloat pan, gfloat * idata,
|
||||||
gfloat * idata, gfloat * odata, guint num_samples)
|
gfloat * odata, guint n)
|
||||||
{
|
{
|
||||||
guint i;
|
if (pan == 0.0) {
|
||||||
gfloat lival, rival, pan;
|
audiopanoramam_orc_process_f32_ch2_none (odata, idata, n);
|
||||||
|
} else if (pan > 0.0) {
|
||||||
if (filter->panorama > 0.0) {
|
gfloat lpan = 1.0 - pan;
|
||||||
pan = 1.0 - filter->panorama;
|
audiopanoramam_orc_process_f32_ch2_sim_left (odata, idata, lpan, n);
|
||||||
for (i = 0; i < num_samples; i++) {
|
|
||||||
lival = *idata++;
|
|
||||||
rival = *idata++;
|
|
||||||
|
|
||||||
*odata++ = lival * pan;
|
|
||||||
*odata++ = rival;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
pan = 1.0 + filter->panorama;
|
gfloat rpan = 1.0 + pan;
|
||||||
for (i = 0; i < num_samples; i++) {
|
audiopanoramam_orc_process_f32_ch2_sim_right (odata, idata, rpan, n);
|
||||||
lival = *idata++;
|
|
||||||
rival = *idata++;
|
|
||||||
|
|
||||||
*odata++ = lival;
|
|
||||||
*odata++ = rival * pan;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -638,13 +523,13 @@ gst_audio_panorama_transform (GstBaseTransform * base, GstBuffer * inbuf,
|
||||||
|
|
||||||
if (G_UNLIKELY (GST_BUFFER_FLAG_IS_SET (inbuf, GST_BUFFER_FLAG_GAP))) {
|
if (G_UNLIKELY (GST_BUFFER_FLAG_IS_SET (inbuf, GST_BUFFER_FLAG_GAP))) {
|
||||||
GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_FLAG_GAP);
|
GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_FLAG_GAP);
|
||||||
memset (outmap.data, 0, outmap.size);
|
orc_memset (outmap.data, 0, outmap.size);
|
||||||
} else {
|
} else {
|
||||||
/* output always stereo, input mono or stereo,
|
/* output always stereo, input mono or stereo,
|
||||||
* and info describes input format */
|
* and info describes input format */
|
||||||
guint num_samples = outmap.size / (2 * GST_AUDIO_INFO_BPS (&filter->info));
|
guint num_samples = outmap.size / (2 * GST_AUDIO_INFO_BPS (&filter->info));
|
||||||
|
|
||||||
filter->process (filter, inmap.data, outmap.data, num_samples);
|
filter->process (filter->panorama, inmap.data, outmap.data, num_samples);
|
||||||
}
|
}
|
||||||
|
|
||||||
gst_buffer_unmap (inbuf, &inmap);
|
gst_buffer_unmap (inbuf, &inmap);
|
||||||
|
|
|
@ -37,7 +37,7 @@ G_BEGIN_DECLS
|
||||||
typedef struct _GstAudioPanorama GstAudioPanorama;
|
typedef struct _GstAudioPanorama GstAudioPanorama;
|
||||||
typedef struct _GstAudioPanoramaClass GstAudioPanoramaClass;
|
typedef struct _GstAudioPanoramaClass GstAudioPanoramaClass;
|
||||||
|
|
||||||
typedef void (*GstAudioPanoramaProcessFunc)(GstAudioPanorama*, guint8*, guint8*, guint);
|
typedef void (*GstAudioPanoramaProcessFunc)(gfloat, guint8*, guint8*, guint);
|
||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
|
|
258
gst/audiofx/audiopanoramaorc.orc
Normal file
258
gst/audiofx/audiopanoramaorc.orc
Normal file
|
@ -0,0 +1,258 @@
|
||||||
|
# pass through functions
|
||||||
|
|
||||||
|
.function audiopanoramam_orc_process_s16_ch1_none
|
||||||
|
.source 2 s1 gint16
|
||||||
|
.dest 4 d1 gint16
|
||||||
|
|
||||||
|
mergewl d1 s1 s1
|
||||||
|
|
||||||
|
|
||||||
|
.function audiopanoramam_orc_process_f32_ch1_none
|
||||||
|
.source 4 s1 gfloat
|
||||||
|
.dest 8 d1 gfloat
|
||||||
|
|
||||||
|
mergelq d1 s1 s1
|
||||||
|
|
||||||
|
|
||||||
|
.function audiopanoramam_orc_process_s16_ch2_none
|
||||||
|
.source 4 s1 gint16
|
||||||
|
.dest 4 d1 gint16
|
||||||
|
|
||||||
|
x2 copyw d1 s1
|
||||||
|
|
||||||
|
|
||||||
|
.function audiopanoramam_orc_process_f32_ch2_none
|
||||||
|
.source 8 s1 gfloat
|
||||||
|
.dest 8 d1 gfloat
|
||||||
|
|
||||||
|
x2 copyl d1 s1
|
||||||
|
|
||||||
|
|
||||||
|
# psychoacoustic processing function
|
||||||
|
|
||||||
|
.function audiopanoramam_orc_process_s16_ch1_psy
|
||||||
|
.source 2 s1 gint16
|
||||||
|
.dest 4 d1 gint16
|
||||||
|
.floatparam 4 lpan
|
||||||
|
.floatparam 4 rpan
|
||||||
|
.temp 8 t1
|
||||||
|
.temp 4 left
|
||||||
|
.temp 4 right
|
||||||
|
|
||||||
|
convswl left s1
|
||||||
|
convlf left left
|
||||||
|
mulf right left rpan
|
||||||
|
mulf left left lpan
|
||||||
|
mergelq t1 left right
|
||||||
|
x2 convfl t1 t1
|
||||||
|
x2 convssslw d1 t1
|
||||||
|
|
||||||
|
|
||||||
|
.function audiopanoramam_orc_process_f32_ch1_psy
|
||||||
|
.source 4 s1 gfloat
|
||||||
|
.dest 8 d1 gfloat
|
||||||
|
.floatparam 4 lpan
|
||||||
|
.floatparam 4 rpan
|
||||||
|
.temp 4 left
|
||||||
|
.temp 4 right
|
||||||
|
|
||||||
|
mulf right s1 rpan
|
||||||
|
mulf left s1 lpan
|
||||||
|
mergelq d1 left right
|
||||||
|
|
||||||
|
|
||||||
|
.function audiopanoramam_orc_process_s16_ch2_psy_right
|
||||||
|
.source 4 s1 gint16
|
||||||
|
.dest 4 d1 gint16
|
||||||
|
.floatparam 4 llpan
|
||||||
|
.floatparam 4 rlpan
|
||||||
|
.temp 8 t1
|
||||||
|
.temp 4 left
|
||||||
|
.temp 4 right
|
||||||
|
.temp 4 right1
|
||||||
|
|
||||||
|
x2 convswl t1 s1
|
||||||
|
x2 convlf t1 t1
|
||||||
|
select0ql left t1
|
||||||
|
select1ql right t1
|
||||||
|
mulf right1 left rlpan
|
||||||
|
mulf left left llpan
|
||||||
|
addf right right1 right
|
||||||
|
mergelq t1 left right
|
||||||
|
x2 convfl t1 t1
|
||||||
|
x2 convssslw d1 t1
|
||||||
|
|
||||||
|
|
||||||
|
.function audiopanoramam_orc_process_s16_ch2_psy_left
|
||||||
|
.source 4 s1 gint16
|
||||||
|
.dest 4 d1 gint16
|
||||||
|
.floatparam 4 lrpan
|
||||||
|
.floatparam 4 rrpan
|
||||||
|
.temp 8 t1
|
||||||
|
.temp 4 left
|
||||||
|
.temp 4 left1
|
||||||
|
.temp 4 right
|
||||||
|
|
||||||
|
x2 convswl t1 s1
|
||||||
|
x2 convlf t1 t1
|
||||||
|
select0ql left t1
|
||||||
|
select1ql right t1
|
||||||
|
mulf left1 right lrpan
|
||||||
|
mulf right right rrpan
|
||||||
|
addf left left1 left
|
||||||
|
mergelq t1 left right
|
||||||
|
x2 convfl t1 t1
|
||||||
|
x2 convssslw d1 t1
|
||||||
|
|
||||||
|
|
||||||
|
.function audiopanoramam_orc_process_f32_ch2_psy_right
|
||||||
|
.source 8 s1 gfloat
|
||||||
|
.dest 8 d1 gfloat
|
||||||
|
.floatparam 4 llpan
|
||||||
|
.floatparam 4 rlpan
|
||||||
|
.temp 4 left
|
||||||
|
.temp 4 right
|
||||||
|
.temp 4 right1
|
||||||
|
|
||||||
|
select0ql left s1
|
||||||
|
select1ql right s1
|
||||||
|
mulf right1 left rlpan
|
||||||
|
mulf left left llpan
|
||||||
|
addf right right1 right
|
||||||
|
mergelq d1 left right
|
||||||
|
|
||||||
|
|
||||||
|
.function audiopanoramam_orc_process_f32_ch2_psy_left
|
||||||
|
.source 8 s1 gfloat
|
||||||
|
.dest 8 d1 gfloat
|
||||||
|
.floatparam 4 lrpan
|
||||||
|
.floatparam 4 rrpan
|
||||||
|
.temp 4 left
|
||||||
|
.temp 4 left1
|
||||||
|
.temp 4 right
|
||||||
|
|
||||||
|
select0ql left s1
|
||||||
|
select1ql right s1
|
||||||
|
mulf left1 right lrpan
|
||||||
|
mulf right right rrpan
|
||||||
|
addf left left1 left
|
||||||
|
mergelq d1 left right
|
||||||
|
|
||||||
|
# simple processing functions
|
||||||
|
|
||||||
|
.function audiopanoramam_orc_process_s16_ch1_sim_right
|
||||||
|
.source 2 s1 gint16
|
||||||
|
.dest 4 d1 gint16
|
||||||
|
.floatparam 4 rpan
|
||||||
|
.temp 8 t1
|
||||||
|
.temp 4 left
|
||||||
|
.temp 4 right
|
||||||
|
|
||||||
|
convswl left s1
|
||||||
|
convlf left left
|
||||||
|
mulf right left rpan
|
||||||
|
mergelq t1 left right
|
||||||
|
x2 convfl t1 t1
|
||||||
|
x2 convssslw d1 t1
|
||||||
|
|
||||||
|
|
||||||
|
.function audiopanoramam_orc_process_s16_ch1_sim_left
|
||||||
|
.source 2 s1 gint16
|
||||||
|
.dest 4 d1 gint16
|
||||||
|
.floatparam 4 lpan
|
||||||
|
.temp 8 t1
|
||||||
|
.temp 4 left
|
||||||
|
.temp 4 right
|
||||||
|
|
||||||
|
convswl right s1
|
||||||
|
convlf right right
|
||||||
|
mulf left right lpan
|
||||||
|
mergelq t1 left right
|
||||||
|
x2 convfl t1 t1
|
||||||
|
x2 convssslw d1 t1
|
||||||
|
|
||||||
|
|
||||||
|
.function audiopanoramam_orc_process_s16_ch2_sim_right
|
||||||
|
.source 4 s1 gint16
|
||||||
|
.dest 4 d1 gint16
|
||||||
|
.floatparam 4 rpan
|
||||||
|
.temp 8 t1
|
||||||
|
.temp 4 left
|
||||||
|
.temp 4 right
|
||||||
|
|
||||||
|
x2 convswl t1 s1
|
||||||
|
x2 convlf t1 t1
|
||||||
|
select0ql left t1
|
||||||
|
select1ql right t1
|
||||||
|
mulf right right rpan
|
||||||
|
mergelq t1 left right
|
||||||
|
x2 convfl t1 t1
|
||||||
|
x2 convssslw d1 t1
|
||||||
|
|
||||||
|
|
||||||
|
.function audiopanoramam_orc_process_s16_ch2_sim_left
|
||||||
|
.source 4 s1 gint16
|
||||||
|
.dest 4 d1 gint16
|
||||||
|
.floatparam 4 lpan
|
||||||
|
.temp 8 t1
|
||||||
|
.temp 4 left
|
||||||
|
.temp 4 right
|
||||||
|
|
||||||
|
x2 convswl t1 s1
|
||||||
|
x2 convlf t1 t1
|
||||||
|
select0ql left t1
|
||||||
|
select1ql right t1
|
||||||
|
mulf left left lpan
|
||||||
|
mergelq t1 left right
|
||||||
|
x2 convfl t1 t1
|
||||||
|
x2 convssslw d1 t1
|
||||||
|
|
||||||
|
|
||||||
|
.function audiopanoramam_orc_process_f32_ch1_sim_right
|
||||||
|
.source 4 s1 gfloat
|
||||||
|
.dest 8 d1 gfloat
|
||||||
|
.floatparam 4 rpan
|
||||||
|
.temp 4 left
|
||||||
|
.temp 4 right
|
||||||
|
|
||||||
|
copyl left s1
|
||||||
|
mulf right s1 rpan
|
||||||
|
mergelq d1 left right
|
||||||
|
|
||||||
|
|
||||||
|
.function audiopanoramam_orc_process_f32_ch1_sim_left
|
||||||
|
.source 4 s1 gfloat
|
||||||
|
.dest 8 d1 gfloat
|
||||||
|
.floatparam 4 lpan
|
||||||
|
.temp 4 left
|
||||||
|
.temp 4 right
|
||||||
|
|
||||||
|
mulf left s1 lpan
|
||||||
|
copyl right s1
|
||||||
|
mergelq d1 left right
|
||||||
|
|
||||||
|
|
||||||
|
.function audiopanoramam_orc_process_f32_ch2_sim_right
|
||||||
|
.source 8 s1 gfloat
|
||||||
|
.dest 8 d1 gfloat
|
||||||
|
.floatparam 4 rpan
|
||||||
|
.temp 4 left
|
||||||
|
.temp 4 right
|
||||||
|
|
||||||
|
select0ql left s1
|
||||||
|
select1ql right s1
|
||||||
|
mulf right right rpan
|
||||||
|
mergelq d1 left right
|
||||||
|
|
||||||
|
.function audiopanoramam_orc_process_f32_ch2_sim_left
|
||||||
|
.source 8 s1 gfloat
|
||||||
|
.dest 8 d1 gfloat
|
||||||
|
.floatparam 4 lpan
|
||||||
|
.temp 4 left
|
||||||
|
.temp 4 right
|
||||||
|
|
||||||
|
select0ql left s1
|
||||||
|
select1ql right s1
|
||||||
|
mulf left left lpan
|
||||||
|
mergelq d1 left right
|
||||||
|
|
Loading…
Reference in a new issue