📄 q_plsf_3.cpp
字号:
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]------------------------------------------------------------------------------*/Word16 Test_Vq_subvec4( Word16 * lsf_r1, const Word16 * dico, Word16 * wf1, Word16 dico_size, Flag *pOverflow){ Word16 tst_index4 = 0; /*------------------------------------------------------------------------ CALL Vq_subvec4(lsf_r1 = lsf_r1 dico = dico wf1 = wf1 dico_size = dico_size) MODIFYING(nothing) RETURNING(index = index) ------------------------------------------------------------------------*/ tst_index4 = Vq_subvec4( lsf_r1, dico, wf1, dico_size, pOverflow); return(tst_index4);}/****************************************************************************//*------------------------------------------------------------------------------ FUNCTION NAME: Vq_subvec3------------------------------------------------------------------------------ INPUT AND OUTPUT DEFINITIONS Inputs: lsf_r1 = pointer to the first LSF residual vector (Q15) (Word16) dico = pointer to the quantization codebook (Q15) (const Word16) wf1 = pointer to the first LSF weighting factor (Q13) (Word16) dico_size = size of quantization codebook (Q0) (Word16) use_half = flag to indicate use of every second entry in the codebook (Flag) Outputs: buffer pointed to by lsf_r1 contains the selected vector pOverflow -- pointer to Flag -- Flag set when overflow occurs Returns: index = quantization index (Q0) (Word16) Global Variables Used: None Local Variables Needed: None------------------------------------------------------------------------------ FUNCTION DESCRIPTION This function performs the quantization of a 3 dimensional subvector.------------------------------------------------------------------------------ REQUIREMENTS None------------------------------------------------------------------------------ REFERENCES q_plsf_3.c, UMTS GSM AMR speech codec, R99 - Version 3.2.0, March 2, 2001------------------------------------------------------------------------------ PSEUDO-CODEstatic Word16Vq_subvec3( // o: quantization index, Q0 Word16 * lsf_r1, // i: 1st LSF residual vector, Q15 Word16 * dico, // i: quantization codebook, Q15 Word16 * wf1, // i: 1st LSF weighting factors, Q13 Word16 dico_size, // i: size of quantization codebook, Q0 Flag use_half) // i: use every second entry in codebook{ Word16 i, index = 0; Word16 *p_dico, temp; Word32 dist_min, dist; dist_min = MAX_32; p_dico = dico; if (use_half == 0) { for (i = 0; i < dico_size; i++) { temp = sub(lsf_r1[0], *p_dico++); temp = mult(wf1[0], temp); dist = L_mult(temp, temp); temp = sub(lsf_r1[1], *p_dico++); temp = mult(wf1[1], temp); dist = L_mac(dist, temp, temp); temp = sub(lsf_r1[2], *p_dico++); temp = mult(wf1[2], temp); dist = L_mac(dist, temp, temp); if (L_sub(dist, dist_min) < (Word32) 0) { dist_min = dist; index = i; } } p_dico = &dico[add(index, add(index, index))]; } else { for (i = 0; i < dico_size; i++) { temp = sub(lsf_r1[0], *p_dico++); temp = mult(wf1[0], temp); dist = L_mult(temp, temp); temp = sub(lsf_r1[1], *p_dico++); temp = mult(wf1[1], temp); dist = L_mac(dist, temp, temp); temp = sub(lsf_r1[2], *p_dico++); temp = mult(wf1[2], temp); dist = L_mac(dist, temp, temp); if (L_sub(dist, dist_min) < (Word32) 0) { dist_min = dist; index = i; } p_dico = p_dico + 3; add(0,0); } p_dico = &dico[shl(add(index, add(index, index)),1)]; } // Reading the selected vector lsf_r1[0] = *p_dico++; lsf_r1[1] = *p_dico++; lsf_r1[2] = *p_dico++; return index;}------------------------------------------------------------------------------ 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 Word16 Vq_subvec3( /* o: quantization index, Q0 */ Word16 * lsf_r1, /* i: 1st LSF residual vector, Q15 */ const Word16 * dico, /* i: quantization codebook, Q15 */ Word16 * wf1, /* i: 1st LSF weighting factors, Q13 */ Word16 dico_size, /* i: size of quantization codebook, Q0 */ Flag use_half, /* i: use every second entry in codebook */ Flag *pOverflow) /* o : Flag set when overflow occurs */{ register Word16 i; Word16 temp; const Word16 *p_dico; Word16 p_dico_index = 0; Word16 index = 0; Word32 dist_min; Word32 dist; Word16 lsf_r1_0; Word16 lsf_r1_1; Word16 lsf_r1_2; Word16 wf1_0; Word16 wf1_1; Word16 wf1_2; OSCL_UNUSED_ARG(pOverflow); dist_min = MAX_32; p_dico = dico; lsf_r1_0 = lsf_r1[0]; lsf_r1_1 = lsf_r1[1]; lsf_r1_2 = lsf_r1[2]; wf1_0 = wf1[0]; wf1_1 = wf1[1]; wf1_2 = wf1[2]; if (use_half != 0) { p_dico_index = 3; } for (i = 0; i < dico_size; i++) { temp = lsf_r1_0 - (*p_dico++); temp = (Word16)((((Word32) wf1_0) * temp) >> 15); dist = ((Word32) temp) * temp; temp = lsf_r1_1 - (*p_dico++); temp = (Word16)((((Word32) wf1_1) * temp) >> 15); dist += ((Word32) temp) * temp; temp = lsf_r1_2 - (*p_dico++); temp = (Word16)((((Word32) wf1_2) * temp) >> 15); dist += ((Word32) temp) * temp; if (dist < dist_min) { dist_min = dist; index = i; } p_dico = p_dico + p_dico_index; } p_dico = dico + (3 * index); if (use_half != 0) { p_dico += (3 * index); } /* Reading the selected vector */ *lsf_r1++ = *p_dico++; *lsf_r1++ = *p_dico++; *lsf_r1 = *p_dico++; return(index);}/****************************************************************************//*------------------------------------------------------------------------------ FUNCTION NAME: Test_Vq_subvec3------------------------------------------------------------------------------ INPUT AND OUTPUT DEFINITIONS Inputs: lsf_r1 = pointer to the first LSF residual vector (Q15) (Word16) dico = pointer to the quantization codebook (Q15) (const Word16) wf1 = pointer to the first LSF weighting factor (Q13) (Word16) dico_size = size of quantization codebook (Q0) (Word16) use_half = flag to indicate use of every second entry in the codebook (Flag) Outputs: buffer pointed to by lsf_r1 contains the selected vector pOverflow -- pointer to Flag -- Flag set when overflow occurs Returns: index = quantization index (Q0) (Word16) Global Variables Used: None Local Variables Needed: None------------------------------------------------------------------------------ FUNCTION DESCRIPTION This function calls the static function Vq_subvec3. It is used for testing purposes only------------------------------------------------------------------------------ REQUIREMENTS None------------------------------------------------------------------------------ REFERENCES None------------------------------------------------------------------------------ PSEUDO-CODE CALL Vq_subvec3(lsf_r1 = lsf_r1 dico = dico wf1 = wf1 dico_size = dico_size use_half = use_half) MODIFYING(nothing) RETURNING(index = tst_index3)------------------------------------------------------------------------------ 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]------------------------------------------------------------------------------*/Word16 Test_Vq_subvec3( Word16 * lsf_r1, const Word16 * dico, Word16 * wf1, Word16 dico_size, Flag use_half, Flag *pOverflow){ Word16 tst_index3 = 0; /*------------------------------------------------------------------------ CALL Vq_subvec3(lsf_r1 = lsf_r1 dico = dico wf1 = wf1 dico_size = dico_size use_half = use_half) MODIFYING(nothing) RETURNING(index = index) ------------------------------------------------------------------------*/ tst_index3 = Vq_subvec3( lsf_r1, dico, wf1, dico_size, use_half, pOverflow); return(tst_index3);}/****************************************************************************//*------------------------------------------------------------------------------ FUNCTION NAME: Q_plsf_3------------------------------------------------------------------------------ INPUT AND OUTPUT DEFINITIONS Inputs: st = pointer to structures of type Q_plsfState (Q_plsfState) mode = coder mode (enum) lsp1 = pointer to the first LSP vector (Word16) lsp1_q = pointer to the quantized first LSP vector (Word16) indice = pointer to the quantization indices of 3 vectors (Word16) pred_init_i = pointer to the index of the initial value for MA prediction in DTX mode (Word16) Outputs: lsp1_q points to a vector containing the new quantized LSPs indice points to the new quantization indices of 3 vectors pred_init_i points to the new initial index for MA prediction
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -