Help - Search - Members - Calendar
Full Version: encoding lossless from lossy
Hydrogenaudio Forums > Lossless Audio Compression > Lossless / Other Codecs
morganwahl
So, here's the deal:
I've got several audio CDs that were burned from (I suspect) lossy sources. Is there any lossless codec that can take this into account when encoding, and get them back to something like their original bitrates?

I think it's possible in theory, since if the audio of a track was at one point represented by only 256kbps then there should be a way to get it back to something close to that.

Sorry if this is a repeat of an earlier post. I couldn't for the life of me figure out a search query for this.
VCSkier
sorry to break the news to you, but what you want is impossible, although it would be nice. when you rip your cd's to wav, you will have all the artifacts of the lossy file, preserved losslessly, and then when you reencode (to mp3, or whatever) new artifacts will be introduced, and the old ones will be worsened. there is unfortunately no way to avoid this...
morganwahl
QUOTE(VCSkier @ Jun 13 2005, 12:44 AM)
sorry to break the news to you, but what you want is impossible, although it would be nice.  when you rip your cd's to wav, you will have all the artifacts of the lossy file, preserved losslessly, and then when you reencode (to mp3, or whatever) new artifacts will be introduced, and the old ones will be worsened.  there is unfortunately no way to avoid this...
*



yes, I know that reencoding to MP3 is no good, but that's OK. what i mean is encoding to something like flac, but that's designed to recognize the kind of patterns that crop up in wavs that are from MP3s.

the simplest example i can think of:

joint stereo MP3s throw away stereo information below a certin frequency, so that the resulting wav files will have identical left and right channels, when you only look at the data below a certain frequency. Now, i know in FLAC if the left and right channels are identical in a frame, it only stores one and you have ~50% compression right there. So why not have it split the signal by some frequency and check what the best stereo model to use is on each part.
dreamliner77
Remember: mp3 encoding adds (random) noise. Random noise is the hardest for lossless encoders to handle. You'll likely end up with bitrates above what a lossless source would give you.
morganwahl
QUOTE(dreamliner77 @ Jun 13 2005, 01:27 AM)
Remember: mp3 encoding adds (random) noise.  Random noise is the hardest for lossless encoders to handle.  You'll likely end up with bitrates above what a lossless source would give you.
*


random? what part of an MPEG or Vorbis stream is randomnly chosen?
DreamTactix291
When the encoder quantises the data it adds this random quantisation noise. It is simply the nature of lossy encoding.

While not lossless there might be a solution that might be good enough and not as big as lossless. WavPack lossy at 320k wouldn't be ridiculously bigger than the source that was originally 256k mp3 and should only add (hopefully inaudible) quantisation noise. Sadly this is about the best option I can' thiink of sad.gif
VCSkier
QUOTE(morganwahl @ Jun 13 2005, 01:35 AM)
QUOTE(dreamliner77 @ Jun 13 2005, 01:27 AM)
Remember: mp3 encoding adds (random) noise.  Random noise is the hardest for lossless encoders to handle.  You'll likely end up with bitrates above what a lossless source would give you.
*


random? what part of an MPEG or Vorbis stream is randomnly chosen?
*


good point. random was probably not the best word, but noise is produced, none the less, and that noise, would be difficult to encode. anyway, AFAIK, what you seek does not exist.

edit: lol, DreamTactix291 beat me to the reply, and obviously, he knows more about it than i do... oh well. lalala.gif
Cygnus X1
QUOTE(morganwahl @ Jun 13 2005, 12:35 AM)
QUOTE(dreamliner77 @ Jun 13 2005, 01:27 AM)
Remember: mp3 encoding adds (random) noise.  Random noise is the hardest for lossless encoders to handle.  You'll likely end up with bitrates above what a lossless source would give you.
*


random? what part of an MPEG or Vorbis stream is randomly chosen?
*



Nothing is randomly chosen, but you have to remember, with less data to work with, a lossy encoder has to be crafty about how it stores signals. Less important components of a signal (such as masked sounds or those below our threshold of hearing) are either chucked (such in the case of a lowpass) or coded with less precision than important sounds (i.e., salient parts of the signal). This imprecision results in noise, which generally is kept at a level below what you can perceive. When transcoding, however, the lossless encoder sees that extra noise and garbage in the signal, which doesn't compress well, often yielding a bigger file.

(LOL, I'm getting slow...beat by two people!)
dreamliner77
Ok, nevermind a few beers tonight... It may not be completely random noise, but it is quanitization noise.
HotshotGG
If I remember correctly I do believe it's because, white noise is Gaussian. Therefore it has no correlation ;-D. (if I am mixing that up feel free to correct me).
Jojo
QUOTE(morganwahl @ Jun 12 2005, 08:58 PM)
joint stereo MP3s throw away stereo information
*


btw. that's wrong smile.gif
JensRex
QUOTE(morganwahl @ Jun 13 2005, 06:58 AM)
joint stereo MP3s throw away stereo information
*
No, it does not.

Edit: beaten by Jojo.
SebastianG
QUOTE(HotshotGG @ Jun 13 2005, 07:45 AM)
If I remember correctly I do believe it's because, white noise is Gaussian. Therefore it has no correlation ;-D.  (if I am mixing that up feel free to correct me).
*



the samples of white noise are not necessarily gaussian distributed. Noise being white just means there's no correlation between the samples (ie they have been independently chosen). But: Transformed white noise (a high dimensional orthogonal transform like the MDCT) is pretty gaussian-like no matter what kind of distribution you had before. This is due to fact that the sum of many independant random variables will produce a new gaussian-like distribution.

For high signal to noise ratios the quantization noise is usually pretty uncorrelated (ie mostly white). For lower signal to noise ratios there's usually high correlation between the quantization noise and the original signal. In this case the introduced artefact isn't noise anymore alone but can be all sorts of weird things like the tremolo thing of harmonics we encountered (Vorbis encoder).

Dithering comes to mind -- but this might stand in conflict with reducing the bitrate. :-)


Sebi
Sunhillow
QUOTE(morganwahl @ Jun 13 2005, 06:58 AM)
joint stereo MP3s throw away stereo information below a certin frequency, so that the resulting wav files will have identical left and right channels, when you only look at the data below a certain frequency.


intensity stereo throws away phase information above a certain frequency, only level information is stored.

But at lame only uses mid-side stereo, which in theory throws away nothing.
Defsac
To answer your original question, there's no codec specifically engineered for efficiently and losslessly storing audio from a lossy source.
mandel
Sadly in this situation you are kind of screwed. Best bet is just to convert them to FLAC or similar and accept that the file will be big. If you try re-encoding to lossy the result will sound 'not good'™.

I think the only way to achieve what you want would be if somebody made a new lossy encoder that had the ability to losslessly convert an encoded-decoded wav file back to the encoded source. Even then it'd only work for files encoded in this new format. I suspect this lies somewhere between impossible and very unlikely.
SebastianG
QUOTE(mandel @ Jun 13 2005, 04:09 PM)
I think the only way to achieve what you want would be if somebody made a new lossy encoder that had the ability to losslessly convert an encoded-decoded wav file back to the encoded source.  Even then it'd only work for files encoded in this new format.  I suspect this lies somewhere between impossible and very unlikely.
*



I was thinking about a 24bit -> 16bit conversion tool which embeds an arbritary binary file (ie the original mp3) in the lower bits of the PCM samples adaptivly (using psychoacoustics) so the file can be restored from the PCM wave. Applying psychoacoustics similarily like it is used in most lossy codecs it should be possible to embed a 200 kbps file into the 1411 kbps PCM file without noticable artefacts (considering typical loudness). One could throw in some ecnryption (to get pseudo random lower bits which is usefull for dithering) and some FEC codes to be able to restore the original data even though in the case the WAVE hasn't been perfectly ripped from the CD again and stuff...

So, from the user point of view it could look like this:
- decode mp3 to 24 bit wave
- run tool to convert 24 bit wave to 16 bit wave + embedding the original mp3
- burn the 16 bit wave as audio track on a CD
- rip the track from the CD
- run a tool which decodes the original mp3 from the lower bits of the WAVE

The reason why I did not start coding such tools is solely the lack of motivation. There isn't really a need for this, is it ?

Sebi
HotshotGG
QUOTE
For high signal to noise ratios the quantization noise is usually pretty uncorrelated (ie mostly white). For lower signal to noise ratios there's usually high correlation between the quantization noise and the original signal. In this case the introduced artefact isn't noise anymore alone but can be all sorts of weird things like the tremolo thing of harmonics we encountered (Vorbis encoder).


Interesting I understand what you are getting at. Now is the signal to noise ratio indepedent of each critical band, etc?

QUOTE
The reason why I did not start coding such tools is solely the lack of motivation. There isn't really a need for this, is it ?


I don't think it's worth all of the trouble, your idea does sound very interesting though. Why go to all that trouble when one can just encode with Wavpack if they wanted lossy + correction file? wink.gif
Axon
Sounds like this is a job for the Creative X-Fi Audio Processor!
HotshotGG
QUOTE
Sounds like this is a job for the Creative X-Fi Audio Processor!


blink.gif you go ahead and buy and tell us how if you see any noticeable improvement tongue.gif
SebastianG
QUOTE(HotshotGG @ Jun 13 2005, 07:16 PM)
QUOTE
For high signal to noise ratios the quantization noise is usually pretty uncorrelated (ie mostly white). For lower signal to noise ratios there's usually high correlation between the quantization noise and the original signal. In this case the introduced artefact isn't noise anymore alone but can be all sorts of weird things like the tremolo thing of harmonics we encountered (Vorbis encoder).


Interesting I understand what you are getting at. Now is the signal to noise ratio indepedent of each critical band, etc?
*



I should say that the above paragraph applies to non-dithered scalar quantizers which are currently used in most lossy codecs.

Answering the question: In lossy audio codecs you usually want to use different SNRs for different critical bands. This can be achieved by transforming the signal and use frequency adaptive quantizer step sizes. Due to this frequency noise shaping the time domain noise will be correlated (which is what we want actually). In the frequency domain things are getting a bit complicated. Sometimes you want the frequency domain noise to be correlated too in order to shape the noise in time. That's what's TNS (temporal noise shaping) is doing ... but this is pretty off-topic, so I'll just shut up now.


Sebi
Mo0zOoH
QUOTE(Axon @ Jun 13 2005, 10:23 PM)
Sounds like this is a job for the Creative X-Fi Audio Processor!
*


Hahahaha, nice one! laugh.gif
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2008 Invision Power Services, Inc.