HydrogenAudio

Lossy Audio Compression => MP3 => MP3 - General => Topic started by: gts on 2003-02-27 13:42:00

Title: mp3 to wav to mp3 to wav same?
Post by: gts on 2003-02-27 13:42:00
If a file is encoded to mp3, then coverted back to a wav, and then that wav is convered back to mp3, will the both mp3s be the same?
Title: mp3 to wav to mp3 to wav same?
Post by: CiTay on 2003-02-27 13:46:36
No. MP3 encoding is a lossy process. The WAV that was decoded from the MP3 will only have the information that was present in the MP3. It doesn't magically "expand" to the original state, like i.e. a ZIP file. So a WAV decoded from a 128 kbit Xing MP3 will sound just as bad as that MP3.

To be more specific: Encoding the file again will of course result in another quality loss.
Title: mp3 to wav to mp3 to wav same?
Post by: gts on 2003-02-27 14:05:34
Well the first conversion from wav to mp3 removes inaudible information.
Then convert that mp3 to wav, which is basically loss less, right?
Now the second conversion to mp3 should try to remove the same inaudible information we already removed the first time and no more, therefore the second mp3 should be bit for bit the same, right?
Title: mp3 to wav to mp3 to wav same?
Post by: Xenion on 2003-02-27 14:15:30
Quote
Well the first conversion from wav to mp3 removes inaudible information.
Then convert that mp3 to wav, which is basically loss less, right?
Now the second conversion to mp3 should try to remove the same inaudible information we already removed the first time and no more, therefore the second mp3 should be bit for bit the same, right?

no

original wav => mp3 =lossy
mp3 => wav = lossless but not better quality than the mp3 file
that decoded wav => mp3 again = a lossy progress again

so the second encoded mp3 will have worse quality compared to the mp3 you've encoded first
Title: mp3 to wav to mp3 to wav same?
Post by: X-Fixer on 2003-02-27 14:26:44
Quote
Well the first conversion from wav to mp3 removes inaudible information.
Then convert that mp3 to wav, which is basically loss less, right?
Now the second conversion to mp3 should try to remove the same inaudible information we already removed the first time and no more, therefore the second mp3 should be bit for bit the same, right?

theoretically this could work this way. (second encode will try to "remove already removed information", just like attempt to delete file twice doesn't result in deleting 2 files). but practically, none lossy codec I know works this way. reencoding/transcoding always results in quality loss, because psychoacoustic masking "isn't perfect" and will cause more and more degradations. this is the whole point of using lossless codecs for archiving.
Title: mp3 to wav to mp3 to wav same?
Post by: gts on 2003-02-27 22:30:39
Quote
theoretically this could work this way. (second encode will try to "remove already removed information", just like attempt to delete file twice doesn't result in deleting 2 files). but practically, none lossy codec I know works this way. reencoding/transcoding always results in quality loss, because psychoacoustic masking "isn't perfect" and will cause more and more degradations. this is the whole point of using lossless codecs for archiving.

I think you understand what I am thinking.
Now, I agree the psycho acoustic masking isn't perfect, but it doesn't have to be perfect, just consistant, and we should get the same mp3 in the end.
Title: mp3 to wav to mp3 to wav same?
Post by: gts on 2003-02-27 22:33:58
Quote
original wav => mp3 =lossy

agreed
Quote
mp3 => wav = lossless but not better quality than the mp3 file

agreed
Quote
that decoded wav => mp3 again = a lossy progress again

disagree
How can the codec remove what has already been removed?
If it can't, then it is NOT a lossy process.
Title: mp3 to wav to mp3 to wav same?
Post by: Messer on 2003-02-27 22:39:01
Codec does not remove anything. It rounds some values to be able to store them in less bits then original ones. In next reencoding cycles it rounds them again and again, accumulating rounding errors.

Please search the forum it's been discussed many times before.
Title: mp3 to wav to mp3 to wav same?
Post by: gts on 2003-02-27 22:43:29
Thank you.
What search words will find the topic?
mp3?
Codec?
rounding?
lossy?
I assumed it had been discussed.
But, I can't find it, and have no idea what search terms will bring it up.
If anyone has a link, that would be helpful.

Thanks!
Title: mp3 to wav to mp3 to wav same?
Post by: Mac on 2003-02-27 22:46:40
I'll chip in because it took me a few goes of reading debates in the past to get a grip on it

You get your original wav off a cd and encode it to mp3, and some of the data gets thrown away and replaced by garbage.  It still sounds pretty good because the psychoacoustics only threw away things you couldn't hear.  Decode that to wav and you'll still have the same information, only taking up more space.

Run that new wav through the encoder again...  but this time the encoder is trying it's hardest to sound like that wav, not the original one.  It can discard more data and still sound pretty similar to your wav,  but it won't sound perfectly like it - meaning it will sound worse than the last time.
Title: mp3 to wav to mp3 to wav same?
Post by: Messer on 2003-02-27 22:49:33
I'd try "reencoding".
This is for example the topic from current month that discusses the same subject: Encode/decode cycles in lossy codecs (http://www.hydrogenaudio.org/forums/index.php?act=ST&f=1&t=6410&hl=reencoding&s=).
Title: mp3 to wav to mp3 to wav same?
Post by: gts on 2003-02-27 23:01:12
Thank you!
Title: mp3 to wav to mp3 to wav same?
Post by: CiTay on 2003-02-27 23:21:18
Quote
Codec does not remove anything. It rounds some values to be able to store them in less bits then original ones.


Of course the psychacoustic model removes a lot!

Quote
How can the codec remove what has already been removed?


It doesn't care if the WAV was previously MP3 encoded. It's like JPEG-compression: You can save a JPG as a BMP, but it will only have the quality of the original JPG. Compress the BMP as JPG again, and you get worse quality than the original JPG. There is no way of cutting a WAV (ex-MP3) down to ~1/10th of the original bitrate without applying the same methods of data-reduction as usual.
Title: mp3 to wav to mp3 to wav same?
Post by: gts on 2003-02-27 23:30:41
Quote
It doesn't care if the WAV was previously MP3 encoded.


In reality no.
But, in theory, it DOES care.

In the jpeg analogy, lets say we can only see 100 colors.
We reduce the picture down to the 100 we can see. (like wav to mp3)
Then we convert it back to full color (like mp3 to wav)
Then we go back to the 100 colors (like wav back to mp3)
In theory it would be the exact same as the first reduction to 100 colors.
Title: mp3 to wav to mp3 to wav same?
Post by: Messer on 2003-02-27 23:35:58
Quote
Quote
Codec does not remove anything. It rounds some values to be able to store them in less bits then original ones.


Of course the psychacoustic model removes a lot!

I know 

Just wanted to move focus from "removing" to "rounding" (quantisation). Before someone understands this concept, is usually trapped in thinking like: "the unnecessary information  is already removed so next reencoding shouldn't do anything at all, just 'rebuild' compressed file", and it's hard to drop this argument without knowing that essential process in lossy compression is adding (quantisation noise) not removing...

Title: mp3 to wav to mp3 to wav same?
Post by: gts on 2003-02-27 23:37:42
Quote
that essential process in lossy compression is adding (quantisation noise) not removing...

Brilliant!
Thank you.
I understand now.
Title: mp3 to wav to mp3 to wav same?
Post by: fewtch on 2003-02-27 23:42:17
There's a simple way to test this.  Encode a .wav to .mp3 (preferably use a value like 128k CBR to more easily hear artifacts), then decode it back to .wav.  Now, repeat the encode/decode process about 10 or 20 times.  If it sounds the same after 10-20 encodes/decodes/reencodes as it did originally, then you'll know the answer (hint - it won't).

Nothing better than experiments to prove the truth or falsehood of something. 
Title: mp3 to wav to mp3 to wav same?
Post by: Artemis3 on 2003-02-28 01:14:57
If you record a CD into a cassette tape, then use the tape to master a new CD, does it sound the same as the original? If you later copy this second CD to a new tape, does it sound the same as the first tape? Same answer.

Thats why we call those "Lossy". Same happens when you do VHS copy from a VHS source. VHS stores in much lower bandwidth than that used in the external transport cables (made to connect to a TV, which needs the higher bandwidth).

The problem is that a decoded mp3 is not longer the same as the original wav, it is a degraded file you want to encode again, so the result, is obviously even more degradation.
Title: mp3 to wav to mp3 to wav same?
Post by: gts on 2003-02-28 01:29:37
Quote
If you record a CD into a cassette tape, then use the tape to master a new CD, does it sound the same as the original? If you later copy this second CD to a new tape, does it sound the same as the first tape? Same answer.

Thats why we call those "Lossy". Same happens when you do VHS copy from a VHS source. VHS stores in much lower bandwidth than that used in the external transport cables (made to connect to a TV, which needs the higher bandwidth).


True, but an invalid analogy to mp3s.

See my post on the jpeg analogy.
That shows how in theory lossy compression can avoid becoming progressivelyworse.
However, that is not how mp3 lossy compression works.
Title: mp3 to wav to mp3 to wav same?
Post by: rjamorim on 2003-02-28 01:39:46
Quote
In the jpeg analogy, lets say we can only see 100 colors.
We reduce the picture down to the 100 we can see. (like wav to mp3)
Then we convert it back to full color (like mp3 to wav)
Then we go back to the 100 colors (like wav back to mp3)
In theory it would be the exact same as the first reduction to 100 colors.

But reducing the amount of colors is only ONE of the JPEG artifacts


There's also smoothing, detail loss, blockiness...


Same thing is for audio. It's not only reducing the amount of "sounds". It reduces details, introduces pre-echo and other artifacts...
Title: mp3 to wav to mp3 to wav same?
Post by: gts on 2003-02-28 01:44:08
Quote
But reducing the amount of colors is only ONE of the JPEG artifacts


There's also smoothing, detail loss, blockiness...


Same thing is for audio. It's not only reducing the amount of "sounds". It reduces details, introduces pre-echo and other artifacts...


but the point is not to explain jpegs or mp3.

It is to show how a lossy format can possbily not get progressivly worse upon repeated encodings and decoding.
Title: mp3 to wav to mp3 to wav same?
Post by: rjamorim on 2003-02-28 02:05:52
Quote
but the point is not to explain jpegs or mp3.

It is to show how a lossy format can possbily not get progressivly worse upon repeated encodings and decoding.

Well, it can get no perceptually worse if you use very high bitrates on good encoders for each new reencoding cycle.

But it's unavoidable. It gets worse.

Codecs like AAC, MP3 and Vorbis have an added issue, that is the MDCT. The more cosine transforms you apply to a signal, the worse it gets, no matter the bitrate you use. MPC, in this case, has the advantage of being a subband codec, and therefore, doesn't degrade that much with repeated reencodings.

JPEG uses DCT as well, btw.
Title: mp3 to wav to mp3 to wav same?
Post by: andrew3199 on 2003-02-28 03:29:08
I think we can all agree that there is some loss when encoding from Wave to MP3 but it's not all bad, take for instance the ongoing debate about CD and the good old plastic disc, Some people won't listen to anything else but LP'S saying Compact disc lacks the emotion of a good LP based system and  cd's are to clinical, having listened to both i think there is a very good point to the argument, for the same reason MP3's could even sound better than the origin CD...The following review although for the Airhead headphone amp is very intresting....



        "MP3s. Sure, my computer’s hard drive is loaded with time-shifted copies of music that I have previously purchased (ahem), but I never regarded them as anything approaching hi-fi, especially when listening via my Rio player or my laptop’s speakers. I mentioned something to that effect to Tyl Hertzens of HeadRoom, and he replied that I shouldn’t jump to such hasty conclusions. He told me that MP3 decoding is a completely different process than WAV (CD-ROM) or Redbook (CD music) decoding, which results in a more "organic" sound. He went on to say that MP3s with sampling rates in the 300+ kbps range can sound better than CD. Tyl is onto something. I am not about to say that MP3s played back through a hi-fi rig compares with CD, but I agree that MP3’s strengths and weaknesses mesh well with headphone playback. For example, with the high resolution capabilities of the TAH and Sennheiser or Grado, I heard further into many recordings than I could with my home rig. I perceived the decay of plucked notes on an acoustic guitar and the startling snap of snare drum shots, and could even distinguish among the drums used. And there was no harshness whatsoever. (I typically listen at a sampling rate of 128 kbps, which is a pretty good comprise between compression and not). In terms of its smoothness, it made me think I was listening to quality tube gear. That is a tough feat to pull off: "smooth detail." Furthermore, I was starting to eat my words regarding soundstaging. MP3 is a reflection of CD in the sense that some recordings are imbued with much more ambiance and dimensionality than others. On some MP3s, I could actually hear beyond the soundstage and into the ambiance of the recording venue, which, as I said, is my hi-fi Holy Grail. Admittedly, the soundstage was still not in the shape or position that I prefer, and yet I was amazed that I was getting that kind of sound from an MP3. Other hi-fi attributes were also present on MP3 via the HeadRoom: dynamic punch when called for, and a tight bass perhaps in the 30-hz range from a particular synth-based recording. I have no basis to compare what TAH is doing for MP3s relative to other headphone amps, but I can tell you that MP3s lost much of their magic without the amp. I never thought I would use "MP3" and "magic" in the same sentence"

Go here for Stereotimes full review

http://www.stereotimes.com/acc071301.shtm (http://www.stereotimes.com/acc071301.shtm)
Title: mp3 to wav to mp3 to wav same?
Post by: rjamorim on 2003-02-28 03:36:17
Quote
for the same reason MP3's could even sound better than the origin CD...

He told me that MP3 decoding is a completely different process than WAV (CD-ROM) or Redbook (CD music) decoding, which results in a more "organic" sound.

He went on to say that MP3s with sampling rates in the 300+ kbps range can sound better than CD.

it made me think I was listening to quality tube gear.

That is a tough feat to pull off: "smooth detail."

MP3 is a reflection of CD in the sense that some recordings are imbued with much more ambiance and dimensionality than others.

On some MP3s, I could actually hear beyond the soundstage and into the ambiance of the recording venue, which, as I said, is my hi-fi Holy Grail.

Other hi-fi attributes were also present on MP3 via the HeadRoom: dynamic punch when called for, and a tight bass perhaps in the 30-hz range from a particular synth-based recording.

OMG! Somebody please bring me my salts.

"Organic" sound? HAH! WTF is that???

Really, I guess it's the first time I hear of someone that actually enjoys MP3 artifacts. I wonder what encoder he's using.

"Lame sounds too much like CD. So I prefer Xing, because it sounds different - so it must be better than CD"
Title: mp3 to wav to mp3 to wav same?
Post by: dreamliner77 on 2003-02-28 04:19:41
Quote
I perceived the decay of plucked notes on an acoustic guitar and the startling snap of snare drum shots, and could even distinguish among the drums used. And there was no harshness whatsoever. (I typically listen at a sampling rate of 128 kbps, which is a pretty good comprise between compression and not).



Gee,  when I hear something that wasn't there before, I call it an artifact. 

Quote
In terms of its smoothness, it made me think I was listening to quality tube gear. That is a tough feat to pull off: "smooth detail."


Repeat with me now, "distortion"
Title: mp3 to wav to mp3 to wav same?
Post by: NeoRenegade on 2003-03-02 22:14:59
gts, with regards to your JPEG analogy... you refer more similarly to the way that GIF works - GIF works only on 256-colour images. Any image you save as a GIF will become a 256-colour image, but aside from changing the amount of colors of the image, GIF doesn't use any perceptual encoding. The compression is achieved through methods very similar to ZIP archive compression. A superior image format to GIF is PNG. It uses a similar compression method but does not limit you to 256 colours.

These image formats cannot be compared to MP3. Rather, you can consider FLAC, LPAC or Monkey's Audio, to be the audio equivalent of GIF or PNG. They analyze the waveform of the file and eliminate redundant information in such a way as that the decoder replaces it bit-perfectly.
Title: mp3 to wav to mp3 to wav same?
Post by: kdo on 2003-03-02 23:37:52
Quote
Codecs like AAC, MP3 and Vorbis have an added issue, that is the MDCT. The more cosine transforms you apply to a signal, the worse it gets, no matter the bitrate you use. MPC, in this case, has the advantage of being a subband codec, and therefore, doesn't degrade that much with repeated reencodings.

I see other people keep repeating this kind of argument, that now sounds more like a magic formula to me. sort of "mdct ist dead, subband ist god"

Do you actually refer to the problem of time resolution?
Wouldn't it be more accurate then to talk about "not-so-good time resolution vs. better time res."?

Besides, theoretically AAC (and Vorbis?) short blocks can achieve nearly as good time res. as MPC. Is it right?

Also, IAFAIK, a codec being "subband" might not guarantee a better time res., per se. It's just the mpeg subbanding algo is such that the time res is high. Is it right?
Title: mp3 to wav to mp3 to wav same?
Post by: aggies11 on 2003-08-21 02:13:55
Not to resurrect a dead thread or anything, but it does seem to be the most appropriate place for the question.  (If it's not, please forgive me  )

  I understand the reasoning why re-encoding is still a lossy process, but I've always been curious about the following idea(s):

  Assuming mp3 encoding, in it's basic form consists of 2 steps (I'm not too well versed in the nitty gritty of encoding, so don't hessitate to correct me where I'm wrong  : - a lossy psycho-perceptual "throwing away" / modifying of the waveform. - followed by a lossless compression of this new modified wave (presumably the same waveform that results from decoding).

  Could it not be possible than to design some sort of method to *insert* the decoded wave, back into the encode process, *after* the "throwing away" / alteration point, so that this wave (which has already undergone this process, in it's original encoding) can now undergo the same lossless compression.  There by getting it back to it's "original" mp3 encoded state?

  And in a somewhat related manner:  Is the mp3 decode process, reversable?  Ie. Is there an inverse algorithm that can be used to take a decoded waveform, and reconstruct the mp3 that generated it.  (Obviously knowing all the original encoding conditions).  Not encoding in the traditional sense, merely an "undoing" of whatever the decode process did.

  Of course, I am by no means saying these things are possible, I'm merely curious about the ideas

Thanks in advance,

Aggies
Title: mp3 to wav to mp3 to wav same?
Post by: Doctor on 2003-08-21 02:54:45
aggies: no.

Lossy sound encoding is not like you described. It's more like analysing the frequency content of the file in small chunks, deciding which frequencies to dump or round and compressing the frequency information. The decoding is then synthesizing the frequencies back into waveforms while making sure that small chunks flow smoothly into each other.

Frequency information is more complex than the waveform, so you would know enough to reconstruct it.

If you try to analyze the file again, you will get the frequencies that were in the first mp3 plus noise coming from rounding and smoothing the chunks together. The encoder will not necessarily be able to tell that the noise is to be discarded, in fact, the noise may modify your original frequencies in unpredictable ways. So the encoder may decide to dump or round something else.

There was another thread recently, where we could agree that in theory one could write a codec that would be reencode without loss. However, the codec would be very inefficient.
Title: mp3 to wav to mp3 to wav same?
Post by: phong on 2003-08-21 02:58:55
An interesting thought, but probably academic.  MP3 (as I understand it, please someone correct me if I'm wrong) undergoes a lossy transformation (from time to frequency domain) before the quantization step.

A general purpose algorithm for recreating the original MP3 is possible for certain definitions of "possible."  One such algorithm is a brute force technique of generating every MP3 of the correct length and comparing their output with the wav file.  It would complete in exponential time.  In this case, that would probably mean "many orders of magnitude longer than the age of the universe".  You'd have to be certain that your decoder produced output the same way as the one that decoded that wav file otherwise you'd wait an awful long time just to get 42.

This is probably what I would call a Hard Problem ™.  If I had a dollar, I'd wager it's NP-complete, but I can't prove it (in the mathmatical sense).  If you find a solution to an NP-complete problem that finishes in polynomial time, you would become Very Famous ™.  I'm on the P != NP side of the fence though, so good luck.  :-)

edit: Doh, need to type faster or write shorter posts.
Title: mp3 to wav to mp3 to wav same?
Post by: AtaqueEG on 2003-08-21 03:18:21
Quote
Repeat with me now, "distortion"

And distortion is only desirable in old tube guitar amps (the sound of rock!  B) )
Title: mp3 to wav to mp3 to wav same?
Post by: 2Bdecided on 2003-08-21 10:33:03
Quote
Could it not be possible than to design some sort of method to *insert* the decoded wave, back into the encode process, *after* the "throwing away" / alteration point, so that this wave (which has already undergone this process, in it's original encoding) can now undergo the same lossless compression.  There by getting it back to it's "original" mp3 encoded state?

IIRC FhG looked at this. You could call it an mp3 un-decoder if you like.

I don't know if they managed it. But in theory it's no harder than cracking an encryption algorithm. Forget the audio processing - think of mp3 decoding as a mathematical process for converting one set of numbers into a larger set of numbers - the task is to reverse the transformation.

Now, it may be impractically complicated to do so, but to say it's impossible is foolish - especially when there isn't even any encryption key to crack! And remember - we can get a close result just by re-encoding the .wav, so it's not like you have to start from no knowledge.


Cheers,
David.
Title: mp3 to wav to mp3 to wav same?
Post by: 2Bdecided on 2003-08-21 10:39:19
In reply to the original question, the simplistic answer is to think of psychoacoustic coding as a spreading process.

The audio signal is spread in the time and frequency domain (blurred, if you want to use an image analogy) as much as possible, without it being noticeable.

But next time you send the audio through the codec, it gets spread again. So now it's even more spread, or blurred, and (even in a perfect codec) this takes it beyond the point where the blurring is just noticeable. And if you repeat this many times... yuk!


That's a simplistic answer. I've written a proper one here:

http://groups.google.com/groups?hl=en&lr=&...ogle.com&rnum=7 (http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&selm=cd71db10.0303120153.6c277d14%40posting.google.com&rnum=7)

Cheers,
David.
Title: mp3 to wav to mp3 to wav same?
Post by: sld on 2003-08-21 10:40:48
(Redundant post, sorry)
Title: mp3 to wav to mp3 to wav same?
Post by: Vietwoojagig on 2003-08-21 12:53:20
I remember long time ago, there was a technology called DCC (Digital Compact Cassette). At that time, the MiniDisk was invented too.  To proove the quality of the codecs, they made a test:

CD -copy-> DCC -copy-> DCC -copy-> DCC ....

and

CD -copy-> MD -copy-> MD -copy-> MD ....

They found out, that the quality of the music after 10 MD copies was horrable, but the the quality of the DCC stayed the same. Even after 100 copies, no difference to copy 1.

The devices where plugged via SP/DIF, so each time a copy was made, an decoding to 44.1/16Bit and encoding was necessary.

To come to the point: What did the people of Philips (creators of DCC) made diffent than every other creator of codecs? Why was copy1 bit-identical to copy 2 and to copy 100?
Title: mp3 to wav to mp3 to wav same?
Post by: 2Bdecided on 2003-08-21 13:24:02
DCC used (what would become) MPEG-1 layer I.

You can download such an encoder and test the claim for yourself. (e.g. SoloH - set it to layer I, 384kbps). I think you'll find that the claim is maketing nonesense or urban legend - the quality degrades as you transcode, just like any lossy codec.


However, high bitrate layer I and layer II is designed so that it can be transcoded several times before audible problems appear. This is because it was expected that these codecs would be widely used in broadcasting, where 10 generations of coding/decoding may be required.

Despite this design goal, the results are not bit-identical, and would probably not sound particularly good on critical material to critical ears.

For digital distribution, the BBC and some other broadcasters in europe used NICAM rather than high bitrate MPEG. (Now 128kbps mp2 is considered broadcast quality they don't seem to worry about things like quality!)


I've just tried the experiment using an MPEG 1 layer I encoder, and of course it doesn't work.

What's more, now that I've engaged my brain, it's obvious that the DCC > DCC copy would not be bit exact even if the audio codec offered this possibility, because there is no mechanism with the PCM SPDIF signal to synchronise the two audio codecs. MPEG operates using frames of audio data. Ignoring for a moment the fact that bit-perfect transcoding is impossible, you can't even begin to think about getting close unless you align the frames in the coded and re-coded versions (because quantisation decisions are made on a frame by frame basis). Correct alignment is something you only have a 1 in 384 chance of hitting when dubbing between two DCC decks.

And, even if you did, the copy would not be bit perfect, for all the reasons discussed in this thread.

Cheers,
David.
Title: mp3 to wav to mp3 to wav same?
Post by: aggies11 on 2003-08-21 17:06:28
Thanks for the quick replies. Very informative indeed

  Just a re-clarification of my point, incase it wasn't too clear:  In the first example, what I'm trying to describe is not re-encoding as is commonly understood. It's more of a "cheat".  Where by you "skip" the processes that typically adds noise and error.  The idea that "this piece of audio has already been processed, so no need to process it again".  Key to this idea of course is the concept that the mp3 process goes something like "take the sample, edit, change, manipulate it, etc, psycho-perceuptually minimize it, all so that it can compress nicely".  Where this last process, the "compression", is essentially reversable.  You don't get the original back of course, but you can get the "edited changed, maipulated part" back.

  Ofcourse, thats based on my general and "mainstream" impression of how mp3 operates.  Which is likely not the case, heh.  So I guess thats what I am asking right now?  Is ther no real "compression" part of the mp3 encode process?  A compression in the sense that it's reversible?  (I wonder where I got this idea from? heh.  I think I may have read somewhere on the use of huffman encoding in Vorbis, so I just assumed thatt some form of "end of the line" lossless compression is used in most audio codecs  ).

  With regards to mp3 "Un-decode" being NP-complete:  does that mean to say that there are non-deterministic aspects of the decode algorithm?  Or at least, non-inversable?  I'd imagine that only those sort of characteristics would require a "brute force" attack, heh.

Thanks again for the responses

Aggies
Title: mp3 to wav to mp3 to wav same?
Post by: phong on 2003-08-21 19:29:51
The answer to the first question is "no" and to the second "probably yes."  I don't know how much CS theory you know, and I'm rusty on the mathy parts, so here's a link that explains it:
http://www.wikipedia.org/wiki/Complexity_c...lasses_P_and_NP (http://www.wikipedia.org/wiki/Complexity_classes_P_and_NP)

After sleeping on it, I'm thinking that the mp3 problem might be computable faster than exponential time because of the maximum block length in mp3 files.  It would still be intractably slow though.
Title: mp3 to wav to mp3 to wav same?
Post by: Doctor on 2003-08-22 03:29:27
Yawn.

phong: I think you are wrong on both counts in the last message, but I like your iterative approach. ;-)

aggies: it's perfectly clear what you mean, and your intuition is not far off, but you need to read more into the replies.

Obviously every mainstream data compressor will use every trick to pack data as tight as possible. Huffman and similar algorithms (Rice, arithmetic etc.) are indeed the last step because they pack data on the level of individual bits, and there is not much packing you can do beyond that.

The central idea of lossy audio compression is to represent sound is the most compressible way so that quality loss is inaudible. Fewer numbers or rounder numbers pack tighter, so individual frequencies are dropped or rounded at the codec's discretion to maximize compressor efficiency down the line.

The decompressor is of course deterministic, but it is indeed irreversible because it performs blending and rounding. That translates to noise - new content - that you will have to locate and discard in order to reconstruct the original mp3.

Now, back to the iterative approach: if it were possible to specify a meaningful distance between two decodings so that successive approximations could minimize it, the problem would land squarely in P. I'm not going to develop this further, because I've got to make the architects happy with their hatches.
Title: mp3 to wav to mp3 to wav same?
Post by: phong on 2003-08-22 03:46:07
I think I mis-specified which questions I was answering.  The no was to the "non-deterministic aspects to the decode algorithm" and the "probably yes" was to the "non-inversable" part.
Title: mp3 to wav to mp3 to wav same?
Post by: ExUser on 2003-08-22 04:08:07
Quote
I don't know if they managed it. But in theory it's no harder than cracking an encryption algorithm. Forget the audio processing - think of mp3 decoding as a mathematical process for converting one set of numbers into a larger set of numbers - the task is to reverse the transformation.

Now, it may be impractically complicated to do so, but to say it's impossible is foolish - especially when there isn't even any encryption key to crack! And remember - we can get a close result just by re-encoding the .wav, so it's not like you have to start from no knowledge.

Wouldn't the pigeonhole principle prevent something like this from working properly?

I've thought of something similar, figuring that a neural net might actually be useful in something like this, assuming you could devise a good input/output scheme.

My idea was more for restoration of JPEG artifacting, rather than music, but this way you could train the net for a certain kind of restoration (ie, specifically restoring nature photos) and just improve image quality somewhat, due to knowledge of the specific type of image.

I later figured, after reading some stuff about compression, the pigeonhole principle, and the like, that it wouldn't really be possible to create something that brought lost fidelity back. That information is lost from the bitstream and cannot be retrieved. There may be some elaborate hacks to restore a facsimile of that information with a fraction of the original dataset, like SBR, but unless properly coded data is there, all the un-coder would be able to do would be to make the audio sound better to our ears, not necessarily more accurate.

I could be completely off-base here... I know nothing of the mathematics of compression, only calculus and computer programming.
Title: mp3 to wav to mp3 to wav same?
Post by: bexx on 2003-08-22 04:29:26
Isn't wavpacklossy/hybrid whatever its called not lossy when re-encoding?
Title: mp3 to wav to mp3 to wav same?
Post by: sublimelouie on 2003-08-22 04:51:27
easiest way to think of it, its like xeroxing a xerox, just never as good as original and if you keep re-encoding same file, it will get worse and worse...


i had the same question LONG AGO lol
Title: mp3 to wav to mp3 to wav same?
Post by: aggies11 on 2003-08-22 05:26:21
Sublime:
easiest way to think of it, its like xeroxing a xerox, just never as good as original and if you keep re-encoding same file, it will get worse and worse...

  Ideed.  And with that in mind, the idea would be to somehow be able to determine the  "copiers memory after scanning the original image", from the end resulting copy.  Obviously it's not the original, but it would be able to reproduce the copy, at will, without any loss.

    But alas, I had thought/feared it was as such.  I figured that I couldnt' be the first person to think along those lines, and that if it was possible it'd probably already be done.

  With regards to the pigeon hole though, I'd say that one has to take such theories with a grain of salt.  Yes, in the most strictist of sense, you can't recreate more information (or recover lost information), from data that has lost/reduced it.  In music thats lost fidelity, in images it could be lost resolution/clarity.  For the simple reason that the set of input to produce that output is larger than 1. Ie. Theres many starting points to get you to that end state, so there is no way to figure out which one it was. Too many pigeons, not enough holes .

  However it becomes very difficult to correctly quantify the "amount" of "information" in some item of data.  Meaning that you can sometimes "cheat".  For example, look at image reconstruction algorithms.  They can take a blurry/low resolution picture and enhace it to a a more clear/higher res image.  In the strictest sense, that should be impossible.  But they use things like light refraction from known light sources, and other such "cheats" to essentially eliminate alot of the possibilities. To reduce the number of pigeons, if you will.  Which in actuallity, is that they are increasing the amount of "information" found in the image. They are able to find "more" info in the image.  Conventional information theory says that you can't get "more" from "less".  But you can get around that in neat ways where you can show that "less" is actually not as little as you had thought.


  I've always wondered about the classic NP traveling salesmen problem.  Yes it's way above polynomial time to compute all possible routes, to find the best one.  But what if you could cheat, eliminating subroutes that were likely not in the solution. So that any master route containing the sub route, would automatically be ignored.  Do it enough, you can reduce the complexity of the result set.  Sure it's not guaranteed to succeed.  But what if you had a probability of sucess of 80%.  Than statistically you just run it a bunch of times to guarantee sucess, which still comes in as polynomial.  Basically the idea that each possible answer is NOT equally likely to be correct.  And so you focus your attentions on the much smaller subset of more likeli answers.

    But I digress a bit, heh.  If there is indeed uncertainty in the decode process, such that it does not have a well defined inverse, than all hope is lost, heh.  Although, that should mean than that it is possible for more than one mp3 datastream to decode to the exact same resulting wav? 

  Interesting indeed.

Aggies
Title: mp3 to wav to mp3 to wav same?
Post by: 2Bdecided on 2003-08-22 11:05:35
This reply is in response to no one in particular...

Be careful saying that things are "impossible".

50 years ago, there were a lot of old 78rpm discs around that people wanted to issue onto LPs. But they couldn't get the noise out of them. Or if they did, the results sounded horrible. And there's a problem: you have a valid signal, and added noise. And theory tells you that when the two are mixed together, you can no longer separate them. Where both are essentially unknown, you can't reconstruct either. It is not possible. You can't get back that nice clean audio signal from within all that noise.


And then Cedar came along, followed by many others, and built products that declick and denoise old records! How? Is theory wrong? No! But it doesn't matter if the result is mathematically identical to what was originally recorded - it just matters that, after cedar processing, it sounds significantly better than the noisy version.

Whether or not you can "un-decode" an mp3, I'm not sure. I'm 100% certain that you can't get from the mp3 back to the original .wav without loss. However, we often say "the information has been lost - it can't be put back". Not perfectly, no. But come 2050, when the only source of some recordings are 128kbps mp3s, I bet you some bright spark has a process which makes them sound a lot closer to the original than the surviving mp3 does.

So, my advice is to try to do the impossible. (Though please, don't jump out of your upstairs window thinking you can fly!). Because some people succeed, and they usually make a lot of money out of a product that is "good enough" - much more money than the theorists who say "it is theoretically impossible to do this perfectly".

Cheers,
David.
Title: mp3 to wav to mp3 to wav same?
Post by: Gabriel on 2003-08-22 11:23:30
Quote
IIRC FhG looked at this. You could call it an mp3 un-decoder if you like.

What they did is an mp3 re-coder.
By using a wav originating from a decoded mp3, they tryed to recreate the mp3 file.

They are "discovering" the encoder delay and for each frame  the stereo mode, the block size, the scalefactor.

Result was not perfect, but way better than doing a trivial re-encode.

Now, the problem is that I can not find this paper again...
Title: mp3 to wav to mp3 to wav same?
Post by: smg on 2003-08-22 14:46:15
Quote
This reply is in response to no one in particular...

Be careful saying that things are "impossible".

50 years ago, there were a lot of old 78rpm discs around that people wanted to issue onto LPs. But they couldn't get the noise out of them. Or if they did, the results sounded horrible. And there's a problem: you have a valid signal, and added noise. And theory tells you that when the two are mixed together, you can no longer separate them. Where both are essentially unknown, you can't reconstruct either. It is not possible. You can't get back that nice clean audio signal from within all that noise.


And then Cedar came along, followed by many others, and built products that declick and denoise old records! How? Is theory wrong? No! But it doesn't matter if the result is mathematically identical to what was originally recorded - it just matters that, after cedar processing, it sounds significantly better than the noisy version.

Whether or not you can "un-decode" an mp3, I'm not sure. I'm 100% certain that you can't get from the mp3 back to the original .wav without loss. However, we often say "the information has been lost - it can't be put back". Not perfectly, no. But come 2050, when the only source of some recordings are 128kbps mp3s, I bet you some bright spark has a process which makes them sound a lot closer to the original than the surviving mp3 does.

So, my advice is to try to do the impossible. (Though please, don't jump out of your upstairs window thinking you can fly!). Because some people succeed, and they usually make a lot of money out of a product that is "good enough" - much more money than the theorists who say "it is theoretically impossible to do this perfectly".

Cheers,
David.

This is what I like about this forum.
To qoute a famous US President John F Kennedy............
"Some folks dream of things as they are and say why...I dream of things that never where and say, Why Not
 
Title: mp3 to wav to mp3 to wav same?
Post by: phong on 2003-08-22 16:13:35
Quote
Do it enough, you can reduce the complexity of the result set. Sure it's not guaranteed to succeed. But what if you had a probability of sucess of 80%. Than statistically you just run it a bunch of times to guarantee sucess, which still comes in as polynomial.

This is a very good definition of a heuristic.  Heuristics are used all the time to get "pretty good" answers to Hard problems.  A good example is checking a number for primality.  You can do this with 100% certainty by factoring (very slow), or a recently discovered algorithm that takes O(n^12) (still quite slow).  There are other algorithms (some of which only work on certain sets of numbers) that when given a number to test and a seed number will tell you if it's prime or not, but get it wrong a certain percentage of the time (for the sake of example, we'll say they guess right 75% of the time).  These tests can be run quickly, and changing the seed number results in an independant test.  If you test a number with a few dozen seed numbers you can be sure that it's prime within a very small margin of error.

So, it's certainly possible to develop a heuristic to create a close approximation of the original mp3 file from a decoded wav file, and it would be much easier than getting the EXACT mp3 file back.  Don't ask me to write it though, it doesn't sound like fun at all.  I'd much rather work on graph coloring register allocation.

As far as "image enhancement" algorithms go...  Most don't get much additional information from the image.  Instead, they make up ficticious image data that looks pretty.
Title: mp3 to wav to mp3 to wav same?
Post by: ErikS on 2003-08-22 16:50:38
Quote
Now, the problem is that I can not find this paper again...

looking for this? http://www.hydrogenaudio.org/forums/index.php?showtopic=3382 (http://www.hydrogenaudio.org/forums/index.php?showtopic=3382)
Title: mp3 to wav to mp3 to wav same?
Post by: Zilva on 2003-09-10 10:06:42
Cosine transformation is NOT LOSSY. After transofmation you just cut some frequences. If you have no information in cut out freequences you get NOT LOSSY compression. So if you cut something once you can't cut it second time. There is no "rounding" or something similar. For example you have sequence of bytes '15 35 156 204 32 0 14 87 5 9 45 34 35 147 21 224' let assume that after cosine transform you have '245 125 54 2 20 6 1 2 0 1 0 0 0 0 0 0'. In order to compress you just cut off last 6 bytes. After decoding you will get exactly the same wav file. So mpeg compressin NOT ALWAYS is lossy. In case of repeatedly compresing-decompresing the same file with the same parameters you will not loose anything.
And there is no need to use 192 or even 128 kbps if your sound source is radio quality. You won't get any better qualty. Imagine that instead last 6 zeroes you will cut only 3. You just have bigger files. Here helps much VBR because it will cut more or less depending on how much zeroes you have at the end of spectrum.
Title: mp3 to wav to mp3 to wav same?
Post by: tigre on 2003-09-10 10:35:03
Quote
Cosine transformation is NOT LOSSY. After transofmation you just cut some frequences. If you have no information in cut out freequences you get NOT LOSSY compression. So if you cut something once you can't cut it second time. There is no "rounding" or something similar. For example you have sequence of bytes '15 35 156 204 32 0 14 87 5 9 45 34 35 147 21 224' let assume that after cosine transform you have '245 125 54 2 20 6 1 2 0 1 0 0 0 0 0 0'. In order to compress you just cut off last 6 bytes. After decoding you will get exactly the same wav file. So mpeg compressin NOT ALWAYS is lossy. In case of repeatedly compresing-decompresing the same file with the same parameters you will not loose anything.
And there is no need to use 192 or even 128 kbps if your sound source is radio quality. You won't get any better qualty. Imagine that instead last 6 zeroes you will cut only 3. You just have bigger files. Here helps much VBR because it will cut more or less depending on how much zeroes you have at the end of spectrum.

Some things of what you say seem right, but leed to at least questionable conclusions. What about this?
- The transform results are stored digitally - to compress the storage space is limited, so rounding/truncation errors happen
- Unless you try to compress artificial test signals there's always noise or noise-like content (at least dither), so there are hardly any "0"s after transform
- On reencoding the positions of transform windows are different than before because mp3 encoding/decoding adds samples in the beginning
- Even if the positions would be the same, the windows overlap, so when encoding again it's not possible to restore the windows from the encoding step before exactly as they've been.

Maybe I'm wrong. Why don't you provide an example for a file that doesn't change on multiple en-/decoding? (There's an upload forum...)
Title: mp3 to wav to mp3 to wav same?
Post by: 2Bdecided on 2003-09-10 11:11:28
Quote
Cosine transformation is NOT LOSSY.

Not in and of themselves, no.

But when the the output is overlapped in the time and frequency domain, there's no way of going back.

Cheers,
David.
Title: mp3 to wav to mp3 to wav same?
Post by: makarov on 2005-01-30 06:33:10
An analogy to JPEG lossy image compression was made above. I have a curious fact about it.

It is true that successive decompress-compress cycles on the same image each reduce its quality further. However, it turns out that (with JPEG) the biggest information loss occurs when the original lossless image is first compressed into JPEG. If you do successive decompress-compress cycles (at the same JPEG quality setting) and check the information loss at each cycle (which is easily done by subtracting one image from another pixel-by-pixel and presenting the subtraction result as an image), you'll see that the magnitude of artefacts introduced at the second compression is much smaller than that introduced at the initial compression. Firthermore, the magnitude of artefacts introduced at the third and following compressions is still smaller than that at the second compression. The artefacts still do build up and eventually trash the image completely, but not nearly as fast as if you'd expect if each next compression threw away as much information as the first one. JPEG has a limited robustness against stupid users doing image editing and recompression cycles.

Now, I don't know whether MP3 has the same robustness or not.
Title: mp3 to wav to mp3 to wav same?
Post by: MugFunky on 2005-01-31 03:06:10
wow.. old post. ("holy thread resurrection, batman!!!!11!!1!1")

JPEG isn't the same as mp3, even though they use DCT and mDCT.

for starters, though the mDCT is perfectly reconstructible, the input filterbank of mp3 (where it splits into 32 subbands, mp2 style) is not perfectly reconstructible.  Jpeg goes straight for the DCT, and there's no overlapping.

also, JPEG uses a fixed quantizer and a fixed quant matrix for each block.  there's no encoder delay or overlapping blocks or anything like that.  theoretically you're only going to get rounding error from the repeated DCT and iDCT, and the conversion to 8 bits (even more loss if dither is used in the decoder).

the big, glaring difference, however, is that mp3 uses psychoacoustics and JPEG uses jack-all in the way of psychovisuals (the quant matrix could be seen as a primitive form if it).  assuming a perfect, transparent mp3 encode - what it's done is examined the source, and determined specific masking thresholds for the human auditory system.  imagine a spectrogram with a curved line under it.  the encoder will bring noise up to that line, but if it goes over it, it will be audible.

when you re-encode an mp3, the encoder has no knowledge of the masking decisions the previous encoder made.  so it'll draw a line of it's own, and add noise up to but not over it.  the big problem is that the total quantization noise in the resulting file is now up to twice the magnitude it was in the original mp3.  this guarantees there will be audible artefacts.

the above assumes a perfect psy-model, which of course mp3 doesn't have.  things get even worse when the original encode wasn't perfect.

basically, you can't make analogies between image and audio coding, because much of what goes in an audio encoder is completely meaningless in images - that's why we can't swap our eyes for ears and get the same use out of them.
Title: mp3 to wav to mp3 to wav same?
Post by: h.tuehn on 2005-01-31 06:16:11
I don't want to correct anything MugFunky or makarov wrote, only add something that may have seemed too obvious to them.

What they write confirms, but does not explicitly state, is that with JPEG or MPEG, audio or visual, no matter what, you can not regain the losses by applying a higher bit-rate.  The best you can achieve is limited by whatever was used with the original encode.  To achieve a better rip, you need to have the original.  In other words, you would only want to re-encode downward (such as for a thumbnail or image or a listening sample).  Otherwise, you're losing both disk space and quality for what might be best described as psycho-mentality.