SPRA118
NOTE: You load F[|I|] << 11 to scale it with DML (Q11 format).
Function: Transition detector. tr(k) = 1 td(k–1) = 1 and |dq(k)| u 24 * 2yl(k–1)
Inputs: TD, YL (high word), DQ
Output: branch to UPA2 () (TR = 0), branch to TRIGB (TR = 1)
Cycles: Min: 6 (usual), Max: 25
NOTE: At the end of this routine, either perform TRIGA and TRIGB, or continue the program normally. Note that G.726 recommendation indicates in the text td(k) instead of td(k–1), and yl(k) instead of yl(k–1), but it is in contradiction with the further block description.
Function: Speed control trigger block. ap(k) = ap(k–1) if tr(k) = 0, ap(k) = 1 if tr(k) = 1 Inputs: B (B u 0 tr = 1)
Outputs: AP
Cycles: Min: 0 (usual), Max: 2
NOTE: By using long-word instruction, td(k) is initialized at the same time as ap(k), performing by this way a part of TRIGB (20).
Function: Predictor trigger block. If tr(k) = 1, ai(k) = 0 for i = 1, 2; bi(k) = 0 for i = 1, ..., 6; and td(k) = 0
Input: none
Output: A1, A2, B1, ..., B6, TD, and branch to FUNCTW() if performed
Cycles: Min: 0 (usual), Max: 7
NOTE: This routine (just as TRIGA) is executed in function of the precedent “conditional branch” at the end of the routine, TRANS (18). See TRIGA (19) for execution conditions. If tr(k) = 1 (transition is detected), TRIGB is performed: A1, A2, B1, ..., B6 are set to 0, then routines (21) to (29) are skipped to avoid Ai and Bi adaptation. Otherwise, (transition not detected), TRIGB is not performed: Ai, Bi, and TD keep their value, and are then adapted (for Ai, Bi: routines (21–23) and (25–26)), or calculated (for TD). Note that TD is initialized at the same time as AP (see TRIGA (19)).
5.4.21UPA2
Function: Update a2 coefficient of second order predictor. a2(k) = (1 – 2–7)a2(k–1) + 2–7{sgn[p(k)] sgn[p(k–2)] – f[a1(k–1)] sgn[p(k)] sgn[p(k–1)]}
Inputs: PK0high (PK0 = sgn(p(k)), PK0low (P(k)), PK1, PK2, A1, A2
G.726 Adaptive Differential Pulse Code Modulation (ADPCM) on the TMS320C54x DSP |
57 |
SPRA118
Outputs: A (unlimited A2)
Cycles: Min: 0, Max: 25 (usual)
NOTE: PK0low makes it possible to give the real sign of p(k). In fact, it is worth 0 if p(k) = 0. Otherwise, it is given by PK0 (0/–1) and is worth +/– 1. This routine is not performed if tr(k) = 1.
Function: Limits on a2 coefficient of second order predictor. |a2(k)| v 0.75
Input: A (unlimited A2)
Output: A2
Cycles: Min: 0, Max: 6 (usual)
NOTE: Computing value for 0.75 is 12288 (Q14 format). This routine is not performed if tr(k) = 1.
5.4.23UPA1
Function: Update a1 coefficient of second order predictor. a1(k) = (1 – 2–8)a1(k–1) + 3.2–8 sgn[p(k)] sgn[p(k–1)]
Inputs: PK0high (PK0 = sgn(p(k)), PK0low (P(k)), PK1, A1
Outputs: A (A1T)
Cycles: Min: 6, Max: 12 (usual)
NOTE: PK0low permits, to give the real sign of p(k). It is 0 if p(k) = 0, otherwise, it is given by PK0 (0/–1) and is worth +/–1. This routine is not performed if tr(k) = 1.
Function: Limits on a1 coefficient of second order predictor. |a1(k)| v 1 – 2–4 – a2(k)
Input: A (A1T), A2 (A2P)
Output: A1 (A1P)
Cycles: Min: 0, Max: 7 (usual)
NOTE: Computing value for 1 – 2–4 is 15360 (Q14 format). This routine is not performed if tr(k) = 1.
5.4.25XOR
Function: “Exclusive or” of sign of difference signal and sign of delayed difference signal. Ui(k) = sign (dq(k)) ** sign (dq(k–i))
Inputs: DQ1 sign, ..., DQ6 sign, SIGN (DQS), AR7 (points to DQ6 sign)
58 G.726 Adaptive Differential Pulse Code Modulation (ADPCM) on the TMS320C54x DSP
SPRA118
Output: B (Ui)
Cycles: Min: 0, Max: 12 (usual)
NOTE: DQi sign is pointed by AR7 in table DQFLOAT. This routine is partially executed before each UPBi (26). This routine is not performed if tr(k) = 1.
5.4.26UPB
Function: Update for coefficients of sixth-order predictor. bi(k) = (1–2–8)bi(k–1) + 2–7 Ui(k) for 16-, 24-, 32-Kbps coding; bi(k) = (1–2–9)bi(k–1) + 2–7 Ui(k) for 40 Kbps coding
Inputs: B (Ui), Bi, DQ, SHIFT
Outputs: B1 (B1P), ..., B6 (B6P)
Cycles: Min: 0, Max: 40 (usual)
NOTE: If DQ = 0, then Ui is forced to be 0. SHIFT is –8 for 16, 24, 32 Kbps, and is –9 for 40 Kbps coding. It corresponds to the term 2–8 or 2–9 for Bi adaptation. This routine is not performed if tr(k) = 1.
Function: Partial band-signal detection. td(k) = 1 if a2(k) t –0.71875, td(k) = 0. Otherwise:
Input: A2 (A2P)
Output: TD (TDP)
Cycles: Min: 0, Max: 3
NOTE: Computing value for –0.71875 is –11776 (Q14 format). This routine is not performed if tr(k) = 1.
Function: Compute magnitude of the difference of shortand long-term functions of quantizer output sequence, and then perform threshold comparison for quantizing speed control
parameter. Ax = 0 if y(k) w 3 and |dms(k–1) – dml(k–1)| w 2–3 dml(k–1) and td(k–1) = 0, Ax = 1. Otherwise:
Inputs: DMS, DML, TD (TDP), Y
Output: A (AX << 9)
Cycles: Min: 0 (rare), Med: 6, Max: 21
NOTE: If td(k) = 1 (TD = –1), the routine is limited to 6 execution cycles, else if |dms(k–1) – dml(k–1)| w 2–3 dml(k–1), the routine is limited to 19 cycles. Otherwise, the cycle number is
21.If tr(k) = 1, the routine is not performed.
Function: Low-pass filter of speed control parameter. ap(k) = (1– 2–4)ap(k–1) + 2–3 Ax
G.726 Adaptive Differential Pulse Code Modulation (ADPCM) on the TMS320C54x DSP |
59 |
SPRA118
Inputs: A (AX << 9), AP
Output: AP (APP)
Cycles: Min: 0, Max: 4 (usual)
NOTE: This routine is not performed if tr(k) = 1. AX << 9 is either 29 or 0. It corresponds to 2 for AP scale (Q8 format). The difference between AX << 9 and AP is computed before dividing the result by 16.
Function: Map quantizer output into logarithmic. I(k) → W[|I(k)|]
Input: AR2 (points to W[|I|])
Output: A (W[|I|] << 5
Cycles: 1
NOTE: You load W[|I|] << 5 to scale it with DMS (Q9 format) for routine FILTD (31). Values of W|I| are included in the |I| table pointed by AR2.
Function: Update of fast quantizer scale factor. yu(k) = (1 – 2–5).y(k) + 2–5.W[|I(k)|]
Inputs: A(W[|I|] << 5), Y
Output: BH (YUT)
Cycles: 3
NOTE: To prepare FILTE (33), operations are carried out using the high part of the accumulator.
Function: Limit quantizer scale factor. 1.06 v y(k) v 10
Input: BH (YUT)
Output: YU (YUP), AH (YUP)
Cycles: 5
NOTE: Computing value for 1.06 is 544, and 5120 for 10 (Q9 format).
Function: Update of slow quantizer scale factor. yl = (1 – 2–6).yl(k–1) + 2–6.yu(k)
Inputs: YL, AH (YUP)
Outputs: YL (YLP)
60 G.726 Adaptive Differential Pulse Code Modulation (ADPCM) on the TMS320C54x DSP
SPRA118
Cycles: 5
NOTE: YL must be calculated before applying the 2–6 factor. As the theoretical format of YL is Q25, (–YL) is truncated to obtain Q15 format, as specified in G.726 recommendation.
Function: Convert 16-bit 2’s complement to floating-point. DQ → (DQ0 mantissa, DQ0 exponent, DQ0 sign)
Input: DQ, SIGN (DQS), AR7 (points to DQ6 exponent)
Output: DQ0 exponent, DQ0 mantissa, DQ0 sign (in DQFLOAT buffer), AR7 (points to DQ5 exponent)
Cycles: 13
NOTE: Exponent EXP of DQ is defined by: 2EXP–1 v |DQ| 2EXP . Mantissa MANT of DQ is obtained with the 6 most significant bits (MSB) of DQ. MANT has the following limits: 0 v MANT t 1, which implies that MANT format is Q6. Sign of DQ is 0 if DQ positive, –1 if DQ negative. If DQ 0 0, find the exponent of DQ by means of the EXP and DSUBT instructions, and MANT via the NORM instruction. If DQ = 0, EXP is 0 and MANT is defined to be 1/2 (= 32).For this particular case, the sign is given by the variable SIGN (DQS = sign of DQ given by the inverse quantizer). Note that DQ = 0 does not imply that DQS = 0.
Function: Convert 16-bit 2’s complement to floating point. SR → (SR0 mantissa, SR0 exponent, SR0 sign)
Input: SD (SR), AR6 (points to SR2 sign)
Output: SR0, AR5 (points to SR1 exponent)
Cycles: 14
NOTE: See FLOATA for definitions of exponent, mantissa, and sign; but contrary to DQ, SR = 0 always implies that the sign of SR is also 0 (this means that, in this case, SR is positive).
Function: Memory block. For the input x, the output is given by y(k) = x(k–1).
Input: x
Output: y
Cycles: 10
NOTE: This routine applies for all delayed variables. For the one-time delayed variables such as DMS, DML, AP, Ai, Bi, TD, YL, YU, x(k + 1) has the same memory location as x(k). So, the delay was applied at the time these variables were updated. Thus, this routine really applies to the variables that are delayed several times, such as Pki, SRi, DQi. As for PKi, PK2 location just follows the PK1 location, so the instruction DELAY automatically realizes the PK2 update. In the case of Sri and Sri, these variables are automatically delayed, due to the use of two circular buffers (DQFLOAT for DQi and SRFLOAT for SRi). Only the addresses of the next DQ6 and the next SR2 must be saved (ADDQ6 and ADSR2).
G.726 Adaptive Differential Pulse Code Modulation (ADPCM) on the TMS320C54x DSP |
61 |