* @in_channels: number of input channels
* @out_channels: number of output channels
* @matrix: (transfer full) (nullable): channel conversion matrix, m[@in_channels][@out_channels].
- * If identity matrix, passthrough applies. If %NULL, @in_channels must be
- * equal to @out_channels, in which case an identity matrix is generated.
+ * If identity matrix, passthrough applies. If %NULL, a (potentially truncated)
+ * identity matrix is generated.
*
* Create a new channel mixer object for the given parameters.
*
|| format == GST_AUDIO_FORMAT_F64, NULL);
g_return_val_if_fail (in_channels > 0 && in_channels < 64, NULL);
g_return_val_if_fail (out_channels > 0 && out_channels < 64, NULL);
- g_return_val_if_fail (matrix != NULL || in_channels == out_channels, NULL);
mix = g_slice_new0 (GstAudioChannelMixer);
mix->in_channels = in_channels;
mix->out_channels = out_channels;
if (!matrix) {
- /* Generate identity matrix */
+ /* Generate (potentially truncated) identity matrix */
gint i, j;
mix->matrix = g_new0 (gfloat *, in_channels);
{
guint i, j;
+ /* audio-channel-mixer will generate an identity matrix */
+ if (gst_value_array_get_size (value) == 0)
+ return TRUE;
+
if (gst_value_array_get_size (value) != out_channels) {
GST_ERROR ("Invalid mix matrix size, should be %d", out_channels);
goto fail;
convert->current_channels = out->channels;
if (opt_matrix) {
- gfloat **matrix =
- mix_matrix_from_g_value (in->channels, out->channels, opt_matrix);
+ gfloat **matrix = NULL;
+
+ if (gst_value_array_get_size (opt_matrix))
+ matrix =
+ mix_matrix_from_g_value (in->channels, out->channels, opt_matrix);
convert->mix =
gst_audio_channel_mixer_new_with_matrix (0, format, in->channels,
* |[
* gst-launch-1.0 audiotestsrc ! audio/x-raw, channels=4 ! audioconvert mix-matrix="<<(float)1.0, (float)0.0, (float)0.0, (float)0.0>, <(float)0.0, (float)1.0, (float)0.0, (float)0.0>>" ! audio/x-raw,channels=2 ! autoaudiosink
* ]|
+ *
+ * > If an empty mix matrix is specified, a (potentially truncated)
+ * > identity matrix will be generated.
*/
/*
/* Only remove the channels and channel-mask for non-NONE layouts,
* or if a mix matrix was manually specified */
- if (gst_value_array_get_size (&this->mix_matrix) ||
+ if (this->mix_matrix_was_set ||
!gst_structure_get (s, "channel-mask", GST_TYPE_BITMASK, &mask, NULL) ||
(mask != 0 || (gst_structure_get_int (s, "channels", &channels)
&& channels == 1))) {
GST_AUDIO_CONVERTER_OPT_NOISE_SHAPING_METHOD,
GST_TYPE_AUDIO_NOISE_SHAPING_METHOD, this->ns, NULL);
- if (gst_value_array_get_size (&this->mix_matrix))
+ if (this->mix_matrix_was_set)
gst_structure_set_value (config, GST_AUDIO_CONVERTER_OPT_MIX_MATRIX,
&this->mix_matrix);
break;
case PROP_MIX_MATRIX:
if (!gst_value_array_get_size (value)) {
- g_warning ("Empty mix matrix");
+ g_value_copy (value, &this->mix_matrix);
+ this->mix_matrix_was_set = TRUE;
} else {
const GValue *first_row = gst_value_array_get_value (value, 0);
g_value_unset (&this->mix_matrix);
g_value_copy (value, &this->mix_matrix);
+ this->mix_matrix_was_set = TRUE;
} else {
g_warning ("Empty mix matrix's first row");
}
g_value_set_enum (value, this->ns);
break;
case PROP_MIX_MATRIX:
- if (gst_value_array_get_size (&this->mix_matrix))
+ if (this->mix_matrix_was_set)
g_value_copy (&this->mix_matrix, value);
break;
default: