HydrogenAudio

Hosted Forums => foobar2000 => Support - (fb2k) => Topic started by: Dandruff on 2008-03-04 07:55:56

Title: corrupted(?) 24-bit FLAC file not playable
Post by: Dandruff on 2008-03-04 07:55:56
mmh, foobar2000 v0.9.5.1 doesn't playback 24 bit flac files properly here! foobar basically can read the file, but the output gets distorted!

Reaper (http://www.reaper.fm) for example plays it fine!


FIXED
Title: corrupted(?) 24-bit FLAC file not playable
Post by: DotNoir on 2008-03-04 08:48:13
mmh, foobar2000 v0.9.5.1 doesn't playback 24 bit flac files properly here! foobar basically can read the file, but the output gets distorted!

here an example: http://www.outburst-audio.com/misc/24-bps.flac (http://www.outburst-audio.com/misc/24-bps.flac) (1.2 MB)



Reaper (http://www.reaper.fm) for example plays it fine!


The FLAC file is corrupted, got this error with the FLACs own FLACTester (comes with the FLAC installer)
Code: [Select]
[1/1]    C:\Users\Antti\Downloads\24-bps.flac...FLAC__STREAM_DECODER_UNPARSEABLE_STREAM
1 files, 1 errors [1]


Also, Reaper can't play it here.
Title: corrupted(?) 24-bit FLAC file not playable
Post by: Dandruff on 2008-03-04 09:09:12
The FLAC file is corrupted, got this error with the FLACs own FLACTester (comes with the FLAC installer)
Code: [Select]
[1/1]    C:\Users\Antti\Downloads\24-bps.flac...FLAC__STREAM_DECODER_UNPARSEABLE_STREAM
1 files, 1 errors [1]


ok, thanks - i'll forward this to the reaper developer. but with the updated dll posted below, reaper plays the file fine.


Also, Reaper can't play it here.


it can (in the next version). here the updated dll for reaper 2.106: http://landoleet.org/reaper_flac.dll (http://landoleet.org/reaper_flac.dll) from http://www.cockos.com/forum/showthread.php?p=162266 (http://www.cockos.com/forum/showthread.php?p=162266)



so foobar should play 24 bps files properly? did you test it with a file?
Title: corrupted(?) 24-bit FLAC file not playable
Post by: DotNoir on 2008-03-04 10:31:45
Here's (http://koti.mbnet.fi/tritonus/DotNoir/test.flac) a 24bit flac I just made. works fine in fb2k.
Title: corrupted(?) 24-bit FLAC file not playable
Post by: Dandruff on 2008-03-04 11:13:03
alright, thanks!
Title: corrupted(?) 24-bit FLAC file not playable
Post by: Dandruff on 2008-03-04 21:29:40
reaper developer has no clue why the encoded 24 bps files don't play properly in foobar2000. he said that the flac command line decoder is able to decode it. of course reaper (with the updated dll) itself also can decode it fine ...


http://www.cockos.com/forum/showpost.php?p...mp;postcount=33 (http://www.cockos.com/forum/showpost.php?p=162395&postcount=33)


strange thing 
Title: corrupted(?) 24-bit FLAC file not playable
Post by: Dandruff on 2008-03-07 09:31:00
Also, Reaper can't play it here.


it can (in the next version). here the updated dll for reaper 2.106: http://landoleet.org/reaper_flac.dll (http://landoleet.org/reaper_flac.dll) from http://www.cockos.com/forum/showthread.php?p=162266 (http://www.cockos.com/forum/showthread.php?p=162266)

Reaper 2.108 (http://www.reaper.fm/files/2.x/reaper2108-install.exe) now got released with FLAC 1.2.1 encoding and decoding support. But foobar2000 still can't decode 24 bps files created with Reaper. Sound gets distorted heavily.

I've also started a thread about this problem at the FLAC SourceForge project page: http://sourceforge.net/tracker/index.php?f...amp;atid=213478 (http://sourceforge.net/tracker/index.php?func=detail&aid=1907495&group_id=13478&atid=213478)


Any ideas?
Title: corrupted(?) 24-bit FLAC file not playable
Post by: Egor on 2008-03-07 10:59:18
Confirmed, foobar2000 0.9.5.1 cannot properly decode the sample - output is heavily distorted (verified with "Convert to... WAV" option to eliminate possible hardware problems).

Apparently, that's a bug in foobar2000. Winamp 5.52 can play the sample, and the reference FLAC CLI tools version 1.2.0 and 1.2.1 can decode it as well.
Title: corrupted(?) 24-bit FLAC file not playable
Post by: Dandruff on 2008-03-08 05:43:45
Apparently, that's a bug in foobar2000.

Thanks! That's what the Reaper developer said to me too.


Any Foobar2000 developer reading here?
Title: corrupted(?) 24-bit FLAC file not playable
Post by: Egor on 2008-03-08 11:18:12
Since the topic got new title, I have to say that the sample is not corrupted, it is a valid 1.2.x flac file (at least, the latest reference flac tools say the file is OK).
I guess flac-tester had a problem with that 24-bit file because it is not 1.2.x-compatible. The new compression method was accidently added in the 1.2.1 flac encoder for 24-bit audio, so pre-1.2.0 decoders cannot decode such 24b samples (no backwards compatibility, unfortunately).
Title: corrupted(?) 24-bit FLAC file not playable
Post by: Dandruff on 2008-03-10 18:52:53
Since the topic got new title, I have to say that the sample is not corrupted, it is a valid 1.2.x flac file (at least, the latest reference flac tools say the file is OK).

good to know, thanks! the reaper developer also didn't trust the flac-tester utility
Title: corrupted(?) 24-bit FLAC file not playable
Post by: Peter on 2008-04-13 14:52:17
On this file, libFLAC returns 24-bit samples improperly padded to 32-bit, with most significant bits filled with garbage instead of correct sign expansion. I'd like to hear a reply from Josh about this before I implement a workaround which would have negative impact on everyone's decoding speeds, even on correct files.

This problem isn't 24-bit specific at all, the same issue could potentially occur with 16-bit files.
Title: corrupted(?) 24-bit FLAC file not playable
Post by: Dandruff on 2008-04-21 23:25:34
foobar2000 v0.9.5.1 doesn't playback 24 bit flac files properly here! foobar basically can read the file, but the output gets distorted!

here an example: http://www.outburst-audio.com/misc/24-bps.flac (http://www.outburst-audio.com/misc/24-bps.flac) (1.2 MB)



FIXED in version 0.9.5.2! Many thanks!
Title: corrupted(?) 24-bit FLAC file not playable
Post by: Peter on 2008-04-27 19:12:15
Looks like I accidentally left the fix active in 0.9.5.2 release. I still don't believe that this is a legit behavior of FLAC tools and anybody else converting FLAC decoder's output to floating-point values will run into the same problem.
I hope Josh is looking into this.

Edit: since the original file link no longer works, I uploaded a copy of the offending file.
Title: corrupted(?) 24-bit FLAC file not playable
Post by: Dandruff on 2008-04-27 19:58:23
Ok, thank you Peter! I've added your reply to the FLAC SourceForge Tracker: http://sourceforge.net/tracker/index.php?f...amp;atid=213478 (http://sourceforge.net/tracker/index.php?func=detail&aid=1907495&group_id=13478&atid=213478)
Title: corrupted(?) 24-bit FLAC file not playable
Post by: Dandruff on 2008-05-26 16:19:55
Looks like I accidentally left the fix active in 0.9.5.2 release.


0.9.5.3 still can play this "corrupted" file fine!
Title: corrupted(?) 24-bit FLAC file not playable
Post by: jcoalson on 2008-05-30 07:25:47
looking at this now...
Title: corrupted(?) 24-bit FLAC file not playable
Post by: jcoalson on 2008-05-30 07:52:12
ok, short story, I'm pretty sure 24_bps.flac is corrupt, was it created with reaper?  I would like to see the code it is using to call libFLAC because I'll bet it's not passing in properly sign-extended data to FLAC__stream_encoder_process().

the giveaway is that if you decode it to wav with flac.exe and re-encode it with flac.exe, this .flac file is ~20% smaller than 24_bps.flac.  and it all happens to work because of 1) the magic of 2's-complement arithmetic; 2) flac.exe does the same 'fix' that foobar is now doing.  these 2 things together magically cancel out the initial encoding error.

long story:

in this clip, sample 0 of channel 0 is 0 and sample 1 of channel 0 is -364 (0xfffe94 in the wav file).  the first FLAC subframe of channel 0 is a FIXED subframe with order 1, meaning the first sample (0) is stored raw and the second sample (-364) is stored as a residual value "sample[1]-sample[0]" == -364 - 0 == -364

but that is not what is actually in 24_bps.flac, the first residual sample it has encoded is 16776852 (0xfffe94), which is exactly what I would expect if the client passed in bad data (explained next), and also explains why the compression ratio is bad (because 16776852 takes more bits to store than -364)

when samples are passed in to FLAC__stream_encoder_process(), they must be 32-bit signed ints regardless of the sample resolution.  so to pass in -364, the sample value should be 0xfffffe94, but if the client is not sign-extending properly, it will pass in 0xfffe94 and due to the above mentioned magic, it will all appear to work (magic extends even to the md5 summing).

now this could have been avoided if libFLAC did range checking on the input but this noticeably slows things down, which I am hesitant to do for something that should be caught in testing.  (maybe it could be done in debug builds.)

Josh
Title: corrupted(?) 24-bit FLAC file not playable
Post by: Dandruff on 2008-05-30 09:45:50
I'm pretty sure 24_bps.flac is corrupt, was it created with reaper?


Thanks for the reaply! Yes, it was created with Reaper.

I've forwarded your reply to http://www.cockos.com/forum/showpost.php?p...mp;postcount=44 (http://www.cockos.com/forum/showpost.php?p=190492&postcount=44)
Title: corrupted(?) 24-bit FLAC file not playable
Post by: Dandruff on 2009-03-05 07:49:04
Ok, Cockos just fixed it for the next version: http://forum.cockos.com/showthread.php?p=291813 (http://forum.cockos.com/showthread.php?p=291813)