📄 ton_stab.cpp
字号:
state = pointer to pointer to structure type tonStabState. lsp = pointer to unquantized LSPs of type Word16 Outputs: pOverflow = 1 if there is an overflow else it is zero. Returns: None. Global Variables Used: None Local Variables Needed: None------------------------------------------------------------------------------ FUNCTION DESCRIPTION Function: check_lsp() Purpose: Check the LSP's to detect resonances------------------------------------------------------------------------------ REQUIREMENTS None.------------------------------------------------------------------------------ REFERENCES ton_stab.c, UMTS GSM AMR speech codec, R99 - Version 3.2.0, March 2, 2001------------------------------------------------------------------------------ PSEUDO-CODEWord16 check_lsp(tonStabState *st, // i/o : State struct Word16 *lsp // i : unquantized LSP's){ Word16 i, dist, dist_min1, dist_min2, dist_th; // Check for a resonance: // Find minimum distance between lsp[i] and lsp[i+1] dist_min1 = MAX_16; for (i = 3; i < M-2; i++) { dist = sub(lsp[i], lsp[i+1]); if (sub(dist, dist_min1) < 0) { dist_min1 = dist; } } dist_min2 = MAX_16; for (i = 1; i < 3; i++) { dist = sub(lsp[i], lsp[i+1]); if (sub(dist, dist_min2) < 0) { dist_min2 = dist; } } if (sub(lsp[1], 32000) > 0) { dist_th = 600; } else if (sub(lsp[1], 30500) > 0) { dist_th = 800; } else { dist_th = 1100; } if (sub(dist_min1, 1500) < 0 || sub(dist_min2, dist_th) < 0) { st->count = add(st->count, 1); } else { st->count = 0; } // Need 12 consecutive frames to set the flag if (sub(st->count, 12) >= 0) { st->count = 12; return 1; } else { return 0; }}------------------------------------------------------------------------------ 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 check_lsp(tonStabState *st, /* i/o : State struct */ Word16 *lsp, /* i : unquantized LSP's */ Flag *pOverflow ){ Word16 i; Word16 dist; Word16 dist_min1; Word16 dist_min2; Word16 dist_th; Word16 *p_lsp = &lsp[3]; Word16 *p_lsp_1 = &lsp[4]; OSCL_UNUSED_ARG(pOverflow); /* Check for a resonance: */ /* Find minimum distance between lsp[i] and lsp[i+1] */ dist_min1 = MAX_16; for (i = 3; i < M - 2; i++) { dist = *(p_lsp++) - *(p_lsp_1++); if (dist < dist_min1) { dist_min1 = dist; } } dist_min2 = MAX_16; p_lsp = &lsp[1]; p_lsp_1 = &lsp[2]; for (i = 1; i < 3; i++) { dist = *(p_lsp++) - *(p_lsp_1++); if (dist < dist_min2) { dist_min2 = dist; } } if (lsp[1] > 32000) { dist_th = 600; } else if (lsp[1] > 30500) { dist_th = 800; } else { dist_th = 1100; } if ((dist_min1 < 1500) || (dist_min2 < dist_th)) { st->count++; } else { st->count = 0; } /* Need 12 consecutive frames to set the flag */ if (st->count >= 12) { st->count = 12; return 1; } else { return 0; }}/****************************************************************************//*------------------------------------------------------------------------------ FUNCTION NAME: check_gp_clipping------------------------------------------------------------------------------ INPUT AND OUTPUT DEFINITIONS Inputs: state = pointer to pointer to structure type tonStabState. g_pitch = pitch gain of type Word16 Outputs: pOverflow = 1 if there is an overflow else it is zero. Returns: None. Global Variables Used: None Local Variables Needed: None------------------------------------------------------------------------------ FUNCTION DESCRIPTION Function: Check_Gp_Clipping() Purpose: Verify that the sum of the last (N_FRAME+1) pitch gains is under a certain threshold.------------------------------------------------------------------------------ REQUIREMENTS None.------------------------------------------------------------------------------ REFERENCES ton_stab.c, UMTS GSM AMR speech codec, R99 - Version 3.2.0, March 2, 2001------------------------------------------------------------------------------ PSEUDO-CODEWord16 check_gp_clipping(tonStabState *st, // i/o : State struct Word16 g_pitch // i : pitch gain){ Word16 i, sum; sum = shr(g_pitch, 3); // Division by 8 for (i = 0; i < N_FRAME; i++) { sum = add(sum, st->gp[i]); } if (sub(sum, GP_CLIP) > 0) { return 1; } else { return 0; }}------------------------------------------------------------------------------ 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 check_gp_clipping(tonStabState *st, /* i/o : State struct */ Word16 g_pitch, /* i : pitch gain */ Flag *pOverflow ){ Word16 i; Word16 sum; sum = shr(g_pitch, 3, pOverflow); /* Division by 8 */ for (i = 0; i < N_FRAME; i++) { sum = add(sum, st->gp[i], pOverflow); } if (sum > GP_CLIP) { return 1; } else { return 0; }}/****************************************************************************//*------------------------------------------------------------------------------ FUNCTION NAME: update_gp_clipping------------------------------------------------------------------------------ INPUT AND OUTPUT DEFINITIONS Inputs: state = pointer to pointer to structure type tonStabState. g_pitch = pitch gain of type Word16 Outputs: pOverflow = 1 if there is an overflow else it is zero. Returns: None. Global Variables Used: None Local Variables Needed: None------------------------------------------------------------------------------ FUNCTION DESCRIPTION Function: Update_Gp_Clipping() Purpose: Update past pitch gain memory------------------------------------------------------------------------------ REQUIREMENTS None.------------------------------------------------------------------------------ REFERENCES ton_stab.c, UMTS GSM AMR speech codec, R99 - Version 3.2.0, March 2, 2001------------------------------------------------------------------------------ PSEUDO-CODEvoid update_gp_clipping(tonStabState *st, // i/o : State struct Word16 g_pitch // i : pitch gain){ Copy(&st->gp[1], &st->gp[0], N_FRAME-1); st->gp[N_FRAME-1] = shr(g_pitch, 3);}------------------------------------------------------------------------------ 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 update_gp_clipping(tonStabState *st, /* i/o : State struct */ Word16 g_pitch, /* i : pitch gain */ Flag *pOverflow ){ OSCL_UNUSED_ARG(pOverflow); for (int i = 0; i < N_FRAME - 1; i++) { st->gp[i] = st->gp[i+1]; } st->gp[N_FRAME-1] = g_pitch >> 3;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -