<div>Is this a common warning? The decoder doesn&#39;t return an error on it, but I see it a lot in my test application on windows. It is non existent on my linux box. I haven&#39;t tried mingw yet.</div><div><br></div><div>
please note that I&#39;m using visual studio 2008 w/the vcproj that Bjoern Rasmussen made for 0.5.2 (w/some file references removed) at the moment and it is giving a lot of C4554 warnings &quot;<span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:11px">&#39;operator&#39; : check operator precedence for possible error; use parentheses to clarify precedence<span style="font-family:arial;font-size:small">&quot;, especially where the EC_CODE_* macros are used. I would have to agree with msdev, it would be nice to have precedence clarified.</span></span></div>

<div><br></div><div>
<span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:11px"><span style="font-family:arial;font-size:small">The idea of my app below is that I take a raw mono 16-bit little endian signed PCM, Celt it, then immediately turn it back into the same PCM format again. However my output file clearly suffers from &quot;uint decode error&quot; on windows, but on linux it&#39;s just peachy.</span></span></div>

<div><br></div><div><br></div><div><div>#include &lt;stdlib.h&gt;</div><div>#include &lt;stdio.h&gt;</div><div>#include &lt;string.h&gt;</div><div><br></div><div>#include &lt;libcelt/celt.h&gt;</div><div><br></div><div>int gBitRate=128000;</div>

<div>int gFrameSize=256;</div><div>int gSampleRate=44100;</div><div>int gNrChannels=1;</div><div><br></div><div>int main(int argc, char* argv[])</div><div>{</div><div><span style="white-space:pre">        </span>const char* inputfilename=&quot;..\\input_mono.snd&quot;;</div>

<div><span style="white-space:pre">        </span>const char* encodedfilename=&quot;..\\encoded_mono.celt&quot;;</div><div><span style="white-space:pre">        </span>const char* outputfilename=&quot;..\\output_mono.snd&quot;;</div>
<div><br></div><div><span style="white-space:pre">        </span>FILE* encodedfile=0;</div><div><br></div><div><span style="white-space:pre">        </span>FILE* inputfile=fopen(inputfilename,&quot;rb&quot;);</div>
<div><span style="white-space:pre">        </span>if(!inputfile)</div><div><span style="white-space:pre">        </span>{</div><div><span style="white-space:pre">                </span>printf(&quot;ERROR opening %s for reading\n&quot;,inputfilename);</div>

<div><span style="white-space:pre">                </span>return -1;</div><div><span style="white-space:pre">        </span>}</div><div><br></div><div><span style="white-space:pre">        </span>encodedfile=fopen(encodedfilename,&quot;wb&quot;);</div>

<div><span style="white-space:pre">        </span>if(!encodedfile)</div><div><span style="white-space:pre">        </span>{</div><div><span style="white-space:pre">                </span>printf(&quot;ERROR opening %s for writing\n&quot;,encodedfilename);</div>

<div><span style="white-space:pre">                </span>return -1;</div><div><span style="white-space:pre">        </span>}</div><div><br></div><div><span style="white-space:pre">        </span>FILE* outputfile=fopen(outputfilename,&quot;wb&quot;);</div>

<div><span style="white-space:pre">        </span>if(!outputfile)</div><div><span style="white-space:pre">        </span>{</div><div><span style="white-space:pre">                </span>printf(&quot;ERROR opening %s for writing\n&quot;,outputfilename);</div>

<div><span style="white-space:pre">                </span>return -1;</div><div><span style="white-space:pre">        </span>}</div><div><br></div><div><span style="white-space:pre">        </span>int bytes_per_packet = ((gBitRate*gFrameSize/gSampleRate+4)/8)*gNrChannels;</div>

<div><br></div><div><span style="white-space:pre">        </span>int error=0;</div><div><span style="white-space:pre">        </span>celt_int16* pcmbuffer=(celt_int16*)malloc(sizeof(celt_int16)*gFrameSize*gNrChannels);</div>
<div><span style="white-space:pre">        </span>unsigned char* encodedbuffer=(unsigned char*)malloc(bytes_per_packet);</div><div><span style="white-space:pre">        </span>CELTMode* mode=celt_mode_create(gSampleRate,gFrameSize,&amp;error);</div>

<div><span style="white-space:pre">        </span>if(mode==NULL || error!=CELT_OK)</div><div><span style="white-space:pre">        </span>{</div><div><span style="white-space:pre">                </span>printf(&quot;ERROR: celt_mode_create %s\n&quot;,celt_strerror(error));</div>

<div><span style="white-space:pre">                </span>return -1;</div><div><span style="white-space:pre">        </span>}</div><div><span style="white-space:pre">        </span>int offset=0;</div>
<div><span style="white-space:pre">        </span>int res=0;</div><div><br></div><div><span style="white-space:pre">        </span>CELTEncoder* encoder=celt_encoder_create(mode,gNrChannels,&amp;error);</div>
<div><span style="white-space:pre">        </span>if(encoder==NULL || error!=CELT_OK)</div><div><span style="white-space:pre">        </span>{</div><div><span style="white-space:pre">                </span>printf(&quot;ERROR: celt_encoder_create %s\n&quot;,celt_strerror(error));</div>

<div><span style="white-space:pre">                </span>return -1;</div><div><span style="white-space:pre">        </span>}</div><div><br></div><div><span style="white-space:pre">        </span>while((res=fread(pcmbuffer,sizeof(celt_int16)*gFrameSize*gNrChannels,1,inputfile))==1)</div>

<div><span style="white-space:pre">        </span>{</div><div><span style="white-space:pre">                </span>int ret=celt_encode(encoder,pcmbuffer,NULL,encodedbuffer,bytes_per_packet);</div>
<div><span style="white-space:pre">                </span>if(ret&lt;0)</div><div><span style="white-space:pre">                </span>{</div><div><span style="white-space:pre">                        </span>printf(&quot;ERROR: celt_encode %s\n&quot;,celt_strerror(ret));</div>

<div><span style="white-space:pre">                        </span>return -1;</div><div><span style="white-space:pre">                </span>}</div><div><span style="white-space:pre">                </span>else if(ret!=bytes_per_packet)</div>
<div><span style="white-space:pre">                </span>{</div><div><span style="white-space:pre">                        </span>printf(&quot;ERROR: celt_encode got %d bytes, expected %d\n&quot;,ret, bytes_per_packet);</div>
<div><span style="white-space:pre">                        </span>return -1;</div><div><span style="white-space:pre">                </span>}</div><div><span style="white-space:pre">                </span>else</div>
<div><span style="white-space:pre">                </span>{</div><div><span style="white-space:pre">                        </span>if(fwrite(encodedbuffer,bytes_per_packet,sizeof(unsigned char),encodedfile)!=1)</div>
<div><span style="white-space:pre">                        </span>{</div><div><span style="white-space:pre">                                </span>printf(&quot;ERROR: failed writing bytes to %s\n&quot;,encodedfilename);</div>
<div><span style="white-space:pre">                                </span>return -1;</div><div><span style="white-space:pre">                        </span>}</div><div><span style="white-space:pre">                        </span>else</div>
<div><span style="white-space:pre">                        </span>{</div><div><span style="white-space:pre">                                </span>printf(&quot;writing offset: %d, size %d\n&quot;,offset,bytes_per_packet);</div>
<div><span style="white-space:pre">                                </span>offset+=bytes_per_packet;</div><div><span style="white-space:pre">                        </span>}</div><div><span style="white-space:pre">                </span>}</div>
<div><span style="white-space:pre">        </span>}</div><div><span style="white-space:pre">        </span>fclose(inputfile);</div><div><span style="white-space:pre">        </span>fclose(encodedfile);</div>
<div><br></div><div><span style="white-space:pre">        </span>celt_encoder_destroy(encoder);</div><div><span style="white-space:pre">        </span>celt_mode_destroy(mode);</div><div><br>
</div><div><span style="white-space:pre">        </span>CELTMode* mode2=celt_mode_create(gSampleRate,gFrameSize,&amp;error);</div><div><span style="white-space:pre">        </span>if(mode2==NULL || error!=CELT_OK)</div>
<div><span style="white-space:pre">        </span>{</div><div><span style="white-space:pre">                </span>printf(&quot;ERROR: celt_mode_create 2 %s\n&quot;,celt_strerror(error));</div><div>
<span style="white-space:pre">                </span>return -1;</div><div><span style="white-space:pre">        </span>}</div><div><br></div><div><span style="white-space:pre">        </span>encodedfile=fopen(encodedfilename,&quot;rb&quot;);</div>
<div><span style="white-space:pre">        </span>if(!encodedfile)</div><div><span style="white-space:pre">        </span>{</div><div><span style="white-space:pre">                </span>printf(&quot;ERROR opening %s for reading\n&quot;,encodedfilename);</div>

<div><span style="white-space:pre">                </span>return -1;</div><div><span style="white-space:pre">        </span>}</div><div><br></div><div><span style="white-space:pre">        </span>CELTDecoder* decoder=celt_decoder_create(mode2,gNrChannels,&amp;error);</div>

<div><span style="white-space:pre">        </span>if(decoder==NULL || error!=CELT_OK)</div><div><span style="white-space:pre">        </span>{</div><div><span style="white-space:pre">                </span>printf(&quot;ERROR: celt_decoder_create %s\n&quot;,celt_strerror(error));</div>

<div><span style="white-space:pre">                </span>return -1;</div><div><span style="white-space:pre">        </span>}</div><div><br></div><div><br></div><div><span style="white-space:pre">        </span>fseek(encodedfile,0,2);</div>
<div><span style="white-space:pre">        </span>int filesize=ftell(encodedfile);</div><div><span style="white-space:pre">        </span>fseek(encodedfile,0,0);</div><div><span style="white-space:pre">        </span>offset=0;</div>
<div><span style="white-space:pre">        </span>while((res=fread(encodedbuffer,bytes_per_packet,1,encodedfile))==1)</div><div><span style="white-space:pre">        </span>{</div><div><span style="white-space:pre">                </span>printf(&quot;reading offset: %d, size %d, %.2f\n&quot;,offset,bytes_per_packet,((float)offset/(float)filesize)*100.0f);</div>

<div><span style="white-space:pre">                </span>offset+=bytes_per_packet;</div><div><br></div><div><span style="white-space:pre">                </span>int ret=celt_decode(decoder,encodedbuffer,bytes_per_packet,pcmbuffer);</div>
<div><span style="white-space:pre">                </span>if(ret!=CELT_OK)</div><div><span style="white-space:pre">                </span>{</div><div><span style="white-space:pre">                        </span>printf(&quot;ERROR: celt_decode %s\n&quot;,celt_strerror(ret));</div>

<div><span style="white-space:pre">                        </span>return -1;</div><div><span style="white-space:pre">                </span>}</div><div><span style="white-space:pre">                </span>else</div>
<div><span style="white-space:pre">                </span>{</div><div><span style="white-space:pre">                        </span>fwrite(pcmbuffer,sizeof(celt_int16)*gFrameSize*gNrChannels,1,outputfile);</div>
<div><span style="white-space:pre">                </span>}</div><div><span style="white-space:pre">        </span>}</div><div><br></div><div><span style="white-space:pre">        </span>fclose(outputfile);</div>
<div><span style="white-space:pre">        </span>fclose(encodedfile);</div><div><br></div><div><span style="white-space:pre">        </span>celt_decoder_destroy(decoder);</div><div><br></div>
<div><span style="white-space:pre">        </span>celt_mode_destroy(mode2);</div><div><br></div><div><span style="white-space:pre">        </span>free(pcmbuffer);</div><div><span style="white-space:pre">        </span>free(encodedbuffer);</div>

<div>}</div></div>