summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Sauer <ensonic@users.sf.net>2016-05-03 22:59:27 -0700
committerStefan Sauer <ensonic@users.sf.net>2016-05-03 23:03:14 -0700
commit36597cf201cf3c035333f4d0c09aa32f83fb02f7 (patch)
tree942bc9682da13f533e0f5f61579564bc5ccd4b16
parent1face2a66216b40650669a3cf19097d3bc7521b1 (diff)
wavparse: simplify and correct header scanning
The wav spec tells that 'fmt' (and 'bext' if present) must come before 'data'. There is no requirement for 'fmt' to be first. We already had a list of chunks to skip, but it is easier to just skip any chunk while seeking for 'fmt'. This fixes reading files generated by ProTools.
-rw-r--r--gst/wavparse/gstwavparse.c43
1 files changed, 8 insertions, 35 deletions
diff --git a/gst/wavparse/gstwavparse.c b/gst/wavparse/gstwavparse.c
index 16483b7e5..a83b06879 100644
--- a/gst/wavparse/gstwavparse.c
+++ b/gst/wavparse/gstwavparse.c
@@ -59,15 +59,6 @@
GST_DEBUG_CATEGORY_STATIC (wavparse_debug);
#define GST_CAT_DEFAULT (wavparse_debug)
-#define GST_RIFF_TAG_Fake GST_MAKE_FOURCC ('F','a','k','e')
-
-#define GST_BWF_TAG_iXML GST_MAKE_FOURCC ('i','X','M','L')
-#define GST_BWF_TAG_qlty GST_MAKE_FOURCC ('q','l','t','y')
-#define GST_BWF_TAG_mext GST_MAKE_FOURCC ('m','e','x','t')
-#define GST_BWF_TAG_levl GST_MAKE_FOURCC ('l','e','v','l')
-#define GST_BWF_TAG_link GST_MAKE_FOURCC ('l','i','n','k')
-#define GST_BWF_TAG_axml GST_MAKE_FOURCC ('a','x','m','l')
-
/* Data size chunk of RF64,
* see http://tech.ebu.ch/docs/tech/tech3306-2009.pdf */
#define GST_RS64_TAG_DS64 GST_MAKE_FOURCC ('d','s','6','4')
@@ -1091,11 +1082,10 @@ gst_wavparse_stream_headers (GstWavParse * wav)
gint64 upstream_size = 0;
GstStructure *s;
- /* search for "_fmt" chunk, which should be first */
+ /* search for "_fmt" chunk, which must be before "data" */
while (!wav->got_fmt) {
GstBuffer *extra;
- /* The header starts with a 'fmt ' tag */
if (wav->streaming) {
if (!gst_wavparse_peek_chunk (wav, &tag, &size))
return res;
@@ -1117,21 +1107,6 @@ gst_wavparse_stream_headers (GstWavParse * wav)
return res;
}
- if (tag == GST_RIFF_TAG_JUNK || tag == GST_RIFF_TAG_JUNQ ||
- tag == GST_RIFF_TAG_bext || tag == GST_RIFF_TAG_BEXT ||
- tag == GST_RIFF_TAG_LIST || tag == GST_RIFF_TAG_ID32 ||
- tag == GST_RIFF_TAG_id3 || tag == GST_RIFF_TAG_IDVX ||
- tag == GST_BWF_TAG_iXML || tag == GST_BWF_TAG_qlty ||
- tag == GST_BWF_TAG_mext || tag == GST_BWF_TAG_levl ||
- tag == GST_BWF_TAG_link || tag == GST_BWF_TAG_axml ||
- tag == GST_RIFF_TAG_Fake) {
- GST_DEBUG_OBJECT (wav, "skipping %" GST_FOURCC_FORMAT " chunk",
- GST_FOURCC_ARGS (tag));
- gst_buffer_unref (buf);
- buf = NULL;
- continue;
- }
-
if (tag == GST_RS64_TAG_DS64) {
if (!parse_ds64 (wav, buf))
goto fail;
@@ -1139,8 +1114,13 @@ gst_wavparse_stream_headers (GstWavParse * wav)
continue;
}
- if (tag != GST_RIFF_TAG_fmt)
- goto invalid_wav;
+ if (tag != GST_RIFF_TAG_fmt) {
+ GST_DEBUG_OBJECT (wav, "skipping %" GST_FOURCC_FORMAT " chunk",
+ GST_FOURCC_ARGS (tag));
+ gst_buffer_unref (buf);
+ buf = NULL;
+ continue;
+ }
if (!(gst_riff_parse_strf_auds (GST_ELEMENT_CAST (wav), buf, &header,
&extra)))
@@ -1718,13 +1698,6 @@ fail:
res = GST_FLOW_ERROR;
goto exit;
}
-invalid_wav:
- {
- GST_ELEMENT_ERROR (wav, STREAM, TYPE_NOT_FOUND, (NULL),
- ("Invalid WAV header (no fmt at start): %"
- GST_FOURCC_FORMAT, GST_FOURCC_ARGS (tag)));
- goto fail;
- }
parse_header_error:
{
GST_ELEMENT_ERROR (wav, STREAM, DEMUX, (NULL),