summaryrefslogtreecommitdiffstats
path: root/gst-libs/gst/riff/riff-read.c
diff options
context:
space:
mode:
authorRonald S. Bultje <rbultje@ronald.bitfreak.net>2004-05-09 15:49:25 +0000
committerRonald S. Bultje <rbultje@ronald.bitfreak.net>2004-05-09 15:49:25 +0000
commit3ce13c7d9989d5376f738c0ef057c206dec29bdf (patch)
tree3d7c5beeda63ad78259ce8fb6a71ce139c480c17 /gst-libs/gst/riff/riff-read.c
parent23c774e5a36df7c98c856d59275f6860a8cd7b8f (diff)
downloadgst-plugins-bad-3ce13c7d9989d5376f738c0ef057c206dec29bdf.tar.gz
gst-plugins-bad-3ce13c7d9989d5376f738c0ef057c206dec29bdf.tar.bz2
gst-plugins-bad-3ce13c7d9989d5376f738c0ef057c206dec29bdf.zip
gst-libs/gst/riff/: Fix for unaligned RIFF files (i.e. where all the chunks together in a LIST chunk are not of the s...
Original commit message from CVS: * gst-libs/gst/riff/riff-media.c: (gst_riff_create_video_caps_with_data), (gst_riff_create_audio_caps), (gst_riff_create_audio_template_caps): * gst-libs/gst/riff/riff-read.c: (gst_riff_peek_head): Fix for unaligned RIFF files (i.e. where all the chunks together in a LIST chunk are not of the same size as the size given in the LIST chunk header). Fixes several odd WAVE files. Also fix ADPCM (block_align property) in audio, so that wavparse based on this works now as it used to stand-alone.
Diffstat (limited to 'gst-libs/gst/riff/riff-read.c')
-rw-r--r--gst-libs/gst/riff/riff-read.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/gst-libs/gst/riff/riff-read.c b/gst-libs/gst/riff/riff-read.c
index 388ea753..fc47f2c8 100644
--- a/gst-libs/gst/riff/riff-read.c
+++ b/gst-libs/gst/riff/riff-read.c
@@ -154,8 +154,24 @@ gboolean
gst_riff_peek_head (GstRiffRead * riff,
guint32 * tag, guint32 * length, guint * level_up)
{
+ GList *last;
guint8 *data;
+ /* if we're at the end of a chunk, but unaligned, then re-align.
+ * Those are essentially broken files, but unfortunately they
+ * exist. */
+ if ((last = g_list_last (riff->level)) != NULL) {
+ GstRiffLevel *level = last->data;
+ guint64 pos = gst_bytestream_tell (riff->bs);
+
+ if (level->start + level->length - pos < 8) {
+ if (!gst_bytestream_flush (riff->bs, level->start + level->length - pos)) {
+ GST_ELEMENT_ERROR (riff, RESOURCE, READ, (NULL), (NULL));
+ return FALSE;
+ }
+ }
+ }
+
/* read */
while (gst_bytestream_peek_bytes (riff->bs, &data, 8) != 8) {
GstEvent *event = NULL;