## Topic: compression math question (Read 3675 times)previous topic - next topic

0 Members and 1 Guest are viewing this topic.
• hellokeith
compression math question
##### 19 November, 2011, 05:27:29 PM
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

• dhromed
compression math question
##### Reply #1 – 19 November, 2011, 05:48:00 PM
Pretty much.

• lvqcl
• Developer
compression math question
##### Reply #2 – 19 November, 2011, 05:51:00 PM
C >= A

Not true. E.g. 8 kbps MP3 with silence => ~0 kbps FLAC

• Hanseat
compression math question
##### Reply #3 – 19 November, 2011, 06:06:59 PM
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.

• Jillian
compression math question
##### Reply #4 – 19 November, 2011, 08:52:46 PM
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?

• saratoga
compression math question
##### Reply #5 – 19 November, 2011, 10:22:25 PM
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.

• mjb2006
compression math question
##### Reply #6 – 20 November, 2011, 02:23:15 PM
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.

• kwanbis
• Developer (Donating)
compression math question
##### Reply #7 – 20 November, 2011, 04:02:18 PM
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.

• SoAnIs
compression math question
##### Reply #8 – 10 January, 2012, 07:21:06 PM
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.

• testyou
compression math question
##### Reply #9 – 10 January, 2012, 08:51:53 PM
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.

• Porcus
compression math question
##### Reply #10 – 10 January, 2012, 09:08:36 PM
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').