Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: compression math question (Read 5629 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

compression math question

Lossy music file, let's say a modern mp3 or aac, is A.

A is converted to pcm wav, which is now B.

B is compressed using a lossless format such as FLAC or WMAL or Wavpack, which is now C.

For file size, is the following true in all cases?

B >= C >= A

compression math question

Reply #1
Pretty much.

What's the reason you ask?


compression math question

Reply #3
Lossy music file, let's say a modern mp3 or aac, is A.

A is converted to pcm wav, which is now B.

B is compressed using a lossless format such as FLAC or WMAL or Wavpack, which is now C.

For file size, is the following true in all cases?

B >= C >= A

Yes, in real life, with real life quality settings, real life sample rates, real life bit depth and normal audio like speech or music, it is true in all cases that I could imagine. But there is no proof for that.

However, you might be able to construct cases with uncompressable audio, where the lossless compressed file is bigger than the wav file because its overhead. This uncompressable audio might be of very low sample rate, but compressed with Fraunhofer AAC with high constant bitrate (up to 578). Then A >= C >= B
In real life this is next to impossible because noise is not music. Maybe you can construct uncompressable noise, that sounds like music to some people...

Another example is long silence. Some lossless formats might compress silence better than MP3, because silence "costs" 32 kbps in MP3, so that B >= A >= C. This is much more likely in real life than the first example.

compression math question

Reply #4
C >= A is not true in all case. Silence is the problem. But I've no proove that lossless codec compress silence better than lossy codec, may be anyone here knows?

compression math question

Reply #5
C >= A is not true in all case. Silence is the problem. But I've no proove that lossless codec compress silence better than lossy codec, may be anyone here knows?


mp3 bitrate can't go below 32k @ 44.1khz, so with silence most lossless codecs will compress a bit better.  For real audio at 44.1/48khz though lossless size > mp3 size.

compression math question

Reply #6
For lossy formats, not just silence, but also non-tonal noise in certain frequency bands, in the case of HE-AAC and mp3PRO. However, the OP was asking about lossless formats only.

Don't forget about tagging. Throw some giant images in a file and the losslessly compressed file can easily grow larger than the untagged, uncompressed original.

compression math question

Reply #7
Lossy music file, let's say a modern mp3 or aac, is A...

Can I ask why would you ask this? Is the strangest question I have seen here.

compression math question

Reply #8
Remember that we're starting with a lossy file A. MP3, for example, will tend to cut out high frequencies due to the psychoacoustic model used. If the compression algorithm used in the lossy format is less efficient than that used in the lossless format the lossless file could well end up smaller than the lossy file.
C<B<A<Original
This is not the normal case, however it should be mentioned.

compression math question

Reply #9
MP3...will tend to cut out high frequencies...If the compression algorithm used in the lossy format is less efficient than that used in the lossless format...


What?
The lossy format is more space efficient because it throws away frequencies which are difficult to hear.
Keeping those frequencies in a lossless format would be more space inefficient.

compression math question

Reply #10
I tried to ask the same question a couple of years ago, at massive noise (bar a developer or two, who understand the theory).


In principle:
There cannot be more information in track.mp3 file than the encoded size.
If this is decoded to a less efficient format -- track.wav -- it contains precisely the same information.
Now track.mp3 decodes to the same audio as track.wav -- by construction of the latter. Hence track.mp3 encodes -- losslessly -- the same audio.


So -- again, in principle -- one could reverse the decoding which took track.mp3 and returned track.wav, and get back the mp3.
So the best lossless representation of track.wav, is track.mp3 OR SMALLER -- it is certainly not necessarily so that the mp3 file you started with, is the minimum filesize (... try a few with 7-zip ... you might save a percent).


That was the 'in principle' story. The 'in practice' story seems to be a totally different one: I don't think a lossless encoder will be remotely close to finding one of those small mp3 files which decode to track.wav, and certainly not anything better. I tested the FLAC filesize of my CDs recorded with pre-emphasis -- that simple EQ application does hardly change the information content of the file, but the filesize increased massively. In that case, there is 'this simple pattern' which can -- in principle -- be exploited to take tens of percents off the filesize, but nope, the compressors are not looking in that direction (and I suppose that there would be many CPU hours wasted if they should run through 'all simple patterns').