mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-28 03:00:35 +00:00
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.
This commit is contained in:
parent
1face2a662
commit
36597cf201
1 changed files with 8 additions and 35 deletions
|
@ -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),
|
||||
|
|
Loading…
Reference in a new issue