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. 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 "'operator' : check operator precedence for possible error; use parentheses to clarify precedence", especially where the EC_CODE_* macros are used. I would have to agree with msdev, it would be nice to have precedence clarified. 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. #include <stdlib.h> #include <stdio.h> #include <string.h> #include <libcelt/celt.h> int gBitRate=128000; int gFrameSize=256; int gSampleRate=44100; int gNrChannels=1; int main(int argc, char* argv[]) { const char* inputfilename="..\\input_mono.snd"; const char* encodedfilename="..\\encoded_mono.celt"; const char* outputfilename="..\\output_mono.snd"; FILE* encodedfile=0; FILE* inputfile=fopen(inputfilename,"rb"); if(!inputfile) { printf("ERROR opening %s for reading\n",inputfilename); return -1; } encodedfile=fopen(encodedfilename,"wb"); if(!encodedfile) { printf("ERROR opening %s for writing\n",encodedfilename); return -1; } FILE* outputfile=fopen(outputfilename,"wb"); if(!outputfile) { printf("ERROR opening %s for writing\n",outputfilename); return -1; } int bytes_per_packet = ((gBitRate*gFrameSize/gSampleRate+4)/8)*gNrChannels; int error=0; celt_int16* pcmbuffer=(celt_int16*)malloc(sizeof(celt_int16)*gFrameSize*gNrChannels); unsigned char* encodedbuffer=(unsigned char*)malloc(bytes_per_packet); CELTMode* mode=celt_mode_create(gSampleRate,gFrameSize,&error); if(mode==NULL || error!=CELT_OK) { printf("ERROR: celt_mode_create %s\n",celt_strerror(error)); return -1; } int offset=0; int res=0; CELTEncoder* encoder=celt_encoder_create(mode,gNrChannels,&error); if(encoder==NULL || error!=CELT_OK) { printf("ERROR: celt_encoder_create %s\n",celt_strerror(error)); return -1; } while((res=fread(pcmbuffer,sizeof(celt_int16)*gFrameSize*gNrChannels,1,inputfile))==1) { int ret=celt_encode(encoder,pcmbuffer,NULL,encodedbuffer,bytes_per_packet); if(ret<0) { printf("ERROR: celt_encode %s\n",celt_strerror(ret)); return -1; } else if(ret!=bytes_per_packet) { printf("ERROR: celt_encode got %d bytes, expected %d\n",ret, bytes_per_packet); return -1; } else { if(fwrite(encodedbuffer,bytes_per_packet,sizeof(unsigned char),encodedfile)!=1) { printf("ERROR: failed writing bytes to %s\n",encodedfilename); return -1; } else { printf("writing offset: %d, size %d\n",offset,bytes_per_packet); offset+=bytes_per_packet; } } } fclose(inputfile); fclose(encodedfile); celt_encoder_destroy(encoder); celt_mode_destroy(mode); CELTMode* mode2=celt_mode_create(gSampleRate,gFrameSize,&error); if(mode2==NULL || error!=CELT_OK) { printf("ERROR: celt_mode_create 2 %s\n",celt_strerror(error)); return -1; } encodedfile=fopen(encodedfilename,"rb"); if(!encodedfile) { printf("ERROR opening %s for reading\n",encodedfilename); return -1; } CELTDecoder* decoder=celt_decoder_create(mode2,gNrChannels,&error); if(decoder==NULL || error!=CELT_OK) { printf("ERROR: celt_decoder_create %s\n",celt_strerror(error)); return -1; } fseek(encodedfile,0,2); int filesize=ftell(encodedfile); fseek(encodedfile,0,0); offset=0; while((res=fread(encodedbuffer,bytes_per_packet,1,encodedfile))==1) { printf("reading offset: %d, size %d, %.2f\n",offset,bytes_per_packet,((float)offset/(float)filesize)*100.0f); offset+=bytes_per_packet; int ret=celt_decode(decoder,encodedbuffer,bytes_per_packet,pcmbuffer); if(ret!=CELT_OK) { printf("ERROR: celt_decode %s\n",celt_strerror(ret)); return -1; } else { fwrite(pcmbuffer,sizeof(celt_int16)*gFrameSize*gNrChannels,1,outputfile); } } fclose(outputfile); fclose(encodedfile); celt_decoder_destroy(decoder); celt_mode_destroy(mode2); free(pcmbuffer); free(encodedbuffer); } -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.xiph.org/pipermail/opus/attachments/20100303/f7cf1bc1/attachment-0002.htm
FWIW, I've been using CELT with visual C++ 2005 and have experienced no warnings or other problems at all. Of course I built the vcproj myself back when the GIT didn't have one, so perhaps there is something about it or VC 2008 that isn't compiling the code correctly. BTW I do disable C4554, C4244, C4305 and C4100 just to cut down on the clutter. John Ridges celt-dev-request at xiph.org wrote:> > ------------------------------ > > Message: 6 > Date: Wed, 3 Mar 2010 11:38:39 -0800 > From: Torgeir Hagland <torg at gaikai.com> > Subject: [CELT-dev] uint decode error on visual studio... > To: celt-dev at xiph.org > Message-ID: > <90a91871003031138k6ba442ffm374469711d9a98be at mail.gmail.com> > Content-Type: text/plain; charset="iso-8859-1" > > 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. > > 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 "'operator' : check operator precedence > for possible error; use parentheses to clarify precedence", especially where > the EC_CODE_* macros are used. I would have to agree with msdev, it would be > nice to have precedence clarified. > > 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. > > >
In general, that error message means a corrupted packet. I *very rare* cases, it could be a bug in CELT or a compile problem, but I haven't encountered such case for more than a year now. Jean-Marc On 2010-03-03 14:38, Torgeir Hagland wrote:> 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. > > 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 "'operator' : check operator > precedence for possible error; use parentheses to clarify precedence", > especially where the EC_CODE_* macros are used. I would have to agree > with msdev, it would be nice to have precedence clarified. > > 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. > > > #include <stdlib.h> > #include <stdio.h> > #include <string.h> > > #include <libcelt/celt.h> > > int gBitRate=128000; > int gFrameSize=256; > int gSampleRate=44100; > int gNrChannels=1; > > int main(int argc, char* argv[]) > { > const char* inputfilename="..\\input_mono.snd"; > const char* encodedfilename="..\\encoded_mono.celt"; > const char* outputfilename="..\\output_mono.snd"; > > FILE* encodedfile=0; > > FILE* inputfile=fopen(inputfilename,"rb"); > if(!inputfile) > { > printf("ERROR opening %s for reading\n",inputfilename); > return -1; > } > > encodedfile=fopen(encodedfilename,"wb"); > if(!encodedfile) > { > printf("ERROR opening %s for writing\n",encodedfilename); > return -1; > } > > FILE* outputfile=fopen(outputfilename,"wb"); > if(!outputfile) > { > printf("ERROR opening %s for writing\n",outputfilename); > return -1; > } > > int bytes_per_packet = ((gBitRate*gFrameSize/gSampleRate+4)/8)*gNrChannels; > > int error=0; > celt_int16* > pcmbuffer=(celt_int16*)malloc(sizeof(celt_int16)*gFrameSize*gNrChannels); > unsigned char* encodedbuffer=(unsigned char*)malloc(bytes_per_packet); > CELTMode* mode=celt_mode_create(gSampleRate,gFrameSize,&error); > if(mode==NULL || error!=CELT_OK) > { > printf("ERROR: celt_mode_create %s\n",celt_strerror(error)); > return -1; > } > int offset=0; > int res=0; > > CELTEncoder* encoder=celt_encoder_create(mode,gNrChannels,&error); > if(encoder==NULL || error!=CELT_OK) > { > printf("ERROR: celt_encoder_create %s\n",celt_strerror(error)); > return -1; > } > > while((res=fread(pcmbuffer,sizeof(celt_int16)*gFrameSize*gNrChannels,1,inputfile))==1) > { > int ret=celt_encode(encoder,pcmbuffer,NULL,encodedbuffer,bytes_per_packet); > if(ret<0) > { > printf("ERROR: celt_encode %s\n",celt_strerror(ret)); > return -1; > } > else if(ret!=bytes_per_packet) > { > printf("ERROR: celt_encode got %d bytes, expected %d\n",ret, > bytes_per_packet); > return -1; > } > else > { > if(fwrite(encodedbuffer,bytes_per_packet,sizeof(unsigned > char),encodedfile)!=1) > { > printf("ERROR: failed writing bytes to %s\n",encodedfilename); > return -1; > } > else > { > printf("writing offset: %d, size %d\n",offset,bytes_per_packet); > offset+=bytes_per_packet; > } > } > } > fclose(inputfile); > fclose(encodedfile); > > celt_encoder_destroy(encoder); > celt_mode_destroy(mode); > > CELTMode* mode2=celt_mode_create(gSampleRate,gFrameSize,&error); > if(mode2==NULL || error!=CELT_OK) > { > printf("ERROR: celt_mode_create 2 %s\n",celt_strerror(error)); > return -1; > } > > encodedfile=fopen(encodedfilename,"rb"); > if(!encodedfile) > { > printf("ERROR opening %s for reading\n",encodedfilename); > return -1; > } > > CELTDecoder* decoder=celt_decoder_create(mode2,gNrChannels,&error); > if(decoder==NULL || error!=CELT_OK) > { > printf("ERROR: celt_decoder_create %s\n",celt_strerror(error)); > return -1; > } > > > fseek(encodedfile,0,2); > int filesize=ftell(encodedfile); > fseek(encodedfile,0,0); > offset=0; > while((res=fread(encodedbuffer,bytes_per_packet,1,encodedfile))==1) > { > printf("reading offset: %d, size %d, > %.2f\n",offset,bytes_per_packet,((float)offset/(float)filesize)*100.0f); > offset+=bytes_per_packet; > > int ret=celt_decode(decoder,encodedbuffer,bytes_per_packet,pcmbuffer); > if(ret!=CELT_OK) > { > printf("ERROR: celt_decode %s\n",celt_strerror(ret)); > return -1; > } > else > { > fwrite(pcmbuffer,sizeof(celt_int16)*gFrameSize*gNrChannels,1,outputfile); > } > } > > fclose(outputfile); > fclose(encodedfile); > > celt_decoder_destroy(decoder); > > celt_mode_destroy(mode2); > > free(pcmbuffer); > free(encodedbuffer); > } > > > > _______________________________________________ > celt-dev mailing list > celt-dev at xiph.org > http://lists.xiph.org/mailman/listinfo/celt-dev