From 3bc107dd772ec5d8d978cb5a0a4f3334705fe889 Mon Sep 17 00:00:00 2001 From: Michael Smith Date: Fri, 16 Mar 2007 17:29:09 +0000 Subject: [PATCH] gst/audioconvert/gstaudioconvert.c: Previous fix was too simplistic, and broke the tests. Use a better approach; only... Original commit message from CVS: * gst/audioconvert/gstaudioconvert.c: (make_lossless_changes), (strip_width_64), (append_with_other_format): Previous fix was too simplistic, and broke the tests. Use a better approach; only strip 64 from widths for integer audio. --- ChangeLog | 7 +++++++ gst/audioconvert/gstaudioconvert.c | 30 +++++++++++++++++++++++++++--- 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7df33b4524..46ae701364 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2007-03-16 Michael Smith + + * gst/audioconvert/gstaudioconvert.c: (make_lossless_changes), + (strip_width_64), (append_with_other_format): + Previous fix was too simplistic, and broke the tests. Use a better + approach; only strip 64 from widths for integer audio. + 2007-03-16 Michael Smith * gst/audioconvert/gstaudioconvert.c: (make_lossless_changes), diff --git a/gst/audioconvert/gstaudioconvert.c b/gst/audioconvert/gstaudioconvert.c index 59ecfefabe..9070a6e046 100644 --- a/gst/audioconvert/gstaudioconvert.c +++ b/gst/audioconvert/gstaudioconvert.c @@ -380,7 +380,7 @@ static GstStructure * make_lossless_changes (GstStructure * s, gboolean isfloat) { if (isfloat) { - /* float doesn't have a depth or signedness field and only supports a + /* float doesn't have a depth or signedness field and only supports * widths of 32/64 and native endianness */ gst_structure_remove_field (s, "depth"); gst_structure_remove_field (s, "signed"); @@ -413,13 +413,34 @@ make_lossless_changes (GstStructure * s, gboolean isfloat) gst_structure_set_value (s, "signed", &list); g_value_unset (&val); g_value_unset (&list); - /* We don't handle 64 bit integer audio, so we set the width here as well */ - gst_structure_set (s, "width", G_TYPE_INT, 32, NULL); } return s; } +static void +strip_width_64 (GstStructure * s) +{ + const GValue *v = gst_structure_get_value (s, "width"); + GValue widths = { 0 }; + + if (GST_VALUE_HOLDS_LIST (v)) { + int i; + int len = gst_value_list_get_size (v); + + g_value_init (&widths, GST_TYPE_LIST); + + for (i = 0; i < len; i++) { + const GValue *width = gst_value_list_get_value (v, i); + + if (g_value_get_int (width) != 64) + gst_value_list_append_value (&widths, width); + } + gst_structure_set_value (s, "width", &widths); + g_value_unset (&widths); + } +} + /* Little utility function to create a related structure for float/int */ static void append_with_other_format (GstCaps * caps, GstStructure * s, gboolean isfloat) @@ -430,6 +451,9 @@ append_with_other_format (GstCaps * caps, GstStructure * s, gboolean isfloat) s2 = gst_structure_copy (s); gst_structure_set_name (s2, "audio/x-raw-int"); s = make_lossless_changes (s2, FALSE); + /* If 64 bit float was allowed; remove width 64: we don't support it for + * integer*/ + strip_width_64 (s); gst_caps_append_structure (caps, s2); } else { s2 = gst_structure_copy (s);