}
}
+/* buf contains LIST chunk data, and will be padded to even size,
+ * since some buggy files do not account for the padding of chunks
+ * within a LIST in the size of the LIST */
+static inline void
+gst_avi_demux_roundup_list (GstAviDemux * avi, GstBuffer ** buf)
+{
+ if (G_UNLIKELY (GST_BUFFER_SIZE (*buf) & 1)) {
+ GstBuffer *obuf;
+
+ GST_DEBUG_OBJECT (avi, "rounding up dubious list size %d",
+ GST_BUFFER_SIZE (*buf));
+ obuf = gst_buffer_new_and_alloc (GST_BUFFER_SIZE (*buf) + 1);
+ memcpy (GST_BUFFER_DATA (obuf), GST_BUFFER_DATA (*buf),
+ GST_BUFFER_SIZE (*buf));
+ gst_buffer_replace (buf, obuf);
+ }
+}
+
/*
* gst_avi_demux_parse_stream:
* @avi: calling element (used for debugging/errors).
GST_DEBUG_OBJECT (avi, "Parsing stream");
+ gst_avi_demux_roundup_list (avi, &buf);
+
if (avi->num_streams >= GST_AVI_DEMUX_MAX_STREAMS) {
GST_WARNING_OBJECT (avi,
"maximum no of streams (%d) exceeded, ignoring stream",
GST_DEBUG ("'hdrl' LIST tag found. Parsing next chunk");
+ gst_avi_demux_roundup_list (avi, &buf);
+
/* the hdrl starts with a 'avih' header */
if (!gst_riff_parse_chunk (GST_ELEMENT_CAST (avi), buf, &offset, &tag,
&sub))
GST_DEBUG_OBJECT (avi, "hdrl LIST tag found");
+ gst_avi_demux_roundup_list (avi, &buf);
+
/* the hdrl starts with a 'avih' header */
if (!gst_riff_parse_chunk (element, buf, &offset, &tag, &sub))
goto no_avih;