On Thu, Mar 22, 2018 at 3:41 AM, Stéphane Damo <stephane.d...@gmail.com> wrote: > Hello, > > I manage to successfully write 8, 16 and 24 bit, all stereo, FLAC files. But > when I try to write 32 bit FLACs my program crashes. > > FLAC__stream_encoder_set_bits_per_sample is called to match the desired bit > depth (8, 16, 24, 32) > > It's the same code for all bit depths, i provide a fixed-size signed int > buffer to the lib (size=16384), with values with appropriate ranges for each > bit depth (-128...+127 for 8 bit, etc.). > > The crash happens in stream_encoder.c line 2263 : > > encoder->private_->integer_signal[channel][i] = buffer[k++]; > > It happens when I call FLAC__stream_encoder_process_interleaved(encoder, > out, 16384/2) in my code. Its working perfectly for all bit depth except 32 > bit. > > > Output message: Unhandled exception at 0x00F98441 in fmcomposer.exe: > 0xC0000005: Access violation writing location 0x00000000. > > > I'm using the latest code from the github repository. Reading the docs > didn't noticed any thing special to do for writing 32 bit FLACs, it seems it > should be supported. Maybe I am missing something ?
AFAIK: while FLAC format itself supports 32-bit PCM, the official encoder doesn't support it. from include/FLAC/format.h: /** The maximum sample resolution permitted by the format. */ #define FLAC__MAX_BITS_PER_SAMPLE (32u) /** The maximum sample resolution permitted by libFLAC. * * \warning * FLAC__MAX_BITS_PER_SAMPLE is the limit of the FLAC format. However, * the reference encoder/decoder is currently limited to 24 bits because * of prevalent 32-bit math, so make sure and use this value when * appropriate. */ #define FLAC__REFERENCE_CODEC_MAX_BITS_PER_SAMPLE (24u) also, init_stream_internal_() function already checks bit depth: if(encoder->protected_->bits_per_sample < FLAC__MIN_BITS_PER_SAMPLE || encoder->protected_->bits_per_sample > FLAC__REFERENCE_CODEC_MAX_BITS_PER_SAMPLE) return FLAC__STREAM_ENCODER_INIT_STATUS_INVALID_BITS_PER_SAMPLE; so, maybe you forgot to check return value for errors? _______________________________________________ flac-dev mailing list flac-dev@xiph.org http://lists.xiph.org/mailman/listinfo/flac-dev