Christopher Key
2010-Jul-14 11:01 UTC
[Flac-dev] [patch] Decoding non 8/16/24 bps audio to raw format should fail cleanly
When decoding a FLAC file with bits per sample that is not a multiple of 8 and outputting in raw format, the decoder gets as far as the write callback before realising that it doesn't know how to write the data. It then fails with an unhelpful message (or trips an assert() in debug mode). The attached patch performs the check earlier, and gives a more helpful error message. Kind regards, Christopher Key #v+ # metaflac --show-bps data_20bps.flac 20 #v- without patch: #v+ # flac -dc --force-raw-format --sign signed --endian little data_20bps.flac flac 1.2.1, Copyright (C) 2000,2001,2002,2003,2004,2005,2006,2007 Josh Coalson flac comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to redistribute it under certain conditions. Type `flac' for details. data_20bps.flac: ERROR while decoding data state = FLAC__STREAM_DECODER_READ_FRAME #v- with patch: #v+ # flac -dc --force-raw-format --sign signed --endian little data_20bps.flac flac 1.2.1, Copyright (C) 2000,2001,2002,2003,2004,2005,2006,2007 Josh Coalson flac comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to redistribute it under certain conditions. Type `flac' for details. data_20bps.flac: ERROR: bits per sample is 20, must be 8/16/24 for raw format output #v- -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: flac-raw-output-bps-check.patch Url: http://lists.xiph.org/pipermail/flac-dev/attachments/20100714/c3f03970/attachment.txt
Christopher Key
2010-Jul-14 11:39 UTC
[Flac-dev] [patch] Decoding non 8/16/24 bps audio to raw format should fail cleanly
On 14/07/2010 12:01, Christopher Key wrote:> When decoding a FLAC file with bits per sample that is not a multiple > of 8 and outputting in raw format, the decoder gets as far as the > write callback before realising that it doesn't know how to write the > data. It then fails with an unhelpful message (or trips an assert() > in debug mode). The attached patch performs the check earlier, and > gives a more helpful error message. >Apologies for the immediate correction. The newly attached patch is probably somewhat safer, depending on whether libFLAC catches bps==0 || bps>=32 itself. -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: flac-raw-output-bps-check.patch Url: http://lists.xiph.org/pipermail/flac-dev/attachments/20100714/58ce621f/attachment.txt