aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authortrialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38>2020-08-29 14:32:47 +0000
committertrialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38>2020-08-29 14:32:47 +0000
commit1128418e2a6897da9d08c42b2ef02d7d31a2a14c (patch)
tree85a924a683619b2d2befe3b9d9c9874849fd12ea /src
parent2bd02b9b70221c70077960145f371856aba60baa (diff)
downloadqmmp-1128418e2a6897da9d08c42b2ef02d7d31a2a14c.tar.gz
qmmp-1128418e2a6897da9d08c42b2ef02d7d31a2a14c.tar.bz2
qmmp-1128418e2a6897da9d08c42b2ef02d7d31a2a14c.zip
mpeg: fixed xing header parsing for files with CRC protection (#1059)
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@9487 90c681e8-e032-0410-971d-27865f9a5e38
Diffstat (limited to 'src')
-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;