I've just recently gotten into all these different kinds of lossless codecs and I'm fascinated by how they work.

I understand that codecs like FLAC and TTA make a prediction for the next sample and then simply store the difference between the prediction and the actual value - which is most of the time significantly smaller than storing the full amplitude.

My question is.. does it only store that difference value? Or is it having to store the prediction model/function/curve or whatever was used for that particular chunk of data. If it's only storing the difference, and that difference is usually a very small number, then shouldnt compression ratios be much better than 2:1 or 3:1?

Maybe I havent fully understood how this stuff works, anyone able to shed a bit of light on it for me? Thanks.

FLAC and related codecs do store the prediction model (an LPC filter), also called forwards prediction.

However, that only takes a relatively low amount of bytes. The problem is that the prediction mostly a bit off, but the amount by which it is off is very random, so the error cannot be compressed that well.

Monkey's Audio and WavPack use another system, in which they predict based on the previous decoded samples (backwards prediction). This means that you dont have to store the predictor, but it will also be a bit less accurate which means bigger prediction errors.

Following info is for completeness. Current lossless codecs are more advanced that this.

Codecs that *only* store the difference are called delta codecs. both, the coding and decoding is pretty simple (just a sum or a difference), and they aren't much efficient in compression. Storing just the difference would actually require one more bit for each sample, not less! To compress, they store just the needed number of bits to represent that value, but here is the drawback: you need a way to tell the decoder how many bits you're storing, and of course, this goes in the compressed data.

Thanks for the info, I'm studying music tech software development, and lossless compression for audio is something i want to research for my final year. I'm thinking of working at my own form of prediction-difference methods but I also want to try and attack this whole issue from another angle. For now I'm just gonna heavily investigate whats currently going on this field. I may be back for more questions!