Thanks for the advice. With complexity=1, bit rates 5950,8000 and 15000 (CBR only), I'm still getting 30-50 seconds encoding time for a 10-second file. To anyone who has made this work in ARMv4, or knows how to, can I get some advice on the settings? FIXED_POINT is already defined in all relevant files. My source code is patterned after sampleenc and I haven't tried using Ogg.. my source code is attached below in case anyone's interested. I wonder what I'm doing wrong.. Appreciate any help, thanks a lot.
<br><br>Mon<br><br>int PCMToSpx (BSTR FileOpen, BSTR FileSave, bool VAD, short BitRateChoice)<br>{<br> __int8 Speex [6];<br> __int16 SamplingRate = 8000;<br> __int8 BitsPerSampleX8 = 2 /* ie 2*8=16-bit */, NumBytes /*aka nBytes or nbBytes */;
<br><br> FILE *fin, *fout;<br> void *state;<br> int FrameSize, NumFrames = 0;<br> int BitRate, temp; <br> __int16 in [MaxFrameSize];<br> __int8 cbits [MaxFrameBytes];<br> SpeexBits bits;<br><br>// ********************************** Program Statements **********************************//
<br><br> Speex[0] = 'S';<br> Speex[1] = 'p';<br> Speex[2] = 'e';<br> Speex[3] = 'e';<br> Speex[4] = 'x';<br><br> state = speex_encoder_init (&speex_nb_mode);<br><br> fout = _wfopen ((LPCTSTR)FileSave, L"wb");
<br> if (fout == NULL)<br> {<br> return 1;<br> }<br><br> fin = _wfopen ((LPCTSTR) FileOpen, L"rb");<br> if (fin == NULL)<br> {<br> return 2;<br> }<br><br> switch (BitRateChoice)
<br> {<br> case '1':<br> BitRate = 6000;<br> break;<br> case '2':<br> BitRate = 8000;<br> break;<br> case '3':<br> BitRate = 15000;<br> break;
<br> default:<br> BitRate = 8000;<br> break;<br> }<br> speex_encoder_ctl (state, SPEEX_SET_BITRATE, &BitRate);<br><br> if (VAD)<br> temp = 1;<br> else<br> temp = 0;
<br><br> speex_encoder_ctl (state, SPEEX_SET_VAD, &temp);<br><br> speex_encoder_ctl (state, SPEEX_GET_FRAME_SIZE, &FrameSize);<br><br> temp = 1;<br> speex_encoder_ctl (state, SPEEX_SET_COMPLEXITY, &temp);
<br> temp = 0; // Just making sure VBR is off. Probably unnecessary.<br> speex_encoder_ctl (state, SPEEX_SET_VBR, &temp); <br> temp = 8000;<br> speex_encoder_ctl (state, SPEEX_SET_SAMPLING_RATE, &temp);
<br><br> fwrite (Speex, 1, 5, fout);<br> fwrite (&SamplingRate, 2, 1, fout);<br> fwrite (&BitsPerSampleX8, 1, 1, fout);<br><br> fseek(fout,8, SEEK_SET);<br> fseek(fin,0, SEEK_SET);<br><br> speex_bits_init (&bits);
<br><br> while (1)<br> {<br> if (feof(fin))<br> {<br> break;<br> }<br> fread (in, sizeof (short), FrameSize, fin); //place 160 shorts in "in" (1 frame)<br><br> speex_bits_reset (&bits);
<br> speex_encode_int (state, in, &bits);<br> NumBytes = speex_bits_write (&bits, cbits, 300);<br> <br> if (NumFrames == 0)<br> fwrite (&NumBytes, 1, 1, fout);<br><br> fwrite (cbits, 1, NumBytes, fout);
<br> <br> NumFrames++; /**/<br> }<br><br> speex_encoder_destroy (state);<br> speex_bits_destroy (&bits);<br> fclose (fin);<br> fclose (fout);<br><br> return NumFrames;<br>}<br><br><div><span class="gmail_quote">
On 12/12/05, <b class="gmail_sendername">Jean-Marc Valin</b> <<a href="mailto:Jean-Marc.Valin@usherbrooke.ca">Jean-Marc.Valin@usherbrooke.ca</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
You should definitely be able to do narrowband in realtime. For<br>wideband, it depends on the mode and complexity setting. Try setting the<br>complexity to one:<br><br>int tmp = 1;<br>speex_encoder_ctl(encoder, SPEEX_SET_COMPLEXITY, &tmp);
<br><br> Jean-Marc<br><br>Le lundi 12 décembre 2005 à 15:33 +0800, Mo Win a écrit :<br>> Hi. I tried encoding a raw PCM file to Speex in my Windows Mobile<br>> device and it took about 45 seconds to encode a 10-second file. I had
<br>> FIXED_POINT defined and used speex_encode_int. The device has an ARMV4<br>> 400 MHz processor. Question: Is this behavior expected or is it<br>> possible to encode speech to speex real-time such that I can record
<br>> speech directly as speex in my device? What, if any, can be done to<br>> speed up encoding time? As expected, decoding was no problem. I was<br>> using version 1.1.10.<br>><br>> Thank you for all the help,
<br>> Monica<br>> _______________________________________________<br>> Speex-dev mailing list<br>> <a href="mailto:Speex-dev@xiph.org">Speex-dev@xiph.org</a><br>> <a href="http://lists.xiph.org/mailman/listinfo/speex-dev">
http://lists.xiph.org/mailman/listinfo/speex-dev</a><br></blockquote></div><br>