<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.6000.16481" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY style="MARGIN: 4px 4px 1px; FONT: 10pt Tahoma" bgColor=#ffffff>
<DIV><FONT face=Arial>Mike,</FONT></DIV>
<DIV><FONT face=Arial></FONT> </DIV>
<DIV><FONT face=Arial>I did this a year ago on C55 (svn build 11463), and have
attached my patches to nb_celp.c, modes.c, and the project file, to remove all
modes but 8kbps. I have also attached a debug version of stack_alloc.h,
which tracks the maximum depth of the scratch stack, so that you can tweak the
sizes in config.h. You just have to declare the variable and add this init
before the call to speex_encoder_init, and go back and look at the variable
after you run some data through.</FONT></DIV>
<DIV><FONT face=Arial></FONT> </DIV>
<DIV><FONT face=Arial>#ifdef STACKDBG<BR> spxGlobalScratchFree
= spxGlobalScratchPtr;<BR>#endif<BR></FONT></DIV>
<DIV><FONT face=Arial>If you think that the C5416 build is broken, then (as
Jean-Marc said) tell us what version you are using. There is a C54x
project in the speex source tree that runs directly in the Code Composer
simulator. If that fails in the latest code, let me know and I will work
on tracking it down. As Jean-Marc indicated, this build does break from
time to time because of 16/32-bit conversion problems. I have also had
problems with 16/32 bit mismatch in function parameters leading to really
bizarre behavior.</FONT></DIV>
<DIV><FONT face=Arial></FONT> </DIV>
<DIV><FONT face=Arial>You should be able to use the simulator build as a
reference to isolate problems between your encoder and decoder (as long as your
audio samples are small, the simulator is pretty slow for C54).</FONT></DIV>
<DIV><FONT face=Arial></FONT> </DIV>
<DIV><FONT face=Arial>Good luck.</FONT></DIV>
<DIV><FONT face=Arial></FONT> </DIV>
<DIV><FONT face=Arial>- Jim</DIV></FONT>
<DIV><FONT face=Arial></FONT> </DIV>
<DIV>----- Original Message ----- </DIV>
<BLOCKQUOTE
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV
style="BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: black"><B>From:</B>
<A title=Michael.Jacobson@ultratec.com
href="mailto:Michael.Jacobson@ultratec.com">Michael Jacobson</A> </DIV>
<DIV style="FONT: 10pt arial"><B>To:</B> <A title=speex-dev@xiph.org
href="mailto:speex-dev@xiph.org">speex-dev@xiph.org</A> </DIV>
<DIV style="FONT: 10pt arial"><B>Sent:</B> Monday, July 23, 2007 12:54
PM</DIV>
<DIV style="FONT: 10pt arial"><B>Subject:</B> [Speex-dev] Shoehorning speex is
confusing a newbie</DIV>
<DIV><BR></DIV>
<DIV>This is going to take some explaining and I apologize in advance if any
of this is found in the manual or sample code but I couldn't find it. I
just graduated last may and this is my first experience with vocoders and
dissecting a professional's code.</DIV>
<DIV> </DIV>
<DIV>I work for a company that is currently using a G729A vocoder from a 3rd
party software company and is looking into speex so they no longer have to pay
royalties. The product we are trying to force speex into is based
on a TI C5416 DSP that did narrowband 8-bit, 8kbs. The product was
fairly full as it is so some modifications had to be made in order to fit
speex into the project just to allow it to link. The modifications are
based off assumptions that I made when looking over the code so I may have
been absolutely wrong.</DIV>
<DIV> </DIV>
<DIV>The main assumption was about the exc tables. In looking through
modes.c it appeared that only one table was required for 8kbs so I commented
out the portions of the code that referenced the other tables and modified
"static const SpeexNBMode nb_mode" structure so that the pointers to the other
structures that referenced the tables were NULL. We did not have enough
data memory to store all the tables. I thought this would work with my
initialization but when I stepped through the code in nb_celp for encode it
would put it in mode 6 (instead of mode 3), which I believe is 18.2kbs (table
8.2). My set up code is:</DIV>
<DIV> </DIV>
<DIV> st =
speex_encoder_init(&speex_nb_mode);<BR> speex_bits_set_bit_buffer(&bits,
&G729_tx, COMPRESS_LENGTH);</DIV>
<DIV> tmp=TESTENC_QUALITY;
//=4<BR> speex_encoder_ctl(st, SPEEX_SET_QUALITY,
&tmp);<BR> speex_encode_int(st, (spx_int16_t *)samples_in,
&bits);</DIV>
<DIV> </DIV>
<DIV>which I thought would put it in 8kbs narrowband. I tried to use
SPEEX_SET_MODE in there too but it just got overwritten by the set mode in the
encode function. So I thought I'd try to force it into mode 3 and see
what happens, and I got A result, but when I try to decode it my decode stage
gets stuck in an infinite loop:</DIV>
<DIV> </DIV>
<DIV>while
(st->voc_offset<st->subframeSize)<BR>
{<BR>
if
(st->voc_offset>=0)<BR>
exc[st->voc_offset]=sqrt(1.0*ol_pitch);<BR>
st->voc_offset+=ol_pitch;<BR>
}</DIV>
<DIV> </DIV>
<DIV>because both voc_offset and ol_pitch is = 0 because this code is never
entered:</DIV>
<DIV> </DIV>
<DIV>if (SUBMODE(lbr_pitch)!=-1)<BR>
{<BR> ol_pitch =
st->min_pitch+speex_bits_unpack_unsigned(bits, 7);<BR> } </DIV>
<DIV> </DIV>
<DIV>This is how I set up the decoder:</DIV>
<DIV> </DIV>
<DIV> dec =
speex_decoder_init(&speex_nb_mode);<BR> speex_bits_set_bit_buffer(&bits,
&Speex_enc_buffer[0 + COMPRESS_LENGTH*Speex_player_frame],
COMPRESS_LENGTH);<BR> tmp=0;<BR> speex_decoder_ctl(dec,
SPEEX_SET_ENH, &tmp);</DIV>
<DIV> speex_decode_int(dec, &bits, (spx_int16_t
*)samples_out); </DIV>
<DIV> </DIV>
<DIV>There are some things I am sure will be asked. Yes I set flags for
the TI_54X part, disable wideband, manual allocation, and fixed point in
a config file and defined the #define value needed to include that config
file. I do have a heap for the setup of the state structure for encode
and decode and yes I made sure it was big enough to allocate enough to
both. Yes I destroy the structures after I am done en/decoding
them. If there is anything you need to help you help me then I am
defiantly willing to share. I am thoroughly confused and could use some
help.</DIV>
<DIV> </DIV>
<DIV>Thanks.</DIV>
<DIV> </DIV>
<DIV>-Mike Jacobson</DIV>
<DIV><A
href="mailto:michael.jacobson@ultratec.com">michael.jacobson@ultratec.com</A></DIV>
<P>
<HR>
<P></P>_______________________________________________<BR>Speex-dev mailing
list<BR>Speex-dev@xiph.org<BR>http://lists.xiph.org/mailman/listinfo/speex-dev<BR></BLOCKQUOTE></BODY></HTML>