[Speex-dev] high-pass filter issues

Jim Crichton jim.crichton at comcast.net
Wed Aug 29 10:21:55 PDT 2007


Michael,

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.

This worked before your code squeeze, right?  There are many possibilities:

1.  You are overrunning the C stack, so the local variable declarations are clobbering something.
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.
2a.  The len value is bad.
2b.  The FiltID value is bad.  There is code to limit the value to 4, but a negative value might blow up.
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.
4.  You have a memory segment that is crossing a 64K boundary, and an address wrap is occurring.
5.  The problem is somewhere else entirely, and the highpass function has been corrupted by a bad memory write.
6.  There is some kind of link problem, and the highpass function is not where the call is going.

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.

Good luck.

- Jim
  ----- Original Message ----- 
  From: Michael Jacobson 
  To: speex-dev at xiph.org 
  Sent: Wednesday, August 29, 2007 11:05 AM
  Subject: [Speex-dev] high-pass filter issues


  Hi, I am using 1.2beta2 on a C5416 doing narrowband


  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:

  it is called here: ln 1719 for me
     if (st->highpass_enabled)
        highpass(out, out, st->frameSize, (st->isWideband?HIGHPASS_WIDEBAND:HIGHPASS_NARROWBAND)|HIGHPASS_OUTPUT, st->mem_hp);
     /*for (i=0;i<st->frameSize;i++)
       printf ("%d\n", (int)st->frame[i]);*/

  here's the function:

  void highpass(const spx_word16_t *x, spx_word16_t *y, int len, int filtID, spx_mem_t *mem)
  {
     int i;
  #ifdef FIXED_POINT
     const spx_word16_t Pcoef[5][3] = {{16384, -31313, 14991}, {16384, -31569, 15249}, {16384, -31677, 15328}, {16384, -32313, 15947}, {16384, -22446, 6537}};
     const spx_word16_t Zcoef[5][3] = {{15672, -31344, 15672}, {15802, -31601, 15802}, {15847, -31694, 15847}, {16162, -32322, 16162}, {14418, -28836, 14418}};
  #else
     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}};
     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}};
  #endif
     const spx_word16_t *den, *num;
     if (filtID>4)
        filtID=4;
     
     den = Pcoef[filtID]; num = Zcoef[filtID];
     /*return;*/
     for (i=0;i<len;i++)
     {
        spx_word16_t yi;
        spx_word32_t vout = ADD32(MULT16_16(num[0], x[i]),mem[0]);
        yi = EXTRACT16(SATURATE(PSHR32(vout,14),32767));
        mem[0] = ADD32(MAC16_16(mem[1], num[1],x[i]), SHL32(MULT16_32_Q15(-den[1],vout),1));
        mem[1] = ADD32(MULT16_16(num[2],x[i]), SHL32(MULT16_32_Q15(-den[2],vout),1));
        y[i] = yi;
     }
  }


  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:

  #ifdef STATIC_INIT
   #define ENC_WINBUF_SIZE 40
   #define ENC_EXCBUF_SIZE 306
   #define ENC_SWBUF_SIZE 306
   #define ENC_LAGWINDOW_SIZE 11
   #define ENC_OLD_LSP_SIZE 10
   #define ENC_OLD_QLSP_SIZE 10
   #define ENC_MEM_SP_SIZE 20
   #define ENC_MEM_SW_SIZE 20
   #define ENC_SW_WHOLE_SIZE 20
   #define ENC_MEM_EXC_SIZE 20
   #define ENC_MEM_EXC2_SIZE 20
   #define ENC_PI_GAIN_SIZE 8
   #define ENC_PITCH_SIZE 4

   #define DEC_EXCBUF_SIZE 500
   #define DEC_INTERP_QLPC_SIZE 10
   #define DEC_OLD_QLSP_SIZE 10
   #define DEC_MEM_SP_SIZE 20
   #define DEC_PI_GAIN_SIZE 8

   EncState   enc_state;
   char    enc_stack[NB_ENC_STACK];
   spx_word16_t  enc_winbuf[ENC_WINBUF_SIZE];
   spx_word16_t  enc_excbuf[ENC_EXCBUF_SIZE];
   spx_word16_t  enc_swbuf[ENC_SWBUF_SIZE];
   spx_word16_t  enc_lagwindow[ENC_LAGWINDOW_SIZE];
   spx_lsp_t   enc_old_lsp[ENC_OLD_LSP_SIZE];
   spx_lsp_t  enc_old_qlsp[ENC_OLD_QLSP_SIZE];
   spx_mem_t  enc_mem_sp[ENC_MEM_SP_SIZE];
   spx_mem_t  enc_mem_sw[ENC_MEM_SW_SIZE];
   spx_mem_t  enc_mem_sw_whole[ENC_SW_WHOLE_SIZE];
   spx_mem_t  enc_mem_exc[ENC_MEM_EXC_SIZE];
   spx_mem_t  enc_memexc2[ENC_MEM_EXC2_SIZE];
   spx_word32_t enc_pi_gain[ENC_PI_GAIN_SIZE];
   int    enc_pitch[ENC_PITCH_SIZE];

   DecState  dec_state;
   char   dec_stack[NB_DEC_STACK];
   spx_word16_t dec_excbuf[DEC_EXCBUF_SIZE];
   spx_coef_t  dec_interp_qlpc[DEC_INTERP_QLPC_SIZE];
   spx_lsp_t  dec_old_qlsp[DEC_OLD_QLSP_SIZE];
   spx_mem_t  dec_mem_sp[DEC_MEM_SP_SIZE];
   spx_word32_t dec_pi_gain[DEC_PI_GAIN_SIZE];

  #endif 

  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)

  -Mike



------------------------------------------------------------------------------


  _______________________________________________
  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/20070829/889d3aed/attachment.html


More information about the Speex-dev mailing list