[Flac-dev] Idea to possibly improve flac?
Brian Willoughby
brianw at sounds.wa.com
Fri Jan 7 17:24:22 PST 2011
On Jan 7, 2011, at 15:54, Jørgen Vigdal wrote:
> My first suggestion was to use FFT, because I know that 128kbps mp3
> have a low-pass filter at 16kHz (Fraunhofer IIS Encoder). The
> program should not decide whether or not the file is a mp3 based on
> only that, but it could give an indication on that. Perhaps with
> people not very familiar with advanced audio tools know how to spot
> out a mp3, they just want to know if the flac they just bought or
> downloaded is good or not?
What I have found is that audio above 15.8 kHz seems to come and go,
probably based upon available bits. While some MP3 may have more of
a constant state of nothing at those high frequencies, other MP3 bit
rates will have intermittent content.
What does seem to be true is that no version of MP3 or MP4/AAC will
encode anything above 20 kHz. Even with the CD 44.1 kHz sample rate,
there is still some possibilities for frequencies between 20 kHz and
22.05 kHz. Lossy encoding will never encode those frequencies.
With either frequency range, though, you're going to have a slight
problem detecting absence of frequency information. That's because
lossy coding allows noise at all frequencies. So, your FFT is still
going to show something above 15.8 kHz, and even something above 20
kHz, especially if the source was 16-bit instead of 24-bit. Thus,
you'll need an intelligent threshold, and perhaps adaptive algorithms
to detect lossy coding. It's quite normal for some acoustic
recordings to have low levels of audio content at higher frequencies,
especially if the microphone was located a long distance from the
sound source, because of the high-frequency attenuation properties of
air given sufficient distance.
> Another test, if the FFT test is unclear, is to check the
> correlation between left and right channel below 3kHz, which should
> be just about nothing if the source is a mp3 (since mp3 encoders
> sum L and R below 3kHz at low bitrates). If also doing further
> testing, and knowing how the mp3 encoders work, it should be fairly
> easy to determine if a source file might have been an mp3. At least
> the program would be able to tell if the input file is poor
> quality? :)
Some encoders drop information below 10 Hz, some do not. I am not
aware of mono coding for 3 kHz and below. Perhaps this depends upon
whether the Joint Stereo option is being used or not. In any case, I
would suggest that very common encoders might not have the properties
you're describing.
In any case, I don't want to discourage your efforts. I just think
it might be harder than you think. For one thing, lossy coding
doesn't really drop frequencies as described in most introductory
texts, but rather what they really do is allow significant
quantization noise to creep in at different frequencies. Thus, your
16-bit CD might be coded at 8-bit or less in some frequencies, where
it might actually have the equivalent of 24-bit at other
frequencies. Since you generally cannot recode lossy files without
going back to the original, I expect this also means that you can't
detect everything with an FFT, even if you're running the exact same
FFT used by the lossy encoder.
It should be a fun learning experience, though! Keep us posted with
your findings!
Brian Willoughby
Sound Consulting
More information about the Flac-dev
mailing list