avformat/mp3dec: improve junk skipping heuristic
authorwm4 <nfxjfg@googlemail.com>
Tue, 20 Oct 2015 10:17:21 +0000 (12:17 +0200)
committerCarl Eugen Hoyos <cehoyos@ag.or.at>
Tue, 20 Oct 2015 10:35:43 +0000 (12:35 +0200)
commit96b87d5cfaa553b01da60b6982a7ca292a04ea8e
tree5900f1dd51e23446248d49b00e2f68610cc350e3
parente0e28dad9092d7d1ebb36283af1375927d377da4
avformat/mp3dec: improve junk skipping heuristic

Commit 2b3e9bbfb529e6bde238aeb511b55ebe461664c8 caused problems for a
certain API user:

https://code.google.com/p/chromium/issues/detail?id=537725
https://code.google.com/p/chromium/issues/detail?id=542032

The problem seems rather arbitrary, because if there's junk, anything
can happen. In this case, the imperfect junk skipping just caused it to
read different junk, from what I can see.

We can improve the accuracy of junk detection by a lot by checking if 2
consecutive frames use the same configuration. While in theory it might
be completely fine for the 1st frame to have a different format than the
2nd frame, it's exceedingly unlikely, and I can't think of a legitimate
use-case.

This is approximately the same mpg123 does for junk skipping. The
set of compared header bits is the same as the libavcodec mp3 parser
uses for similar purposes.
(cherry picked from commit de1b1a7da9e6ddf42447271e519099a88b389e4a)
libavformat/mp3dec.c