aboutsummaryrefslogtreecommitdiff
path: root/src/plugins/Input/mpeg/decoder_mad.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/Input/mpeg/decoder_mad.cpp')
-rw-r--r--src/plugins/Input/mpeg/decoder_mad.cpp17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/plugins/Input/mpeg/decoder_mad.cpp b/src/plugins/Input/mpeg/decoder_mad.cpp
index 59b77c71d..7f3ca4f93 100644
--- a/src/plugins/Input/mpeg/decoder_mad.cpp
+++ b/src/plugins/Input/mpeg/decoder_mad.cpp
@@ -128,8 +128,23 @@ bool DecoderMAD::findXingHeader(struct mad_bitptr ptr, unsigned int bitlen)
return false;
quint32 xing_magic = mad_bit_read(&ptr, 32);
+ bitlen -= 32;
+
if(xing_magic != XING_MAGIC && xing_magic != XING_MAGIC2)
- return false;
+ {
+ /*
+ * Due to an unfortunate historical accident, a Xing VBR tag may be
+ * misplaced in a stream with CRC protection. We check for this by
+ * assuming the tag began two octets prior and the high bits of the
+ * following flags field are always zero.
+ */
+
+ if(xing_magic != ((quint64(XING_MAGIC) << 16) & 0xffffffffL) && xing_magic != ((quint64(XING_MAGIC2) << 16) & 0xffffffffL))
+ return false;
+
+ mad_bit_skip(&ptr, 16);
+ bitlen += 16;
+ }
m_xing.flags = mad_bit_read(&ptr, 32);
bitlen -= 64;