gst/audioconvert/: Implement a channel mixer.
Original commit message from CVS:
* gst/audioconvert/Makefile.am:
* gst/audioconvert/gstaudioconvert.c: (gst_audio_convert_init),
(gst_audio_convert_link), (gst_audio_convert_change_state),
(gst_audio_convert_channels):
* gst/audioconvert/gstchannelmix.c:
(gst_audio_convert_unset_matrix),
(gst_audio_convert_fill_identical),
(gst_audio_convert_fill_compatible),
(gst_audio_convert_detect_pos), (gst_audio_convert_fill_one_other),
(gst_audio_convert_fill_others),
(gst_audio_convert_fill_normalize),
(gst_audio_convert_fill_matrix), (gst_audio_convert_setup_matrix),
(gst_audio_convert_passthrough), (gst_audio_convert_mix):
* gst/audioconvert/gstchannelmix.h:
Implement a channel mixer.
2004-11-28 16:09:13 +00:00
|
|
|
/* GStreamer
|
|
|
|
* Copyright (C) 2004 Ronald Bultje <rbultje@ronald.bitfreak.net>
|
2008-05-29 11:34:09 +00:00
|
|
|
* Copyright (C) 2008 Sebastian Dröge <slomo@circular-chaos.org>
|
gst/audioconvert/: Implement a channel mixer.
Original commit message from CVS:
* gst/audioconvert/Makefile.am:
* gst/audioconvert/gstaudioconvert.c: (gst_audio_convert_init),
(gst_audio_convert_link), (gst_audio_convert_change_state),
(gst_audio_convert_channels):
* gst/audioconvert/gstchannelmix.c:
(gst_audio_convert_unset_matrix),
(gst_audio_convert_fill_identical),
(gst_audio_convert_fill_compatible),
(gst_audio_convert_detect_pos), (gst_audio_convert_fill_one_other),
(gst_audio_convert_fill_others),
(gst_audio_convert_fill_normalize),
(gst_audio_convert_fill_matrix), (gst_audio_convert_setup_matrix),
(gst_audio_convert_passthrough), (gst_audio_convert_mix):
* gst/audioconvert/gstchannelmix.h:
Implement a channel mixer.
2004-11-28 16:09:13 +00:00
|
|
|
*
|
2016-01-08 15:22:25 +00:00
|
|
|
* audio-channel-mixer.c: setup of channel conversion matrices
|
gst/audioconvert/: Implement a channel mixer.
Original commit message from CVS:
* gst/audioconvert/Makefile.am:
* gst/audioconvert/gstaudioconvert.c: (gst_audio_convert_init),
(gst_audio_convert_link), (gst_audio_convert_change_state),
(gst_audio_convert_channels):
* gst/audioconvert/gstchannelmix.c:
(gst_audio_convert_unset_matrix),
(gst_audio_convert_fill_identical),
(gst_audio_convert_fill_compatible),
(gst_audio_convert_detect_pos), (gst_audio_convert_fill_one_other),
(gst_audio_convert_fill_others),
(gst_audio_convert_fill_normalize),
(gst_audio_convert_fill_matrix), (gst_audio_convert_setup_matrix),
(gst_audio_convert_passthrough), (gst_audio_convert_mix):
* gst/audioconvert/gstchannelmix.h:
Implement a channel mixer.
2004-11-28 16:09:13 +00:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the
|
2012-11-03 23:05:09 +00:00
|
|
|
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
gst/audioconvert/: Implement a channel mixer.
Original commit message from CVS:
* gst/audioconvert/Makefile.am:
* gst/audioconvert/gstaudioconvert.c: (gst_audio_convert_init),
(gst_audio_convert_link), (gst_audio_convert_change_state),
(gst_audio_convert_channels):
* gst/audioconvert/gstchannelmix.c:
(gst_audio_convert_unset_matrix),
(gst_audio_convert_fill_identical),
(gst_audio_convert_fill_compatible),
(gst_audio_convert_detect_pos), (gst_audio_convert_fill_one_other),
(gst_audio_convert_fill_others),
(gst_audio_convert_fill_normalize),
(gst_audio_convert_fill_matrix), (gst_audio_convert_setup_matrix),
(gst_audio_convert_passthrough), (gst_audio_convert_mix):
* gst/audioconvert/gstchannelmix.h:
Implement a channel mixer.
2004-11-28 16:09:13 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <math.h>
|
2004-11-28 20:41:23 +00:00
|
|
|
#include <string.h>
|
gst/audioconvert/: Implement a channel mixer.
Original commit message from CVS:
* gst/audioconvert/Makefile.am:
* gst/audioconvert/gstaudioconvert.c: (gst_audio_convert_init),
(gst_audio_convert_link), (gst_audio_convert_change_state),
(gst_audio_convert_channels):
* gst/audioconvert/gstchannelmix.c:
(gst_audio_convert_unset_matrix),
(gst_audio_convert_fill_identical),
(gst_audio_convert_fill_compatible),
(gst_audio_convert_detect_pos), (gst_audio_convert_fill_one_other),
(gst_audio_convert_fill_others),
(gst_audio_convert_fill_normalize),
(gst_audio_convert_fill_matrix), (gst_audio_convert_setup_matrix),
(gst_audio_convert_passthrough), (gst_audio_convert_mix):
* gst/audioconvert/gstchannelmix.h:
Implement a channel mixer.
2004-11-28 16:09:13 +00:00
|
|
|
|
2016-01-08 15:22:25 +00:00
|
|
|
#include "audio-channel-mixer.h"
|
gst/audioconvert/: Implement a channel mixer.
Original commit message from CVS:
* gst/audioconvert/Makefile.am:
* gst/audioconvert/gstaudioconvert.c: (gst_audio_convert_init),
(gst_audio_convert_link), (gst_audio_convert_change_state),
(gst_audio_convert_channels):
* gst/audioconvert/gstchannelmix.c:
(gst_audio_convert_unset_matrix),
(gst_audio_convert_fill_identical),
(gst_audio_convert_fill_compatible),
(gst_audio_convert_detect_pos), (gst_audio_convert_fill_one_other),
(gst_audio_convert_fill_others),
(gst_audio_convert_fill_normalize),
(gst_audio_convert_fill_matrix), (gst_audio_convert_setup_matrix),
(gst_audio_convert_passthrough), (gst_audio_convert_mix):
* gst/audioconvert/gstchannelmix.h:
Implement a channel mixer.
2004-11-28 16:09:13 +00:00
|
|
|
|
2015-11-06 16:29:22 +00:00
|
|
|
#ifndef GST_DISABLE_GST_DEBUG
|
|
|
|
#define GST_CAT_DEFAULT ensure_debug_category()
|
|
|
|
static GstDebugCategory *
|
|
|
|
ensure_debug_category (void)
|
|
|
|
{
|
|
|
|
static gsize cat_gonce = 0;
|
|
|
|
|
|
|
|
if (g_once_init_enter (&cat_gonce)) {
|
|
|
|
gsize cat_done;
|
|
|
|
|
2016-01-08 15:22:25 +00:00
|
|
|
cat_done = (gsize) _gst_debug_category_new ("audio-channel-mixer", 0,
|
|
|
|
"audio-channel-mixer object");
|
2015-11-06 16:29:22 +00:00
|
|
|
|
|
|
|
g_once_init_leave (&cat_gonce, cat_done);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (GstDebugCategory *) cat_gonce;
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
#define ensure_debug_category() /* NOOP */
|
|
|
|
#endif /* GST_DISABLE_GST_DEBUG */
|
|
|
|
|
|
|
|
|
2016-01-12 14:56:36 +00:00
|
|
|
#define PRECISION_INT 10
|
2015-03-30 09:24:46 +00:00
|
|
|
|
2018-01-31 17:28:57 +00:00
|
|
|
typedef void (*MixerFunc) (GstAudioChannelMixer * mix, const gpointer src[],
|
|
|
|
gpointer dst[], gint samples);
|
2015-11-06 15:03:20 +00:00
|
|
|
|
2016-01-08 15:22:25 +00:00
|
|
|
struct _GstAudioChannelMixer
|
2015-10-27 12:24:31 +00:00
|
|
|
{
|
|
|
|
gint in_channels;
|
|
|
|
gint out_channels;
|
|
|
|
|
|
|
|
/* channel conversion matrix, m[in_channels][out_channels].
|
|
|
|
* If identity matrix, passthrough applies. */
|
|
|
|
gfloat **matrix;
|
gst/audioconvert/: Implement a channel mixer.
Original commit message from CVS:
* gst/audioconvert/Makefile.am:
* gst/audioconvert/gstaudioconvert.c: (gst_audio_convert_init),
(gst_audio_convert_link), (gst_audio_convert_change_state),
(gst_audio_convert_channels):
* gst/audioconvert/gstchannelmix.c:
(gst_audio_convert_unset_matrix),
(gst_audio_convert_fill_identical),
(gst_audio_convert_fill_compatible),
(gst_audio_convert_detect_pos), (gst_audio_convert_fill_one_other),
(gst_audio_convert_fill_others),
(gst_audio_convert_fill_normalize),
(gst_audio_convert_fill_matrix), (gst_audio_convert_setup_matrix),
(gst_audio_convert_passthrough), (gst_audio_convert_mix):
* gst/audioconvert/gstchannelmix.h:
Implement a channel mixer.
2004-11-28 16:09:13 +00:00
|
|
|
|
2015-10-27 12:24:31 +00:00
|
|
|
/* channel conversion matrix with int values, m[in_channels][out_channels].
|
|
|
|
* this is matrix * (2^10) as integers */
|
|
|
|
gint **matrix_int;
|
|
|
|
|
2016-01-08 15:22:25 +00:00
|
|
|
MixerFunc func;
|
2015-10-27 12:24:31 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2016-01-08 15:22:25 +00:00
|
|
|
* gst_audio_channel_mixer_free:
|
|
|
|
* @mix: a #GstAudioChannelMixer
|
2015-10-27 12:24:31 +00:00
|
|
|
*
|
|
|
|
* Free memory allocated by @mix.
|
|
|
|
*/
|
gst/audioconvert/: Implement a channel mixer.
Original commit message from CVS:
* gst/audioconvert/Makefile.am:
* gst/audioconvert/gstaudioconvert.c: (gst_audio_convert_init),
(gst_audio_convert_link), (gst_audio_convert_change_state),
(gst_audio_convert_channels):
* gst/audioconvert/gstchannelmix.c:
(gst_audio_convert_unset_matrix),
(gst_audio_convert_fill_identical),
(gst_audio_convert_fill_compatible),
(gst_audio_convert_detect_pos), (gst_audio_convert_fill_one_other),
(gst_audio_convert_fill_others),
(gst_audio_convert_fill_normalize),
(gst_audio_convert_fill_matrix), (gst_audio_convert_setup_matrix),
(gst_audio_convert_passthrough), (gst_audio_convert_mix):
* gst/audioconvert/gstchannelmix.h:
Implement a channel mixer.
2004-11-28 16:09:13 +00:00
|
|
|
void
|
2016-01-08 15:22:25 +00:00
|
|
|
gst_audio_channel_mixer_free (GstAudioChannelMixer * mix)
|
gst/audioconvert/: Implement a channel mixer.
Original commit message from CVS:
* gst/audioconvert/Makefile.am:
* gst/audioconvert/gstaudioconvert.c: (gst_audio_convert_init),
(gst_audio_convert_link), (gst_audio_convert_change_state),
(gst_audio_convert_channels):
* gst/audioconvert/gstchannelmix.c:
(gst_audio_convert_unset_matrix),
(gst_audio_convert_fill_identical),
(gst_audio_convert_fill_compatible),
(gst_audio_convert_detect_pos), (gst_audio_convert_fill_one_other),
(gst_audio_convert_fill_others),
(gst_audio_convert_fill_normalize),
(gst_audio_convert_fill_matrix), (gst_audio_convert_setup_matrix),
(gst_audio_convert_passthrough), (gst_audio_convert_mix):
* gst/audioconvert/gstchannelmix.h:
Implement a channel mixer.
2004-11-28 16:09:13 +00:00
|
|
|
{
|
|
|
|
gint i;
|
|
|
|
|
|
|
|
/* free */
|
2015-10-27 12:24:31 +00:00
|
|
|
for (i = 0; i < mix->in_channels; i++)
|
|
|
|
g_free (mix->matrix[i]);
|
|
|
|
g_free (mix->matrix);
|
|
|
|
mix->matrix = NULL;
|
2015-03-30 09:24:46 +00:00
|
|
|
|
2015-10-27 12:24:31 +00:00
|
|
|
for (i = 0; i < mix->in_channels; i++)
|
|
|
|
g_free (mix->matrix_int[i]);
|
|
|
|
g_free (mix->matrix_int);
|
|
|
|
mix->matrix_int = NULL;
|
2015-03-30 09:24:46 +00:00
|
|
|
|
2016-01-08 15:22:25 +00:00
|
|
|
g_slice_free (GstAudioChannelMixer, mix);
|
gst/audioconvert/: Implement a channel mixer.
Original commit message from CVS:
* gst/audioconvert/Makefile.am:
* gst/audioconvert/gstaudioconvert.c: (gst_audio_convert_init),
(gst_audio_convert_link), (gst_audio_convert_change_state),
(gst_audio_convert_channels):
* gst/audioconvert/gstchannelmix.c:
(gst_audio_convert_unset_matrix),
(gst_audio_convert_fill_identical),
(gst_audio_convert_fill_compatible),
(gst_audio_convert_detect_pos), (gst_audio_convert_fill_one_other),
(gst_audio_convert_fill_others),
(gst_audio_convert_fill_normalize),
(gst_audio_convert_fill_matrix), (gst_audio_convert_setup_matrix),
(gst_audio_convert_passthrough), (gst_audio_convert_mix):
* gst/audioconvert/gstchannelmix.h:
Implement a channel mixer.
2004-11-28 16:09:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Detect and fill in identical channels. E.g.
|
|
|
|
* forward the left/right front channels in a
|
|
|
|
* 5.1 to 2.0 conversion.
|
|
|
|
*/
|
|
|
|
|
|
|
|
static void
|
2017-08-14 23:29:57 +00:00
|
|
|
gst_audio_channel_mixer_fill_identical (gfloat ** matrix,
|
|
|
|
gint in_channels, GstAudioChannelPosition * in_position, gint out_channels,
|
|
|
|
GstAudioChannelPosition * out_position, GstAudioChannelMixerFlags flags)
|
gst/audioconvert/: Implement a channel mixer.
Original commit message from CVS:
* gst/audioconvert/Makefile.am:
* gst/audioconvert/gstaudioconvert.c: (gst_audio_convert_init),
(gst_audio_convert_link), (gst_audio_convert_change_state),
(gst_audio_convert_channels):
* gst/audioconvert/gstchannelmix.c:
(gst_audio_convert_unset_matrix),
(gst_audio_convert_fill_identical),
(gst_audio_convert_fill_compatible),
(gst_audio_convert_detect_pos), (gst_audio_convert_fill_one_other),
(gst_audio_convert_fill_others),
(gst_audio_convert_fill_normalize),
(gst_audio_convert_fill_matrix), (gst_audio_convert_setup_matrix),
(gst_audio_convert_passthrough), (gst_audio_convert_mix):
* gst/audioconvert/gstchannelmix.h:
Implement a channel mixer.
2004-11-28 16:09:13 +00:00
|
|
|
{
|
|
|
|
gint ci, co;
|
|
|
|
|
|
|
|
/* Apart from the compatible channel assignments, we can also have
|
|
|
|
* same channel assignments. This is much simpler, we simply copy
|
|
|
|
* the value from source to dest! */
|
2017-08-14 23:29:57 +00:00
|
|
|
for (co = 0; co < out_channels; co++) {
|
gst/audioconvert/: Implement a channel mixer.
Original commit message from CVS:
* gst/audioconvert/Makefile.am:
* gst/audioconvert/gstaudioconvert.c: (gst_audio_convert_init),
(gst_audio_convert_link), (gst_audio_convert_change_state),
(gst_audio_convert_channels):
* gst/audioconvert/gstchannelmix.c:
(gst_audio_convert_unset_matrix),
(gst_audio_convert_fill_identical),
(gst_audio_convert_fill_compatible),
(gst_audio_convert_detect_pos), (gst_audio_convert_fill_one_other),
(gst_audio_convert_fill_others),
(gst_audio_convert_fill_normalize),
(gst_audio_convert_fill_matrix), (gst_audio_convert_setup_matrix),
(gst_audio_convert_passthrough), (gst_audio_convert_mix):
* gst/audioconvert/gstchannelmix.h:
Implement a channel mixer.
2004-11-28 16:09:13 +00:00
|
|
|
/* find a channel in input with same position */
|
2017-08-14 23:29:57 +00:00
|
|
|
for (ci = 0; ci < in_channels; ci++) {
|
|
|
|
/* If the input was unpositioned, we're simply building
|
|
|
|
* an identity matrix */
|
|
|
|
if (flags & GST_AUDIO_CHANNEL_MIXER_FLAGS_UNPOSITIONED_IN) {
|
|
|
|
matrix[ci][co] = ci == co ? 1.0 : 0.0;
|
|
|
|
} else if (in_position[ci] == out_position[co]) {
|
|
|
|
matrix[ci][co] = 1.0;
|
gst/audioconvert/: Implement a channel mixer.
Original commit message from CVS:
* gst/audioconvert/Makefile.am:
* gst/audioconvert/gstaudioconvert.c: (gst_audio_convert_init),
(gst_audio_convert_link), (gst_audio_convert_change_state),
(gst_audio_convert_channels):
* gst/audioconvert/gstchannelmix.c:
(gst_audio_convert_unset_matrix),
(gst_audio_convert_fill_identical),
(gst_audio_convert_fill_compatible),
(gst_audio_convert_detect_pos), (gst_audio_convert_fill_one_other),
(gst_audio_convert_fill_others),
(gst_audio_convert_fill_normalize),
(gst_audio_convert_fill_matrix), (gst_audio_convert_setup_matrix),
(gst_audio_convert_passthrough), (gst_audio_convert_mix):
* gst/audioconvert/gstchannelmix.h:
Implement a channel mixer.
2004-11-28 16:09:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Detect and fill in compatible channels. E.g.
|
|
|
|
* forward left/right front to mono (or the other
|
|
|
|
* way around) when going from 2.0 to 1.0.
|
|
|
|
*/
|
|
|
|
|
|
|
|
static void
|
2017-08-14 23:29:57 +00:00
|
|
|
gst_audio_channel_mixer_fill_compatible (gfloat ** matrix, gint in_channels,
|
|
|
|
GstAudioChannelPosition * in_position, gint out_channels,
|
|
|
|
GstAudioChannelPosition * out_position)
|
gst/audioconvert/: Implement a channel mixer.
Original commit message from CVS:
* gst/audioconvert/Makefile.am:
* gst/audioconvert/gstaudioconvert.c: (gst_audio_convert_init),
(gst_audio_convert_link), (gst_audio_convert_change_state),
(gst_audio_convert_channels):
* gst/audioconvert/gstchannelmix.c:
(gst_audio_convert_unset_matrix),
(gst_audio_convert_fill_identical),
(gst_audio_convert_fill_compatible),
(gst_audio_convert_detect_pos), (gst_audio_convert_fill_one_other),
(gst_audio_convert_fill_others),
(gst_audio_convert_fill_normalize),
(gst_audio_convert_fill_matrix), (gst_audio_convert_setup_matrix),
(gst_audio_convert_passthrough), (gst_audio_convert_mix):
* gst/audioconvert/gstchannelmix.h:
Implement a channel mixer.
2004-11-28 16:09:13 +00:00
|
|
|
{
|
|
|
|
/* Conversions from one-channel to compatible two-channel configs */
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
GstAudioChannelPosition pos1[2];
|
|
|
|
GstAudioChannelPosition pos2[1];
|
|
|
|
} conv[] = {
|
|
|
|
/* front: mono <-> stereo */
|
|
|
|
{ {
|
|
|
|
GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT,
|
|
|
|
GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT}, {
|
2011-12-19 11:41:24 +00:00
|
|
|
GST_AUDIO_CHANNEL_POSITION_MONO}},
|
gst/audioconvert/: Implement a channel mixer.
Original commit message from CVS:
* gst/audioconvert/Makefile.am:
* gst/audioconvert/gstaudioconvert.c: (gst_audio_convert_init),
(gst_audio_convert_link), (gst_audio_convert_change_state),
(gst_audio_convert_channels):
* gst/audioconvert/gstchannelmix.c:
(gst_audio_convert_unset_matrix),
(gst_audio_convert_fill_identical),
(gst_audio_convert_fill_compatible),
(gst_audio_convert_detect_pos), (gst_audio_convert_fill_one_other),
(gst_audio_convert_fill_others),
(gst_audio_convert_fill_normalize),
(gst_audio_convert_fill_matrix), (gst_audio_convert_setup_matrix),
(gst_audio_convert_passthrough), (gst_audio_convert_mix):
* gst/audioconvert/gstchannelmix.h:
Implement a channel mixer.
2004-11-28 16:09:13 +00:00
|
|
|
/* front center: 2 <-> 1 */
|
|
|
|
{ {
|
|
|
|
GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT_OF_CENTER,
|
|
|
|
GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT_OF_CENTER}, {
|
|
|
|
GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER}},
|
|
|
|
/* rear: 2 <-> 1 */
|
|
|
|
{ {
|
|
|
|
GST_AUDIO_CHANNEL_POSITION_REAR_LEFT,
|
|
|
|
GST_AUDIO_CHANNEL_POSITION_REAR_RIGHT}, {
|
|
|
|
GST_AUDIO_CHANNEL_POSITION_REAR_CENTER}}, { {
|
|
|
|
GST_AUDIO_CHANNEL_POSITION_INVALID}}
|
|
|
|
};
|
|
|
|
gint c;
|
|
|
|
|
2008-05-29 11:34:09 +00:00
|
|
|
/* conversions from compatible (but not the same) channel schemes */
|
gst/audioconvert/: Implement a channel mixer.
Original commit message from CVS:
* gst/audioconvert/Makefile.am:
* gst/audioconvert/gstaudioconvert.c: (gst_audio_convert_init),
(gst_audio_convert_link), (gst_audio_convert_change_state),
(gst_audio_convert_channels):
* gst/audioconvert/gstchannelmix.c:
(gst_audio_convert_unset_matrix),
(gst_audio_convert_fill_identical),
(gst_audio_convert_fill_compatible),
(gst_audio_convert_detect_pos), (gst_audio_convert_fill_one_other),
(gst_audio_convert_fill_others),
(gst_audio_convert_fill_normalize),
(gst_audio_convert_fill_matrix), (gst_audio_convert_setup_matrix),
(gst_audio_convert_passthrough), (gst_audio_convert_mix):
* gst/audioconvert/gstchannelmix.h:
Implement a channel mixer.
2004-11-28 16:09:13 +00:00
|
|
|
for (c = 0; conv[c].pos1[0] != GST_AUDIO_CHANNEL_POSITION_INVALID; c++) {
|
2008-05-29 11:34:09 +00:00
|
|
|
gint pos1_0 = -1, pos1_1 = -1, pos1_2 = -1;
|
|
|
|
gint pos2_0 = -1, pos2_1 = -1, pos2_2 = -1;
|
|
|
|
gint n;
|
gst/audioconvert/: Implement a channel mixer.
Original commit message from CVS:
* gst/audioconvert/Makefile.am:
* gst/audioconvert/gstaudioconvert.c: (gst_audio_convert_init),
(gst_audio_convert_link), (gst_audio_convert_change_state),
(gst_audio_convert_channels):
* gst/audioconvert/gstchannelmix.c:
(gst_audio_convert_unset_matrix),
(gst_audio_convert_fill_identical),
(gst_audio_convert_fill_compatible),
(gst_audio_convert_detect_pos), (gst_audio_convert_fill_one_other),
(gst_audio_convert_fill_others),
(gst_audio_convert_fill_normalize),
(gst_audio_convert_fill_matrix), (gst_audio_convert_setup_matrix),
(gst_audio_convert_passthrough), (gst_audio_convert_mix):
* gst/audioconvert/gstchannelmix.h:
Implement a channel mixer.
2004-11-28 16:09:13 +00:00
|
|
|
|
2017-08-14 23:29:57 +00:00
|
|
|
for (n = 0; n < in_channels; n++) {
|
|
|
|
if (in_position[n] == conv[c].pos1[0])
|
gst/audioconvert/: Implement a channel mixer.
Original commit message from CVS:
* gst/audioconvert/Makefile.am:
* gst/audioconvert/gstaudioconvert.c: (gst_audio_convert_init),
(gst_audio_convert_link), (gst_audio_convert_change_state),
(gst_audio_convert_channels):
* gst/audioconvert/gstchannelmix.c:
(gst_audio_convert_unset_matrix),
(gst_audio_convert_fill_identical),
(gst_audio_convert_fill_compatible),
(gst_audio_convert_detect_pos), (gst_audio_convert_fill_one_other),
(gst_audio_convert_fill_others),
(gst_audio_convert_fill_normalize),
(gst_audio_convert_fill_matrix), (gst_audio_convert_setup_matrix),
(gst_audio_convert_passthrough), (gst_audio_convert_mix):
* gst/audioconvert/gstchannelmix.h:
Implement a channel mixer.
2004-11-28 16:09:13 +00:00
|
|
|
pos1_0 = n;
|
2017-08-14 23:29:57 +00:00
|
|
|
else if (in_position[n] == conv[c].pos1[1])
|
gst/audioconvert/: Implement a channel mixer.
Original commit message from CVS:
* gst/audioconvert/Makefile.am:
* gst/audioconvert/gstaudioconvert.c: (gst_audio_convert_init),
(gst_audio_convert_link), (gst_audio_convert_change_state),
(gst_audio_convert_channels):
* gst/audioconvert/gstchannelmix.c:
(gst_audio_convert_unset_matrix),
(gst_audio_convert_fill_identical),
(gst_audio_convert_fill_compatible),
(gst_audio_convert_detect_pos), (gst_audio_convert_fill_one_other),
(gst_audio_convert_fill_others),
(gst_audio_convert_fill_normalize),
(gst_audio_convert_fill_matrix), (gst_audio_convert_setup_matrix),
(gst_audio_convert_passthrough), (gst_audio_convert_mix):
* gst/audioconvert/gstchannelmix.h:
Implement a channel mixer.
2004-11-28 16:09:13 +00:00
|
|
|
pos1_1 = n;
|
2017-08-14 23:29:57 +00:00
|
|
|
else if (in_position[n] == conv[c].pos2[0])
|
2008-05-29 11:34:09 +00:00
|
|
|
pos1_2 = n;
|
gst/audioconvert/: Implement a channel mixer.
Original commit message from CVS:
* gst/audioconvert/Makefile.am:
* gst/audioconvert/gstaudioconvert.c: (gst_audio_convert_init),
(gst_audio_convert_link), (gst_audio_convert_change_state),
(gst_audio_convert_channels):
* gst/audioconvert/gstchannelmix.c:
(gst_audio_convert_unset_matrix),
(gst_audio_convert_fill_identical),
(gst_audio_convert_fill_compatible),
(gst_audio_convert_detect_pos), (gst_audio_convert_fill_one_other),
(gst_audio_convert_fill_others),
(gst_audio_convert_fill_normalize),
(gst_audio_convert_fill_matrix), (gst_audio_convert_setup_matrix),
(gst_audio_convert_passthrough), (gst_audio_convert_mix):
* gst/audioconvert/gstchannelmix.h:
Implement a channel mixer.
2004-11-28 16:09:13 +00:00
|
|
|
}
|
2017-08-14 23:29:57 +00:00
|
|
|
for (n = 0; n < out_channels; n++) {
|
|
|
|
if (out_position[n] == conv[c].pos1[0])
|
gst/audioconvert/: Implement a channel mixer.
Original commit message from CVS:
* gst/audioconvert/Makefile.am:
* gst/audioconvert/gstaudioconvert.c: (gst_audio_convert_init),
(gst_audio_convert_link), (gst_audio_convert_change_state),
(gst_audio_convert_channels):
* gst/audioconvert/gstchannelmix.c:
(gst_audio_convert_unset_matrix),
(gst_audio_convert_fill_identical),
(gst_audio_convert_fill_compatible),
(gst_audio_convert_detect_pos), (gst_audio_convert_fill_one_other),
(gst_audio_convert_fill_others),
(gst_audio_convert_fill_normalize),
(gst_audio_convert_fill_matrix), (gst_audio_convert_setup_matrix),
(gst_audio_convert_passthrough), (gst_audio_convert_mix):
* gst/audioconvert/gstchannelmix.h:
Implement a channel mixer.
2004-11-28 16:09:13 +00:00
|
|
|
pos2_0 = n;
|
2017-08-14 23:29:57 +00:00
|
|
|
else if (out_position[n] == conv[c].pos1[1])
|
2008-05-29 11:34:09 +00:00
|
|
|
pos2_1 = n;
|
2017-08-14 23:29:57 +00:00
|
|
|
else if (out_position[n] == conv[c].pos2[0])
|
2008-05-29 11:34:09 +00:00
|
|
|
pos2_2 = n;
|
gst/audioconvert/: Implement a channel mixer.
Original commit message from CVS:
* gst/audioconvert/Makefile.am:
* gst/audioconvert/gstaudioconvert.c: (gst_audio_convert_init),
(gst_audio_convert_link), (gst_audio_convert_change_state),
(gst_audio_convert_channels):
* gst/audioconvert/gstchannelmix.c:
(gst_audio_convert_unset_matrix),
(gst_audio_convert_fill_identical),
(gst_audio_convert_fill_compatible),
(gst_audio_convert_detect_pos), (gst_audio_convert_fill_one_other),
(gst_audio_convert_fill_others),
(gst_audio_convert_fill_normalize),
(gst_audio_convert_fill_matrix), (gst_audio_convert_setup_matrix),
(gst_audio_convert_passthrough), (gst_audio_convert_mix):
* gst/audioconvert/gstchannelmix.h:
Implement a channel mixer.
2004-11-28 16:09:13 +00:00
|
|
|
}
|
|
|
|
|
2008-05-29 11:34:09 +00:00
|
|
|
/* The general idea here is to fill in channels from the same position
|
|
|
|
* as good as possible. This means mixing left<->center and right<->center.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* left -> center */
|
|
|
|
if (pos1_0 != -1 && pos1_2 == -1 && pos2_0 == -1 && pos2_2 != -1)
|
2017-08-14 23:29:57 +00:00
|
|
|
matrix[pos1_0][pos2_2] = 1.0;
|
2008-05-29 11:34:09 +00:00
|
|
|
else if (pos1_0 != -1 && pos1_2 != -1 && pos2_0 == -1 && pos2_2 != -1)
|
2017-08-14 23:29:57 +00:00
|
|
|
matrix[pos1_0][pos2_2] = 0.5;
|
2008-05-29 11:34:09 +00:00
|
|
|
else if (pos1_0 != -1 && pos1_2 == -1 && pos2_0 != -1 && pos2_2 != -1)
|
2017-08-14 23:29:57 +00:00
|
|
|
matrix[pos1_0][pos2_2] = 1.0;
|
2008-05-29 11:34:09 +00:00
|
|
|
|
|
|
|
/* right -> center */
|
|
|
|
if (pos1_1 != -1 && pos1_2 == -1 && pos2_1 == -1 && pos2_2 != -1)
|
2017-08-14 23:29:57 +00:00
|
|
|
matrix[pos1_1][pos2_2] = 1.0;
|
2008-05-29 11:34:09 +00:00
|
|
|
else if (pos1_1 != -1 && pos1_2 != -1 && pos2_1 == -1 && pos2_2 != -1)
|
2017-08-14 23:29:57 +00:00
|
|
|
matrix[pos1_1][pos2_2] = 0.5;
|
2008-05-29 11:34:09 +00:00
|
|
|
else if (pos1_1 != -1 && pos1_2 == -1 && pos2_1 != -1 && pos2_2 != -1)
|
2017-08-14 23:29:57 +00:00
|
|
|
matrix[pos1_1][pos2_2] = 1.0;
|
2008-05-29 11:34:09 +00:00
|
|
|
|
|
|
|
/* center -> left */
|
|
|
|
if (pos1_2 != -1 && pos1_0 == -1 && pos2_2 == -1 && pos2_0 != -1)
|
2017-08-14 23:29:57 +00:00
|
|
|
matrix[pos1_2][pos2_0] = 1.0;
|
2008-05-29 11:34:09 +00:00
|
|
|
else if (pos1_2 != -1 && pos1_0 != -1 && pos2_2 == -1 && pos2_0 != -1)
|
2017-08-14 23:29:57 +00:00
|
|
|
matrix[pos1_2][pos2_0] = 0.5;
|
2008-05-29 11:34:09 +00:00
|
|
|
else if (pos1_2 != -1 && pos1_0 == -1 && pos2_2 != -1 && pos2_0 != -1)
|
2017-08-14 23:29:57 +00:00
|
|
|
matrix[pos1_2][pos2_0] = 1.0;
|
2008-05-29 11:34:09 +00:00
|
|
|
|
|
|
|
/* center -> right */
|
|
|
|
if (pos1_2 != -1 && pos1_1 == -1 && pos2_2 == -1 && pos2_1 != -1)
|
2017-08-14 23:29:57 +00:00
|
|
|
matrix[pos1_2][pos2_1] = 1.0;
|
2008-05-29 11:34:09 +00:00
|
|
|
else if (pos1_2 != -1 && pos1_1 != -1 && pos2_2 == -1 && pos2_1 != -1)
|
2017-08-14 23:29:57 +00:00
|
|
|
matrix[pos1_2][pos2_1] = 0.5;
|
2008-05-29 11:34:09 +00:00
|
|
|
else if (pos1_2 != -1 && pos1_1 == -1 && pos2_2 != -1 && pos2_1 != -1)
|
2017-08-14 23:29:57 +00:00
|
|
|
matrix[pos1_2][pos2_1] = 1.0;
|
gst/audioconvert/: Implement a channel mixer.
Original commit message from CVS:
* gst/audioconvert/Makefile.am:
* gst/audioconvert/gstaudioconvert.c: (gst_audio_convert_init),
(gst_audio_convert_link), (gst_audio_convert_change_state),
(gst_audio_convert_channels):
* gst/audioconvert/gstchannelmix.c:
(gst_audio_convert_unset_matrix),
(gst_audio_convert_fill_identical),
(gst_audio_convert_fill_compatible),
(gst_audio_convert_detect_pos), (gst_audio_convert_fill_one_other),
(gst_audio_convert_fill_others),
(gst_audio_convert_fill_normalize),
(gst_audio_convert_fill_matrix), (gst_audio_convert_setup_matrix),
(gst_audio_convert_passthrough), (gst_audio_convert_mix):
* gst/audioconvert/gstchannelmix.h:
Implement a channel mixer.
2004-11-28 16:09:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Detect and fill in channels not handled by the
|
|
|
|
* above two, e.g. center to left/right front in
|
|
|
|
* 5.1 to 2.0 (or the other way around).
|
|
|
|
*
|
|
|
|
* Unfortunately, limited to static conversions
|
|
|
|
* for now.
|
|
|
|
*/
|
|
|
|
|
|
|
|
static void
|
2016-01-08 15:22:25 +00:00
|
|
|
gst_audio_channel_mixer_detect_pos (gint channels,
|
2015-11-06 14:50:34 +00:00
|
|
|
GstAudioChannelPosition position[64], gint * f, gboolean * has_f, gint * c,
|
|
|
|
gboolean * has_c, gint * r, gboolean * has_r, gint * s, gboolean * has_s,
|
|
|
|
gint * b, gboolean * has_b)
|
gst/audioconvert/: Implement a channel mixer.
Original commit message from CVS:
* gst/audioconvert/Makefile.am:
* gst/audioconvert/gstaudioconvert.c: (gst_audio_convert_init),
(gst_audio_convert_link), (gst_audio_convert_change_state),
(gst_audio_convert_channels):
* gst/audioconvert/gstchannelmix.c:
(gst_audio_convert_unset_matrix),
(gst_audio_convert_fill_identical),
(gst_audio_convert_fill_compatible),
(gst_audio_convert_detect_pos), (gst_audio_convert_fill_one_other),
(gst_audio_convert_fill_others),
(gst_audio_convert_fill_normalize),
(gst_audio_convert_fill_matrix), (gst_audio_convert_setup_matrix),
(gst_audio_convert_passthrough), (gst_audio_convert_mix):
* gst/audioconvert/gstchannelmix.h:
Implement a channel mixer.
2004-11-28 16:09:13 +00:00
|
|
|
{
|
|
|
|
gint n;
|
|
|
|
|
2015-10-27 12:24:31 +00:00
|
|
|
for (n = 0; n < channels; n++) {
|
|
|
|
switch (position[n]) {
|
2011-12-19 11:41:24 +00:00
|
|
|
case GST_AUDIO_CHANNEL_POSITION_MONO:
|
2008-05-29 11:34:09 +00:00
|
|
|
f[1] = n;
|
|
|
|
*has_f = TRUE;
|
|
|
|
break;
|
gst/audioconvert/: Implement a channel mixer.
Original commit message from CVS:
* gst/audioconvert/Makefile.am:
* gst/audioconvert/gstaudioconvert.c: (gst_audio_convert_init),
(gst_audio_convert_link), (gst_audio_convert_change_state),
(gst_audio_convert_channels):
* gst/audioconvert/gstchannelmix.c:
(gst_audio_convert_unset_matrix),
(gst_audio_convert_fill_identical),
(gst_audio_convert_fill_compatible),
(gst_audio_convert_detect_pos), (gst_audio_convert_fill_one_other),
(gst_audio_convert_fill_others),
(gst_audio_convert_fill_normalize),
(gst_audio_convert_fill_matrix), (gst_audio_convert_setup_matrix),
(gst_audio_convert_passthrough), (gst_audio_convert_mix):
* gst/audioconvert/gstchannelmix.h:
Implement a channel mixer.
2004-11-28 16:09:13 +00:00
|
|
|
case GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT:
|
2008-05-29 11:34:09 +00:00
|
|
|
f[0] = n;
|
|
|
|
*has_f = TRUE;
|
|
|
|
break;
|
gst/audioconvert/: Implement a channel mixer.
Original commit message from CVS:
* gst/audioconvert/Makefile.am:
* gst/audioconvert/gstaudioconvert.c: (gst_audio_convert_init),
(gst_audio_convert_link), (gst_audio_convert_change_state),
(gst_audio_convert_channels):
* gst/audioconvert/gstchannelmix.c:
(gst_audio_convert_unset_matrix),
(gst_audio_convert_fill_identical),
(gst_audio_convert_fill_compatible),
(gst_audio_convert_detect_pos), (gst_audio_convert_fill_one_other),
(gst_audio_convert_fill_others),
(gst_audio_convert_fill_normalize),
(gst_audio_convert_fill_matrix), (gst_audio_convert_setup_matrix),
(gst_audio_convert_passthrough), (gst_audio_convert_mix):
* gst/audioconvert/gstchannelmix.h:
Implement a channel mixer.
2004-11-28 16:09:13 +00:00
|
|
|
case GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT:
|
2008-05-29 11:34:09 +00:00
|
|
|
f[2] = n;
|
gst/audioconvert/: Implement a channel mixer.
Original commit message from CVS:
* gst/audioconvert/Makefile.am:
* gst/audioconvert/gstaudioconvert.c: (gst_audio_convert_init),
(gst_audio_convert_link), (gst_audio_convert_change_state),
(gst_audio_convert_channels):
* gst/audioconvert/gstchannelmix.c:
(gst_audio_convert_unset_matrix),
(gst_audio_convert_fill_identical),
(gst_audio_convert_fill_compatible),
(gst_audio_convert_detect_pos), (gst_audio_convert_fill_one_other),
(gst_audio_convert_fill_others),
(gst_audio_convert_fill_normalize),
(gst_audio_convert_fill_matrix), (gst_audio_convert_setup_matrix),
(gst_audio_convert_passthrough), (gst_audio_convert_mix):
* gst/audioconvert/gstchannelmix.h:
Implement a channel mixer.
2004-11-28 16:09:13 +00:00
|
|
|
*has_f = TRUE;
|
|
|
|
break;
|
|
|
|
case GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER:
|
2008-05-29 11:34:09 +00:00
|
|
|
c[1] = n;
|
|
|
|
*has_c = TRUE;
|
|
|
|
break;
|
gst/audioconvert/: Implement a channel mixer.
Original commit message from CVS:
* gst/audioconvert/Makefile.am:
* gst/audioconvert/gstaudioconvert.c: (gst_audio_convert_init),
(gst_audio_convert_link), (gst_audio_convert_change_state),
(gst_audio_convert_channels):
* gst/audioconvert/gstchannelmix.c:
(gst_audio_convert_unset_matrix),
(gst_audio_convert_fill_identical),
(gst_audio_convert_fill_compatible),
(gst_audio_convert_detect_pos), (gst_audio_convert_fill_one_other),
(gst_audio_convert_fill_others),
(gst_audio_convert_fill_normalize),
(gst_audio_convert_fill_matrix), (gst_audio_convert_setup_matrix),
(gst_audio_convert_passthrough), (gst_audio_convert_mix):
* gst/audioconvert/gstchannelmix.h:
Implement a channel mixer.
2004-11-28 16:09:13 +00:00
|
|
|
case GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT_OF_CENTER:
|
2008-05-29 11:34:09 +00:00
|
|
|
c[0] = n;
|
|
|
|
*has_c = TRUE;
|
|
|
|
break;
|
gst/audioconvert/: Implement a channel mixer.
Original commit message from CVS:
* gst/audioconvert/Makefile.am:
* gst/audioconvert/gstaudioconvert.c: (gst_audio_convert_init),
(gst_audio_convert_link), (gst_audio_convert_change_state),
(gst_audio_convert_channels):
* gst/audioconvert/gstchannelmix.c:
(gst_audio_convert_unset_matrix),
(gst_audio_convert_fill_identical),
(gst_audio_convert_fill_compatible),
(gst_audio_convert_detect_pos), (gst_audio_convert_fill_one_other),
(gst_audio_convert_fill_others),
(gst_audio_convert_fill_normalize),
(gst_audio_convert_fill_matrix), (gst_audio_convert_setup_matrix),
(gst_audio_convert_passthrough), (gst_audio_convert_mix):
* gst/audioconvert/gstchannelmix.h:
Implement a channel mixer.
2004-11-28 16:09:13 +00:00
|
|
|
case GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT_OF_CENTER:
|
2008-05-29 11:34:09 +00:00
|
|
|
c[2] = n;
|
gst/audioconvert/: Implement a channel mixer.
Original commit message from CVS:
* gst/audioconvert/Makefile.am:
* gst/audioconvert/gstaudioconvert.c: (gst_audio_convert_init),
(gst_audio_convert_link), (gst_audio_convert_change_state),
(gst_audio_convert_channels):
* gst/audioconvert/gstchannelmix.c:
(gst_audio_convert_unset_matrix),
(gst_audio_convert_fill_identical),
(gst_audio_convert_fill_compatible),
(gst_audio_convert_detect_pos), (gst_audio_convert_fill_one_other),
(gst_audio_convert_fill_others),
(gst_audio_convert_fill_normalize),
(gst_audio_convert_fill_matrix), (gst_audio_convert_setup_matrix),
(gst_audio_convert_passthrough), (gst_audio_convert_mix):
* gst/audioconvert/gstchannelmix.h:
Implement a channel mixer.
2004-11-28 16:09:13 +00:00
|
|
|
*has_c = TRUE;
|
|
|
|
break;
|
|
|
|
case GST_AUDIO_CHANNEL_POSITION_REAR_CENTER:
|
2008-05-29 11:34:09 +00:00
|
|
|
r[1] = n;
|
|
|
|
*has_r = TRUE;
|
|
|
|
break;
|
gst/audioconvert/: Implement a channel mixer.
Original commit message from CVS:
* gst/audioconvert/Makefile.am:
* gst/audioconvert/gstaudioconvert.c: (gst_audio_convert_init),
(gst_audio_convert_link), (gst_audio_convert_change_state),
(gst_audio_convert_channels):
* gst/audioconvert/gstchannelmix.c:
(gst_audio_convert_unset_matrix),
(gst_audio_convert_fill_identical),
(gst_audio_convert_fill_compatible),
(gst_audio_convert_detect_pos), (gst_audio_convert_fill_one_other),
(gst_audio_convert_fill_others),
(gst_audio_convert_fill_normalize),
(gst_audio_convert_fill_matrix), (gst_audio_convert_setup_matrix),
(gst_audio_convert_passthrough), (gst_audio_convert_mix):
* gst/audioconvert/gstchannelmix.h:
Implement a channel mixer.
2004-11-28 16:09:13 +00:00
|
|
|
case GST_AUDIO_CHANNEL_POSITION_REAR_LEFT:
|
2008-05-29 11:34:09 +00:00
|
|
|
r[0] = n;
|
|
|
|
*has_r = TRUE;
|
|
|
|
break;
|
gst/audioconvert/: Implement a channel mixer.
Original commit message from CVS:
* gst/audioconvert/Makefile.am:
* gst/audioconvert/gstaudioconvert.c: (gst_audio_convert_init),
(gst_audio_convert_link), (gst_audio_convert_change_state),
(gst_audio_convert_channels):
* gst/audioconvert/gstchannelmix.c:
(gst_audio_convert_unset_matrix),
(gst_audio_convert_fill_identical),
(gst_audio_convert_fill_compatible),
(gst_audio_convert_detect_pos), (gst_audio_convert_fill_one_other),
(gst_audio_convert_fill_others),
(gst_audio_convert_fill_normalize),
(gst_audio_convert_fill_matrix), (gst_audio_convert_setup_matrix),
(gst_audio_convert_passthrough), (gst_audio_convert_mix):
* gst/audioconvert/gstchannelmix.h:
Implement a channel mixer.
2004-11-28 16:09:13 +00:00
|
|
|
case GST_AUDIO_CHANNEL_POSITION_REAR_RIGHT:
|
2008-05-29 11:34:09 +00:00
|
|
|
r[2] = n;
|
gst/audioconvert/: Implement a channel mixer.
Original commit message from CVS:
* gst/audioconvert/Makefile.am:
* gst/audioconvert/gstaudioconvert.c: (gst_audio_convert_init),
(gst_audio_convert_link), (gst_audio_convert_change_state),
(gst_audio_convert_channels):
* gst/audioconvert/gstchannelmix.c:
(gst_audio_convert_unset_matrix),
(gst_audio_convert_fill_identical),
(gst_audio_convert_fill_compatible),
(gst_audio_convert_detect_pos), (gst_audio_convert_fill_one_other),
(gst_audio_convert_fill_others),
(gst_audio_convert_fill_normalize),
(gst_audio_convert_fill_matrix), (gst_audio_convert_setup_matrix),
(gst_audio_convert_passthrough), (gst_audio_convert_mix):
* gst/audioconvert/gstchannelmix.h:
Implement a channel mixer.
2004-11-28 16:09:13 +00:00
|
|
|
*has_r = TRUE;
|
|
|
|
break;
|
|
|
|
case GST_AUDIO_CHANNEL_POSITION_SIDE_LEFT:
|
2008-05-29 11:34:09 +00:00
|
|
|
s[0] = n;
|
|
|
|
*has_s = TRUE;
|
|
|
|
break;
|
gst/audioconvert/: Implement a channel mixer.
Original commit message from CVS:
* gst/audioconvert/Makefile.am:
* gst/audioconvert/gstaudioconvert.c: (gst_audio_convert_init),
(gst_audio_convert_link), (gst_audio_convert_change_state),
(gst_audio_convert_channels):
* gst/audioconvert/gstchannelmix.c:
(gst_audio_convert_unset_matrix),
(gst_audio_convert_fill_identical),
(gst_audio_convert_fill_compatible),
(gst_audio_convert_detect_pos), (gst_audio_convert_fill_one_other),
(gst_audio_convert_fill_others),
(gst_audio_convert_fill_normalize),
(gst_audio_convert_fill_matrix), (gst_audio_convert_setup_matrix),
(gst_audio_convert_passthrough), (gst_audio_convert_mix):
* gst/audioconvert/gstchannelmix.h:
Implement a channel mixer.
2004-11-28 16:09:13 +00:00
|
|
|
case GST_AUDIO_CHANNEL_POSITION_SIDE_RIGHT:
|
2008-05-29 11:34:09 +00:00
|
|
|
s[2] = n;
|
gst/audioconvert/: Implement a channel mixer.
Original commit message from CVS:
* gst/audioconvert/Makefile.am:
* gst/audioconvert/gstaudioconvert.c: (gst_audio_convert_init),
(gst_audio_convert_link), (gst_audio_convert_change_state),
(gst_audio_convert_channels):
* gst/audioconvert/gstchannelmix.c:
(gst_audio_convert_unset_matrix),
(gst_audio_convert_fill_identical),
(gst_audio_convert_fill_compatible),
(gst_audio_convert_detect_pos), (gst_audio_convert_fill_one_other),
(gst_audio_convert_fill_others),
(gst_audio_convert_fill_normalize),
(gst_audio_convert_fill_matrix), (gst_audio_convert_setup_matrix),
(gst_audio_convert_passthrough), (gst_audio_convert_mix):
* gst/audioconvert/gstchannelmix.h:
Implement a channel mixer.
2004-11-28 16:09:13 +00:00
|
|
|
*has_s = TRUE;
|
|
|
|
break;
|
2011-12-19 11:41:24 +00:00
|
|
|
case GST_AUDIO_CHANNEL_POSITION_LFE1:
|
gst/audioconvert/: Implement a channel mixer.
Original commit message from CVS:
* gst/audioconvert/Makefile.am:
* gst/audioconvert/gstaudioconvert.c: (gst_audio_convert_init),
(gst_audio_convert_link), (gst_audio_convert_change_state),
(gst_audio_convert_channels):
* gst/audioconvert/gstchannelmix.c:
(gst_audio_convert_unset_matrix),
(gst_audio_convert_fill_identical),
(gst_audio_convert_fill_compatible),
(gst_audio_convert_detect_pos), (gst_audio_convert_fill_one_other),
(gst_audio_convert_fill_others),
(gst_audio_convert_fill_normalize),
(gst_audio_convert_fill_matrix), (gst_audio_convert_setup_matrix),
(gst_audio_convert_passthrough), (gst_audio_convert_mix):
* gst/audioconvert/gstchannelmix.h:
Implement a channel mixer.
2004-11-28 16:09:13 +00:00
|
|
|
*has_b = TRUE;
|
2008-05-29 11:34:09 +00:00
|
|
|
b[1] = n;
|
gst/audioconvert/: Implement a channel mixer.
Original commit message from CVS:
* gst/audioconvert/Makefile.am:
* gst/audioconvert/gstaudioconvert.c: (gst_audio_convert_init),
(gst_audio_convert_link), (gst_audio_convert_change_state),
(gst_audio_convert_channels):
* gst/audioconvert/gstchannelmix.c:
(gst_audio_convert_unset_matrix),
(gst_audio_convert_fill_identical),
(gst_audio_convert_fill_compatible),
(gst_audio_convert_detect_pos), (gst_audio_convert_fill_one_other),
(gst_audio_convert_fill_others),
(gst_audio_convert_fill_normalize),
(gst_audio_convert_fill_matrix), (gst_audio_convert_setup_matrix),
(gst_audio_convert_passthrough), (gst_audio_convert_mix):
* gst/audioconvert/gstchannelmix.h:
Implement a channel mixer.
2004-11-28 16:09:13 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-01-08 15:22:25 +00:00
|
|
|
gst_audio_channel_mixer_fill_one_other (gfloat ** matrix,
|
2015-10-27 12:24:31 +00:00
|
|
|
gint * from_idx, gint * to_idx, gfloat ratio)
|
gst/audioconvert/: Implement a channel mixer.
Original commit message from CVS:
* gst/audioconvert/Makefile.am:
* gst/audioconvert/gstaudioconvert.c: (gst_audio_convert_init),
(gst_audio_convert_link), (gst_audio_convert_change_state),
(gst_audio_convert_channels):
* gst/audioconvert/gstchannelmix.c:
(gst_audio_convert_unset_matrix),
(gst_audio_convert_fill_identical),
(gst_audio_convert_fill_compatible),
(gst_audio_convert_detect_pos), (gst_audio_convert_fill_one_other),
(gst_audio_convert_fill_others),
(gst_audio_convert_fill_normalize),
(gst_audio_convert_fill_matrix), (gst_audio_convert_setup_matrix),
(gst_audio_convert_passthrough), (gst_audio_convert_mix):
* gst/audioconvert/gstchannelmix.h:
Implement a channel mixer.
2004-11-28 16:09:13 +00:00
|
|
|
{
|
|
|
|
|
2008-05-29 11:34:09 +00:00
|
|
|
/* src & dst have center => passthrough */
|
|
|
|
if (from_idx[1] != -1 && to_idx[1] != -1) {
|
|
|
|
matrix[from_idx[1]][to_idx[1]] = ratio;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* src & dst have left => passthrough */
|
|
|
|
if (from_idx[0] != -1 && to_idx[0] != -1) {
|
|
|
|
matrix[from_idx[0]][to_idx[0]] = ratio;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* src & dst have right => passthrough */
|
|
|
|
if (from_idx[2] != -1 && to_idx[2] != -1) {
|
|
|
|
matrix[from_idx[2]][to_idx[2]] = ratio;
|
|
|
|
}
|
gst/audioconvert/: Implement a channel mixer.
Original commit message from CVS:
* gst/audioconvert/Makefile.am:
* gst/audioconvert/gstaudioconvert.c: (gst_audio_convert_init),
(gst_audio_convert_link), (gst_audio_convert_change_state),
(gst_audio_convert_channels):
* gst/audioconvert/gstchannelmix.c:
(gst_audio_convert_unset_matrix),
(gst_audio_convert_fill_identical),
(gst_audio_convert_fill_compatible),
(gst_audio_convert_detect_pos), (gst_audio_convert_fill_one_other),
(gst_audio_convert_fill_others),
(gst_audio_convert_fill_normalize),
(gst_audio_convert_fill_matrix), (gst_audio_convert_setup_matrix),
(gst_audio_convert_passthrough), (gst_audio_convert_mix):
* gst/audioconvert/gstchannelmix.h:
Implement a channel mixer.
2004-11-28 16:09:13 +00:00
|
|
|
|
2008-05-29 11:34:09 +00:00
|
|
|
/* src has left & dst has center => put into center */
|
2008-05-29 12:17:16 +00:00
|
|
|
if (from_idx[0] != -1 && to_idx[1] != -1 && from_idx[1] != -1) {
|
|
|
|
matrix[from_idx[0]][to_idx[1]] = 0.5 * ratio;
|
|
|
|
} else if (from_idx[0] != -1 && to_idx[1] != -1 && from_idx[1] == -1) {
|
2008-05-29 11:34:09 +00:00
|
|
|
matrix[from_idx[0]][to_idx[1]] = ratio;
|
|
|
|
}
|
2008-05-29 12:17:16 +00:00
|
|
|
|
2008-05-29 11:34:09 +00:00
|
|
|
/* src has right & dst has center => put into center */
|
2008-05-29 12:17:16 +00:00
|
|
|
if (from_idx[2] != -1 && to_idx[1] != -1 && from_idx[1] != -1) {
|
|
|
|
matrix[from_idx[2]][to_idx[1]] = 0.5 * ratio;
|
|
|
|
} else if (from_idx[2] != -1 && to_idx[1] != -1 && from_idx[1] == -1) {
|
2008-05-29 11:34:09 +00:00
|
|
|
matrix[from_idx[2]][to_idx[1]] = ratio;
|
gst/audioconvert/: Implement a channel mixer.
Original commit message from CVS:
* gst/audioconvert/Makefile.am:
* gst/audioconvert/gstaudioconvert.c: (gst_audio_convert_init),
(gst_audio_convert_link), (gst_audio_convert_change_state),
(gst_audio_convert_channels):
* gst/audioconvert/gstchannelmix.c:
(gst_audio_convert_unset_matrix),
(gst_audio_convert_fill_identical),
(gst_audio_convert_fill_compatible),
(gst_audio_convert_detect_pos), (gst_audio_convert_fill_one_other),
(gst_audio_convert_fill_others),
(gst_audio_convert_fill_normalize),
(gst_audio_convert_fill_matrix), (gst_audio_convert_setup_matrix),
(gst_audio_convert_passthrough), (gst_audio_convert_mix):
* gst/audioconvert/gstchannelmix.h:
Implement a channel mixer.
2004-11-28 16:09:13 +00:00
|
|
|
}
|
|
|
|
|
2008-05-29 11:34:09 +00:00
|
|
|
/* src has center & dst has left => passthrough */
|
2008-05-29 12:17:16 +00:00
|
|
|
if (from_idx[1] != -1 && to_idx[0] != -1 && from_idx[0] != -1) {
|
|
|
|
matrix[from_idx[1]][to_idx[0]] = 0.5 * ratio;
|
|
|
|
} else if (from_idx[1] != -1 && to_idx[0] != -1 && from_idx[0] == -1) {
|
2008-05-29 11:34:09 +00:00
|
|
|
matrix[from_idx[1]][to_idx[0]] = ratio;
|
|
|
|
}
|
2008-05-29 12:17:16 +00:00
|
|
|
|
2008-05-29 11:34:09 +00:00
|
|
|
/* src has center & dst has right => passthrough */
|
2008-05-29 12:17:16 +00:00
|
|
|
if (from_idx[1] != -1 && to_idx[2] != -1 && from_idx[2] != -1) {
|
|
|
|
matrix[from_idx[1]][to_idx[2]] = 0.5 * ratio;
|
|
|
|
} else if (from_idx[1] != -1 && to_idx[2] != -1 && from_idx[2] == -1) {
|
2008-05-29 11:34:09 +00:00
|
|
|
matrix[from_idx[1]][to_idx[2]] = ratio;
|
gst/audioconvert/: Implement a channel mixer.
Original commit message from CVS:
* gst/audioconvert/Makefile.am:
* gst/audioconvert/gstaudioconvert.c: (gst_audio_convert_init),
(gst_audio_convert_link), (gst_audio_convert_change_state),
(gst_audio_convert_channels):
* gst/audioconvert/gstchannelmix.c:
(gst_audio_convert_unset_matrix),
(gst_audio_convert_fill_identical),
(gst_audio_convert_fill_compatible),
(gst_audio_convert_detect_pos), (gst_audio_convert_fill_one_other),
(gst_audio_convert_fill_others),
(gst_audio_convert_fill_normalize),
(gst_audio_convert_fill_matrix), (gst_audio_convert_setup_matrix),
(gst_audio_convert_passthrough), (gst_audio_convert_mix):
* gst/audioconvert/gstchannelmix.h:
Implement a channel mixer.
2004-11-28 16:09:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-05-29 11:34:09 +00:00
|
|
|
#define RATIO_CENTER_FRONT (1.0 / sqrt (2.0))
|
|
|
|
#define RATIO_CENTER_SIDE (1.0 / 2.0)
|
|
|
|
#define RATIO_CENTER_REAR (1.0 / sqrt (8.0))
|
|
|
|
|
gst/audioconvert/: Implement a channel mixer.
Original commit message from CVS:
* gst/audioconvert/Makefile.am:
* gst/audioconvert/gstaudioconvert.c: (gst_audio_convert_init),
(gst_audio_convert_link), (gst_audio_convert_change_state),
(gst_audio_convert_channels):
* gst/audioconvert/gstchannelmix.c:
(gst_audio_convert_unset_matrix),
(gst_audio_convert_fill_identical),
(gst_audio_convert_fill_compatible),
(gst_audio_convert_detect_pos), (gst_audio_convert_fill_one_other),
(gst_audio_convert_fill_others),
(gst_audio_convert_fill_normalize),
(gst_audio_convert_fill_matrix), (gst_audio_convert_setup_matrix),
(gst_audio_convert_passthrough), (gst_audio_convert_mix):
* gst/audioconvert/gstchannelmix.h:
Implement a channel mixer.
2004-11-28 16:09:13 +00:00
|
|
|
#define RATIO_FRONT_CENTER (1.0 / sqrt (2.0))
|
2008-05-29 11:34:09 +00:00
|
|
|
#define RATIO_FRONT_SIDE (1.0 / sqrt (2.0))
|
|
|
|
#define RATIO_FRONT_REAR (1.0 / 2.0)
|
|
|
|
|
|
|
|
#define RATIO_SIDE_CENTER (1.0 / 2.0)
|
|
|
|
#define RATIO_SIDE_FRONT (1.0 / sqrt (2.0))
|
|
|
|
#define RATIO_SIDE_REAR (1.0 / sqrt (2.0))
|
|
|
|
|
gst/audioconvert/: Implement a channel mixer.
Original commit message from CVS:
* gst/audioconvert/Makefile.am:
* gst/audioconvert/gstaudioconvert.c: (gst_audio_convert_init),
(gst_audio_convert_link), (gst_audio_convert_change_state),
(gst_audio_convert_channels):
* gst/audioconvert/gstchannelmix.c:
(gst_audio_convert_unset_matrix),
(gst_audio_convert_fill_identical),
(gst_audio_convert_fill_compatible),
(gst_audio_convert_detect_pos), (gst_audio_convert_fill_one_other),
(gst_audio_convert_fill_others),
(gst_audio_convert_fill_normalize),
(gst_audio_convert_fill_matrix), (gst_audio_convert_setup_matrix),
(gst_audio_convert_passthrough), (gst_audio_convert_mix):
* gst/audioconvert/gstchannelmix.h:
Implement a channel mixer.
2004-11-28 16:09:13 +00:00
|
|
|
#define RATIO_CENTER_BASS (1.0 / sqrt (2.0))
|
2008-05-29 11:34:09 +00:00
|
|
|
#define RATIO_FRONT_BASS (1.0)
|
2008-05-21 11:30:58 +00:00
|
|
|
#define RATIO_SIDE_BASS (1.0 / sqrt (2.0))
|
2008-05-29 11:34:09 +00:00
|
|
|
#define RATIO_REAR_BASS (1.0 / sqrt (2.0))
|
gst/audioconvert/: Implement a channel mixer.
Original commit message from CVS:
* gst/audioconvert/Makefile.am:
* gst/audioconvert/gstaudioconvert.c: (gst_audio_convert_init),
(gst_audio_convert_link), (gst_audio_convert_change_state),
(gst_audio_convert_channels):
* gst/audioconvert/gstchannelmix.c:
(gst_audio_convert_unset_matrix),
(gst_audio_convert_fill_identical),
(gst_audio_convert_fill_compatible),
(gst_audio_convert_detect_pos), (gst_audio_convert_fill_one_other),
(gst_audio_convert_fill_others),
(gst_audio_convert_fill_normalize),
(gst_audio_convert_fill_matrix), (gst_audio_convert_setup_matrix),
(gst_audio_convert_passthrough), (gst_audio_convert_mix):
* gst/audioconvert/gstchannelmix.h:
Implement a channel mixer.
2004-11-28 16:09:13 +00:00
|
|
|
|
|
|
|
static void
|
2017-08-14 23:29:57 +00:00
|
|
|
gst_audio_channel_mixer_fill_others (gfloat ** matrix, gint in_channels,
|
|
|
|
GstAudioChannelPosition * in_position, gint out_channels,
|
|
|
|
GstAudioChannelPosition * out_position)
|
gst/audioconvert/: Implement a channel mixer.
Original commit message from CVS:
* gst/audioconvert/Makefile.am:
* gst/audioconvert/gstaudioconvert.c: (gst_audio_convert_init),
(gst_audio_convert_link), (gst_audio_convert_change_state),
(gst_audio_convert_channels):
* gst/audioconvert/gstchannelmix.c:
(gst_audio_convert_unset_matrix),
(gst_audio_convert_fill_identical),
(gst_audio_convert_fill_compatible),
(gst_audio_convert_detect_pos), (gst_audio_convert_fill_one_other),
(gst_audio_convert_fill_others),
(gst_audio_convert_fill_normalize),
(gst_audio_convert_fill_matrix), (gst_audio_convert_setup_matrix),
(gst_audio_convert_passthrough), (gst_audio_convert_mix):
* gst/audioconvert/gstchannelmix.h:
Implement a channel mixer.
2004-11-28 16:09:13 +00:00
|
|
|
{
|
|
|
|
gboolean in_has_front = FALSE, out_has_front = FALSE,
|
|
|
|
in_has_center = FALSE, out_has_center = FALSE,
|
|
|
|
in_has_rear = FALSE, out_has_rear = FALSE,
|
|
|
|
in_has_side = FALSE, out_has_side = FALSE,
|
|
|
|
in_has_bass = FALSE, out_has_bass = FALSE;
|
2008-05-29 11:34:09 +00:00
|
|
|
/* LEFT, RIGHT, MONO */
|
|
|
|
gint in_f[3] = { -1, -1, -1 };
|
|
|
|
gint out_f[3] = { -1, -1, -1 };
|
|
|
|
/* LOC, ROC, CENTER */
|
|
|
|
gint in_c[3] = { -1, -1, -1 };
|
|
|
|
gint out_c[3] = { -1, -1, -1 };
|
|
|
|
/* RLEFT, RRIGHT, RCENTER */
|
|
|
|
gint in_r[3] = { -1, -1, -1 };
|
|
|
|
gint out_r[3] = { -1, -1, -1 };
|
|
|
|
/* SLEFT, INVALID, SRIGHT */
|
|
|
|
gint in_s[3] = { -1, -1, -1 };
|
|
|
|
gint out_s[3] = { -1, -1, -1 };
|
|
|
|
/* INVALID, LFE, INVALID */
|
|
|
|
gint in_b[3] = { -1, -1, -1 };
|
|
|
|
gint out_b[3] = { -1, -1, -1 };
|
gst/audioconvert/: Implement a channel mixer.
Original commit message from CVS:
* gst/audioconvert/Makefile.am:
* gst/audioconvert/gstaudioconvert.c: (gst_audio_convert_init),
(gst_audio_convert_link), (gst_audio_convert_change_state),
(gst_audio_convert_channels):
* gst/audioconvert/gstchannelmix.c:
(gst_audio_convert_unset_matrix),
(gst_audio_convert_fill_identical),
(gst_audio_convert_fill_compatible),
(gst_audio_convert_detect_pos), (gst_audio_convert_fill_one_other),
(gst_audio_convert_fill_others),
(gst_audio_convert_fill_normalize),
(gst_audio_convert_fill_matrix), (gst_audio_convert_setup_matrix),
(gst_audio_convert_passthrough), (gst_audio_convert_mix):
* gst/audioconvert/gstchannelmix.h:
Implement a channel mixer.
2004-11-28 16:09:13 +00:00
|
|
|
|
|
|
|
/* First see where (if at all) the various channels from/to
|
|
|
|
* which we want to convert are located in our matrix/array. */
|
2017-08-14 23:29:57 +00:00
|
|
|
gst_audio_channel_mixer_detect_pos (in_channels, in_position,
|
gst/audioconvert/: Implement a channel mixer.
Original commit message from CVS:
* gst/audioconvert/Makefile.am:
* gst/audioconvert/gstaudioconvert.c: (gst_audio_convert_init),
(gst_audio_convert_link), (gst_audio_convert_change_state),
(gst_audio_convert_channels):
* gst/audioconvert/gstchannelmix.c:
(gst_audio_convert_unset_matrix),
(gst_audio_convert_fill_identical),
(gst_audio_convert_fill_compatible),
(gst_audio_convert_detect_pos), (gst_audio_convert_fill_one_other),
(gst_audio_convert_fill_others),
(gst_audio_convert_fill_normalize),
(gst_audio_convert_fill_matrix), (gst_audio_convert_setup_matrix),
(gst_audio_convert_passthrough), (gst_audio_convert_mix):
* gst/audioconvert/gstchannelmix.h:
Implement a channel mixer.
2004-11-28 16:09:13 +00:00
|
|
|
in_f, &in_has_front,
|
|
|
|
in_c, &in_has_center, in_r, &in_has_rear,
|
|
|
|
in_s, &in_has_side, in_b, &in_has_bass);
|
2017-08-14 23:29:57 +00:00
|
|
|
gst_audio_channel_mixer_detect_pos (out_channels, out_position,
|
gst/audioconvert/: Implement a channel mixer.
Original commit message from CVS:
* gst/audioconvert/Makefile.am:
* gst/audioconvert/gstaudioconvert.c: (gst_audio_convert_init),
(gst_audio_convert_link), (gst_audio_convert_change_state),
(gst_audio_convert_channels):
* gst/audioconvert/gstchannelmix.c:
(gst_audio_convert_unset_matrix),
(gst_audio_convert_fill_identical),
(gst_audio_convert_fill_compatible),
(gst_audio_convert_detect_pos), (gst_audio_convert_fill_one_other),
(gst_audio_convert_fill_others),
(gst_audio_convert_fill_normalize),
(gst_audio_convert_fill_matrix), (gst_audio_convert_setup_matrix),
(gst_audio_convert_passthrough), (gst_audio_convert_mix):
* gst/audioconvert/gstchannelmix.h:
Implement a channel mixer.
2004-11-28 16:09:13 +00:00
|
|
|
out_f, &out_has_front,
|
|
|
|
out_c, &out_has_center, out_r, &out_has_rear,
|
|
|
|
out_s, &out_has_side, out_b, &out_has_bass);
|
|
|
|
|
2008-05-29 11:34:09 +00:00
|
|
|
/* The general idea here is:
|
|
|
|
* - if the source has a channel that the destination doesn't have mix
|
|
|
|
* it into the nearest available destination channel
|
|
|
|
* - if the destination has a channel that the source doesn't have mix
|
|
|
|
* the nearest source channel into the destination channel
|
|
|
|
*
|
|
|
|
* The ratio for the mixing becomes lower as the distance between the
|
|
|
|
* channels gets larger
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* center <-> front/side/rear */
|
gst/audioconvert/: Implement a channel mixer.
Original commit message from CVS:
* gst/audioconvert/Makefile.am:
* gst/audioconvert/gstaudioconvert.c: (gst_audio_convert_init),
(gst_audio_convert_link), (gst_audio_convert_change_state),
(gst_audio_convert_channels):
* gst/audioconvert/gstchannelmix.c:
(gst_audio_convert_unset_matrix),
(gst_audio_convert_fill_identical),
(gst_audio_convert_fill_compatible),
(gst_audio_convert_detect_pos), (gst_audio_convert_fill_one_other),
(gst_audio_convert_fill_others),
(gst_audio_convert_fill_normalize),
(gst_audio_convert_fill_matrix), (gst_audio_convert_setup_matrix),
(gst_audio_convert_passthrough), (gst_audio_convert_mix):
* gst/audioconvert/gstchannelmix.h:
Implement a channel mixer.
2004-11-28 16:09:13 +00:00
|
|
|
if (!in_has_center && in_has_front && out_has_center) {
|
2017-08-14 23:29:57 +00:00
|
|
|
gst_audio_channel_mixer_fill_one_other (matrix, in_f, out_c,
|
2015-10-27 12:24:31 +00:00
|
|
|
RATIO_CENTER_FRONT);
|
2008-05-29 11:34:09 +00:00
|
|
|
} else if (!in_has_center && !in_has_front && in_has_side && out_has_center) {
|
2017-08-14 23:29:57 +00:00
|
|
|
gst_audio_channel_mixer_fill_one_other (matrix, in_s, out_c,
|
2015-10-27 12:24:31 +00:00
|
|
|
RATIO_CENTER_SIDE);
|
2008-05-29 11:34:09 +00:00
|
|
|
} else if (!in_has_center && !in_has_front && !in_has_side && in_has_rear
|
|
|
|
&& out_has_center) {
|
2017-08-14 23:29:57 +00:00
|
|
|
gst_audio_channel_mixer_fill_one_other (matrix, in_r, out_c,
|
2015-10-27 12:24:31 +00:00
|
|
|
RATIO_CENTER_REAR);
|
gst/audioconvert/: Implement a channel mixer.
Original commit message from CVS:
* gst/audioconvert/Makefile.am:
* gst/audioconvert/gstaudioconvert.c: (gst_audio_convert_init),
(gst_audio_convert_link), (gst_audio_convert_change_state),
(gst_audio_convert_channels):
* gst/audioconvert/gstchannelmix.c:
(gst_audio_convert_unset_matrix),
(gst_audio_convert_fill_identical),
(gst_audio_convert_fill_compatible),
(gst_audio_convert_detect_pos), (gst_audio_convert_fill_one_other),
(gst_audio_convert_fill_others),
(gst_audio_convert_fill_normalize),
(gst_audio_convert_fill_matrix), (gst_audio_convert_setup_matrix),
(gst_audio_convert_passthrough), (gst_audio_convert_mix):
* gst/audioconvert/gstchannelmix.h:
Implement a channel mixer.
2004-11-28 16:09:13 +00:00
|
|
|
} else if (in_has_center && !out_has_center && out_has_front) {
|
2017-08-14 23:29:57 +00:00
|
|
|
gst_audio_channel_mixer_fill_one_other (matrix, in_c, out_f,
|
2015-10-27 12:24:31 +00:00
|
|
|
RATIO_CENTER_FRONT);
|
2008-05-29 11:34:09 +00:00
|
|
|
} else if (in_has_center && !out_has_center && !out_has_front && out_has_side) {
|
2017-08-14 23:29:57 +00:00
|
|
|
gst_audio_channel_mixer_fill_one_other (matrix, in_c, out_s,
|
2015-10-27 12:24:31 +00:00
|
|
|
RATIO_CENTER_SIDE);
|
2008-05-29 11:34:09 +00:00
|
|
|
} else if (in_has_center && !out_has_center && !out_has_front && !out_has_side
|
|
|
|
&& out_has_rear) {
|
2017-08-14 23:29:57 +00:00
|
|
|
gst_audio_channel_mixer_fill_one_other (matrix, in_c, out_r,
|
2015-10-27 12:24:31 +00:00
|
|
|
RATIO_CENTER_REAR);
|
gst/audioconvert/: Implement a channel mixer.
Original commit message from CVS:
* gst/audioconvert/Makefile.am:
* gst/audioconvert/gstaudioconvert.c: (gst_audio_convert_init),
(gst_audio_convert_link), (gst_audio_convert_change_state),
(gst_audio_convert_channels):
* gst/audioconvert/gstchannelmix.c:
(gst_audio_convert_unset_matrix),
(gst_audio_convert_fill_identical),
(gst_audio_convert_fill_compatible),
(gst_audio_convert_detect_pos), (gst_audio_convert_fill_one_other),
(gst_audio_convert_fill_others),
(gst_audio_convert_fill_normalize),
(gst_audio_convert_fill_matrix), (gst_audio_convert_setup_matrix),
(gst_audio_convert_passthrough), (gst_audio_convert_mix):
* gst/audioconvert/gstchannelmix.h:
Implement a channel mixer.
2004-11-28 16:09:13 +00:00
|
|
|
}
|
|
|
|
|
2008-05-29 11:34:09 +00:00
|
|
|
/* front <-> center/side/rear */
|
|
|
|
if (!in_has_front && in_has_center && !in_has_side && out_has_front) {
|
2017-08-14 23:29:57 +00:00
|
|
|
gst_audio_channel_mixer_fill_one_other (matrix, in_c, out_f,
|
2015-10-27 12:24:31 +00:00
|
|
|
RATIO_CENTER_FRONT);
|
2008-05-29 11:34:09 +00:00
|
|
|
} else if (!in_has_front && !in_has_center && in_has_side && out_has_front) {
|
2017-08-14 23:29:57 +00:00
|
|
|
gst_audio_channel_mixer_fill_one_other (matrix, in_s, out_f,
|
2015-11-06 14:50:34 +00:00
|
|
|
RATIO_FRONT_SIDE);
|
2008-05-29 11:34:09 +00:00
|
|
|
} else if (!in_has_front && in_has_center && in_has_side && out_has_front) {
|
2017-08-14 23:29:57 +00:00
|
|
|
gst_audio_channel_mixer_fill_one_other (matrix, in_c, out_f,
|
2015-10-27 12:24:31 +00:00
|
|
|
0.5 * RATIO_CENTER_FRONT);
|
2017-08-14 23:29:57 +00:00
|
|
|
gst_audio_channel_mixer_fill_one_other (matrix, in_s, out_f,
|
2015-10-27 12:24:31 +00:00
|
|
|
0.5 * RATIO_FRONT_SIDE);
|
2008-05-29 11:34:09 +00:00
|
|
|
} else if (!in_has_front && !in_has_center && !in_has_side && in_has_rear
|
|
|
|
&& out_has_front) {
|
2017-08-14 23:29:57 +00:00
|
|
|
gst_audio_channel_mixer_fill_one_other (matrix, in_r, out_f,
|
2015-11-06 14:50:34 +00:00
|
|
|
RATIO_FRONT_REAR);
|
2008-05-29 11:34:09 +00:00
|
|
|
} else if (in_has_front && out_has_center && !out_has_side && !out_has_front) {
|
2017-08-14 23:29:57 +00:00
|
|
|
gst_audio_channel_mixer_fill_one_other (matrix,
|
2015-10-27 12:24:31 +00:00
|
|
|
in_f, out_c, RATIO_CENTER_FRONT);
|
2008-05-29 11:34:09 +00:00
|
|
|
} else if (in_has_front && !out_has_center && out_has_side && !out_has_front) {
|
2017-08-14 23:29:57 +00:00
|
|
|
gst_audio_channel_mixer_fill_one_other (matrix, in_f, out_s,
|
2015-11-06 14:50:34 +00:00
|
|
|
RATIO_FRONT_SIDE);
|
2008-05-29 11:34:09 +00:00
|
|
|
} else if (in_has_front && out_has_center && out_has_side && !out_has_front) {
|
2017-08-14 23:29:57 +00:00
|
|
|
gst_audio_channel_mixer_fill_one_other (matrix, in_f, out_c,
|
2015-10-27 12:24:31 +00:00
|
|
|
0.5 * RATIO_CENTER_FRONT);
|
2017-08-14 23:29:57 +00:00
|
|
|
gst_audio_channel_mixer_fill_one_other (matrix, in_f, out_s,
|
2015-10-27 12:24:31 +00:00
|
|
|
0.5 * RATIO_FRONT_SIDE);
|
2008-05-29 11:34:09 +00:00
|
|
|
} else if (in_has_front && !out_has_center && !out_has_side && !out_has_front
|
|
|
|
&& out_has_rear) {
|
2017-08-14 23:29:57 +00:00
|
|
|
gst_audio_channel_mixer_fill_one_other (matrix, in_f, out_r,
|
2015-11-06 14:50:34 +00:00
|
|
|
RATIO_FRONT_REAR);
|
2008-05-29 11:34:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* side <-> center/front/rear */
|
|
|
|
if (!in_has_side && in_has_front && !in_has_rear && out_has_side) {
|
2017-08-14 23:29:57 +00:00
|
|
|
gst_audio_channel_mixer_fill_one_other (matrix, in_f, out_s,
|
2015-11-06 14:50:34 +00:00
|
|
|
RATIO_FRONT_SIDE);
|
2008-05-29 11:34:09 +00:00
|
|
|
} else if (!in_has_side && !in_has_front && in_has_rear && out_has_side) {
|
2017-08-14 23:29:57 +00:00
|
|
|
gst_audio_channel_mixer_fill_one_other (matrix, in_r, out_s,
|
2015-11-06 14:50:34 +00:00
|
|
|
RATIO_SIDE_REAR);
|
2008-05-29 11:34:09 +00:00
|
|
|
} else if (!in_has_side && in_has_front && in_has_rear && out_has_side) {
|
2017-08-14 23:29:57 +00:00
|
|
|
gst_audio_channel_mixer_fill_one_other (matrix, in_f, out_s,
|
2015-10-27 12:24:31 +00:00
|
|
|
0.5 * RATIO_FRONT_SIDE);
|
2017-08-14 23:29:57 +00:00
|
|
|
gst_audio_channel_mixer_fill_one_other (matrix, in_r, out_s,
|
2015-10-27 12:24:31 +00:00
|
|
|
0.5 * RATIO_SIDE_REAR);
|
2008-05-29 11:34:09 +00:00
|
|
|
} else if (!in_has_side && !in_has_front && !in_has_rear && in_has_center
|
|
|
|
&& out_has_side) {
|
2017-08-14 23:29:57 +00:00
|
|
|
gst_audio_channel_mixer_fill_one_other (matrix, in_c, out_s,
|
2015-10-27 12:24:31 +00:00
|
|
|
RATIO_CENTER_SIDE);
|
2008-05-29 11:34:09 +00:00
|
|
|
} else if (in_has_side && out_has_front && !out_has_rear && !out_has_side) {
|
2017-08-14 23:29:57 +00:00
|
|
|
gst_audio_channel_mixer_fill_one_other (matrix, in_s, out_f,
|
2015-11-06 14:50:34 +00:00
|
|
|
RATIO_FRONT_SIDE);
|
2008-05-29 11:34:09 +00:00
|
|
|
} else if (in_has_side && !out_has_front && out_has_rear && !out_has_side) {
|
2017-08-14 23:29:57 +00:00
|
|
|
gst_audio_channel_mixer_fill_one_other (matrix, in_s, out_r,
|
2015-11-06 14:50:34 +00:00
|
|
|
RATIO_SIDE_REAR);
|
2008-05-29 11:34:09 +00:00
|
|
|
} else if (in_has_side && out_has_front && out_has_rear && !out_has_side) {
|
2017-08-14 23:29:57 +00:00
|
|
|
gst_audio_channel_mixer_fill_one_other (matrix, in_s, out_f,
|
2015-10-27 12:24:31 +00:00
|
|
|
0.5 * RATIO_FRONT_SIDE);
|
2017-08-14 23:29:57 +00:00
|
|
|
gst_audio_channel_mixer_fill_one_other (matrix, in_s, out_r,
|
2015-10-27 12:24:31 +00:00
|
|
|
0.5 * RATIO_SIDE_REAR);
|
2008-05-29 11:34:09 +00:00
|
|
|
} else if (in_has_side && !out_has_front && !out_has_rear && out_has_center
|
|
|
|
&& !out_has_side) {
|
2017-08-14 23:29:57 +00:00
|
|
|
gst_audio_channel_mixer_fill_one_other (matrix, in_s, out_c,
|
2015-10-27 12:24:31 +00:00
|
|
|
RATIO_CENTER_SIDE);
|
gst/audioconvert/: Implement a channel mixer.
Original commit message from CVS:
* gst/audioconvert/Makefile.am:
* gst/audioconvert/gstaudioconvert.c: (gst_audio_convert_init),
(gst_audio_convert_link), (gst_audio_convert_change_state),
(gst_audio_convert_channels):
* gst/audioconvert/gstchannelmix.c:
(gst_audio_convert_unset_matrix),
(gst_audio_convert_fill_identical),
(gst_audio_convert_fill_compatible),
(gst_audio_convert_detect_pos), (gst_audio_convert_fill_one_other),
(gst_audio_convert_fill_others),
(gst_audio_convert_fill_normalize),
(gst_audio_convert_fill_matrix), (gst_audio_convert_setup_matrix),
(gst_audio_convert_passthrough), (gst_audio_convert_mix):
* gst/audioconvert/gstchannelmix.h:
Implement a channel mixer.
2004-11-28 16:09:13 +00:00
|
|
|
}
|
|
|
|
|
2008-05-29 11:34:09 +00:00
|
|
|
/* rear <-> center/front/side */
|
|
|
|
if (!in_has_rear && in_has_side && out_has_rear) {
|
2017-08-14 23:29:57 +00:00
|
|
|
gst_audio_channel_mixer_fill_one_other (matrix, in_s, out_r,
|
2015-11-06 14:50:34 +00:00
|
|
|
RATIO_SIDE_REAR);
|
2008-05-29 11:34:09 +00:00
|
|
|
} else if (!in_has_rear && !in_has_side && in_has_front && out_has_rear) {
|
2017-08-14 23:29:57 +00:00
|
|
|
gst_audio_channel_mixer_fill_one_other (matrix, in_f, out_r,
|
2015-11-06 14:50:34 +00:00
|
|
|
RATIO_FRONT_REAR);
|
2008-05-29 11:34:09 +00:00
|
|
|
} else if (!in_has_rear && !in_has_side && !in_has_front && in_has_center
|
|
|
|
&& out_has_rear) {
|
2017-08-14 23:29:57 +00:00
|
|
|
gst_audio_channel_mixer_fill_one_other (matrix, in_c, out_r,
|
2015-10-27 12:24:31 +00:00
|
|
|
RATIO_CENTER_REAR);
|
2008-05-29 11:34:09 +00:00
|
|
|
} else if (in_has_rear && !out_has_rear && out_has_side) {
|
2017-08-14 23:29:57 +00:00
|
|
|
gst_audio_channel_mixer_fill_one_other (matrix, in_r, out_s,
|
2015-11-06 14:50:34 +00:00
|
|
|
RATIO_SIDE_REAR);
|
2008-05-29 11:34:09 +00:00
|
|
|
} else if (in_has_rear && !out_has_rear && !out_has_side && out_has_front) {
|
2017-08-14 23:29:57 +00:00
|
|
|
gst_audio_channel_mixer_fill_one_other (matrix, in_r, out_f,
|
2015-11-06 14:50:34 +00:00
|
|
|
RATIO_FRONT_REAR);
|
2008-05-29 11:34:09 +00:00
|
|
|
} else if (in_has_rear && !out_has_rear && !out_has_side && !out_has_front
|
|
|
|
&& out_has_center) {
|
2017-08-14 23:29:57 +00:00
|
|
|
gst_audio_channel_mixer_fill_one_other (matrix, in_r, out_c,
|
2015-10-27 12:24:31 +00:00
|
|
|
RATIO_CENTER_REAR);
|
2008-05-29 11:34:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* bass <-> any */
|
gst/audioconvert/: Implement a channel mixer.
Original commit message from CVS:
* gst/audioconvert/Makefile.am:
* gst/audioconvert/gstaudioconvert.c: (gst_audio_convert_init),
(gst_audio_convert_link), (gst_audio_convert_change_state),
(gst_audio_convert_channels):
* gst/audioconvert/gstchannelmix.c:
(gst_audio_convert_unset_matrix),
(gst_audio_convert_fill_identical),
(gst_audio_convert_fill_compatible),
(gst_audio_convert_detect_pos), (gst_audio_convert_fill_one_other),
(gst_audio_convert_fill_others),
(gst_audio_convert_fill_normalize),
(gst_audio_convert_fill_matrix), (gst_audio_convert_setup_matrix),
(gst_audio_convert_passthrough), (gst_audio_convert_mix):
* gst/audioconvert/gstchannelmix.h:
Implement a channel mixer.
2004-11-28 16:09:13 +00:00
|
|
|
if (in_has_bass && !out_has_bass) {
|
|
|
|
if (out_has_center) {
|
2017-08-14 23:29:57 +00:00
|
|
|
gst_audio_channel_mixer_fill_one_other (matrix, in_b, out_c,
|
2015-10-27 12:24:31 +00:00
|
|
|
RATIO_CENTER_BASS);
|
gst/audioconvert/: Implement a channel mixer.
Original commit message from CVS:
* gst/audioconvert/Makefile.am:
* gst/audioconvert/gstaudioconvert.c: (gst_audio_convert_init),
(gst_audio_convert_link), (gst_audio_convert_change_state),
(gst_audio_convert_channels):
* gst/audioconvert/gstchannelmix.c:
(gst_audio_convert_unset_matrix),
(gst_audio_convert_fill_identical),
(gst_audio_convert_fill_compatible),
(gst_audio_convert_detect_pos), (gst_audio_convert_fill_one_other),
(gst_audio_convert_fill_others),
(gst_audio_convert_fill_normalize),
(gst_audio_convert_fill_matrix), (gst_audio_convert_setup_matrix),
(gst_audio_convert_passthrough), (gst_audio_convert_mix):
* gst/audioconvert/gstchannelmix.h:
Implement a channel mixer.
2004-11-28 16:09:13 +00:00
|
|
|
}
|
2008-05-29 11:34:09 +00:00
|
|
|
if (out_has_front) {
|
2017-08-14 23:29:57 +00:00
|
|
|
gst_audio_channel_mixer_fill_one_other (matrix, in_b, out_f,
|
2015-10-27 12:24:31 +00:00
|
|
|
RATIO_FRONT_BASS);
|
gst/audioconvert/: Implement a channel mixer.
Original commit message from CVS:
* gst/audioconvert/Makefile.am:
* gst/audioconvert/gstaudioconvert.c: (gst_audio_convert_init),
(gst_audio_convert_link), (gst_audio_convert_change_state),
(gst_audio_convert_channels):
* gst/audioconvert/gstchannelmix.c:
(gst_audio_convert_unset_matrix),
(gst_audio_convert_fill_identical),
(gst_audio_convert_fill_compatible),
(gst_audio_convert_detect_pos), (gst_audio_convert_fill_one_other),
(gst_audio_convert_fill_others),
(gst_audio_convert_fill_normalize),
(gst_audio_convert_fill_matrix), (gst_audio_convert_setup_matrix),
(gst_audio_convert_passthrough), (gst_audio_convert_mix):
* gst/audioconvert/gstchannelmix.h:
Implement a channel mixer.
2004-11-28 16:09:13 +00:00
|
|
|
}
|
2008-05-21 11:30:58 +00:00
|
|
|
if (out_has_side) {
|
2017-08-14 23:29:57 +00:00
|
|
|
gst_audio_channel_mixer_fill_one_other (matrix, in_b, out_s,
|
2015-10-27 12:24:31 +00:00
|
|
|
RATIO_SIDE_BASS);
|
2008-05-21 11:30:58 +00:00
|
|
|
}
|
2008-05-29 11:34:09 +00:00
|
|
|
if (out_has_rear) {
|
2017-08-14 23:29:57 +00:00
|
|
|
gst_audio_channel_mixer_fill_one_other (matrix, in_b, out_r,
|
2015-10-27 12:24:31 +00:00
|
|
|
RATIO_REAR_BASS);
|
gst/audioconvert/: Implement a channel mixer.
Original commit message from CVS:
* gst/audioconvert/Makefile.am:
* gst/audioconvert/gstaudioconvert.c: (gst_audio_convert_init),
(gst_audio_convert_link), (gst_audio_convert_change_state),
(gst_audio_convert_channels):
* gst/audioconvert/gstchannelmix.c:
(gst_audio_convert_unset_matrix),
(gst_audio_convert_fill_identical),
(gst_audio_convert_fill_compatible),
(gst_audio_convert_detect_pos), (gst_audio_convert_fill_one_other),
(gst_audio_convert_fill_others),
(gst_audio_convert_fill_normalize),
(gst_audio_convert_fill_matrix), (gst_audio_convert_setup_matrix),
(gst_audio_convert_passthrough), (gst_audio_convert_mix):
* gst/audioconvert/gstchannelmix.h:
Implement a channel mixer.
2004-11-28 16:09:13 +00:00
|
|
|
}
|
2008-05-29 11:34:09 +00:00
|
|
|
} else if (!in_has_bass && out_has_bass) {
|
gst/audioconvert/: Implement a channel mixer.
Original commit message from CVS:
* gst/audioconvert/Makefile.am:
* gst/audioconvert/gstaudioconvert.c: (gst_audio_convert_init),
(gst_audio_convert_link), (gst_audio_convert_change_state),
(gst_audio_convert_channels):
* gst/audioconvert/gstchannelmix.c:
(gst_audio_convert_unset_matrix),
(gst_audio_convert_fill_identical),
(gst_audio_convert_fill_compatible),
(gst_audio_convert_detect_pos), (gst_audio_convert_fill_one_other),
(gst_audio_convert_fill_others),
(gst_audio_convert_fill_normalize),
(gst_audio_convert_fill_matrix), (gst_audio_convert_setup_matrix),
(gst_audio_convert_passthrough), (gst_audio_convert_mix):
* gst/audioconvert/gstchannelmix.h:
Implement a channel mixer.
2004-11-28 16:09:13 +00:00
|
|
|
if (in_has_center) {
|
2017-08-14 23:29:57 +00:00
|
|
|
gst_audio_channel_mixer_fill_one_other (matrix, in_c, out_b,
|
2015-10-27 12:24:31 +00:00
|
|
|
RATIO_CENTER_BASS);
|
gst/audioconvert/: Implement a channel mixer.
Original commit message from CVS:
* gst/audioconvert/Makefile.am:
* gst/audioconvert/gstaudioconvert.c: (gst_audio_convert_init),
(gst_audio_convert_link), (gst_audio_convert_change_state),
(gst_audio_convert_channels):
* gst/audioconvert/gstchannelmix.c:
(gst_audio_convert_unset_matrix),
(gst_audio_convert_fill_identical),
(gst_audio_convert_fill_compatible),
(gst_audio_convert_detect_pos), (gst_audio_convert_fill_one_other),
(gst_audio_convert_fill_others),
(gst_audio_convert_fill_normalize),
(gst_audio_convert_fill_matrix), (gst_audio_convert_setup_matrix),
(gst_audio_convert_passthrough), (gst_audio_convert_mix):
* gst/audioconvert/gstchannelmix.h:
Implement a channel mixer.
2004-11-28 16:09:13 +00:00
|
|
|
}
|
2008-05-29 11:34:09 +00:00
|
|
|
if (in_has_front) {
|
2017-08-14 23:29:57 +00:00
|
|
|
gst_audio_channel_mixer_fill_one_other (matrix, in_f, out_b,
|
2015-10-27 12:24:31 +00:00
|
|
|
RATIO_FRONT_BASS);
|
gst/audioconvert/: Implement a channel mixer.
Original commit message from CVS:
* gst/audioconvert/Makefile.am:
* gst/audioconvert/gstaudioconvert.c: (gst_audio_convert_init),
(gst_audio_convert_link), (gst_audio_convert_change_state),
(gst_audio_convert_channels):
* gst/audioconvert/gstchannelmix.c:
(gst_audio_convert_unset_matrix),
(gst_audio_convert_fill_identical),
(gst_audio_convert_fill_compatible),
(gst_audio_convert_detect_pos), (gst_audio_convert_fill_one_other),
(gst_audio_convert_fill_others),
(gst_audio_convert_fill_normalize),
(gst_audio_convert_fill_matrix), (gst_audio_convert_setup_matrix),
(gst_audio_convert_passthrough), (gst_audio_convert_mix):
* gst/audioconvert/gstchannelmix.h:
Implement a channel mixer.
2004-11-28 16:09:13 +00:00
|
|
|
}
|
2008-05-21 11:30:58 +00:00
|
|
|
if (in_has_side) {
|
2017-08-14 23:29:57 +00:00
|
|
|
gst_audio_channel_mixer_fill_one_other (matrix, in_s, out_b,
|
2015-10-27 12:24:31 +00:00
|
|
|
RATIO_REAR_BASS);
|
2008-05-29 11:34:09 +00:00
|
|
|
}
|
|
|
|
if (in_has_rear) {
|
2017-08-14 23:29:57 +00:00
|
|
|
gst_audio_channel_mixer_fill_one_other (matrix, in_r, out_b,
|
2015-10-27 12:24:31 +00:00
|
|
|
RATIO_REAR_BASS);
|
2008-05-21 11:30:58 +00:00
|
|
|
}
|
|
|
|
}
|
gst/audioconvert/: Implement a channel mixer.
Original commit message from CVS:
* gst/audioconvert/Makefile.am:
* gst/audioconvert/gstaudioconvert.c: (gst_audio_convert_init),
(gst_audio_convert_link), (gst_audio_convert_change_state),
(gst_audio_convert_channels):
* gst/audioconvert/gstchannelmix.c:
(gst_audio_convert_unset_matrix),
(gst_audio_convert_fill_identical),
(gst_audio_convert_fill_compatible),
(gst_audio_convert_detect_pos), (gst_audio_convert_fill_one_other),
(gst_audio_convert_fill_others),
(gst_audio_convert_fill_normalize),
(gst_audio_convert_fill_matrix), (gst_audio_convert_setup_matrix),
(gst_audio_convert_passthrough), (gst_audio_convert_mix):
* gst/audioconvert/gstchannelmix.h:
Implement a channel mixer.
2004-11-28 16:09:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Normalize output values.
|
|
|
|
*/
|
|
|
|
|
|
|
|
static void
|
2017-08-14 23:29:57 +00:00
|
|
|
gst_audio_channel_mixer_fill_normalize (gfloat ** matrix, gint in_channels,
|
|
|
|
gint out_channels)
|
gst/audioconvert/: Implement a channel mixer.
Original commit message from CVS:
* gst/audioconvert/Makefile.am:
* gst/audioconvert/gstaudioconvert.c: (gst_audio_convert_init),
(gst_audio_convert_link), (gst_audio_convert_change_state),
(gst_audio_convert_channels):
* gst/audioconvert/gstchannelmix.c:
(gst_audio_convert_unset_matrix),
(gst_audio_convert_fill_identical),
(gst_audio_convert_fill_compatible),
(gst_audio_convert_detect_pos), (gst_audio_convert_fill_one_other),
(gst_audio_convert_fill_others),
(gst_audio_convert_fill_normalize),
(gst_audio_convert_fill_matrix), (gst_audio_convert_setup_matrix),
(gst_audio_convert_passthrough), (gst_audio_convert_mix):
* gst/audioconvert/gstchannelmix.h:
Implement a channel mixer.
2004-11-28 16:09:13 +00:00
|
|
|
{
|
|
|
|
gfloat sum, top = 0;
|
|
|
|
gint i, j;
|
|
|
|
|
2017-08-14 23:29:57 +00:00
|
|
|
for (j = 0; j < out_channels; j++) {
|
gst/audioconvert/: Implement a channel mixer.
Original commit message from CVS:
* gst/audioconvert/Makefile.am:
* gst/audioconvert/gstaudioconvert.c: (gst_audio_convert_init),
(gst_audio_convert_link), (gst_audio_convert_change_state),
(gst_audio_convert_channels):
* gst/audioconvert/gstchannelmix.c:
(gst_audio_convert_unset_matrix),
(gst_audio_convert_fill_identical),
(gst_audio_convert_fill_compatible),
(gst_audio_convert_detect_pos), (gst_audio_convert_fill_one_other),
(gst_audio_convert_fill_others),
(gst_audio_convert_fill_normalize),
(gst_audio_convert_fill_matrix), (gst_audio_convert_setup_matrix),
(gst_audio_convert_passthrough), (gst_audio_convert_mix):
* gst/audioconvert/gstchannelmix.h:
Implement a channel mixer.
2004-11-28 16:09:13 +00:00
|
|
|
/* calculate sum */
|
|
|
|
sum = 0.0;
|
2017-08-14 23:29:57 +00:00
|
|
|
for (i = 0; i < in_channels; i++) {
|
|
|
|
sum += fabs (matrix[i][j]);
|
gst/audioconvert/: Implement a channel mixer.
Original commit message from CVS:
* gst/audioconvert/Makefile.am:
* gst/audioconvert/gstaudioconvert.c: (gst_audio_convert_init),
(gst_audio_convert_link), (gst_audio_convert_change_state),
(gst_audio_convert_channels):
* gst/audioconvert/gstchannelmix.c:
(gst_audio_convert_unset_matrix),
(gst_audio_convert_fill_identical),
(gst_audio_convert_fill_compatible),
(gst_audio_convert_detect_pos), (gst_audio_convert_fill_one_other),
(gst_audio_convert_fill_others),
(gst_audio_convert_fill_normalize),
(gst_audio_convert_fill_matrix), (gst_audio_convert_setup_matrix),
(gst_audio_convert_passthrough), (gst_audio_convert_mix):
* gst/audioconvert/gstchannelmix.h:
Implement a channel mixer.
2004-11-28 16:09:13 +00:00
|
|
|
}
|
|
|
|
if (sum > top) {
|
|
|
|
top = sum;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-10-27 12:24:31 +00:00
|
|
|
/* normalize to mix */
|
2008-05-21 07:28:04 +00:00
|
|
|
if (top == 0.0)
|
|
|
|
return;
|
|
|
|
|
2017-08-14 23:29:57 +00:00
|
|
|
for (j = 0; j < out_channels; j++) {
|
|
|
|
for (i = 0; i < in_channels; i++) {
|
|
|
|
matrix[i][j] /= top;
|
gst/audioconvert/: Implement a channel mixer.
Original commit message from CVS:
* gst/audioconvert/Makefile.am:
* gst/audioconvert/gstaudioconvert.c: (gst_audio_convert_init),
(gst_audio_convert_link), (gst_audio_convert_change_state),
(gst_audio_convert_channels):
* gst/audioconvert/gstchannelmix.c:
(gst_audio_convert_unset_matrix),
(gst_audio_convert_fill_identical),
(gst_audio_convert_fill_compatible),
(gst_audio_convert_detect_pos), (gst_audio_convert_fill_one_other),
(gst_audio_convert_fill_others),
(gst_audio_convert_fill_normalize),
(gst_audio_convert_fill_matrix), (gst_audio_convert_setup_matrix),
(gst_audio_convert_passthrough), (gst_audio_convert_mix):
* gst/audioconvert/gstchannelmix.h:
Implement a channel mixer.
2004-11-28 16:09:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-05-29 11:34:09 +00:00
|
|
|
static gboolean
|
2017-08-14 23:29:57 +00:00
|
|
|
gst_audio_channel_mixer_fill_special (gfloat ** matrix, gint in_channels,
|
|
|
|
GstAudioChannelPosition * in_position, gint out_channels,
|
|
|
|
GstAudioChannelPosition * out_position)
|
2008-05-29 11:34:09 +00:00
|
|
|
{
|
|
|
|
/* Special, standard conversions here */
|
|
|
|
|
|
|
|
/* Mono<->Stereo, just a fast-path */
|
2017-08-14 23:29:57 +00:00
|
|
|
if (in_channels == 2 && out_channels == 1 &&
|
|
|
|
((in_position[0] == GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT &&
|
|
|
|
in_position[1] == GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT) ||
|
|
|
|
(in_position[0] == GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT &&
|
|
|
|
in_position[1] == GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT)) &&
|
|
|
|
out_position[0] == GST_AUDIO_CHANNEL_POSITION_MONO) {
|
|
|
|
matrix[0][0] = 0.5;
|
|
|
|
matrix[1][0] = 0.5;
|
2008-05-29 11:34:09 +00:00
|
|
|
return TRUE;
|
2017-08-14 23:29:57 +00:00
|
|
|
} else if (in_channels == 1 && out_channels == 2 &&
|
|
|
|
((out_position[0] == GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT &&
|
|
|
|
out_position[1] == GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT) ||
|
|
|
|
(out_position[0] == GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT &&
|
|
|
|
out_position[1] == GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT)) &&
|
|
|
|
in_position[0] == GST_AUDIO_CHANNEL_POSITION_MONO) {
|
|
|
|
matrix[0][0] = 1.0;
|
|
|
|
matrix[0][1] = 1.0;
|
2008-05-29 11:34:09 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* TODO: 5.1 <-> Stereo and other standard conversions */
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
gst/audioconvert/: Implement a channel mixer.
Original commit message from CVS:
* gst/audioconvert/Makefile.am:
* gst/audioconvert/gstaudioconvert.c: (gst_audio_convert_init),
(gst_audio_convert_link), (gst_audio_convert_change_state),
(gst_audio_convert_channels):
* gst/audioconvert/gstchannelmix.c:
(gst_audio_convert_unset_matrix),
(gst_audio_convert_fill_identical),
(gst_audio_convert_fill_compatible),
(gst_audio_convert_detect_pos), (gst_audio_convert_fill_one_other),
(gst_audio_convert_fill_others),
(gst_audio_convert_fill_normalize),
(gst_audio_convert_fill_matrix), (gst_audio_convert_setup_matrix),
(gst_audio_convert_passthrough), (gst_audio_convert_mix):
* gst/audioconvert/gstchannelmix.h:
Implement a channel mixer.
2004-11-28 16:09:13 +00:00
|
|
|
/*
|
|
|
|
* Automagically generate conversion matrix.
|
|
|
|
*/
|
|
|
|
|
|
|
|
static void
|
2017-08-14 23:29:57 +00:00
|
|
|
gst_audio_channel_mixer_fill_matrix (gfloat ** matrix,
|
|
|
|
GstAudioChannelMixerFlags flags, gint in_channels,
|
|
|
|
GstAudioChannelPosition * in_position, gint out_channels,
|
|
|
|
GstAudioChannelPosition * out_position)
|
gst/audioconvert/: Implement a channel mixer.
Original commit message from CVS:
* gst/audioconvert/Makefile.am:
* gst/audioconvert/gstaudioconvert.c: (gst_audio_convert_init),
(gst_audio_convert_link), (gst_audio_convert_change_state),
(gst_audio_convert_channels):
* gst/audioconvert/gstchannelmix.c:
(gst_audio_convert_unset_matrix),
(gst_audio_convert_fill_identical),
(gst_audio_convert_fill_compatible),
(gst_audio_convert_detect_pos), (gst_audio_convert_fill_one_other),
(gst_audio_convert_fill_others),
(gst_audio_convert_fill_normalize),
(gst_audio_convert_fill_matrix), (gst_audio_convert_setup_matrix),
(gst_audio_convert_passthrough), (gst_audio_convert_mix):
* gst/audioconvert/gstchannelmix.h:
Implement a channel mixer.
2004-11-28 16:09:13 +00:00
|
|
|
{
|
2017-08-14 23:29:57 +00:00
|
|
|
if (gst_audio_channel_mixer_fill_special (matrix, in_channels, in_position,
|
|
|
|
out_channels, out_position))
|
2008-05-29 11:34:09 +00:00
|
|
|
return;
|
|
|
|
|
2017-08-14 23:29:57 +00:00
|
|
|
gst_audio_channel_mixer_fill_identical (matrix, in_channels, in_position,
|
|
|
|
out_channels, out_position, flags);
|
2008-05-06 12:12:16 +00:00
|
|
|
|
2017-08-14 23:29:57 +00:00
|
|
|
if (!(flags & GST_AUDIO_CHANNEL_MIXER_FLAGS_UNPOSITIONED_IN)) {
|
|
|
|
gst_audio_channel_mixer_fill_compatible (matrix, in_channels, in_position,
|
|
|
|
out_channels, out_position);
|
|
|
|
gst_audio_channel_mixer_fill_others (matrix, in_channels, in_position,
|
|
|
|
out_channels, out_position);
|
|
|
|
gst_audio_channel_mixer_fill_normalize (matrix, in_channels, out_channels);
|
2008-05-06 12:12:16 +00:00
|
|
|
}
|
gst/audioconvert/: Implement a channel mixer.
Original commit message from CVS:
* gst/audioconvert/Makefile.am:
* gst/audioconvert/gstaudioconvert.c: (gst_audio_convert_init),
(gst_audio_convert_link), (gst_audio_convert_change_state),
(gst_audio_convert_channels):
* gst/audioconvert/gstchannelmix.c:
(gst_audio_convert_unset_matrix),
(gst_audio_convert_fill_identical),
(gst_audio_convert_fill_compatible),
(gst_audio_convert_detect_pos), (gst_audio_convert_fill_one_other),
(gst_audio_convert_fill_others),
(gst_audio_convert_fill_normalize),
(gst_audio_convert_fill_matrix), (gst_audio_convert_setup_matrix),
(gst_audio_convert_passthrough), (gst_audio_convert_mix):
* gst/audioconvert/gstchannelmix.h:
Implement a channel mixer.
2004-11-28 16:09:13 +00:00
|
|
|
}
|
|
|
|
|
2015-10-27 12:24:31 +00:00
|
|
|
/* only call mix after mix->matrix is fully set up and normalized */
|
2015-03-30 09:24:46 +00:00
|
|
|
static void
|
2016-01-08 15:22:25 +00:00
|
|
|
gst_audio_channel_mixer_setup_matrix_int (GstAudioChannelMixer * mix)
|
2015-03-30 09:24:46 +00:00
|
|
|
{
|
|
|
|
gint i, j;
|
|
|
|
gfloat tmp;
|
2016-01-12 14:56:36 +00:00
|
|
|
gfloat factor = (1 << PRECISION_INT);
|
2015-03-30 09:24:46 +00:00
|
|
|
|
2015-10-27 12:24:31 +00:00
|
|
|
mix->matrix_int = g_new0 (gint *, mix->in_channels);
|
2015-03-30 09:24:46 +00:00
|
|
|
|
2015-10-27 12:24:31 +00:00
|
|
|
for (i = 0; i < mix->in_channels; i++) {
|
|
|
|
mix->matrix_int[i] = g_new (gint, mix->out_channels);
|
2015-03-30 09:24:46 +00:00
|
|
|
|
2015-10-27 12:24:31 +00:00
|
|
|
for (j = 0; j < mix->out_channels; j++) {
|
|
|
|
tmp = mix->matrix[i][j] * factor;
|
|
|
|
mix->matrix_int[i][j] = (gint) tmp;
|
2015-03-30 09:24:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-08-14 23:29:57 +00:00
|
|
|
static gfloat **
|
|
|
|
gst_audio_channel_mixer_setup_matrix (GstAudioChannelMixerFlags flags,
|
|
|
|
gint in_channels, GstAudioChannelPosition * in_position,
|
|
|
|
gint out_channels, GstAudioChannelPosition * out_position)
|
gst/audioconvert/: Implement a channel mixer.
Original commit message from CVS:
* gst/audioconvert/Makefile.am:
* gst/audioconvert/gstaudioconvert.c: (gst_audio_convert_init),
(gst_audio_convert_link), (gst_audio_convert_change_state),
(gst_audio_convert_channels):
* gst/audioconvert/gstchannelmix.c:
(gst_audio_convert_unset_matrix),
(gst_audio_convert_fill_identical),
(gst_audio_convert_fill_compatible),
(gst_audio_convert_detect_pos), (gst_audio_convert_fill_one_other),
(gst_audio_convert_fill_others),
(gst_audio_convert_fill_normalize),
(gst_audio_convert_fill_matrix), (gst_audio_convert_setup_matrix),
(gst_audio_convert_passthrough), (gst_audio_convert_mix):
* gst/audioconvert/gstchannelmix.h:
Implement a channel mixer.
2004-11-28 16:09:13 +00:00
|
|
|
{
|
|
|
|
gint i, j;
|
2017-08-14 23:29:57 +00:00
|
|
|
gfloat **matrix = g_new0 (gfloat *, in_channels);
|
gst/audioconvert/: Implement a channel mixer.
Original commit message from CVS:
* gst/audioconvert/Makefile.am:
* gst/audioconvert/gstaudioconvert.c: (gst_audio_convert_init),
(gst_audio_convert_link), (gst_audio_convert_change_state),
(gst_audio_convert_channels):
* gst/audioconvert/gstchannelmix.c:
(gst_audio_convert_unset_matrix),
(gst_audio_convert_fill_identical),
(gst_audio_convert_fill_compatible),
(gst_audio_convert_detect_pos), (gst_audio_convert_fill_one_other),
(gst_audio_convert_fill_others),
(gst_audio_convert_fill_normalize),
(gst_audio_convert_fill_matrix), (gst_audio_convert_setup_matrix),
(gst_audio_convert_passthrough), (gst_audio_convert_mix):
* gst/audioconvert/gstchannelmix.h:
Implement a channel mixer.
2004-11-28 16:09:13 +00:00
|
|
|
|
2017-08-14 23:29:57 +00:00
|
|
|
for (i = 0; i < in_channels; i++) {
|
|
|
|
matrix[i] = g_new (gfloat, out_channels);
|
|
|
|
for (j = 0; j < out_channels; j++)
|
|
|
|
matrix[i][j] = 0.;
|
gst/audioconvert/: Implement a channel mixer.
Original commit message from CVS:
* gst/audioconvert/Makefile.am:
* gst/audioconvert/gstaudioconvert.c: (gst_audio_convert_init),
(gst_audio_convert_link), (gst_audio_convert_change_state),
(gst_audio_convert_channels):
* gst/audioconvert/gstchannelmix.c:
(gst_audio_convert_unset_matrix),
(gst_audio_convert_fill_identical),
(gst_audio_convert_fill_compatible),
(gst_audio_convert_detect_pos), (gst_audio_convert_fill_one_other),
(gst_audio_convert_fill_others),
(gst_audio_convert_fill_normalize),
(gst_audio_convert_fill_matrix), (gst_audio_convert_setup_matrix),
(gst_audio_convert_passthrough), (gst_audio_convert_mix):
* gst/audioconvert/gstchannelmix.h:
Implement a channel mixer.
2004-11-28 16:09:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* setup the matrix' internal values */
|
2017-08-14 23:29:57 +00:00
|
|
|
gst_audio_channel_mixer_fill_matrix (matrix, flags, in_channels, in_position,
|
|
|
|
out_channels, out_position);
|
2015-03-30 09:24:46 +00:00
|
|
|
|
2017-08-14 23:29:57 +00:00
|
|
|
return matrix;
|
gst/audioconvert/: Implement a channel mixer.
Original commit message from CVS:
* gst/audioconvert/Makefile.am:
* gst/audioconvert/gstaudioconvert.c: (gst_audio_convert_init),
(gst_audio_convert_link), (gst_audio_convert_change_state),
(gst_audio_convert_channels):
* gst/audioconvert/gstchannelmix.c:
(gst_audio_convert_unset_matrix),
(gst_audio_convert_fill_identical),
(gst_audio_convert_fill_compatible),
(gst_audio_convert_detect_pos), (gst_audio_convert_fill_one_other),
(gst_audio_convert_fill_others),
(gst_audio_convert_fill_normalize),
(gst_audio_convert_fill_matrix), (gst_audio_convert_setup_matrix),
(gst_audio_convert_passthrough), (gst_audio_convert_mix):
* gst/audioconvert/gstchannelmix.h:
Implement a channel mixer.
2004-11-28 16:09:13 +00:00
|
|
|
}
|
|
|
|
|
2018-01-31 17:28:57 +00:00
|
|
|
#define DEFINE_GET_DATA_FUNCS(type) \
|
|
|
|
static inline type \
|
|
|
|
_get_in_data_interleaved_##type (const type * in_data[], \
|
|
|
|
gint sample, gint channel, gint total_channels) \
|
|
|
|
{ \
|
|
|
|
return in_data[0][sample * total_channels + channel]; \
|
|
|
|
} \
|
|
|
|
\
|
|
|
|
static inline type * \
|
|
|
|
_get_out_data_interleaved_##type (type * out_data[], \
|
|
|
|
gint sample, gint channel, gint total_channels) \
|
|
|
|
{ \
|
|
|
|
return &out_data[0][sample * total_channels + channel]; \
|
|
|
|
} \
|
|
|
|
\
|
|
|
|
static inline type \
|
|
|
|
_get_in_data_planar_##type (const type * in_data[], \
|
|
|
|
gint sample, gint channel, gint total_channels) \
|
|
|
|
{ \
|
|
|
|
(void) total_channels; \
|
|
|
|
return in_data[channel][sample]; \
|
|
|
|
} \
|
|
|
|
\
|
|
|
|
static inline type * \
|
|
|
|
_get_out_data_planar_##type (type * out_data[], \
|
|
|
|
gint sample, gint channel, gint total_channels) \
|
|
|
|
{ \
|
|
|
|
(void) total_channels; \
|
|
|
|
return &out_data[channel][sample]; \
|
2016-01-12 10:43:20 +00:00
|
|
|
}
|
|
|
|
|
2018-01-31 17:28:57 +00:00
|
|
|
#define DEFINE_INTEGER_MIX_FUNC(bits, resbits, inlayout, outlayout) \
|
|
|
|
static void \
|
|
|
|
gst_audio_channel_mixer_mix_int##bits##_##inlayout##_##outlayout ( \
|
|
|
|
GstAudioChannelMixer * mix, const gint##bits * in_data[], \
|
|
|
|
gint##bits * out_data[], gint samples) \
|
|
|
|
{ \
|
|
|
|
gint in, out, n; \
|
|
|
|
gint##resbits res; \
|
|
|
|
gint inchannels, outchannels; \
|
|
|
|
\
|
|
|
|
inchannels = mix->in_channels; \
|
|
|
|
outchannels = mix->out_channels; \
|
|
|
|
\
|
|
|
|
for (n = 0; n < samples; n++) { \
|
|
|
|
for (out = 0; out < outchannels; out++) { \
|
|
|
|
/* convert */ \
|
|
|
|
res = 0; \
|
|
|
|
for (in = 0; in < inchannels; in++) \
|
|
|
|
res += \
|
|
|
|
_get_in_data_##inlayout##_gint##bits (in_data, n, in, inchannels) * \
|
|
|
|
(gint##resbits) mix->matrix_int[in][out]; \
|
|
|
|
\
|
|
|
|
/* remove factor from int matrix */ \
|
|
|
|
res = (res + (1 << (PRECISION_INT - 1))) >> PRECISION_INT; \
|
|
|
|
*_get_out_data_##outlayout##_gint##bits (out_data, n, out, outchannels) = \
|
|
|
|
CLAMP (res, G_MININT##bits, G_MAXINT##bits); \
|
|
|
|
} \
|
|
|
|
} \
|
2016-01-12 10:43:20 +00:00
|
|
|
}
|
|
|
|
|
2018-01-31 17:28:57 +00:00
|
|
|
#define DEFINE_FLOAT_MIX_FUNC(type, inlayout, outlayout) \
|
|
|
|
static void \
|
|
|
|
gst_audio_channel_mixer_mix_##type##_##inlayout##_##outlayout ( \
|
|
|
|
GstAudioChannelMixer * mix, const g##type * in_data[], \
|
|
|
|
g##type * out_data[], gint samples) \
|
|
|
|
{ \
|
|
|
|
gint in, out, n; \
|
|
|
|
g##type res; \
|
|
|
|
gint inchannels, outchannels; \
|
|
|
|
\
|
|
|
|
inchannels = mix->in_channels; \
|
|
|
|
outchannels = mix->out_channels; \
|
|
|
|
\
|
|
|
|
for (n = 0; n < samples; n++) { \
|
|
|
|
for (out = 0; out < outchannels; out++) { \
|
|
|
|
/* convert */ \
|
|
|
|
res = 0.0; \
|
|
|
|
for (in = 0; in < inchannels; in++) \
|
|
|
|
res += \
|
|
|
|
_get_in_data_##inlayout##_g##type (in_data, n, in, inchannels) * \
|
|
|
|
mix->matrix[in][out]; \
|
|
|
|
\
|
|
|
|
*_get_out_data_##outlayout##_g##type (out_data, n, out, outchannels) = res; \
|
|
|
|
} \
|
|
|
|
} \
|
gst/audioconvert/: Implement a channel mixer.
Original commit message from CVS:
* gst/audioconvert/Makefile.am:
* gst/audioconvert/gstaudioconvert.c: (gst_audio_convert_init),
(gst_audio_convert_link), (gst_audio_convert_change_state),
(gst_audio_convert_channels):
* gst/audioconvert/gstchannelmix.c:
(gst_audio_convert_unset_matrix),
(gst_audio_convert_fill_identical),
(gst_audio_convert_fill_compatible),
(gst_audio_convert_detect_pos), (gst_audio_convert_fill_one_other),
(gst_audio_convert_fill_others),
(gst_audio_convert_fill_normalize),
(gst_audio_convert_fill_matrix), (gst_audio_convert_setup_matrix),
(gst_audio_convert_passthrough), (gst_audio_convert_mix):
* gst/audioconvert/gstchannelmix.h:
Implement a channel mixer.
2004-11-28 16:09:13 +00:00
|
|
|
}
|
Add float as an intermediate format, as well as float mixing. Enable test that was failing before. Fixes #339837
Original commit message from CVS:
* gst/audioconvert/audioconvert.c: (float), (double), (float_hq),
(double_hq), (audio_convert_get_func_index),
(audio_convert_prepare_context), (audio_convert_convert):
* gst/audioconvert/audioconvert.h:
* gst/audioconvert/gstchannelmix.c: (gst_channel_mix_setup_matrix),
(gst_channel_mix_mix_int), (gst_channel_mix_mix_float):
* gst/audioconvert/gstchannelmix.h:
* tests/check/elements/audioconvert.c: (GST_START_TEST):
Add float as an intermediate format, as well as float mixing. Enable
test that was failing before. Fixes #339837
2007-02-22 09:04:37 +00:00
|
|
|
|
2018-01-31 17:28:57 +00:00
|
|
|
DEFINE_GET_DATA_FUNCS (gint16);
|
|
|
|
DEFINE_INTEGER_MIX_FUNC (16, 32, interleaved, interleaved);
|
|
|
|
DEFINE_INTEGER_MIX_FUNC (16, 32, interleaved, planar);
|
|
|
|
DEFINE_INTEGER_MIX_FUNC (16, 32, planar, interleaved);
|
|
|
|
DEFINE_INTEGER_MIX_FUNC (16, 32, planar, planar);
|
|
|
|
|
|
|
|
DEFINE_GET_DATA_FUNCS (gint32);
|
|
|
|
DEFINE_INTEGER_MIX_FUNC (32, 64, interleaved, interleaved);
|
|
|
|
DEFINE_INTEGER_MIX_FUNC (32, 64, interleaved, planar);
|
|
|
|
DEFINE_INTEGER_MIX_FUNC (32, 64, planar, interleaved);
|
|
|
|
DEFINE_INTEGER_MIX_FUNC (32, 64, planar, planar);
|
|
|
|
|
|
|
|
DEFINE_GET_DATA_FUNCS (gfloat);
|
|
|
|
DEFINE_FLOAT_MIX_FUNC (float, interleaved, interleaved);
|
|
|
|
DEFINE_FLOAT_MIX_FUNC (float, interleaved, planar);
|
|
|
|
DEFINE_FLOAT_MIX_FUNC (float, planar, interleaved);
|
|
|
|
DEFINE_FLOAT_MIX_FUNC (float, planar, planar);
|
|
|
|
|
|
|
|
DEFINE_GET_DATA_FUNCS (gdouble);
|
|
|
|
DEFINE_FLOAT_MIX_FUNC (double, interleaved, interleaved);
|
|
|
|
DEFINE_FLOAT_MIX_FUNC (double, interleaved, planar);
|
|
|
|
DEFINE_FLOAT_MIX_FUNC (double, planar, interleaved);
|
|
|
|
DEFINE_FLOAT_MIX_FUNC (double, planar, planar);
|
2015-10-27 12:24:31 +00:00
|
|
|
|
2015-11-06 15:03:20 +00:00
|
|
|
/**
|
2017-08-14 23:29:57 +00:00
|
|
|
* gst_audio_channel_mixer_new_with_matrix: (skip):
|
2016-01-08 15:22:25 +00:00
|
|
|
* @flags: #GstAudioChannelMixerFlags
|
|
|
|
* @in_channels: number of input channels
|
|
|
|
* @out_channels: number of output channels
|
2017-08-14 23:29:57 +00:00
|
|
|
* @matrix: (transfer full) (nullable): channel conversion matrix, m[@in_channels][@out_channels].
|
2017-10-11 16:03:20 +00:00
|
|
|
* If identity matrix, passthrough applies. If %NULL, a (potentially truncated)
|
|
|
|
* identity matrix is generated.
|
2015-11-06 15:03:20 +00:00
|
|
|
*
|
2016-01-08 15:22:25 +00:00
|
|
|
* Create a new channel mixer object for the given parameters.
|
2015-11-06 15:03:20 +00:00
|
|
|
*
|
2022-10-14 19:04:00 +00:00
|
|
|
* Returns: a new #GstAudioChannelMixer object.
|
2017-08-14 23:29:57 +00:00
|
|
|
* Free with gst_audio_channel_mixer_free() after usage.
|
|
|
|
*
|
|
|
|
* Since: 1.14
|
2015-11-06 15:03:20 +00:00
|
|
|
*/
|
2016-01-08 15:22:25 +00:00
|
|
|
GstAudioChannelMixer *
|
2017-08-14 23:29:57 +00:00
|
|
|
gst_audio_channel_mixer_new_with_matrix (GstAudioChannelMixerFlags flags,
|
2015-11-06 15:03:20 +00:00
|
|
|
GstAudioFormat format,
|
2017-08-14 23:29:57 +00:00
|
|
|
gint in_channels, gint out_channels, gfloat ** matrix)
|
2015-11-06 15:03:20 +00:00
|
|
|
{
|
2016-01-08 15:22:25 +00:00
|
|
|
GstAudioChannelMixer *mix;
|
2015-11-06 15:03:20 +00:00
|
|
|
|
2016-01-12 10:43:20 +00:00
|
|
|
g_return_val_if_fail (format == GST_AUDIO_FORMAT_S16
|
|
|
|
|| format == GST_AUDIO_FORMAT_S32
|
|
|
|
|| format == GST_AUDIO_FORMAT_F32
|
2015-11-06 15:03:20 +00:00
|
|
|
|| format == GST_AUDIO_FORMAT_F64, NULL);
|
2023-02-13 19:46:03 +00:00
|
|
|
g_return_val_if_fail (in_channels > 0 && in_channels <= 64, NULL);
|
|
|
|
g_return_val_if_fail (out_channels > 0 && out_channels <= 64, NULL);
|
2015-11-06 15:03:20 +00:00
|
|
|
|
2016-01-08 15:22:25 +00:00
|
|
|
mix = g_slice_new0 (GstAudioChannelMixer);
|
2015-11-06 15:03:20 +00:00
|
|
|
mix->in_channels = in_channels;
|
|
|
|
mix->out_channels = out_channels;
|
|
|
|
|
2017-08-14 23:29:57 +00:00
|
|
|
if (!matrix) {
|
2017-10-11 16:03:20 +00:00
|
|
|
/* Generate (potentially truncated) identity matrix */
|
2017-08-14 23:29:57 +00:00
|
|
|
gint i, j;
|
|
|
|
|
|
|
|
mix->matrix = g_new0 (gfloat *, in_channels);
|
|
|
|
|
|
|
|
for (i = 0; i < in_channels; i++) {
|
|
|
|
mix->matrix[i] = g_new (gfloat, out_channels);
|
|
|
|
for (j = 0; j < out_channels; j++) {
|
|
|
|
mix->matrix[i][j] = i == j ? 1.0 : 0.0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
mix->matrix = matrix;
|
|
|
|
}
|
|
|
|
|
|
|
|
gst_audio_channel_mixer_setup_matrix_int (mix);
|
2015-11-06 15:42:35 +00:00
|
|
|
|
2017-08-14 23:29:57 +00:00
|
|
|
#ifndef GST_DISABLE_GST_DEBUG
|
|
|
|
/* debug */
|
|
|
|
{
|
|
|
|
GString *s;
|
|
|
|
gint i, j;
|
|
|
|
|
|
|
|
s = g_string_new ("Matrix for");
|
|
|
|
g_string_append_printf (s, " %d -> %d: ",
|
|
|
|
mix->in_channels, mix->out_channels);
|
|
|
|
g_string_append (s, "{");
|
|
|
|
for (i = 0; i < mix->in_channels; i++) {
|
|
|
|
if (i != 0)
|
|
|
|
g_string_append (s, ",");
|
|
|
|
g_string_append (s, " {");
|
|
|
|
for (j = 0; j < mix->out_channels; j++) {
|
|
|
|
if (j != 0)
|
|
|
|
g_string_append (s, ",");
|
|
|
|
g_string_append_printf (s, " %f", mix->matrix[i][j]);
|
|
|
|
}
|
|
|
|
g_string_append (s, " }");
|
|
|
|
}
|
|
|
|
g_string_append (s, " }");
|
|
|
|
GST_DEBUG ("%s", s->str);
|
|
|
|
g_string_free (s, TRUE);
|
|
|
|
}
|
|
|
|
#endif
|
2015-11-06 15:03:20 +00:00
|
|
|
|
2017-08-14 23:29:57 +00:00
|
|
|
switch (format) {
|
2016-01-12 10:43:20 +00:00
|
|
|
case GST_AUDIO_FORMAT_S16:
|
2018-01-31 17:28:57 +00:00
|
|
|
if (flags & GST_AUDIO_CHANNEL_MIXER_FLAGS_NON_INTERLEAVED_IN) {
|
|
|
|
if (flags & GST_AUDIO_CHANNEL_MIXER_FLAGS_NON_INTERLEAVED_OUT) {
|
|
|
|
mix->func = (MixerFunc)
|
|
|
|
gst_audio_channel_mixer_mix_int16_planar_planar;
|
|
|
|
} else {
|
|
|
|
mix->func = (MixerFunc)
|
|
|
|
gst_audio_channel_mixer_mix_int16_planar_interleaved;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (flags & GST_AUDIO_CHANNEL_MIXER_FLAGS_NON_INTERLEAVED_OUT) {
|
|
|
|
mix->func = (MixerFunc)
|
|
|
|
gst_audio_channel_mixer_mix_int16_interleaved_planar;
|
|
|
|
} else {
|
|
|
|
mix->func = (MixerFunc)
|
|
|
|
gst_audio_channel_mixer_mix_int16_interleaved_interleaved;
|
|
|
|
}
|
|
|
|
}
|
2016-01-12 10:43:20 +00:00
|
|
|
break;
|
2015-11-06 15:03:20 +00:00
|
|
|
case GST_AUDIO_FORMAT_S32:
|
2018-01-31 17:28:57 +00:00
|
|
|
if (flags & GST_AUDIO_CHANNEL_MIXER_FLAGS_NON_INTERLEAVED_IN) {
|
|
|
|
if (flags & GST_AUDIO_CHANNEL_MIXER_FLAGS_NON_INTERLEAVED_OUT) {
|
|
|
|
mix->func = (MixerFunc)
|
|
|
|
gst_audio_channel_mixer_mix_int32_planar_planar;
|
|
|
|
} else {
|
|
|
|
mix->func = (MixerFunc)
|
|
|
|
gst_audio_channel_mixer_mix_int32_planar_interleaved;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (flags & GST_AUDIO_CHANNEL_MIXER_FLAGS_NON_INTERLEAVED_OUT) {
|
|
|
|
mix->func = (MixerFunc)
|
|
|
|
gst_audio_channel_mixer_mix_int32_interleaved_planar;
|
|
|
|
} else {
|
|
|
|
mix->func = (MixerFunc)
|
|
|
|
gst_audio_channel_mixer_mix_int32_interleaved_interleaved;
|
|
|
|
}
|
|
|
|
}
|
2016-01-12 10:43:20 +00:00
|
|
|
break;
|
|
|
|
case GST_AUDIO_FORMAT_F32:
|
2018-01-31 17:28:57 +00:00
|
|
|
if (flags & GST_AUDIO_CHANNEL_MIXER_FLAGS_NON_INTERLEAVED_IN) {
|
|
|
|
if (flags & GST_AUDIO_CHANNEL_MIXER_FLAGS_NON_INTERLEAVED_OUT) {
|
|
|
|
mix->func = (MixerFunc)
|
|
|
|
gst_audio_channel_mixer_mix_float_planar_planar;
|
|
|
|
} else {
|
|
|
|
mix->func = (MixerFunc)
|
|
|
|
gst_audio_channel_mixer_mix_float_planar_interleaved;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (flags & GST_AUDIO_CHANNEL_MIXER_FLAGS_NON_INTERLEAVED_OUT) {
|
|
|
|
mix->func = (MixerFunc)
|
|
|
|
gst_audio_channel_mixer_mix_float_interleaved_planar;
|
|
|
|
} else {
|
|
|
|
mix->func = (MixerFunc)
|
|
|
|
gst_audio_channel_mixer_mix_float_interleaved_interleaved;
|
|
|
|
}
|
|
|
|
}
|
2015-11-06 15:03:20 +00:00
|
|
|
break;
|
|
|
|
case GST_AUDIO_FORMAT_F64:
|
2018-01-31 17:28:57 +00:00
|
|
|
if (flags & GST_AUDIO_CHANNEL_MIXER_FLAGS_NON_INTERLEAVED_IN) {
|
|
|
|
if (flags & GST_AUDIO_CHANNEL_MIXER_FLAGS_NON_INTERLEAVED_OUT) {
|
|
|
|
mix->func = (MixerFunc)
|
|
|
|
gst_audio_channel_mixer_mix_double_planar_planar;
|
|
|
|
} else {
|
|
|
|
mix->func = (MixerFunc)
|
|
|
|
gst_audio_channel_mixer_mix_double_planar_interleaved;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (flags & GST_AUDIO_CHANNEL_MIXER_FLAGS_NON_INTERLEAVED_OUT) {
|
|
|
|
mix->func = (MixerFunc)
|
|
|
|
gst_audio_channel_mixer_mix_double_interleaved_planar;
|
|
|
|
} else {
|
|
|
|
mix->func = (MixerFunc)
|
|
|
|
gst_audio_channel_mixer_mix_double_interleaved_interleaved;
|
|
|
|
}
|
|
|
|
}
|
2015-11-06 15:03:20 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
g_assert_not_reached ();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return mix;
|
|
|
|
}
|
|
|
|
|
2017-08-14 23:29:57 +00:00
|
|
|
/**
|
|
|
|
* gst_audio_channel_mixer_new: (skip):
|
|
|
|
* @flags: #GstAudioChannelMixerFlags
|
|
|
|
* @in_channels: number of input channels
|
|
|
|
* @in_position: positions of input channels
|
|
|
|
* @out_channels: number of output channels
|
|
|
|
* @out_position: positions of output channels
|
|
|
|
*
|
|
|
|
* Create a new channel mixer object for the given parameters.
|
|
|
|
*
|
2022-10-14 19:04:00 +00:00
|
|
|
* Returns: a new #GstAudioChannelMixer object.
|
2017-08-14 23:29:57 +00:00
|
|
|
* Free with gst_audio_channel_mixer_free() after usage.
|
|
|
|
*/
|
|
|
|
GstAudioChannelMixer *
|
|
|
|
gst_audio_channel_mixer_new (GstAudioChannelMixerFlags flags,
|
|
|
|
GstAudioFormat format,
|
|
|
|
gint in_channels,
|
|
|
|
GstAudioChannelPosition * in_position,
|
|
|
|
gint out_channels, GstAudioChannelPosition * out_position)
|
|
|
|
{
|
|
|
|
gfloat **matrix;
|
|
|
|
|
|
|
|
g_return_val_if_fail (format == GST_AUDIO_FORMAT_S16
|
|
|
|
|| format == GST_AUDIO_FORMAT_S32
|
|
|
|
|| format == GST_AUDIO_FORMAT_F32
|
|
|
|
|| format == GST_AUDIO_FORMAT_F64, NULL);
|
2023-02-13 19:46:03 +00:00
|
|
|
g_return_val_if_fail (in_channels > 0 && in_channels <= 64, NULL);
|
|
|
|
g_return_val_if_fail (out_channels > 0 && out_channels <= 64, NULL);
|
2017-08-14 23:29:57 +00:00
|
|
|
|
|
|
|
matrix =
|
|
|
|
gst_audio_channel_mixer_setup_matrix (flags, in_channels, in_position,
|
|
|
|
out_channels, out_position);
|
|
|
|
return gst_audio_channel_mixer_new_with_matrix (flags, format, in_channels,
|
|
|
|
out_channels, matrix);
|
|
|
|
}
|
|
|
|
|
2015-11-06 15:03:20 +00:00
|
|
|
/**
|
2016-01-08 15:22:25 +00:00
|
|
|
* gst_audio_channel_mixer_is_passthrough:
|
|
|
|
* @mix: a #GstAudioChannelMixer
|
2015-11-06 15:03:20 +00:00
|
|
|
*
|
|
|
|
* Check if @mix is in passthrough.
|
|
|
|
*
|
2017-08-14 23:29:57 +00:00
|
|
|
* Only N x N mix identity matrices are considered passthrough,
|
|
|
|
* this is determined by comparing the contents of the matrix
|
|
|
|
* with 0.0 and 1.0.
|
|
|
|
*
|
|
|
|
* As this is floating point comparisons, if the values have been
|
|
|
|
* generated, they should be rounded up or down by explicit
|
|
|
|
* assignment of 0.0 or 1.0 to values within a user-defined
|
|
|
|
* epsilon, this code doesn't make assumptions as to what may
|
|
|
|
* constitute an appropriate epsilon.
|
|
|
|
*
|
2015-11-06 15:03:20 +00:00
|
|
|
* Returns: %TRUE is @mix is passthrough.
|
|
|
|
*/
|
|
|
|
gboolean
|
2016-01-08 15:22:25 +00:00
|
|
|
gst_audio_channel_mixer_is_passthrough (GstAudioChannelMixer * mix)
|
2015-11-06 15:03:20 +00:00
|
|
|
{
|
2017-08-14 23:29:57 +00:00
|
|
|
gint i, j;
|
|
|
|
gboolean res;
|
2015-11-06 15:03:20 +00:00
|
|
|
|
|
|
|
/* only NxN matrices can be identities */
|
|
|
|
if (mix->in_channels != mix->out_channels)
|
|
|
|
return FALSE;
|
|
|
|
|
2017-08-14 23:29:57 +00:00
|
|
|
res = TRUE;
|
2015-11-06 15:03:20 +00:00
|
|
|
|
|
|
|
for (i = 0; i < mix->in_channels; i++) {
|
2017-08-14 23:29:57 +00:00
|
|
|
for (j = 0; j < mix->out_channels; j++) {
|
|
|
|
if ((i == j && mix->matrix[i][j] != 1.0f) ||
|
|
|
|
(i != j && mix->matrix[i][j] != 0.0f)) {
|
|
|
|
res = FALSE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2015-11-06 15:03:20 +00:00
|
|
|
}
|
2017-08-14 23:29:57 +00:00
|
|
|
|
|
|
|
return res;
|
2015-11-06 15:03:20 +00:00
|
|
|
}
|
|
|
|
|
2015-10-27 12:24:31 +00:00
|
|
|
/**
|
2016-01-08 15:22:25 +00:00
|
|
|
* gst_audio_channel_mixer_samples:
|
|
|
|
* @mix: a #GstAudioChannelMixer
|
2015-12-10 16:46:26 +00:00
|
|
|
* @in: input samples
|
|
|
|
* @out: output samples
|
2015-11-06 11:46:36 +00:00
|
|
|
* @samples: number of samples
|
2015-10-27 12:24:31 +00:00
|
|
|
*
|
2015-12-10 16:46:26 +00:00
|
|
|
* In case the samples are interleaved, @in and @out must point to an
|
|
|
|
* array with a single element pointing to a block of interleaved samples.
|
|
|
|
*
|
|
|
|
* If non-interleaved samples are used, @in and @out must point to an
|
|
|
|
* array with pointers to memory blocks, one for each channel.
|
|
|
|
*
|
2015-11-06 11:46:36 +00:00
|
|
|
* Perform channel mixing on @in_data and write the result to @out_data.
|
|
|
|
* @in_data and @out_data need to be in @format and @layout.
|
2015-10-27 12:24:31 +00:00
|
|
|
*/
|
|
|
|
void
|
2016-01-08 15:22:25 +00:00
|
|
|
gst_audio_channel_mixer_samples (GstAudioChannelMixer * mix,
|
2015-12-10 16:46:26 +00:00
|
|
|
const gpointer in[], gpointer out[], gint samples)
|
2015-10-27 12:24:31 +00:00
|
|
|
{
|
|
|
|
g_return_if_fail (mix != NULL);
|
|
|
|
g_return_if_fail (mix->matrix != NULL);
|
|
|
|
|
2018-01-31 17:28:57 +00:00
|
|
|
mix->func (mix, in, out, samples);
|
2015-10-27 12:24:31 +00:00
|
|
|
}
|