📄 c8_31pf.cpp
字号:
When the code is written for a specific target processor the the resources used should be documented below. HEAP MEMORY USED: x bytes STACK MEMORY USED: x bytes CLOCK CYCLES: (cycle count equation for this function) + (variable used to represent cycle count for each subroutine called) where: (cycle count variable) = cycle count for [subroutine name]------------------------------------------------------------------------------ CAUTION [optional] [State any special notes, constraints or cautions for users of this function]------------------------------------------------------------------------------*/static Word16 compress10( Word16 pos_indxA, /* i : signs of 4 pulses (signs only) */ Word16 pos_indxB, /* i : position index of 8 pulses (pos only) */ Word16 pos_indxC, /* i : position and sign of 8 pulses (compressed) */ Flag *pOverflow) /* o : Flag set when overflow occurs */{ Word16 indx; Word16 ia; Word16 ib; Word16 ic; Word32 tempWord32; OSCL_UNUSED_ARG(pOverflow); ia = pos_indxA >> 1; ib = pos_indxB >> 1; tempWord32 = ((Word32) ib * 5) << 1; tempWord32 = tempWord32 >> 1; ib = (Word16) tempWord32; ic = pos_indxC >> 1; tempWord32 = ((Word32) ic * 25) << 1; tempWord32 = tempWord32 >> 1; ic = (Word16) tempWord32; ib += ic; ib += ia; indx = ib << 3; ia = pos_indxA & 1; ib = ((Word16)(pos_indxB & 1)) << 1; ic = ((Word16)(pos_indxC & 1)) << 2; ib += ic; ib += ia; indx += ib; return indx;}/****************************************************************************//*------------------------------------------------------------------------------ FUNCTION NAME: compress_code()------------------------------------------------------------------------------ INPUT AND OUTPUT DEFINITIONS Inputs: sign_indx Array of type Word16 -- signs of 4 pulses (signs only) pos_indx Array of type Word16 -- position index of 8 pulses (position only) Outputs: indx Array of type Word16 -- position and sign of 8 pulses (compressed) pOverflow Pointer to Flag -- set when overflow occurs Returns: None Global Variables Used: None Local Variables Needed: None------------------------------------------------------------------------------ FUNCTION DESCRIPTION PURPOSE: compression of the linear codewords to 4+three indeces one bit from each pulse is made robust to errors by minimizing the phase shift of a bit error. 4 signs (one for each track) i0,i4,i1 => one index (7+3) bits, 3 LSBs more robust i2,i6,i5 => one index (7+3) bits, 3 LSBs more robust i3,i7 => one index (5+2) bits, 2-3 LSbs more robust------------------------------------------------------------------------------ REQUIREMENTS None------------------------------------------------------------------------------ REFERENCES [1] c3_14pf.c, UMTS GSM AMR speech codec, R99 - Version 3.2.0, March 2, 2001------------------------------------------------------------------------------ PSEUDO-CODE------------------------------------------------------------------------------ RESOURCES USED [optional] When the code is written for a specific target processor the the resources used should be documented below. HEAP MEMORY USED: x bytes STACK MEMORY USED: x bytes CLOCK CYCLES: (cycle count equation for this function) + (variable used to represent cycle count for each subroutine called) where: (cycle count variable) = cycle count for [subroutine name]------------------------------------------------------------------------------ CAUTION [optional] [State any special notes, constraints or cautions for users of this function]------------------------------------------------------------------------------*/static void compress_code( Word16 sign_indx[], /* i : signs of 4 pulses (signs only) */ Word16 pos_indx[], /* i : position index of 8 pulses (position only) */ Word16 indx[], /* o : position and sign of 8 pulses (compressed) */ Flag *pOverflow) /* o : Flag set when overflow occurs */{ Word16 i; Word16 ia; Word16 ib; Word16 ic; Word16 *p_indx = &indx[0]; Word16 *p_sign_indx = &sign_indx[0]; Word32 tempWord32; for (i = 0; i < NB_TRACK_MR102; i++) { *(p_indx++) = *(p_sign_indx++); } /* First index indx[NB_TRACK] = (ia/2+(ib/2)*5 +(ic/2)*25)*8 + ia%2 + (ib%2)*2 + (ic%2)*4; */ indx[NB_TRACK_MR102] = compress10( pos_indx[0], pos_indx[4], pos_indx[1], pOverflow); /* Second index indx[NB_TRACK+1] = (ia/2+(ib/2)*5 +(ic/2)*25)*8 + ia%2 + (ib%2)*2 + (ic%2)*4; */ indx[NB_TRACK_MR102+1] = compress10( pos_indx[2], pos_indx[6], pos_indx[5], pOverflow); /* Third index if ((ib/2)%2 == 1) indx[NB_TRACK+2] = ((((4-ia/2) + (ib/2)*5)*32+12)/25)*4 + ia%2 + (ib%2)*2; else indx[NB_TRACK+2] = ((((ia/2) + (ib/2)*5)*32+12)/25)*4 + ia%2 + (ib%2)*2; */ ib = pos_indx[7] >> 1; ib &= 1; ia = pos_indx[3] >> 1; if (ib == 1) { ia = 4 - ia; } ib = pos_indx[7] >> 1; tempWord32 = ((Word32) ib * 5) << 1; tempWord32 = tempWord32 >> 1; ib = (Word16) tempWord32; ib += ia; ib <<= 5; ib += 12; ic = (Word16)(((Word32) ib * 1311) >> 15); ic <<= 2; ia = pos_indx[3] & 1; ib = ((Word16)(pos_indx[7] & 1)) << 1; ib += ic; ib += ia; indx[NB_TRACK_MR102+2] = ib;} /* compress_code *//****************************************************************************//*------------------------------------------------------------------------------ FUNCTION NAME: code_8i40_31bits()------------------------------------------------------------------------------ INPUT AND OUTPUT DEFINITIONS Inputs: x Array of type Word16 -- target vector cn Array of type Word16 -- residual after long term prediction h Array of type Word16 -- impulse response of weighted synthesis filter Outputs: cod Array of type Word16 -- algebraic (fixed) codebook excitation y Array of type Word16 -- filtered fixed codebook excitation indx Array of type Word16 -- index of 8 pulses (signs+positions) pOverflow Pointer to Flag -- set when overflow occurs Returns: None Global Variables Used: None Local Variables Needed: None------------------------------------------------------------------------------ FUNCTION DESCRIPTION FUNCTION: PURPOSE: Searches a 31 bit algebraic codebook containing 8 pulses in a frame of 40 samples. DESCRIPTION: The code contains 8 nonzero pulses: i0...i7. All pulses can have two possible amplitudes: +1 or -1. The 40 positions in a subframe are divided into 4 tracks of interleaved positions. Each track contains two pulses. The pulses can have the following possible positions: i0, i4 : 0, 4, 8, 12, 16, 20, 24, 28, 32, 36 i1, i5 : 1, 5, 9, 13, 17, 21, 25, 29, 33, 37 i2, i6 : 2, 6, 10, 14, 18, 22, 26, 30, 34, 38 i3, i7 : 3, 7, 11, 15, 19, 23, 27, 31, 35, 39 Each pair of pulses require 1 bit for their signs. The positions are encoded together 3,3 and 2 resulting in (7+3) + (7+3) + (5+2) bits for their positions. This results in a 31 (4 sign and 27 pos) bit codebook. The function determines the optimal pulse signs and positions, builds the codevector, and computes the filtered codevector.------------------------------------------------------------------------------ REQUIREMENTS None------------------------------------------------------------------------------ REFERENCES [1] c8_31pf.c, UMTS GSM AMR speech codec, R99 - Version 3.2.0, March 2, 2001------------------------------------------------------------------------------ PSEUDO-CODE------------------------------------------------------------------------------ RESOURCES USED [optional] When the code is written for a specific target processor the the resources used should be documented below. HEAP MEMORY USED: x bytes STACK MEMORY USED: x bytes CLOCK CYCLES: (cycle count equation for this function) + (variable used to represent cycle count for each subroutine called) where: (cycle count variable) = cycle count for [subroutine name]------------------------------------------------------------------------------ CAUTION [optional] [State any special notes, constraints or cautions for users of this function]------------------------------------------------------------------------------*/void code_8i40_31bits( Word16 x[], /* i : target vector */ Word16 cn[], /* i : residual after long term prediction */ Word16 h[], /* i : impulse response of weighted synthesis filter */ Word16 cod[], /* o : algebraic (fixed) codebook excitation */ Word16 y[], /* o : filtered fixed codebook excitation */ Word16 indx[], /* o : 7 Word16, index of 8 pulses (signs+positions) */ Flag *pOverflow /* o : Flag set when overflow occurs */){ Word16 ipos[NB_PULSE]; Word16 pos_max[NB_TRACK_MR102]; Word16 codvec[NB_PULSE]; Word16 dn[L_CODE]; Word16 sign[L_CODE]; Word16 rr[L_CODE][L_CODE]; Word16 linear_signs[NB_TRACK_MR102]; Word16 linear_codewords[NB_PULSE]; cor_h_x2( h, x, dn, 2, NB_TRACK_MR102, STEP_MR102, pOverflow); /* 2 = use GSMEFR scaling */ set_sign12k2( dn, cn, sign, pos_max, NB_TRACK_MR102, ipos, STEP_MR102, pOverflow); /* same setsign alg as GSM-EFR new constants though*/ cor_h( h, sign, rr, pOverflow); search_10and8i40( NB_PULSE, STEP_MR102, NB_TRACK_MR102, dn, rr, ipos, pos_max, codvec, pOverflow); build_code( codvec, sign, cod, h, y, linear_signs, linear_codewords, pOverflow); compress_code( linear_signs, linear_codewords, indx, pOverflow);} /* code_8i40_31bits */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -