<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
Hi Lakhdar,<br>
<br>
yes, sorry, it was a typo. I am decoding bytes 63 to 124, not 63 to
125.<br>
Yes, Case 1 is good.<br>
Yes, what you said is correct: As soon as I reset the memory state,
the output is not as expected anymore.<br>
In Case 1 (which is good), I don't reset the memory state after
decoding 1 frame.<br>
<br>
In Case 2 I am not skipping the frame by skipping some bytes.<br>
Instead I only read the bytes 63 to 124 from the encoded file and
decode it.<br>
<br>
Personally, I do not care if the results are binarily the same, but
for some reason, the output in Case 2 is so that I can not work with
it.<br>
I can play it, but processing it further is not possible because the
values are different than what I expected. <br>
<br>
In the encoded file (when viewed with WinHex) I see something like a
header. Is it really a header? Does it affect the decoding somehow?
I am asking because when I decode bytes 63 to 124 only, I skip this
header of course, and it might be an explanation why the results are
different.<br>
<br>
In which way does the previous frame affect the next frame?<br>
<br>
Thank you so much for the help.<br>
<br>
Greetings,<br>
Hermann<br>
<br>
Am 22.12.2011 19:53, schrieb Lakhdar Bourokba:
<blockquote
cite="mid:CAN7bMhx0WOp99gYm=0n1Rk6FY+mSJtznfxHRr5X9qXvO96=o5A@mail.gmail.com"
type="cite">HI Hermann,<br>
I am not sure I understand exactly what you are trying to do.<br>
Let me try to describe what I understood (I assumed your byte
array starts @ 1 and not 0 as it is supposed to be in C) : <br>
<br>
##############################<br>
CASE 1: (output is good)<br>
##############################<br>
- INITILIAZE_DECODER (reset state memory)<br>
- READ bytes 1 to 124 <br>
- SpxDecode(DinBuf, DoutBuf, unsigned int Dinlen)<br>
- DECODE bytes 1 to 62<br>
---OUTPUT Frame 1----<br>
-293<br>
-8234<br>
2134<br>
17<br>
- DECODE bytes 63 to 124 <br>
---OUTPUT Frame 2----<br>
-9323<br>
-732<br>
189<br>
2329<br>
<br>
##############################<br>
CASE 2: (output is not as expected)<br>
##############################<br>
- INITILIAZE_DECODER (reset state memory)<br>
- SKIP bytes 1 to 62 (This is where I get confused, do you
actually skip FRAME 1 ?)<br>
- READ bytes 63 to 124 <br>
- DECODE bytes 63 to 124 (and not 125 as you mentioned, I think
it's a typo but I just want to make sure)<br>
---OUTPUT Frame 2----<br>
732<br>
9273<br>
-799<br>
-723<br>
<br>
<br>
<br>
If what is described above is what you are doing, you can not
expect both outputs to be identical.<br>
The reason is because the decoder has a different state prior to
processing FRAME 2.<br>
- In case 2, the decoder has its state reset to the default
state.<br>
- In case 1, the decoder memory state has been modified by the
processing of FRAME 1.<br>
<br>
If I got it wrong, please provide more details.<br>
L.<br>
<br>
<br>
<div class="gmail_quote">On Wed, Dec 21, 2011 at 6:03 PM, Hermann
Weber <span dir="ltr"><<a moz-do-not-send="true"
href="mailto:hermie.weber@gmx.de" target="_blank">hermie.weber@gmx.de</a>></span>
wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">
Sorry, it seems I have only replied to Lakhdar, not to the
newsgroup.<br>
Below is my reply to Lakhdar, and I would like to make it more
clear<br>
now, using some pseudo values for simplicity:<br>
<br>
I read bytes 1 to 124 from my encoded spx file.<br>
I decode themt and get the values:<br>
---Frame 1----<br>
-293<br>
-8234<br>
2134<br>
17<br>
---Frame 2----<br>
-9323<br>
-732<br>
189<br>
2329<br>
<br>
Both frames are just perfect as I need them.<br>
<br>
But now when I read bytes 63 to 125 from my encoded spx and
decode it, I<br>
get the values<br>
732<br>
9273<br>
-799<br>
-723<br>
<br>
This is weird because I expected to get the encoded values<br>
-9323<br>
-732<br>
189<br>
2329<br>
<div><br>
I hope I could explain it well.<br>
</div>
Am I missing something here?<br>
<div>
<div><br>
Thank you very much.<br>
Hermann<br>
<br>
<br>
<br>
Hi Lakhdar,<br>
<br>
I am not sure if I do anything wrong with the dec state
memory.<br>
Could you perhaps take a look at what I am (perhaps
wrongly) doing?<br>
<br>
int __stdcall SpxDecode(unsigned char* DinBuf, float*
DoutBuf, unsigned<br>
int Dinlen)<br>
{<br>
<br>
//char *testFile;<br>
//FILE *ftest;<br>
//testFile = "test2";<br>
//ftest = fopen(testFile, "wb");<br>
//fwrite(inBuf,1,inlen,ftest);<br>
//fwrite(outBuf, 1, outBufpos, ftest);<br>
//fclose(ftest);<br>
<br>
//take every 62 bytes<br>
//decode, then write to outbuf<br>
<br>
char cbits[MAX_FRAME_BYTES];<br>
float output[MAX_FRAME_SIZE];<br>
short out[MAX_FRAME_SIZE];<br>
unsigned int i,j;<br>
<br>
unsigned char* tout; tout = (unsigned char*)&out;<br>
<br>
for (i=0; i<(Dinlen/62); i++)<br>
{<br>
for (j=0;j<62;j++) cbits[j] =
DinBuf[(i*62)+j];<br>
<br>
speex_bits_read_from(&bits, cbits, 62);<br>
speex_decode(decstate, &bits, output);<br>
<br>
for (j=0;j<160;j++) DoutBuf[j+(i*160)] =
output[j];<br>
}<br>
<br>
return 43;<br>
}<br>
<br>
Btw, just if you wondering what I am doing... I am feeding
(62 *<br>
NumberOfFramesThatIWantToRead) bytes from VB6 and return
it as a float<br>
array.<br>
<br>
Greetings,<br>
Hermann<br>
<br>
Am 21.12.2011 15:26, schrieb Lakhdar Bourokba:<br>
> Hi Hermann,<br>
> Could it be your decoder state memory that is not
longer sync ?<br>
> When a decoder processes a frame, it uses that frame
and its memory<br>
state (affected by the previous frames) to generate the
output samples.<br>
If you skip the previous frames, the decoder state memory
will not be<br>
the same (as when you do full decoding) which causes the
output to be<br>
different.<br>
> I hope this helps.<br>
> L.<br>
><br>
><br>
> On Wed, Dec 21, 2011 at 5:17 AM, Hermann Weber <<a
moz-do-not-send="true" href="mailto:hermie.weber@gmx.de"
target="_blank">hermie.weber@gmx.de</a>><br>
wrote:<br>
><br>
> Hello!<br>
><br>
> I am still using version 1.0.4.<br>
><br>
> When I have encoded a larger file and then only
want to decode<br>
only one<br>
> frame from it (for example the 2nd frame), is
there anything special<br>
> that I have to keep in mind?<br>
><br>
> I thought that I could simply read the bytes
from the encoded<br>
file for<br>
> example from the start position of the 2nd frame
and then decode<br>
it. I<br>
> did that, and I can play it play, but the values
in the decoded 2nd<br>
> frame are different than they are when I decode
the entire file<br>
and then<br>
> look at the values for the 2nd frame.<br>
> I hope I could explain it well.<br>
><br>
> I noticed that there is a pattern in the
beginning of the encoded<br>
file,<br>
> and I am not sure if I have to take it into
account somehow.<br>
><br>
> It would be nice if someone could tell me if
something comes to<br>
his/her<br>
> mind that I might be doing wrong.<br>
><br>
> Thank you very much.<br>
><br>
> Hermann<br>
> _______________________________________________<br>
> Speex-dev mailing list<br>
> <a moz-do-not-send="true"
href="mailto:Speex-dev@xiph.org" target="_blank">Speex-dev@xiph.org</a><br>
> <a moz-do-not-send="true"
href="http://lists.xiph.org/mailman/listinfo/speex-dev"
target="_blank">http://lists.xiph.org/mailman/listinfo/speex-dev</a><br>
><br>
><br>
<br>
<br>
Hello!<br>
<br>
I am still using version 1.0.4.<br>
<br>
When I have encoded a larger file and then only want to
decode only one<br>
frame from it (for example the 2nd frame), is there
anything special<br>
that I have to keep in mind?<br>
<br>
I thought that I could simply read the bytes from the
encoded file for<br>
example from the start position of the 2nd frame and then
decode it. I<br>
did that, and I can play it play, but the values in the
decoded 2nd<br>
frame are different than they are when I decode the entire
file and then<br>
look at the values for the 2nd frame.<br>
I hope I could explain it well.<br>
<br>
I noticed that there is a pattern in the beginning of the
encoded file,<br>
and I am not sure if I have to take it into account
somehow.<br>
<br>
It would be nice if someone could tell me if something
comes to his/her<br>
mind that I might be doing wrong.<br>
<br>
Thank you very much.<br>
<br>
Hermann<br>
_______________________________________________<br>
Speex-dev mailing list<br>
<a moz-do-not-send="true" href="mailto:Speex-dev@xiph.org"
target="_blank">Speex-dev@xiph.org</a><br>
<a moz-do-not-send="true"
href="http://lists.xiph.org/mailman/listinfo/speex-dev"
target="_blank">http://lists.xiph.org/mailman/listinfo/speex-dev</a><br>
</div>
</div>
</blockquote>
</div>
<br>
</blockquote>
<br>
</body>
</html>