<div>Is this a common warning? The decoder doesn'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't tried mingw yet.</div><div><br></div><div>
please note that I'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 "<span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:11px">'operator' : check operator precedence for possible error; use parentheses to clarify precedence<span style="font-family:arial;font-size:small">", 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 "uint decode error" on windows, but on linux it's just peachy.</span></span></div>
<div><br></div><div><br></div><div><div>#include <stdlib.h></div><div>#include <stdio.h></div><div>#include <string.h></div><div><br></div><div>#include <libcelt/celt.h></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="..\\input_mono.snd";</div>
<div><span style="white-space:pre">        </span>const char* encodedfilename="..\\encoded_mono.celt";</div><div><span style="white-space:pre">        </span>const char* outputfilename="..\\output_mono.snd";</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,"rb");</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("ERROR opening %s for reading\n",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,"wb");</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("ERROR opening %s for writing\n",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,"wb");</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("ERROR opening %s for writing\n",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,&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("ERROR: celt_mode_create %s\n",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,&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("ERROR: celt_encoder_create %s\n",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<0)</div><div><span style="white-space:pre">                </span>{</div><div><span style="white-space:pre">                        </span>printf("ERROR: celt_encode %s\n",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("ERROR: celt_encode got %d bytes, expected %d\n",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("ERROR: failed writing bytes to %s\n",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("writing offset: %d, size %d\n",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,&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("ERROR: celt_mode_create 2 %s\n",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,"rb");</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("ERROR opening %s for reading\n",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,&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("ERROR: celt_decoder_create %s\n",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("reading offset: %d, size %d, %.2f\n",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("ERROR: celt_decode %s\n",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>