From 015af606b6544a840846eb4ff90a468d95ab3fdd Mon Sep 17 00:00:00 2001 From: Mathieu Duponchelle Date: Thu, 15 Aug 2024 16:32:09 +0200 Subject: [PATCH] audio-converter: support more numerical types for mix matrix Part-of: --- .../gst-libs/gst/audio/audio-converter.c | 25 ++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/subprojects/gst-plugins-base/gst-libs/gst/audio/audio-converter.c b/subprojects/gst-plugins-base/gst-libs/gst/audio/audio-converter.c index 13d8e5511f..e8e556410d 100644 --- a/subprojects/gst-plugins-base/gst-libs/gst/audio/audio-converter.c +++ b/subprojects/gst-plugins-base/gst-libs/gst/audio/audio-converter.c @@ -786,8 +786,13 @@ check_mix_matrix (guint in_channels, guint out_channels, const GValue * value) const GValue *itm; itm = gst_value_array_get_value (row, i); - if (!G_VALUE_HOLDS_FLOAT (itm)) { - GST_ERROR ("Invalid mix matrix element type, should be float"); + if (!G_VALUE_HOLDS_FLOAT (itm) && + !G_VALUE_HOLDS_DOUBLE (itm) && + !G_VALUE_HOLDS_INT (itm) && + !G_VALUE_HOLDS_INT64 (itm) && + !G_VALUE_HOLDS_UINT (itm) && !G_VALUE_HOLDS_UINT64 (itm)) { + GST_ERROR + ("Invalid mix matrix element type, should be float or double or integer"); goto fail; } } @@ -817,7 +822,21 @@ mix_matrix_from_g_value (guint in_channels, guint out_channels, gfloat coefficient; itm = gst_value_array_get_value (row, i); - coefficient = g_value_get_float (itm); + if (G_VALUE_HOLDS_FLOAT (itm)) + coefficient = g_value_get_float (itm); + else if (G_VALUE_HOLDS_DOUBLE (itm)) + coefficient = g_value_get_double (itm); + else if (G_VALUE_HOLDS_INT (itm)) + coefficient = g_value_get_int (itm); + else if (G_VALUE_HOLDS_INT64 (itm)) + coefficient = g_value_get_int64 (itm); + else if (G_VALUE_HOLDS_UINT (itm)) + coefficient = g_value_get_uint (itm); + else if (G_VALUE_HOLDS_UINT64 (itm)) + coefficient = g_value_get_uint64 (itm); + else + g_assert_not_reached (); + matrix[i][j] = coefficient; } }