channelmix: GstChannel -> GstAudioChannel

Rename GstChannel to GstAudioChannel
This commit is contained in:
Wim Taymans 2015-11-06 15:50:34 +01:00
parent 59db8ce542
commit 7f5104f52f
3 changed files with 136 additions and 122 deletions

View file

@ -78,7 +78,7 @@ struct _GstAudioConverter
GstAudioFormat mix_format; GstAudioFormat mix_format;
gboolean mix_passthrough; gboolean mix_passthrough;
GstChannelMix *mix; GstAudioChannelMix *mix;
AudioConvertFunc convert_out; AudioConvertFunc convert_out;
@ -203,7 +203,7 @@ gst_audio_converter_new (GstAudioInfo * in, GstAudioInfo * out,
{ {
GstAudioConverter *convert; GstAudioConverter *convert;
gint in_depth, out_depth; gint in_depth, out_depth;
GstChannelMixFlags flags; GstAudioChannelMixFlags flags;
gboolean in_int, out_int; gboolean in_int, out_int;
GstAudioFormat format; GstAudioFormat format;
GstAudioDitherMethod dither; GstAudioDitherMethod dither;
@ -242,10 +242,10 @@ gst_audio_converter_new (GstAudioInfo * in, GstAudioInfo * out,
flags = flags =
GST_AUDIO_INFO_IS_UNPOSITIONED (in) ? GST_AUDIO_INFO_IS_UNPOSITIONED (in) ?
GST_CHANNEL_MIX_FLAGS_UNPOSITIONED_IN : 0; GST_AUDIO_CHANNEL_MIX_FLAGS_UNPOSITIONED_IN : 0;
flags |= flags |=
GST_AUDIO_INFO_IS_UNPOSITIONED (out) ? GST_AUDIO_INFO_IS_UNPOSITIONED (out) ?
GST_CHANNEL_MIX_FLAGS_UNPOSITIONED_OUT : 0; GST_AUDIO_CHANNEL_MIX_FLAGS_UNPOSITIONED_OUT : 0;
/* step 1, unpack */ /* step 1, unpack */
@ -264,9 +264,10 @@ gst_audio_converter_new (GstAudioInfo * in, GstAudioInfo * out,
/* step 3, channel mix */ /* step 3, channel mix */
convert->mix_format = format; convert->mix_format = format;
convert->mix = gst_channel_mix_new (flags, in->channels, in->position, convert->mix = gst_audio_channel_mix_new (flags, in->channels, in->position,
out->channels, out->position); out->channels, out->position);
convert->mix_passthrough = gst_channel_mix_is_passthrough (convert->mix); convert->mix_passthrough =
gst_audio_channel_mix_is_passthrough (convert->mix);
GST_INFO ("mix format %s, passthrough %d, in_channels %d, out_channels %d", GST_INFO ("mix format %s, passthrough %d, in_channels %d, out_channels %d",
gst_audio_format_to_string (format), convert->mix_passthrough, gst_audio_format_to_string (format), convert->mix_passthrough,
in->channels, out->channels); in->channels, out->channels);
@ -336,7 +337,7 @@ gst_audio_converter_free (GstAudioConverter * convert)
if (convert->quant) if (convert->quant)
gst_audio_quantize_free (convert->quant); gst_audio_quantize_free (convert->quant);
if (convert->mix) if (convert->mix)
gst_channel_mix_free (convert->mix); gst_audio_channel_mix_free (convert->mix);
gst_audio_info_init (&convert->in); gst_audio_info_init (&convert->in);
gst_audio_info_init (&convert->out); gst_audio_info_init (&convert->out);
@ -426,8 +427,8 @@ gst_audio_converter_samples (GstAudioConverter * convert,
else else
outbuf = tmpbuf; outbuf = tmpbuf;
gst_channel_mix_mix (convert->mix, convert->mix_format, convert->in.layout, gst_audio_channel_mix_samples (convert->mix, convert->mix_format,
src, outbuf, samples); convert->in.layout, src, outbuf, samples);
src = outbuf; src = outbuf;
} }
/* step 4, optional convert F64 -> S32 for quantize */ /* step 4, optional convert F64 -> S32 for quantize */

View file

@ -31,9 +31,9 @@
#define INT_MATRIX_FACTOR_EXPONENT 10 #define INT_MATRIX_FACTOR_EXPONENT 10
struct _GstChannelMix struct _GstAudioChannelMix
{ {
GstChannelMixFlags flags; GstAudioChannelMixFlags flags;
gint in_channels; gint in_channels;
gint out_channels; gint out_channels;
@ -53,13 +53,13 @@ struct _GstChannelMix
}; };
/** /**
* gst_channel_mix_free: * gst_audio_channel_mix_free:
* @mix: a #GstChannelMix * @mix: a #GstAudioChannelMix
* *
* Free memory allocated by @mix. * Free memory allocated by @mix.
*/ */
void void
gst_channel_mix_free (GstChannelMix * mix) gst_audio_channel_mix_free (GstAudioChannelMix * mix)
{ {
gint i; gint i;
@ -77,7 +77,7 @@ gst_channel_mix_free (GstChannelMix * mix)
g_free (mix->tmp); g_free (mix->tmp);
mix->tmp = NULL; mix->tmp = NULL;
g_slice_free (GstChannelMix, mix); g_slice_free (GstAudioChannelMix, mix);
} }
/* /*
@ -87,7 +87,7 @@ gst_channel_mix_free (GstChannelMix * mix)
*/ */
static void static void
gst_channel_mix_fill_identical (GstChannelMix * mix) gst_audio_channel_mix_fill_identical (GstAudioChannelMix * mix)
{ {
gint ci, co; gint ci, co;
@ -111,7 +111,7 @@ gst_channel_mix_fill_identical (GstChannelMix * mix)
*/ */
static void static void
gst_channel_mix_fill_compatible (GstChannelMix * mix) gst_audio_channel_mix_fill_compatible (GstAudioChannelMix * mix)
{ {
/* Conversions from one-channel to compatible two-channel configs */ /* Conversions from one-channel to compatible two-channel configs */
struct struct
@ -209,10 +209,10 @@ gst_channel_mix_fill_compatible (GstChannelMix * mix)
*/ */
static void static void
gst_channel_mix_detect_pos (gint channels, GstAudioChannelPosition position[64], gst_audio_channel_mix_detect_pos (gint channels,
gint * f, gboolean * has_f, GstAudioChannelPosition position[64], gint * f, gboolean * has_f, gint * c,
gint * c, gboolean * has_c, gint * r, gboolean * has_r, gboolean * has_c, gint * r, gboolean * has_r, gint * s, gboolean * has_s,
gint * s, gboolean * has_s, gint * b, gboolean * has_b) gint * b, gboolean * has_b)
{ {
gint n; gint n;
@ -273,7 +273,7 @@ gst_channel_mix_detect_pos (gint channels, GstAudioChannelPosition position[64],
} }
static void static void
gst_channel_mix_fill_one_other (gfloat ** matrix, gst_audio_channel_mix_fill_one_other (gfloat ** matrix,
gint * from_idx, gint * to_idx, gfloat ratio) gint * from_idx, gint * to_idx, gfloat ratio)
{ {
@ -339,7 +339,7 @@ gst_channel_mix_fill_one_other (gfloat ** matrix,
#define RATIO_REAR_BASS (1.0 / sqrt (2.0)) #define RATIO_REAR_BASS (1.0 / sqrt (2.0))
static void static void
gst_channel_mix_fill_others (GstChannelMix * mix) gst_audio_channel_mix_fill_others (GstAudioChannelMix * mix)
{ {
gboolean in_has_front = FALSE, out_has_front = FALSE, gboolean in_has_front = FALSE, out_has_front = FALSE,
in_has_center = FALSE, out_has_center = FALSE, in_has_center = FALSE, out_has_center = FALSE,
@ -364,11 +364,11 @@ gst_channel_mix_fill_others (GstChannelMix * mix)
/* First see where (if at all) the various channels from/to /* First see where (if at all) the various channels from/to
* which we want to convert are located in our matrix/array. */ * which we want to convert are located in our matrix/array. */
gst_channel_mix_detect_pos (mix->in_channels, mix->in_position, gst_audio_channel_mix_detect_pos (mix->in_channels, mix->in_position,
in_f, &in_has_front, in_f, &in_has_front,
in_c, &in_has_center, in_r, &in_has_rear, in_c, &in_has_center, in_r, &in_has_rear,
in_s, &in_has_side, in_b, &in_has_bass); in_s, &in_has_side, in_b, &in_has_bass);
gst_channel_mix_detect_pos (mix->out_channels, mix->out_position, gst_audio_channel_mix_detect_pos (mix->out_channels, mix->out_position,
out_f, &out_has_front, out_f, &out_has_front,
out_c, &out_has_center, out_r, &out_has_rear, out_c, &out_has_center, out_r, &out_has_rear,
out_s, &out_has_side, out_b, &out_has_bass); out_s, &out_has_side, out_b, &out_has_bass);
@ -385,137 +385,149 @@ gst_channel_mix_fill_others (GstChannelMix * mix)
/* center <-> front/side/rear */ /* center <-> front/side/rear */
if (!in_has_center && in_has_front && out_has_center) { if (!in_has_center && in_has_front && out_has_center) {
gst_channel_mix_fill_one_other (mix->matrix, in_f, out_c, gst_audio_channel_mix_fill_one_other (mix->matrix, in_f, out_c,
RATIO_CENTER_FRONT); RATIO_CENTER_FRONT);
} else if (!in_has_center && !in_has_front && in_has_side && out_has_center) { } else if (!in_has_center && !in_has_front && in_has_side && out_has_center) {
gst_channel_mix_fill_one_other (mix->matrix, in_s, out_c, gst_audio_channel_mix_fill_one_other (mix->matrix, in_s, out_c,
RATIO_CENTER_SIDE); RATIO_CENTER_SIDE);
} else if (!in_has_center && !in_has_front && !in_has_side && in_has_rear } else if (!in_has_center && !in_has_front && !in_has_side && in_has_rear
&& out_has_center) { && out_has_center) {
gst_channel_mix_fill_one_other (mix->matrix, in_r, out_c, gst_audio_channel_mix_fill_one_other (mix->matrix, in_r, out_c,
RATIO_CENTER_REAR); RATIO_CENTER_REAR);
} else if (in_has_center && !out_has_center && out_has_front) { } else if (in_has_center && !out_has_center && out_has_front) {
gst_channel_mix_fill_one_other (mix->matrix, in_c, out_f, gst_audio_channel_mix_fill_one_other (mix->matrix, in_c, out_f,
RATIO_CENTER_FRONT); RATIO_CENTER_FRONT);
} else if (in_has_center && !out_has_center && !out_has_front && out_has_side) { } else if (in_has_center && !out_has_center && !out_has_front && out_has_side) {
gst_channel_mix_fill_one_other (mix->matrix, in_c, out_s, gst_audio_channel_mix_fill_one_other (mix->matrix, in_c, out_s,
RATIO_CENTER_SIDE); RATIO_CENTER_SIDE);
} else if (in_has_center && !out_has_center && !out_has_front && !out_has_side } else if (in_has_center && !out_has_center && !out_has_front && !out_has_side
&& out_has_rear) { && out_has_rear) {
gst_channel_mix_fill_one_other (mix->matrix, in_c, out_r, gst_audio_channel_mix_fill_one_other (mix->matrix, in_c, out_r,
RATIO_CENTER_REAR); RATIO_CENTER_REAR);
} }
/* front <-> center/side/rear */ /* front <-> center/side/rear */
if (!in_has_front && in_has_center && !in_has_side && out_has_front) { if (!in_has_front && in_has_center && !in_has_side && out_has_front) {
gst_channel_mix_fill_one_other (mix->matrix, in_c, out_f, gst_audio_channel_mix_fill_one_other (mix->matrix, in_c, out_f,
RATIO_CENTER_FRONT); RATIO_CENTER_FRONT);
} else if (!in_has_front && !in_has_center && in_has_side && out_has_front) { } else if (!in_has_front && !in_has_center && in_has_side && out_has_front) {
gst_channel_mix_fill_one_other (mix->matrix, in_s, out_f, RATIO_FRONT_SIDE); gst_audio_channel_mix_fill_one_other (mix->matrix, in_s, out_f,
RATIO_FRONT_SIDE);
} else if (!in_has_front && in_has_center && in_has_side && out_has_front) { } else if (!in_has_front && in_has_center && in_has_side && out_has_front) {
gst_channel_mix_fill_one_other (mix->matrix, in_c, out_f, gst_audio_channel_mix_fill_one_other (mix->matrix, in_c, out_f,
0.5 * RATIO_CENTER_FRONT); 0.5 * RATIO_CENTER_FRONT);
gst_channel_mix_fill_one_other (mix->matrix, in_s, out_f, gst_audio_channel_mix_fill_one_other (mix->matrix, in_s, out_f,
0.5 * RATIO_FRONT_SIDE); 0.5 * RATIO_FRONT_SIDE);
} else if (!in_has_front && !in_has_center && !in_has_side && in_has_rear } else if (!in_has_front && !in_has_center && !in_has_side && in_has_rear
&& out_has_front) { && out_has_front) {
gst_channel_mix_fill_one_other (mix->matrix, in_r, out_f, RATIO_FRONT_REAR); gst_audio_channel_mix_fill_one_other (mix->matrix, in_r, out_f,
RATIO_FRONT_REAR);
} else if (in_has_front && out_has_center && !out_has_side && !out_has_front) { } else if (in_has_front && out_has_center && !out_has_side && !out_has_front) {
gst_channel_mix_fill_one_other (mix->matrix, gst_audio_channel_mix_fill_one_other (mix->matrix,
in_f, out_c, RATIO_CENTER_FRONT); in_f, out_c, RATIO_CENTER_FRONT);
} else if (in_has_front && !out_has_center && out_has_side && !out_has_front) { } else if (in_has_front && !out_has_center && out_has_side && !out_has_front) {
gst_channel_mix_fill_one_other (mix->matrix, in_f, out_s, RATIO_FRONT_SIDE); gst_audio_channel_mix_fill_one_other (mix->matrix, in_f, out_s,
RATIO_FRONT_SIDE);
} else if (in_has_front && out_has_center && out_has_side && !out_has_front) { } else if (in_has_front && out_has_center && out_has_side && !out_has_front) {
gst_channel_mix_fill_one_other (mix->matrix, in_f, out_c, gst_audio_channel_mix_fill_one_other (mix->matrix, in_f, out_c,
0.5 * RATIO_CENTER_FRONT); 0.5 * RATIO_CENTER_FRONT);
gst_channel_mix_fill_one_other (mix->matrix, in_f, out_s, gst_audio_channel_mix_fill_one_other (mix->matrix, in_f, out_s,
0.5 * RATIO_FRONT_SIDE); 0.5 * RATIO_FRONT_SIDE);
} else if (in_has_front && !out_has_center && !out_has_side && !out_has_front } else if (in_has_front && !out_has_center && !out_has_side && !out_has_front
&& out_has_rear) { && out_has_rear) {
gst_channel_mix_fill_one_other (mix->matrix, in_f, out_r, RATIO_FRONT_REAR); gst_audio_channel_mix_fill_one_other (mix->matrix, in_f, out_r,
RATIO_FRONT_REAR);
} }
/* side <-> center/front/rear */ /* side <-> center/front/rear */
if (!in_has_side && in_has_front && !in_has_rear && out_has_side) { if (!in_has_side && in_has_front && !in_has_rear && out_has_side) {
gst_channel_mix_fill_one_other (mix->matrix, in_f, out_s, RATIO_FRONT_SIDE); gst_audio_channel_mix_fill_one_other (mix->matrix, in_f, out_s,
RATIO_FRONT_SIDE);
} else if (!in_has_side && !in_has_front && in_has_rear && out_has_side) { } else if (!in_has_side && !in_has_front && in_has_rear && out_has_side) {
gst_channel_mix_fill_one_other (mix->matrix, in_r, out_s, RATIO_SIDE_REAR); gst_audio_channel_mix_fill_one_other (mix->matrix, in_r, out_s,
RATIO_SIDE_REAR);
} else if (!in_has_side && in_has_front && in_has_rear && out_has_side) { } else if (!in_has_side && in_has_front && in_has_rear && out_has_side) {
gst_channel_mix_fill_one_other (mix->matrix, in_f, out_s, gst_audio_channel_mix_fill_one_other (mix->matrix, in_f, out_s,
0.5 * RATIO_FRONT_SIDE); 0.5 * RATIO_FRONT_SIDE);
gst_channel_mix_fill_one_other (mix->matrix, in_r, out_s, gst_audio_channel_mix_fill_one_other (mix->matrix, in_r, out_s,
0.5 * RATIO_SIDE_REAR); 0.5 * RATIO_SIDE_REAR);
} else if (!in_has_side && !in_has_front && !in_has_rear && in_has_center } else if (!in_has_side && !in_has_front && !in_has_rear && in_has_center
&& out_has_side) { && out_has_side) {
gst_channel_mix_fill_one_other (mix->matrix, in_c, out_s, gst_audio_channel_mix_fill_one_other (mix->matrix, in_c, out_s,
RATIO_CENTER_SIDE); RATIO_CENTER_SIDE);
} else if (in_has_side && out_has_front && !out_has_rear && !out_has_side) { } else if (in_has_side && out_has_front && !out_has_rear && !out_has_side) {
gst_channel_mix_fill_one_other (mix->matrix, in_s, out_f, RATIO_FRONT_SIDE); gst_audio_channel_mix_fill_one_other (mix->matrix, in_s, out_f,
RATIO_FRONT_SIDE);
} else if (in_has_side && !out_has_front && out_has_rear && !out_has_side) { } else if (in_has_side && !out_has_front && out_has_rear && !out_has_side) {
gst_channel_mix_fill_one_other (mix->matrix, in_s, out_r, RATIO_SIDE_REAR); gst_audio_channel_mix_fill_one_other (mix->matrix, in_s, out_r,
RATIO_SIDE_REAR);
} else if (in_has_side && out_has_front && out_has_rear && !out_has_side) { } else if (in_has_side && out_has_front && out_has_rear && !out_has_side) {
gst_channel_mix_fill_one_other (mix->matrix, in_s, out_f, gst_audio_channel_mix_fill_one_other (mix->matrix, in_s, out_f,
0.5 * RATIO_FRONT_SIDE); 0.5 * RATIO_FRONT_SIDE);
gst_channel_mix_fill_one_other (mix->matrix, in_s, out_r, gst_audio_channel_mix_fill_one_other (mix->matrix, in_s, out_r,
0.5 * RATIO_SIDE_REAR); 0.5 * RATIO_SIDE_REAR);
} else if (in_has_side && !out_has_front && !out_has_rear && out_has_center } else if (in_has_side && !out_has_front && !out_has_rear && out_has_center
&& !out_has_side) { && !out_has_side) {
gst_channel_mix_fill_one_other (mix->matrix, in_s, out_c, gst_audio_channel_mix_fill_one_other (mix->matrix, in_s, out_c,
RATIO_CENTER_SIDE); RATIO_CENTER_SIDE);
} }
/* rear <-> center/front/side */ /* rear <-> center/front/side */
if (!in_has_rear && in_has_side && out_has_rear) { if (!in_has_rear && in_has_side && out_has_rear) {
gst_channel_mix_fill_one_other (mix->matrix, in_s, out_r, RATIO_SIDE_REAR); gst_audio_channel_mix_fill_one_other (mix->matrix, in_s, out_r,
RATIO_SIDE_REAR);
} else if (!in_has_rear && !in_has_side && in_has_front && out_has_rear) { } else if (!in_has_rear && !in_has_side && in_has_front && out_has_rear) {
gst_channel_mix_fill_one_other (mix->matrix, in_f, out_r, RATIO_FRONT_REAR); gst_audio_channel_mix_fill_one_other (mix->matrix, in_f, out_r,
RATIO_FRONT_REAR);
} else if (!in_has_rear && !in_has_side && !in_has_front && in_has_center } else if (!in_has_rear && !in_has_side && !in_has_front && in_has_center
&& out_has_rear) { && out_has_rear) {
gst_channel_mix_fill_one_other (mix->matrix, in_c, out_r, gst_audio_channel_mix_fill_one_other (mix->matrix, in_c, out_r,
RATIO_CENTER_REAR); RATIO_CENTER_REAR);
} else if (in_has_rear && !out_has_rear && out_has_side) { } else if (in_has_rear && !out_has_rear && out_has_side) {
gst_channel_mix_fill_one_other (mix->matrix, in_r, out_s, RATIO_SIDE_REAR); gst_audio_channel_mix_fill_one_other (mix->matrix, in_r, out_s,
RATIO_SIDE_REAR);
} else if (in_has_rear && !out_has_rear && !out_has_side && out_has_front) { } else if (in_has_rear && !out_has_rear && !out_has_side && out_has_front) {
gst_channel_mix_fill_one_other (mix->matrix, in_r, out_f, RATIO_FRONT_REAR); gst_audio_channel_mix_fill_one_other (mix->matrix, in_r, out_f,
RATIO_FRONT_REAR);
} else if (in_has_rear && !out_has_rear && !out_has_side && !out_has_front } else if (in_has_rear && !out_has_rear && !out_has_side && !out_has_front
&& out_has_center) { && out_has_center) {
gst_channel_mix_fill_one_other (mix->matrix, in_r, out_c, gst_audio_channel_mix_fill_one_other (mix->matrix, in_r, out_c,
RATIO_CENTER_REAR); RATIO_CENTER_REAR);
} }
/* bass <-> any */ /* bass <-> any */
if (in_has_bass && !out_has_bass) { if (in_has_bass && !out_has_bass) {
if (out_has_center) { if (out_has_center) {
gst_channel_mix_fill_one_other (mix->matrix, in_b, out_c, gst_audio_channel_mix_fill_one_other (mix->matrix, in_b, out_c,
RATIO_CENTER_BASS); RATIO_CENTER_BASS);
} }
if (out_has_front) { if (out_has_front) {
gst_channel_mix_fill_one_other (mix->matrix, in_b, out_f, gst_audio_channel_mix_fill_one_other (mix->matrix, in_b, out_f,
RATIO_FRONT_BASS); RATIO_FRONT_BASS);
} }
if (out_has_side) { if (out_has_side) {
gst_channel_mix_fill_one_other (mix->matrix, in_b, out_s, gst_audio_channel_mix_fill_one_other (mix->matrix, in_b, out_s,
RATIO_SIDE_BASS); RATIO_SIDE_BASS);
} }
if (out_has_rear) { if (out_has_rear) {
gst_channel_mix_fill_one_other (mix->matrix, in_b, out_r, gst_audio_channel_mix_fill_one_other (mix->matrix, in_b, out_r,
RATIO_REAR_BASS); RATIO_REAR_BASS);
} }
} else if (!in_has_bass && out_has_bass) { } else if (!in_has_bass && out_has_bass) {
if (in_has_center) { if (in_has_center) {
gst_channel_mix_fill_one_other (mix->matrix, in_c, out_b, gst_audio_channel_mix_fill_one_other (mix->matrix, in_c, out_b,
RATIO_CENTER_BASS); RATIO_CENTER_BASS);
} }
if (in_has_front) { if (in_has_front) {
gst_channel_mix_fill_one_other (mix->matrix, in_f, out_b, gst_audio_channel_mix_fill_one_other (mix->matrix, in_f, out_b,
RATIO_FRONT_BASS); RATIO_FRONT_BASS);
} }
if (in_has_side) { if (in_has_side) {
gst_channel_mix_fill_one_other (mix->matrix, in_s, out_b, gst_audio_channel_mix_fill_one_other (mix->matrix, in_s, out_b,
RATIO_REAR_BASS); RATIO_REAR_BASS);
} }
if (in_has_rear) { if (in_has_rear) {
gst_channel_mix_fill_one_other (mix->matrix, in_r, out_b, gst_audio_channel_mix_fill_one_other (mix->matrix, in_r, out_b,
RATIO_REAR_BASS); RATIO_REAR_BASS);
} }
} }
@ -526,7 +538,7 @@ gst_channel_mix_fill_others (GstChannelMix * mix)
*/ */
static void static void
gst_channel_mix_fill_normalize (GstChannelMix * mix) gst_audio_channel_mix_fill_normalize (GstAudioChannelMix * mix)
{ {
gfloat sum, top = 0; gfloat sum, top = 0;
gint i, j; gint i, j;
@ -554,7 +566,7 @@ gst_channel_mix_fill_normalize (GstChannelMix * mix)
} }
static gboolean static gboolean
gst_channel_mix_fill_special (GstChannelMix * mix) gst_audio_channel_mix_fill_special (GstAudioChannelMix * mix)
{ {
/* Special, standard conversions here */ /* Special, standard conversions here */
@ -589,23 +601,23 @@ gst_channel_mix_fill_special (GstChannelMix * mix)
*/ */
static void static void
gst_channel_mix_fill_matrix (GstChannelMix * mix) gst_audio_channel_mix_fill_matrix (GstAudioChannelMix * mix)
{ {
if (gst_channel_mix_fill_special (mix)) if (gst_audio_channel_mix_fill_special (mix))
return; return;
gst_channel_mix_fill_identical (mix); gst_audio_channel_mix_fill_identical (mix);
if (!(mix->flags & GST_CHANNEL_MIX_FLAGS_UNPOSITIONED_IN)) { if (!(mix->flags & GST_AUDIO_CHANNEL_MIX_FLAGS_UNPOSITIONED_IN)) {
gst_channel_mix_fill_compatible (mix); gst_audio_channel_mix_fill_compatible (mix);
gst_channel_mix_fill_others (mix); gst_audio_channel_mix_fill_others (mix);
gst_channel_mix_fill_normalize (mix); gst_audio_channel_mix_fill_normalize (mix);
} }
} }
/* only call mix after mix->matrix is fully set up and normalized */ /* only call mix after mix->matrix is fully set up and normalized */
static void static void
gst_channel_mix_setup_matrix_int (GstChannelMix * mix) gst_audio_channel_mix_setup_matrix_int (GstAudioChannelMix * mix)
{ {
gint i, j; gint i, j;
gfloat tmp; gfloat tmp;
@ -624,7 +636,7 @@ gst_channel_mix_setup_matrix_int (GstChannelMix * mix)
} }
static void static void
gst_channel_mix_setup_matrix (GstChannelMix * mix) gst_audio_channel_mix_setup_matrix (GstAudioChannelMix * mix)
{ {
gint i, j; gint i, j;
@ -639,9 +651,9 @@ gst_channel_mix_setup_matrix (GstChannelMix * mix)
} }
/* setup the matrix' internal values */ /* setup the matrix' internal values */
gst_channel_mix_fill_matrix (mix); gst_audio_channel_mix_fill_matrix (mix);
gst_channel_mix_setup_matrix_int (mix); gst_audio_channel_mix_setup_matrix_int (mix);
#ifndef GST_DISABLE_GST_DEBUG #ifndef GST_DISABLE_GST_DEBUG
/* debug */ /* debug */
@ -670,7 +682,7 @@ gst_channel_mix_setup_matrix (GstChannelMix * mix)
} }
/** /**
* gst_channel_mix_new: * gst_audio_channel_mix_new:
* @flags: * @flags:
* @in_channels: * @in_channels:
* @in_position: * @in_position:
@ -679,19 +691,19 @@ gst_channel_mix_setup_matrix (GstChannelMix * mix)
* *
* Create a new channel mixer object. * Create a new channel mixer object.
* *
* Returns: a new #GstChannelMix object. Free with gst_channel_mix_free() * Returns: a new #GstAudioChannelMix object. Free with gst_audio_channel_mix_free()
* after usage. * after usage.
*/ */
GstChannelMix * GstAudioChannelMix *
gst_channel_mix_new (GstChannelMixFlags flags, gst_audio_channel_mix_new (GstAudioChannelMixFlags flags,
gint in_channels, gint in_channels,
GstAudioChannelPosition in_position[64], GstAudioChannelPosition in_position[64],
gint out_channels, GstAudioChannelPosition out_position[64]) gint out_channels, GstAudioChannelPosition out_position[64])
{ {
GstChannelMix *mix; GstAudioChannelMix *mix;
gint i; gint i;
mix = g_slice_new0 (GstChannelMix); mix = g_slice_new0 (GstAudioChannelMix);
mix->flags = flags; mix->flags = flags;
mix->in_channels = in_channels; mix->in_channels = in_channels;
mix->out_channels = out_channels; mix->out_channels = out_channels;
@ -699,21 +711,21 @@ gst_channel_mix_new (GstChannelMixFlags flags,
mix->in_position[i] = in_position[i]; mix->in_position[i] = in_position[i];
mix->out_position[i] = out_position[i]; mix->out_position[i] = out_position[i];
} }
gst_channel_mix_setup_matrix (mix); gst_audio_channel_mix_setup_matrix (mix);
return mix; return mix;
} }
/** /**
* gst_channel_mix_is_passthrough: * gst_audio_channel_mix_is_passthrough:
* @mix: a #GstChannelMix * @mix: a #GstAudioChannelMix
* *
* Check if @mix is in passthrough. * Check if @mix is in passthrough.
* *
* Returns: %TRUE is @mix is passthrough. * Returns: %TRUE is @mix is passthrough.
*/ */
gboolean gboolean
gst_channel_mix_is_passthrough (GstChannelMix * mix) gst_audio_channel_mix_is_passthrough (GstAudioChannelMix * mix)
{ {
gint i; gint i;
guint64 in_mask, out_mask; guint64 in_mask, out_mask;
@ -738,7 +750,7 @@ gst_channel_mix_is_passthrough (GstChannelMix * mix)
/* IMPORTANT: out_data == in_data is possible, make sure to not overwrite data /* IMPORTANT: out_data == in_data is possible, make sure to not overwrite data
* you might need later on! */ * you might need later on! */
static void static void
gst_channel_mix_mix_int (GstChannelMix * mix, gst_audio_channel_mix_mix_int (GstAudioChannelMix * mix,
const gint32 * in_data, gint32 * out_data, gint samples) const gint32 * in_data, gint32 * out_data, gint samples)
{ {
gint in, out, n; gint in, out, n;
@ -779,7 +791,7 @@ gst_channel_mix_mix_int (GstChannelMix * mix,
} }
static void static void
gst_channel_mix_mix_double (GstChannelMix * mix, gst_audio_channel_mix_mix_double (GstAudioChannelMix * mix,
const gdouble * in_data, gdouble * out_data, gint samples) const gdouble * in_data, gdouble * out_data, gint samples)
{ {
gint in, out, n; gint in, out, n;
@ -817,8 +829,8 @@ gst_channel_mix_mix_double (GstChannelMix * mix,
} }
/** /**
* gst_channel_mix_mix: * gst_audio_channel_mix_samples:
* @mix: a #GstChannelMix * @mix: a #GstAudioChannelMix
* @format: a #GstAudioFormat * @format: a #GstAudioFormat
* @layout: a #GstAudioLayout * @layout: a #GstAudioLayout
* @in_data: input samples * @in_data: input samples
@ -829,7 +841,7 @@ gst_channel_mix_mix_double (GstChannelMix * mix,
* @in_data and @out_data need to be in @format and @layout. * @in_data and @out_data need to be in @format and @layout.
*/ */
void void
gst_channel_mix_mix (GstChannelMix * mix, GstAudioFormat format, gst_audio_channel_mix_samples (GstAudioChannelMix * mix, GstAudioFormat format,
GstAudioLayout layout, const gpointer in_data, gpointer out_data, GstAudioLayout layout, const gpointer in_data, gpointer out_data,
gint samples) gint samples)
{ {
@ -839,11 +851,11 @@ gst_channel_mix_mix (GstChannelMix * mix, GstAudioFormat format,
switch (format) { switch (format) {
case GST_AUDIO_FORMAT_S32: case GST_AUDIO_FORMAT_S32:
gst_channel_mix_mix_int (mix, (const gint32 *) in_data, gst_audio_channel_mix_mix_int (mix, (const gint32 *) in_data,
(gint32 *) out_data, samples); (gint32 *) out_data, samples);
break; break;
case GST_AUDIO_FORMAT_F64: case GST_AUDIO_FORMAT_F64:
gst_channel_mix_mix_double (mix, (const gdouble *) in_data, gst_audio_channel_mix_mix_double (mix, (const gdouble *) in_data,
(gdouble *) out_data, samples); (gdouble *) out_data, samples);
break; break;
default: default:

View file

@ -1,7 +1,8 @@
/* GStreamer /* GStreamer
* Copyright (C) 2004 Ronald Bultje <rbultje@ronald.bitfreak.net> * Copyright (C) 2004 Ronald Bultje <rbultje@ronald.bitfreak.net>
* (C) 2015 Wim Taymans <wim.taymans@gmail.com>
* *
* gstchannelmix.h: setup of channel conversion matrices * audiochannelmix.h: setup of channel conversion matrices
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public * modify it under the terms of the GNU Library General Public
@ -19,48 +20,48 @@
* Boston, MA 02110-1301, USA. * Boston, MA 02110-1301, USA.
*/ */
#ifndef __GST_CHANNEL_MIX_H__ #ifndef __GST_AUDIO_CHANNEL_MIX_H__
#define __GST_CHANNEL_MIX_H__ #define __GST_AUDIO_CHANNEL_MIX_H__
#include <gst/gst.h> #include <gst/gst.h>
#include <gst/audio/audio.h> #include <gst/audio/audio.h>
typedef struct _GstChannelMix GstChannelMix; typedef struct _GstAudioChannelMix GstAudioChannelMix;
/** /**
* GstChannelMixFlags: * GstAudioChannelMixFlags:
* @GST_CHANNEL_MIX_FLAGS_NONE: no flag * @GST_AUDIO_CHANNEL_MIX_FLAGS_NONE: no flag
* @GST_CHANNEL_MIX_FLAGS_UNPOSITIONED_IN: input channels are explicitly unpositioned * @GST_AUDIO_CHANNEL_MIX_FLAGS_UNPOSITIONED_IN: input channels are explicitly unpositioned
* @GST_CHANNEL_MIX_FLAGS_UNPOSITIONED_OUT: output channels are explicitly unpositioned * @GST_AUDIO_CHANNEL_MIX_FLAGS_UNPOSITIONED_OUT: output channels are explicitly unpositioned
* *
* Flags passed to gst_channel_mix_new() * Flags passed to gst_audio_channel_mix_new()
*/ */
typedef enum { typedef enum {
GST_CHANNEL_MIX_FLAGS_NONE = 0, GST_AUDIO_CHANNEL_MIX_FLAGS_NONE = 0,
GST_CHANNEL_MIX_FLAGS_UNPOSITIONED_IN = (1 << 0), GST_AUDIO_CHANNEL_MIX_FLAGS_UNPOSITIONED_IN = (1 << 0),
GST_CHANNEL_MIX_FLAGS_UNPOSITIONED_OUT = (1 << 1) GST_AUDIO_CHANNEL_MIX_FLAGS_UNPOSITIONED_OUT = (1 << 1)
} GstChannelMixFlags; } GstAudioChannelMixFlags;
GstChannelMix * gst_channel_mix_new (GstChannelMixFlags flags, GstAudioChannelMix * gst_audio_channel_mix_new (GstAudioChannelMixFlags flags,
gint in_channels, gint in_channels,
GstAudioChannelPosition in_position[64], GstAudioChannelPosition in_position[64],
gint out_channels, gint out_channels,
GstAudioChannelPosition out_position[64]); GstAudioChannelPosition out_position[64]);
void gst_channel_mix_free (GstChannelMix *mix); void gst_audio_channel_mix_free (GstAudioChannelMix *mix);
/* /*
* Checks for passthrough (= identity matrix). * Checks for passthrough (= identity matrix).
*/ */
gboolean gst_channel_mix_is_passthrough (GstChannelMix *mix); gboolean gst_audio_channel_mix_is_passthrough (GstAudioChannelMix *mix);
/* /*
* Do actual mixing. * Do actual mixing.
*/ */
void gst_channel_mix_mix (GstChannelMix * mix, void gst_audio_channel_mix_samples (GstAudioChannelMix * mix,
GstAudioFormat format, GstAudioFormat format,
GstAudioLayout layout, GstAudioLayout layout,
const gpointer in_data, const gpointer in_data,
gpointer out_data, gpointer out_data,
gint samples); gint samples);
#endif /* __GST_CHANNEL_MIX_H__ */ #endif /* __GST_AUDIO_CHANNEL_MIX_H__ */