3 From 5d505d108800cef210f67dcfed2801ba36beac2a Mon Sep 17 00:00:00 2001
4 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= <sebastian@centricular.com>
5 Date: Fri, 20 Jan 2017 12:41:16 +0200
6 Subject: [PATCH] riff-media: Don't divide block align by zero channels
8 https://bugzilla.gnome.org/show_bug.cgi?id=777525
10 gst-libs/gst/riff/riff-media.c | 36 +++++++++++++++++++++---------------
11 1 file changed, 21 insertions(+), 15 deletions(-)
13 Index: gst-plugins-base0.10-0.10.36/gst-libs/gst/riff/riff-media.c
14 ===================================================================
15 --- gst-plugins-base0.10-0.10.36.orig/gst-libs/gst/riff/riff-media.c 2017-03-23 13:13:29.708612812 -0400
16 +++ gst-plugins-base0.10-0.10.36/gst-libs/gst/riff/riff-media.c 2017-03-23 13:30:34.820954947 -0400
17 @@ -1196,23 +1196,29 @@
19 gint ba = strf->blockalign;
20 gint ch = strf->channels;
21 - gint wd = ba * 8 / ch;
23 - caps = gst_caps_new_simple ("audio/x-raw-float",
24 - "endianness", G_TYPE_INT, G_LITTLE_ENDIAN,
25 - "channels", G_TYPE_INT, ch, "width", G_TYPE_INT, wd, NULL);
26 + if (ba > 0 && ch > 0 && (ba == (64 / 8) * ch || ba == (32 / 8) * ch)) {
27 + gint wd = ba * 8 / ch;
29 - /* Add default channel layout. In theory this should be done
30 - * for 1 and 2 channels too but apparently breaks too many
31 - * things currently. Also we know no default layout for more than
35 - GST_WARNING ("don't know default layout for %d channels", ch);
36 - else if (gst_riff_wave_add_default_channel_layout (caps))
37 - GST_DEBUG ("using default channel layout for %d channels", ch);
39 - GST_WARNING ("failed to add channel layout");
40 + caps = gst_caps_new_simple ("audio/x-raw-float",
41 + "endianness", G_TYPE_INT, G_LITTLE_ENDIAN,
42 + "channels", G_TYPE_INT, ch, "width", G_TYPE_INT, wd, NULL);
44 + /* Add default channel layout. In theory this should be done
45 + * for 1 and 2 channels too but apparently breaks too many
46 + * things currently. Also we know no default layout for more than
50 + GST_WARNING ("don't know default layout for %d channels", ch);
51 + else if (gst_riff_wave_add_default_channel_layout (caps))
52 + GST_DEBUG ("using default channel layout for %d channels", ch);
54 + GST_WARNING ("failed to add channel layout");
57 + GST_WARNING ("invalid block align %d or channel count %d", ba, ch);
61 /* FIXME: this is pretty useless - we need fixed caps */