[Speex-dev] Decoding only a certain frame results in different values than when decoding the entire file
Hermann Weber
hermie.weber at gmx.de
Fri Dec 23 09:37:41 PST 2011
It would be nice to get more input.
I am really lost because I am not sure what is going on here, and there
are no sources to investigate on.
Thank you.
Hermann
Am 22.12.2011 20:55, schrieb Hermann Weber:
> To make it complete, here is the code that I am using to encode a large
> file:
>
> int __stdcall SpxEncode(unsigned char* inBuf, unsigned char* outBuf,
> unsigned int inlen)
> {
> //char *testFile;
> //FILE *ftest;
> //testFile = "test";
> //ftest = fopen(testFile, "wb");
> //fwrite(inBuf,1,inlen,ftest);
>
> //take every 320 bytes
> //copy every short to float array, and make sure to put null in
> unused area
>
> float input[MAX_FRAME_SIZE];
> char cbits[MAX_FRAME_BYTES];
> unsigned int inBufpos = 0, j, outBufpos = 0;
> short *sinBuf;
>
> sinBuf = (short*) inBuf;
>
> do
> {
> j = 0;
> do
> {
> //copy to float array
> input[j] = sinBuf[inBufpos];
> inBufpos++; j++;
> }
> while ((inBufpos % 160 != 0)&& (inBufpos != (inlen/2)));
>
> //fill the rest with null
> if (inBufpos == (inlen/2))
> for (j=(inBufpos%160); j<160; j++) input[j] = 0;
>
> speex_bits_reset(&bits);
> speex_encode(encstate, input,&bits);
>
> /*Copy the bits to an array of char that can be written*/
> speex_bits_write(&bits, cbits, MAX_FRAME_BYTES);
> for (j=0; j<62; j++)
> {
> outBuf[outBufpos] = cbits[j];
> outBufpos++;
> }
>
> }
> while (inBufpos != (inlen/2));
>
> //fwrite(outBuf, 1, outBufpos, ftest);
> //fclose(ftest);
> return 42;
> }
> _______________________________________________
> Speex-dev mailing list
> Speex-dev at xiph.org
> http://lists.xiph.org/mailman/listinfo/speex-dev
>
More information about the Speex-dev
mailing list