mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 20:21:24 +00:00
mpegaudioparse: ensure 2 valid headers in a row when resyncing
This commit is contained in:
parent
59f5b02444
commit
57d01c2526
1 changed files with 17 additions and 9 deletions
|
@ -1333,23 +1333,31 @@ gst_mp3parse_chain (GstPad * pad, GstBuffer * buf)
|
||||||
(0xf << 4) /* mode|mode extension */ | \
|
(0xf << 4) /* mode|mode extension */ | \
|
||||||
(0xf)) /* copyright|emphasis */
|
(0xf)) /* copyright|emphasis */
|
||||||
|
|
||||||
/* require 2 matching headers in a row */
|
/* require 2 valid matching headers in a row */
|
||||||
if ((header2 & HDRMASK) != (header & HDRMASK)) {
|
if ((header2 & HDRMASK) != (header & HDRMASK)) {
|
||||||
GST_DEBUG_OBJECT (mp3parse, "next header doesn't match "
|
GST_DEBUG_OBJECT (mp3parse, "next header doesn't match "
|
||||||
"(header=%08X (%08X), header2=%08X (%08X), bpf=%d)",
|
"(header=%08X (%08X), header2=%08X (%08X), bpf=%d)",
|
||||||
(guint) header, (guint) header & HDRMASK, (guint) header2,
|
(guint) header, (guint) header & HDRMASK, (guint) header2,
|
||||||
(guint) header2 & HDRMASK, bpf);
|
(guint) header2 & HDRMASK, bpf);
|
||||||
/* This frame is invalid. Start looking for a valid frame at the
|
} else if ((((header2 >> 12) & 0xf) == 0) ||
|
||||||
* next position in the stream */
|
(((header2 >> 12) & 0xf) == 0xf)) {
|
||||||
mp3parse->resyncing = TRUE;
|
/* optimized validity check for almost equal headers;
|
||||||
gst_adapter_flush (mp3parse->adapter, 1);
|
* only bitrate needs checking */
|
||||||
if (mp3parse->cur_offset != -1)
|
GST_DEBUG_OBJECT (mp3parse, "next header invalid (bitrate)");
|
||||||
mp3parse->cur_offset++;
|
} else {
|
||||||
mp3parse->tracked_offset++;
|
goto valid;
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
/* This frame is invalid. Start looking for a valid frame at the
|
||||||
|
* next position in the stream */
|
||||||
|
mp3parse->resyncing = TRUE;
|
||||||
|
gst_adapter_flush (mp3parse->adapter, 1);
|
||||||
|
if (mp3parse->cur_offset != -1)
|
||||||
|
mp3parse->cur_offset++;
|
||||||
|
mp3parse->tracked_offset++;
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
valid:
|
||||||
/* if we don't have the whole frame... */
|
/* if we don't have the whole frame... */
|
||||||
if (available < bpf) {
|
if (available < bpf) {
|
||||||
GST_DEBUG_OBJECT (mp3parse, "insufficient data available, need "
|
GST_DEBUG_OBJECT (mp3parse, "insufficient data available, need "
|
||||||
|
|
Loading…
Reference in a new issue