📄 gsm.c
字号:
* temp1 = GSM_SUB( temp1, temp2 );
*
* pgpAssert(*INVA != MIN_WORD);
*
* temp1 = GSM_MULT_R( *INVA, temp1 );
* *LARpp = GSM_ADD( temp1, temp1 );
* }
*/
#undef STEP
#define STEP( B, MIC, INVA ) \
temp1 = GSM_ADD( *LARc++, MIC ) << 10; \
temp1 = GSM_SUB( temp1, B << 1 ); \
temp1 = GSM_MULT_R( INVA, temp1 ); \
*LARpp++ = GSM_ADD( temp1, temp1 );
STEP( 0, -32, 13107 );
STEP( 0, -32, 13107 );
STEP( 2048, -16, 13107 );
STEP( -2560, -16, 13107 );
STEP( 94, -8, 19223 );
STEP( -1792, -8, 17476 );
STEP( -341, -4, 31454 );
STEP( -1144, -4, 29708 );
/* NOTE: the addition of *MIC is used to restore
* the sign of *LARc.
*/
}
/* 4.2.9 */
/* Computation of the quantized reflection coefficients
*/
/* 4.2.9.1 Interpolation of the LARpp[1..8] to get the LARp[1..8]
*/
/*
* Within each frame of 160 analyzed speech samples the short term
* analysis and synthesis filters operate with four different sets of
* coefficients, derived from the previous set of decoded LARs(LARpp(j-1))
* and the actual set of decoded LARs (LARpp(j))
*
* (Initial value: LARpp(j-1)[1..8] = 0.)
*/
static void Coefficients_0_12(
register word * LARpp_j_1,
register word * LARpp_j,
register word * LARp)
{
register int i;
/* register longword ltmp; */
for (i = 1; i <= 8; i++, LARp++, LARpp_j_1++, LARpp_j++) {
*LARp = GSM_ADD( SASR( *LARpp_j_1, 2 ), SASR( *LARpp_j, 2 ));
*LARp = GSM_ADD( *LARp, SASR( *LARpp_j_1, 1));
}
}
static void Coefficients_13_26(
register word * LARpp_j_1,
register word * LARpp_j,
register word * LARp)
{
register int i;
/* register longword ltmp; */
for (i = 1; i <= 8; i++, LARpp_j_1++, LARpp_j++, LARp++) {
*LARp = GSM_ADD( SASR( *LARpp_j_1, 1), SASR( *LARpp_j, 1 ));
}
}
static void Coefficients_27_39(
register word * LARpp_j_1,
register word * LARpp_j,
register word * LARp)
{
register int i;
/* register longword ltmp; */
for (i = 1; i <= 8; i++, LARpp_j_1++, LARpp_j++, LARp++) {
*LARp = GSM_ADD( SASR( *LARpp_j_1, 2 ), SASR( *LARpp_j, 2 ));
*LARp = GSM_ADD( *LARp, SASR( *LARpp_j, 1 ));
}
}
static void Coefficients_40_159(
register word * LARpp_j,
register word * LARp)
{
register int i;
for (i = 1; i <= 8; i++, LARp++, LARpp_j++)
*LARp = *LARpp_j;
}
/* 4.2.9.2 */
static void LARp_to_rp(
register word * LARp) /* [0..7] IN/OUT */
/*
* The input of this procedure is the interpolated LARp[0..7] array.
* The reflection coefficients, rp[i], are used in the analysis
* filter and in the synthesis filter.
*/
{
register int i;
register word temp;
/* register longword ltmp; */
for (i = 1; i <= 8; i++, LARp++) {
/* temp = GSM_ABS( *LARp );
*
* if (temp < 11059) temp <<= 1;
* else if (temp < 20070) temp += 11059;
* else temp = GSM_ADD( temp >> 2, 26112 );
*
* *LARp = *LARp < 0 ? -temp : temp;
*/
if (*LARp < 0) {
temp = *LARp == MIN_WORD ? MAX_WORD : -(*LARp);
*LARp = - ((temp < 11059) ? temp << 1
: ((temp < 20070) ? temp + 11059
: GSM_ADD( temp >> 2, 26112 )));
} else {
temp = *LARp;
*LARp = (temp < 11059) ? temp << 1
: ((temp < 20070) ? temp + 11059
: GSM_ADD( temp >> 2, 26112 ));
}
}
}
/* 4.2.10 */
#ifdef __MC68K__
/*
* This procedure computes the short term residual signal d[..] to be fed
* to the RPE-LTP loop from the s[..] signal and from the local rp[..]
* array (quantized reflection coefficients). As the call of this
* procedure can be done in many ways (see the interpolation of the LAR
* coefficient), it is assumed that the computation begins with index
* k_start (for arrays d[..] and s[..]) and stops with index k_end
* (k_start and k_end are defined in 4.2.9.1). This procedure also
* needs to keep the array u[0..7] in memory for each call.
*/
static asm void Short_term_analysis_filtering(
word *u,
word * rp, /* [0..7] IN */
int k_n, /* k_end - k_start */
word * s /* [0..n-1] IN/OUT */
)
{
fralloc+
/*
* 68K assembler version, with the internal loop unrolled and all the adds
* and multiplies inlined. All variables are placed in registers. Note that the
* multiplies in this routine do _not_ need to check for MIN_WORD * MIN_WORD.
*
* Registers used, in terms of the variables in the C version:
*
* a0: u
* a1: rp
* a2: s
* a3: rpi
* a4: uii
*
* d0: k_n
* d1: di
* d2: sav
* d3: ui
* d4: scratch register
* d5: scratch register
*
*/
movem.l d3-d5/a2-a4,-(a7)
movea.l u,a0
movea.l rp,a1
movea.l s,a2
move.w k_n,d0
moveq #15,d5 // d5 contains the immediate for the GSM_MULT_R right shifts
@loop:
move.w (a2),d1 // di = sav = *s
move.w d1,d2
movea.l a1,a3 // rpi = rp
movea.l a0,a4 // uii = u
// ST_ANAL_INSIDE: Iteration 1
move.w (a4),d3 // ui = *uii
move.w d2,(a4)+ // *uii++ = sav
//GSM_MULT_R(*rpi, di)
move.w (a3),d2
muls.w d1,d2
addi.l #16384,d2
asr.l d5,d2
//sav = GSM_ADD( ui, GSM_MULT_R(*rpi, di))
add.w d3,d2
bvc @endadd1
bmi @pos1
move.w #-32768,d2
bra @endadd1
@pos1:
move.w #32767, d2
@endadd1:
//GSM_MULT_R(*rpi++, ui)
move.w (a3)+,d4
muls.w d3,d4
addi.l #16384,d4
asr.l d5,d4
//di = GSM_ADD( di, GSM_MULT_R(*rpi++, ui))
add.w d4,d1
bvc @endadd2
bmi @pos2
move.w #-32768,d1
bra @endadd2
@pos2:
move.w #32767, d1
@endadd2:
// Iteration 2
move.w (a4),d3 // ui = *uii
move.w d2,(a4)+ // *uii++ = sav
//GSM_MULT_R(*rpi, di)
move.w (a3),d2
muls.w d1,d2
addi.l #16384,d2
asr.l d5,d2
//sav = GSM_ADD( ui, GSM_MULT_R(*rpi, di))
add.w d3,d2
bvc @endadd3
bmi @pos3
move.w #-32768,d2
bra @endadd3
@pos3:
move.w #32767, d2
@endadd3:
//GSM_MULT_R(*rpi++, ui)
move.w (a3)+,d4
muls.w d3,d4
addi.l #16384,d4
asr.l d5,d4
//di = GSM_ADD( di, GSM_MULT_R(*rpi++, ui))
add.w d4,d1
bvc @endadd4
bmi @pos4
move.w #-32768,d1
bra @endadd4
@pos4:
move.w #32767, d1
@endadd4:
// Iteration 3
move.w (a4),d3 // ui = *uii
move.w d2,(a4)+ // *ui++ = sav
//GSM_MULT_R(*rpi, di)
move.w (a3),d2
muls.w d1,d2
addi.l #16384,d2
asr.l d5,d2
//sav = GSM_ADD( ui, GSM_MULT_R(*rpi, di))
add.w d3,d2
bvc @endadd5
bmi @pos5
move.w #-32768,d2
bra @endadd5
@pos5:
move.w #32767, d2
@endadd5:
//GSM_MULT_R(*rpi++, ui)
move.w (a3)+,d4
muls.w d3,d4
addi.l #16384,d4
asr.l d5,d4
//di = GSM_ADD( di, GSM_MULT_R(*rpi++, ui))
add.w d4,d1
bvc @endadd6
bmi @pos6
move.w #-32768,d1
bra @endadd6
@pos6:
move.w #32767, d1
@endadd6:
// Iteration 4
move.w (a4),d3 // ui = *uii
move.w d2,(a4)+ // *ui++ = sav
//GSM_MULT_R(*rpi, di)
move.w (a3),d2
muls.w d1,d2
addi.l #16384,d2
asr.l d5,d2
//sav = GSM_ADD( ui, GSM_MULT_R(*rpi, di))
add.w d3,d2
bvc @endadd7
bmi @pos7
move.w #-32768,d2
bra @endadd7
@pos7:
move.w #32767, d2
@endadd7:
//GSM_MULT_R(*rpi++, ui)
move.w (a3)+,d4
muls.w d3,d4
addi.l #16384,d4
asr.l d5,d4
//di = GSM_ADD( di, GSM_MULT_R(*rpi++, ui))
add.w d4,d1
bvc @endadd8
bmi @pos8
move.w #-32768,d1
bra @endadd8
@pos8:
move.w #32767, d1
@endadd8:
// Iteration 5
move.w (a4),d3 // ui = *uii
move.w d2,(a4)+ // *ui++ = sav
//GSM_MULT_R(*rpi, di)
move.w (a3),d2
muls.w d1,d2
addi.l #16384,d2
asr.l d5,d2
//sav = GSM_ADD( ui, GSM_MULT_R(*rpi, di))
add.w d3,d2
bvc @endadd9
bmi @pos9
move.w #-32768,d2
bra @endadd9
@pos9:
move.w #32767, d2
@endadd9:
//GSM_MULT_R(*rpi++, ui)
move.w (a3)+,d4
muls.w d3,d4
addi.l #16384,d4
asr.l d5,d4
//di = GSM_ADD( di, GSM_MULT_R(*rpi++, ui))
add.w d4,d1
bvc @endadd10
bmi @pos10
move.w #-32768,d1
bra @endadd10
@pos10:
move.w #32767, d1
@endadd10:
// Iteration 6
move.w (a4),d3 // ui = *uii
move.w d2,(a4)+ // *ui++ = sav
//GSM_MULT_R(*rpi, di)
move.w (a3),d2
muls.w d1,d2
addi.l #16384,d2
asr.l d5,d2
//sav = GSM_ADD( ui, GSM_MULT_R(*rpi, di))
add.w d3,d2
bvc @endadd11
bmi @pos1
move.w #-32768,d2
bra @endadd11
@pos11:
move.w #32767, d2
@endadd11:
//GSM_MULT_R(*rpi++, ui)
move.w (a3)+,d4
muls.w d3,d4
addi.l #16384,d4
asr.l d5,d4
//di = GSM_ADD( di, GSM_MULT_R(*rpi++, ui))
add.w d4,d1
bvc @endadd12
bmi @pos12
move.w #-32768,d1
bra @endadd12
@pos12:
move.w #32767, d1
@endadd12:
// Iteration 7
move.w (a4),d3 // ui = *uii
move.w d2,(a4)+ // *ui++ = sav
//GSM_MULT_R(*rpi, di)
move.w (a3),d2
muls.w d1,d2
addi.l #16384,d2
asr.l d5,d2
//sav = GSM_ADD( ui, GSM_MULT_R(*rpi, di))
add.w d3,d2
bvc @endadd13
bmi @pos13
move.w #-32768,d2
bra @endadd13
@pos13:
move.w #32767, d2
@endadd13:
//GSM_MULT_R(*rpi++, ui)
move.w (a3)+,d4
muls.w d3,d4
addi.l #16384,d4
asr.l d5,d4
//di = GSM_ADD( di, GSM_MULT_R(*rpi++, ui))
add.w d4,d1
bvc @endadd14
bmi @pos14
move.w #-32768,d1
bra @endadd14
@pos14:
move.w #32767, d1
@endadd14:
// Iteration 8
move.w (a4),d3 // ui = *uii
move.w d2,(a4)+ // *ui++ = sav
//GSM_MULT_R(*rpi, di)
move.w (a3),d2
muls.w d1,d2
addi.l #16384,d2
asr.l d5,d2
//sav = GSM_ADD( ui, GSM_MULT_R(*rpi, di))
add.w d3,d2
bvc @endadd15
bmi @pos3
move.w #-32768,d2
bra @endadd15
@pos15:
move.w #32767, d2
@endadd15:
//GSM_MULT_R(*rpi++, ui)
move.w (a3)+,d4
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -