<div dir="ltr">

<span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.8px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">Yes, you're right I didnt check for much return error codes from libFLAC. I'll do that and limit the bit depth to 24 bit in my program. Thanks for your help !</span>

<br></div><div class="gmail_extra"><br><div class="gmail_quote">On 24 March 2018 at 11:34, lvqcl <span dir="ltr"><<a href="mailto:lvqcl.mail@gmail.com" target="_blank">lvqcl.mail@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On Thu, Mar 22, 2018 at 3:41 AM, Stéphane Damo <<a href="mailto:stephane.damo@gmail.com">stephane.damo@gmail.com</a>> wrote:<br>
> Hello,<br>
><br>
> I manage to successfully write 8, 16 and 24 bit, all stereo, FLAC files. But<br>
> when I try to write 32 bit FLACs my program crashes.<br>
><br>
> FLAC__stream_encoder_set_bits_<wbr>per_sample is called to match the desired bit<br>
> depth (8, 16, 24, 32)<br>
><br>
> It's the same code for all bit depths, i provide a fixed-size signed int<br>
> buffer to the lib (size=16384), with values with appropriate ranges for each<br>
> bit depth (-128...+127 for 8 bit, etc.).<br>
><br>
> The crash happens in stream_encoder.c line 2263 :<br>
><br>
> encoder->private_->integer_<wbr>signal[channel][i] = buffer[k++];<br>
><br>
> It happens when I call FLAC__stream_encoder_process_<wbr>interleaved(encoder,<br>
> out, 16384/2) in my code. Its working perfectly for all bit depth except 32<br>
> bit.<br>
><br>
><br>
> Output message: Unhandled exception at 0x00F98441 in fmcomposer.exe:<br>
> 0xC0000005: Access violation writing location 0x00000000.<br>
><br>
><br>
> I'm using the latest code from the github repository. Reading the docs<br>
> didn't noticed any thing special to do for writing 32 bit FLACs, it seems it<br>
> should be supported. Maybe I am missing something ?<br>
<br>
</span>AFAIK: while FLAC format itself supports 32-bit PCM, the official<br>
encoder doesn't support it.<br>
<br>
from include/FLAC/format.h:<br>
<br>
<br>
/** The maximum sample resolution permitted by the format. */<br>
#define FLAC__MAX_BITS_PER_SAMPLE (32u)<br>
<br>
/** The maximum sample resolution permitted by libFLAC.<br>
 *<br>
 * \warning<br>
 * FLAC__MAX_BITS_PER_SAMPLE is the limit of the FLAC format.  However,<br>
 * the reference encoder/decoder is currently limited to 24 bits because<br>
 * of prevalent 32-bit math, so make sure and use this value when<br>
 * appropriate.<br>
 */<br>
#define FLAC__REFERENCE_CODEC_MAX_<wbr>BITS_PER_SAMPLE (24u)<br>
<br>
also, init_stream_internal_() function already checks bit depth:<br>
<br>
    if(encoder->protected_->bits_<wbr>per_sample <<br>
FLAC__MIN_BITS_PER_SAMPLE || encoder->protected_->bits_per_<wbr>sample ><br>
FLAC__REFERENCE_CODEC_MAX_<wbr>BITS_PER_SAMPLE)<br>
        return FLAC__STREAM_ENCODER_INIT_<wbr>STATUS_INVALID_BITS_PER_<wbr>SAMPLE;<br>
<br>
<br>
so, maybe you forgot to check return value for errors?<br>
______________________________<wbr>_________________<br>
flac-dev mailing list<br>
<a href="mailto:flac-dev@xiph.org">flac-dev@xiph.org</a><br>
<a href="http://lists.xiph.org/mailman/listinfo/flac-dev" rel="noreferrer" target="_blank">http://lists.xiph.org/mailman/<wbr>listinfo/flac-dev</a><br>
</blockquote></div><br></div>