From 706b1dff39f7373567a55345349b05b87e6facf2 Mon Sep 17 00:00:00 2001 From: Mark Nauwelaerts Date: Sun, 18 May 2008 19:27:59 +0000 Subject: gst/avi/gstavimux.c: Set proper rate in avi stream header for PCM audio, and also do some more sanity checks on caps ... Original commit message from CVS: * gst/avi/gstavimux.c: (gst_avi_mux_audsink_set_caps): Set proper rate in avi stream header for PCM audio, and also do some more sanity checks on caps in this case. Fixes #511489. --- ChangeLog | 6 ++++++ gst/avi/gstavimux.c | 27 ++++++++++++++++++++++----- 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index b334baab..36db384d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2008-05-18 Mark Nauwelaerts + + * gst/avi/gstavimux.c: (gst_avi_mux_audsink_set_caps): + Set proper rate in avi stream header for PCM audio, and also do some + more sanity checks on caps in this case. Fixes #511489. + 2008-05-17 Sebastian Dröge * sys/v4l2/gstv4l2src.c: diff --git a/gst/avi/gstavimux.c b/gst/avi/gstavimux.c index f301e97e..08f28d48 100644 --- a/gst/avi/gstavimux.c +++ b/gst/avi/gstavimux.c @@ -629,11 +629,28 @@ gst_avi_mux_audsink_set_caps (GstPad * pad, GstCaps * vscaps) if (!strcmp (mimetype, "audio/x-raw-int")) { gint width, depth; + gboolean signedness; avipad->auds.format = GST_RIFF_WAVE_FORMAT_PCM; if (!gst_structure_get_int (structure, "width", &width) || - (width != 8 && !gst_structure_get_int (structure, "depth", &depth))) { + !gst_structure_get_int (structure, "depth", &depth) || + !gst_structure_get_boolean (structure, "signed", &signedness)) { + GST_DEBUG_OBJECT (avimux, + "broken caps, width/depth/signed field missing"); + goto refuse_caps; + } + + /* no clear place to put different values for these while keeping to spec */ + if (width != depth) { + GST_DEBUG_OBJECT (avimux, "width must be same as depth!"); + goto refuse_caps; + } + + /* because that's the way the caps will be recreated from riff data */ + if ((width == 8 && signedness) || (width == 16 && !signedness)) { + GST_DEBUG_OBJECT (avimux, + "8-bit PCM must be unsigned, 16-bit PCM signed"); goto refuse_caps; } @@ -683,12 +700,12 @@ gst_avi_mux_audsink_set_caps (GstPad * pad, GstCaps * vscaps) avipad->auds.blockalign = 1; avipad->auds.av_bps = 0; avipad->auds.size = 16; - - if (!avipad->auds.format) - goto refuse_caps; } - avipad->parent.hdr.rate = avipad->auds.blockalign * avipad->auds.rate; + if (!avipad->auds.format) + goto refuse_caps; + + avipad->parent.hdr.rate = avipad->auds.rate; avipad->parent.hdr.samplesize = avipad->auds.blockalign; avipad->parent.hdr.scale = 1; -- cgit