<!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.16525" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY style="MARGIN: 4px 4px 1px; FONT: 10pt Tahoma" bgColor=#ffffff>
<DIV><FONT face=Arial>
<DIV><FONT face=Arial>Michael,</FONT></DIV>
<DIV><FONT face=Arial></FONT> </DIV>
<DIV><FONT face=Arial>Before you suffer any further, do you need the highpass
function? This is a DC block for the input audio. In my application
there is a DC block in front of Speex for other reasons, so I disabled this
function.</FONT></DIV>
<DIV><FONT face=Arial></FONT> </DIV>
<DIV><FONT face=Arial>This worked before your code squeeze, right? There
are many possibilities:</FONT></DIV>
<DIV><FONT face=Arial></FONT> </DIV>
<DIV><FONT face=Arial>1. You are overrunning the C stack, so the local
variable declarations are clobbering something.</FONT></DIV>
<DIV><FONT face=Arial>2. There is a parameter size type mismatch (16-32
bit) between the calling code and the function code, so the mem pointer is read
from the wrong place on the stack.</FONT></DIV>
<DIV><FONT face=Arial>
<DIV><FONT face=Arial>2a. The len value is bad.</FONT></DIV>
<DIV><FONT face=Arial>2b. The FiltID value is bad. There is code to
limit the value to 4, but a negative value might blow up.</FONT></DIV>3.
Some data structure is not aligned on the required boundary. I have been
bitten by this on the C64x with mixed assembly and C files, but I do not
recall if the C54 requires any structures to start on 32-bit
boundaries.</FONT></DIV>
<DIV><FONT face=Arial>4. You have a memory segment that is crossing a 64K
boundary, and an address wrap is occurring.</FONT></DIV>
<DIV><FONT face=Arial>5. The problem is somewhere else entirely, and the
highpass function has been corrupted by a bad memory write.</FONT></DIV>
<DIV><FONT face=Arial>6. There is some kind of link problem, and the
highpass function is not where the call is going.</FONT></DIV>
<DIV><FONT face=Arial></FONT> </DIV>
<DIV><FONT face=Arial>I would assembly step through the code, looking at how the
parameters are stored in registers and onto the stack, and then follow what
happens after the branch. You should learn more by seeing where things run
off at the the assembly level, rather than C. The more I think about it,
the more it sounds like the highpass() code has been corrupted or is
misaligned. You can save the disassembled highpass() code from the
emulator, and load the same file into the simulator, and see if the disassembly
looks the same.</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</FONT></DIV></FONT></DIV>
<BLOCKQUOTE
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV style="FONT: 10pt arial">----- Original Message ----- </DIV>
<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> Wednesday, August 29, 2007 11:05
AM</DIV>
<DIV style="FONT: 10pt arial"><B>Subject:</B> [Speex-dev] high-pass filter
issues</DIV>
<DIV><FONT face=Arial></FONT><BR></DIV>
<DIV>Hi, I am using 1.2beta2 on a C5416 doing narrowband</DIV>
<DIV><FONT face=Arial></FONT> </DIV>
<DIV><FONT face=Arial></FONT> </DIV>
<DIV>in the decode function I am having a problem with the execution of my
program vectoring off to random interrupts that are not used. I have
tracked down the error to the highpass function called in nb_decode -very
close to the end of the function-context:</DIV>
<DIV><FONT face=Arial></FONT> </DIV>
<DIV>it is called here: ln 1719 for me</DIV>
<DIV> if
(st->highpass_enabled)<BR> highpass(out, out,
st->frameSize,
(st->isWideband?HIGHPASS_WIDEBAND:HIGHPASS_NARROWBAND)|HIGHPASS_OUTPUT,
st->mem_hp);<BR> /*for
(i=0;i<st->frameSize;i++)<BR> printf ("%d\n",
(int)st->frame[i]);*/</DIV>
<DIV><FONT face=Arial></FONT> </DIV>
<DIV>here's the function:</DIV>
<DIV><FONT face=Arial></FONT> </DIV>
<DIV>void highpass(const spx_word16_t *x, spx_word16_t *y, int len, int
filtID, spx_mem_t *mem)<BR>{<BR> int i;<BR>#ifdef
FIXED_POINT<BR> const spx_word16_t Pcoef[5][3] = {{16384, -31313,
14991}, {16384, -31569, 15249}, {16384, -31677, 15328}, {16384, -32313,
15947}, {16384, -22446, 6537}};<BR> const spx_word16_t Zcoef[5][3]
= {{15672, -31344, 15672}, {15802, -31601, 15802}, {15847, -31694, 15847},
{16162, -32322, 16162}, {14418, -28836, 14418}};<BR>#else<BR>
const spx_word16_t Pcoef[5][3] = {{1.00000f, -1.91120f, 0.91498f}, {1.00000f,
-1.92683f, 0.93071f}, {1.00000f, -1.93338f, 0.93553f}, {1.00000f, -1.97226f,
0.97332f}, {1.00000f, -1.37000f, 0.39900f}};<BR> const
spx_word16_t Zcoef[5][3] = {{0.95654f, -1.91309f, 0.95654f}, {0.96446f,
-1.92879f, 0.96446f}, {0.96723f, -1.93445f, 0.96723f}, {0.98645f, -1.97277f,
0.98645f}, {0.88000f, -1.76000f, 0.88000f}};<BR>#endif<BR> const
spx_word16_t *den, *num;<BR> if
(filtID>4)<BR> filtID=4;<BR>
<BR> den = Pcoef[filtID]; num = Zcoef[filtID];<BR>
/*return;*/<BR> for (i=0;i<len;i++)<BR>
{<BR> spx_word16_t
yi;<BR> spx_word32_t vout =
ADD32(MULT16_16(num[0], x[i]),mem[0]);<BR> yi =
EXTRACT16(SATURATE(PSHR32(vout,14),32767));<BR>
mem[0] = ADD32(MAC16_16(mem[1], num[1],x[i]),
SHL32(MULT16_32_Q15(-den[1],vout),1));<BR>
mem[1] = ADD32(MULT16_16(num[2],x[i]),
SHL32(MULT16_32_Q15(-den[2],vout),1));<BR> y[i]
= yi;<BR> }<BR>}</DIV>
<DIV><FONT face=Arial></FONT> </DIV>
<DIV><FONT face=Arial></FONT> </DIV>
<DIV>I can step into the function just fine, but when I run it, even just from
the initial variable declarations to the top of that "for" loop I vector
off. I am thinking this might have something to do with me making the
state parameters static instead of running off a heap. these are the
sizes and parameters I used:</DIV>
<DIV><FONT face=Arial></FONT> </DIV>
<DIV>#ifdef STATIC_INIT<BR> #define ENC_WINBUF_SIZE 40<BR> #define
ENC_EXCBUF_SIZE 306<BR> #define ENC_SWBUF_SIZE 306<BR> #define
ENC_LAGWINDOW_SIZE 11<BR> #define ENC_OLD_LSP_SIZE 10<BR> #define
ENC_OLD_QLSP_SIZE 10<BR> #define ENC_MEM_SP_SIZE 20<BR> #define
ENC_MEM_SW_SIZE 20<BR> #define ENC_SW_WHOLE_SIZE 20<BR> #define
ENC_MEM_EXC_SIZE 20<BR> #define ENC_MEM_EXC2_SIZE 20<BR> #define
ENC_PI_GAIN_SIZE 8<BR> #define ENC_PITCH_SIZE 4</DIV>
<DIV><FONT face=Arial></FONT> </DIV>
<DIV> #define DEC_EXCBUF_SIZE 500<BR> #define DEC_INTERP_QLPC_SIZE
10<BR> #define DEC_OLD_QLSP_SIZE 10<BR> #define DEC_MEM_SP_SIZE
20<BR> #define DEC_PI_GAIN_SIZE 8</DIV>
<DIV><FONT face=Arial></FONT> </DIV>
<DIV> EncState enc_state;<BR> char
enc_stack[NB_ENC_STACK];<BR> spx_word16_t
enc_winbuf[ENC_WINBUF_SIZE];<BR> spx_word16_t
enc_excbuf[ENC_EXCBUF_SIZE];<BR> spx_word16_t
enc_swbuf[ENC_SWBUF_SIZE];<BR> spx_word16_t
enc_lagwindow[ENC_LAGWINDOW_SIZE];<BR> spx_lsp_t
enc_old_lsp[ENC_OLD_LSP_SIZE];<BR> spx_lsp_t enc_old_qlsp[ENC_OLD_QLSP_SIZE];<BR> spx_mem_t enc_mem_sp[ENC_MEM_SP_SIZE];<BR> spx_mem_t enc_mem_sw[ENC_MEM_SW_SIZE];<BR> spx_mem_t enc_mem_sw_whole[ENC_SW_WHOLE_SIZE];<BR> spx_mem_t enc_mem_exc[ENC_MEM_EXC_SIZE];<BR> spx_mem_t enc_memexc2[ENC_MEM_EXC2_SIZE];<BR> spx_word32_t enc_pi_gain[ENC_PI_GAIN_SIZE];<BR> int enc_pitch[ENC_PITCH_SIZE];</DIV>
<DIV><FONT face=Arial></FONT> </DIV>
<DIV> DecState dec_state;<BR> char dec_stack[NB_DEC_STACK];<BR> spx_word16_t dec_excbuf[DEC_EXCBUF_SIZE];<BR> spx_coef_t dec_interp_qlpc[DEC_INTERP_QLPC_SIZE];<BR> spx_lsp_t dec_old_qlsp[DEC_OLD_QLSP_SIZE];<BR> spx_mem_t dec_mem_sp[DEC_MEM_SP_SIZE];<BR> spx_word32_t dec_pi_gain[DEC_PI_GAIN_SIZE];</DIV>
<DIV><FONT face=Arial></FONT> </DIV>
<DIV>#endif </DIV>
<DIV><FONT face=Arial></FONT> </DIV>
<DIV>I noticed that when inside the high pass function that len must be
greater that 160 because I single stepped through it and I got to be greater
than A0 and that I cannot read any of the variables passed as a parameter,
they always show up as FP + some value. any thoughts on what might be
going on? (FIXED_POINT is defined)</DIV>
<DIV><FONT face=Arial></FONT> </DIV>
<DIV>-Mike</DIV>
<DIV><FONT face=Arial></FONT> </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>