Hermann Weber
2011-Dec-23 18:03 UTC
[Speex-dev] Decoding only a certain frame results in different values than when decoding the entire file
I found out something: The more frames I decode before the frame that I actually want to decode, the better the quality becomes. For example when I basically want to decode frame #100, I read frame #80 to #100, and then frame 100 has the quality that I need. Why? Is there any information on this behaviour? Thank you. Hermann Am 23.12.2011 18:37, schrieb Hermann Weber:> 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 >> > _______________________________________________ > Speex-dev mailing list > Speex-dev at xiph.org > http://lists.xiph.org/mailman/listinfo/speex-dev >
Steve Checkoway
2011-Dec-23 18:17 UTC
[Speex-dev] Decoding only a certain frame results in different values than when decoding the entire file
On Dec 23, 2011, at 10:03 , Hermann Weber wrote:> I found out something: > > The more frames I decode before the frame that I actually want to > decode, the better the quality becomes. > For example when I basically want to decode frame #100, I read frame > #80 > to #100, and then frame 100 has the quality that I need. > > Why? Is there any information on this behaviour?Speex is a stateful encoder. As it encodes the audio, the state changes. As it decodes, the state changes. You're trying to start somewhere in the middle with the initial state rather than with the state it would have if you started from the beginning and decoded it all. As you've noticed, it can recover from lost frames over time. This is just repeating what Lakhdar Bourokba already said though. As for your question about the header, it really depends on how you're saving the encoded file. -- Steve Checkoway -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 4745 bytes Desc: not available Url : http://lists.xiph.org/pipermail/speex-dev/attachments/20111223/3d2a24e7/attachment.bin
Hermann Weber
2011-Dec-23 18:54 UTC
[Speex-dev] Decoding only a certain frame results in different values than when decoding the entire file
And how many frames does Speex need to "recover"? Or is that not predictable? Greetings, Hermann Am 23.12.2011 19:17, schrieb Steve Checkoway:> > On Dec 23, 2011, at 10:03 , Hermann Weber wrote: > >> I found out something: >> >> The more frames I decode before the frame that I actually want to >> decode, the better the quality becomes. >> For example when I basically want to decode frame #100, I read frame #80 >> to #100, and then frame 100 has the quality that I need. >> >> Why? Is there any information on this behaviour? > > > Speex is a stateful encoder. As it encodes the audio, the state > changes. As it decodes, the state changes. You're trying to start > somewhere in the middle with the initial state rather than with the > state it would have if you started from the beginning and decoded it > all. As you've noticed, it can recover from lost frames over time. > > This is just repeating what Lakhdar Bourokba already said though. > > As for your question about the header, it really depends on how you're > saving the encoded file. > > > > _______________________________________________ > Speex-dev mailing list > Speex-dev at xiph.org > http://lists.xiph.org/mailman/listinfo/speex-dev-------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.xiph.org/pipermail/speex-dev/attachments/20111223/74528cb1/attachment-0001.htm
Maybe Matching Threads
- Decoding only a certain frame results in different values than when decoding the entire file
- Decoding only a certain frame results in different values than when decoding the entire file
- Decoding only a certain frame results in different values than when decoding the entire file
- Decoding only a certain frame results in different values than when decoding the entire file
- Decoding only a certain frame results in different values than when decoding the entire file