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: lossless ADPCM exists ? ADPCM at 16bit ? thank you! (Read 17193 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

lossless ADPCM exists ? ADPCM at 16bit ? thank you!

Hi there ...
do you know if there is "lossless ADPCM" or is it always lossy? From what I've gathered, the most common mode is lossy ADPCM at 4-bit. Do you know if there exists a 16-bit mode, too ? 44,1 Khz ?

thanks a lot!

lossless ADPCM exists ? ADPCM at 16bit ? thank you!

Reply #1
The reason for asking is that I am interested in a digital recorder, which has these features:

* WAV recording (ADPCM)
* 2GB storage (~3,5h using WAV)

(that's part of the features description)

So I was wondering, if these 3,5 hours would be "true" PCM wave (16 bit, 44,1 khz) or lossy ADPCM .... ?

lossless ADPCM exists ? ADPCM at 16bit ? thank you!

Reply #2
No, there is no lossless ADPCM. The only compression that ADPCM achieves comes precisely from reducing the bit-depth (roughly speaking) to 4 bits, so a 16-bit ADPCM would basically achieve no compression at all.

lossless ADPCM exists ? ADPCM at 16bit ? thank you!

Reply #3
No, there is no lossless ADPCM. The only compression that ADPCM achieves comes precisely from reducing the bit-depth (roughly speaking) to 4 bits, so a 16-bit ADPCM would basically achieve no compression at all.


Thanks for helping me!

So what's the maximal bit-depth you can use with ADPCM? I've heard 8-bit, is that correct ?
I thought the good thing about ADPCM is that the continuation of waveform is predicted and that only the difference (of the actual value vs. the predicted value) is stored. In theory this would be lossless (at 16-bit) and still achieve file size reduction, no ?

lossless ADPCM exists ? ADPCM at 16bit ? thank you!

Reply #4
* 2GB storage (~3,5h using WAV)
You could fit 3 hours 9 minutes of 44.1kHz 16-bit stereo audio in 2GB - that's without using ADPCM, which would make it 12.5 hours.

Cheers,
David.


lossless ADPCM exists ? ADPCM at 16bit ? thank you!

Reply #5
Thanks for helping me!

You're welcome.

So what's the maximal bit-depth you can use with ADPCM? I've heard 8-bit, is that correct ?

I wouldn't know, but you're probably right.

I thought the good thing about ADPCM is that the continuation of waveform is predicted and that only the difference (of the actual value vs. the predicted value) is stored. In theory this would be lossless (at 16-bit) and still achieve file size reduction, no ?

In theory, yes, if the difference is losslessly stored you can perfectly recreate the entire waveform. But there is one problem to that. Storing the difference takes twice as many bits as just storing the waveform as is. (I'll explain why if you're interested.)

ADPCM achieves compression by truncating data. Why do you think the lossless coders don't achieve such levels of compression?

lossless ADPCM exists ? ADPCM at 16bit ? thank you!

Reply #6
* 2GB storage (~3,5h using WAV)
You could fit 3 hours 9 minutes of 44.1kHz 16-bit stereo audio in 2GB - that's without using ADPCM, which would make it 12.5 hours.


Thanks for looking into this, too!

If you can fit 3 hours 9 mintues of PCM wave at 44.1kHz/16bit stereo in 2GB and 12.5 hours with ADPCM, what do you think "3,5 hours" correspond to ?

lossless ADPCM exists ? ADPCM at 16bit ? thank you!

Reply #7
Quote
ADPCM achieves compression by truncating data. Why do you think the lossless coders don't achieve such levels of compression?

If that's true, you are right of course. I just don't have an encoder for ADPCM@8bit or 16bit, so I cannot compare file sizes ....

I thought the good thing about ADPCM is that the continuation of waveform is predicted and that only the difference (of the actual value vs. the predicted value) is stored. In theory this would be lossless (at 16-bit) and still achieve file size reduction, no ?

In theory, yes, if the difference is losslessly stored you can perfectly recreate the entire waveform. But there is one problem to that. Storing the difference takes twice as many bits as just storing the waveform as is. (I'll explain why if you're interested.)

Yes, I'd be VERY interested (I'd die for this information ... almost

Because when you look at joint stereo for example, you can reduce losslessly reduce the file size by using the waveform difference ....


lossless ADPCM exists ? ADPCM at 16bit ? thank you!

Reply #8
BTW, here is the mp3player/sound recorder I was talking about:

http://www.soundman.de/

I translated the german feature description which differs from the english description, but I used it as the company's native language is german, and I guess the german description is therefore more accurate in case of doubt.

lossless ADPCM exists ? ADPCM at 16bit ? thank you!

Reply #9
Yes, I'd be VERY interested (I'd die for this information ... almost

Er, I just realised a mistake I've made - you don't need two times more bits, you need just one additional bit. 

But let me at least explain that.

So let's say that we've got a 2-bit audio file - yes, ridiculous, but let's keep it simple. So the possible sample values are 00, 01, 10 and 11. And now, we want to store the differences between two samples. So what are the possible differences we might encounter? Let's look at the example where the current sample has a value of 00 and we want to store the difference between that sample and the next one. The possible values of the next sample are, obviously, 00, 01, 10 and 11 - so the possible differences are 0, +1, +2 and +3. But that's not all - those are positive differences. What if the current sample has a value of 11 and we want to store the difference between that sample and the next one? Then, obviously, the possible differences are 0, -1, -2 and -3. So all in all, we need to be able to store "-3", "-2", "-1", "0", "+1", "+2" and "+3" - that's seven unique values. Can we store seven unique values using only two bits? Not a chance - with two bits you can only have four unique words - 00, 01, 10 and 11. We need one more bit - with three bits we can assign eight unique values (even though we need only seven). So, for example, we might store the differences like this:
000 = -3
001 = -2
010 = -1
011 = 0
100 = +1
101 = +2
110 = +3

The reason why this happens is simple - since the differences can be positive or negative, you need an additional bit which will tell you whether the difference is positive or negative (except for zero, which is the reason why we don't need all eight unique values but only seven).

Because when you look at joint stereo for example, you can reduce losslessly reduce the file size by using the waveform difference ....

In fact, there is also a catch with joint stereo - at least the conversion to mid/side, which I believe you're talking about.
See, if you want to convert left and right channel to mid and side channel losslessly, you will also need one additional bit...
Do you want me to explain why is that, too?

lossless ADPCM exists ? ADPCM at 16bit ? thank you!

Reply #10
Quote
Because when you look at joint stereo for example, you can reduce losslessly reduce the file size by using the waveform difference ....

In fact, there is also a catch with joint stereo - at least the conversion to mid/side, which I believe you're talking about.
See, if you want to convert left and right channel to mid and side channel losslessly, you will also need one additional bit...
Do you want me to explain why is that, too?


yes, I was talking about conversion to mid/side. And no, you wouldn't need to explain that, too, as I guess the reasons are exactly the same as those you already mentioned here.

But when looking into your example, I can't help but wondering if you aren't wrong ....

(1) First of all you started off talking about a 2-bit audio file, but the example you subsequently used is 3-bit audio (000,001,etc.), with 8 possible values (000 through to 001), so the differences wouldn't have to be encoded in 2-bit, but 3-bit which is possible as you can see

(2) I think you are unclear as to where the file size reduction actually comes from. It does NOT come from the fact, that you need less bits to store all the possible difference values, BUT from the fact, that the difference is LIKELY to be smaller than the absolute values!
Besides: that's the reason, why mid/side stereo CAN represent more information to encode than ss stereo and a good mp3-encoder (for example) decides on which blocks to use ss or ms. At least that's my take on it.

lossless ADPCM exists ? ADPCM at 16bit ? thank you!

Reply #11
I'd honestly love to see a documentation, that clearly states what is possible for ADPCM in terms of kHz and bit depth. Even Wikipedia is mute on that point ...

lossless ADPCM exists ? ADPCM at 16bit ? thank you!

Reply #12
Let me explain it that way: If your waveform prediction were perfect, you would have to store these differences: 0,0,0,0,0,0,0 ....  Or with an almost-perfect prediction : 0,2,1,1,1,0,0,1,0,0,1,2,0,1 ...

This difference values would be more compressable when running some lossless mathematical algorithms on them (huffman coding, etc.). But does ADPCM use lossless compression too  (in addition to lossy bit-reduction to 4-bit) ?

lossless ADPCM exists ? ADPCM at 16bit ? thank you!

Reply #13
But when looking into your example, I can't help but wondering if you aren't wrong ....

(1) First of all you started off talking about a 2-bit audio file, but the example you subsequently used is 3-bit audio (000,001,etc.), with 8 possible values (000 through to 001), so the differences wouldn't have to be encoded in 2-bit, but 3-bit which is possible as you can see

I didn't use 3-bit audio. 

As I clearly said:
Quote
Let's look at the example where the current sample has a value of 00 and we want to store the difference between that sample and the next one. The possible values of the next sample are, obviously, 00, 01, 10 and 11 - so the possible differences are 0, +1, +2 and +3. But that's not all - those are positive differences. What if the current sample has a value of 11 and we want to store the difference between that sample and the next one? Then, obviously, the possible differences are 0, -1, -2 and -3. So all in all, we need to be able to store "-3", "-2", "-1", "0", "+1", "+2" and "+3" - that's seven unique values.

The values of all samples there are two-bit values. The point is that, to store the resulting differences, you need to use three bits.

I'm not sure what confused you there.

(2) I think you are unclear as to where the file size reduction actually comes from. It does NOT come from the fact, that you need less bits to store all the possible difference values, BUT from the fact, that the difference is LIKELY to be smaller than the absolute values!

Yes, exactly. But what in the case when the difference is not smaller than the original values? In that case ADPCM truncates data.

lossless ADPCM exists ? ADPCM at 16bit ? thank you!

Reply #14
001 = -2
010 = -1
011 = 0
100 = +1
101 = +2
110 = +3


Of course, you used 3 bit.

1 bit = 0,1
2 bit = 00,01,10,11
3 bit = 001,010,011,100,101,110,111
4 bit = 0000,0001,etc...

lossless ADPCM exists ? ADPCM at 16bit ? thank you!

Reply #15
The values of all samples there are two-bit values. The point is that, to store the resulting differences, you need to use three bits.


No. If A and B represent any value between 0 and 255 (8 bit), the difference can also be encoded with 8 bit (as the difference can be 255 at most if A=0 and B=255 and vice versa). This holds true for any bit depth x.

lossless ADPCM exists ? ADPCM at 16bit ? thank you!

Reply #16
001 = -2
010 = -1
011 = 0
100 = +1
101 = +2
110 = +3


Of course, you used 3 bit.

1 bit = 0,1
2 bit = 00,01,10,11
3 bit = 001,010,011,100,101,110,111
4 bit = 0000,0001,etc...

Well of course I used three bits - I used three bits in order to store the differences! If you actually read my post carefully you'd perfectly understand what was going on. :-/

No. If A and B represent any value between 0 and 255 (8 bit), the difference can also be encoded with 8 bit (as the difference can be 255 at most if A=0 and B=255 and vice versa). This holds true for any bit depth x.

I'm sorry, but you are wrong. The absolute value of the difference will, indeed, always be in-between 0 and 255. But it's not the absolute value of the difference we're interested in, but the actual difference - meaning that whether the difference is positive or negative also matters. If you want you can try re-reading the post in which I've explained it already. If not, here is a shorter version again:

Ok, let's say it is 8-bit this time. So values range from 0 to 255. Nice. And we want to store the difference between each two samples - so far everything is clear. But carefully now:

If one sample has a value of 200 and the next sample has a value of 201, the difference is +1. If, however, one sample has a value of 200 and the next value is 199, the difference is -1.

Is that clear? I hope it is. So, therefore, you need to be able to store both +1 and -1.

The same goes if one value is 200 and the next is 202, or one value is 200 and the next value is 198 - you need to be able to store both +2 and -2.

Increasing the difference like that, we'll finally get to the maximum possible difference in both positive and negative directions:
  • when first value is 0 and the next value is 255, the difference is +255,
  • when first value is 255 and the next value is 0, the difference is -255.

So notice that for every number from 1 to 255 we have two possible differences involving that number - positive and negative. For zero, we've got only one possibility.

How many values did we start with? Here they are: 0, 1, 2, 3, 4, 5,..., 255.

And how many values did we end up with? Here they are: 0, -1, +1, -2, +2, -3, +3, -4, +4, -5, +5,...,-255, +255.

Is it now obvious that we have two times more values than what we started with (actually two times minus one, because zero wasn't doubled)?

lossless ADPCM exists ? ADPCM at 16bit ? thank you!

Reply #17
OK, I understand you now. Sorry, that I was on the wrong track.


This outcome is still very surprising ... to say the least !!! I've never heard that storing the difference would need more information than just storing the absolute values .... that's so .... well, surprising ... 

lossless ADPCM exists ? ADPCM at 16bit ? thank you!

Reply #18
* 2GB storage (~3,5h using WAV)
You could fit 3 hours 9 minutes of 44.1kHz 16-bit stereo audio in 2GB - that's without using ADPCM, which would make it 12.5 hours. Cheers,David.


That's strange, my calculations yield 3,38 and 3,30 hours respectively (for 1GB=1024 or 1000).

lossless ADPCM exists ? ADPCM at 16bit ? thank you!

Reply #19
OK, I understand you now. Sorry, that I was on the wrong track.


This outcome is still very surprising ... to say the least !!! I've never heard that storing the difference would need more information than just storing the absolute values .... that's so .... well, surprising ... 

Well... that's how it is. 

To me it is obvious, because, for example, for 8 bits, you still have 256 possible differences - but whether the difference is positive or negative also matters. Note: positive or negative - two possibilities - that means that you're certainly going to need one additional bit in which to store whether the difference is positive or negative.

If it's still confusing, let's look at the simplest example possible: 1-bit!

The possible values are 0 and 1. Now you want to store differences between two samples.

Now, let's assume the first value is 0. There are two possibilities for the next value: it can be either 0 or 1.
If the next value is 0, the difference is 0.
If the next value is 1, the difference is +1.

Now we only need to see what happens if the current value is 1. Again, there are two possibilities for the next value:
If the next value is 0, the difference is -1.
If the next value is 1, the difference is 0.

And again - the difference can have three possible values (0, +1 and -1), which is more than two possible values which we started with, and it would require an additional bit in order to be stored.

lossless ADPCM exists ? ADPCM at 16bit ? thank you!

Reply #20
If you want to learn, how lossy ADPCM works, you may for instance read this (pdf) ADPCM specification at multimedia.cx (my first result at google, there will be others).

If you want to evaluate, what can be achieved with lossless compression of the sample differences, you may try FLAC -0.

lossless ADPCM exists ? ADPCM at 16bit ? thank you!

Reply #21
@doccolinni: Yes, I already got it, but thanks for posting one more example to make it clear! I was just confused and still am ... not because I don't understand the maths, but because it "feels" weird that the difference would need more bits to be encoded (at least in a worst-case scenario).

@TBeck: Thanks for the infos. What should I try FLAC -0 with ? ADPCM ? To see file size difference or what ? I also had a look at your pdf. It seems very interesting. Unfortunately it doesn't say anything about:

I'd honestly love to see a documentation, that clearly states what is possible for ADPCM in terms of kHz and bit depth. Even Wikipedia is mute on that point ...




lossless ADPCM exists ? ADPCM at 16bit ? thank you!

Reply #22
There are so many ADPCM codecs... http://wiki.multimedia.cx/index.php?title=...CM_Audio_Codecs

About MS ADPCM:
1) http://msdn.microsoft.com/en-us/library/bb943864(VS.85).aspx  - "PCM input files must have a sample rate in the range of 1Khz-50Khz".
So at least frequencies from 1kHz to 50 kHz are supported.

2a) http://msdn.microsoft.com/en-us/library/cc677008(VS.85).aspx  - "ADPCM can achieve compression ratios of up to 4:1."
2b) http://www.xentec.be/products/vox_studio/h...dpcm_format.htm  - "The compression ratio obtained is relatively modest: 16-bit data samples encoded as 4-bit differences result in 4:1 compression format".
So MS ADPCM stores 4-bit differences between the current sample and the previous.

lossless ADPCM exists ? ADPCM at 16bit ? thank you!

Reply #23
And how many values did we end up with? Here they are: 0, -1, +1, -2, +2, -3, +3, -4, +4, -5, +5,...,-255, +255.


Well, for example, a value of 240 can't have a difference of +255, so you could reduce the amount of possible differences to -128 to 255 (or -127? I always have problems with such math ), if you say that 240 with a difference of +255 should be read as a difference of -255...

That doesn't shave of a single bit (-128 to 255 still requires 9 bits) but probably you could spread this to get less truncation when used with 8-bit or lower. (Sounds quite simple to me... is something like this used? I don't know anything about ADPCM)
Music: sounds arranged such that they construct feelings.