blob: cc5a9b8b02cb569e36159938c1a5e80c0281ed04 [file] [log] [blame]
Benny Prijonoa4bf0212006-02-10 15:57:08 +00001/*
2 * Copyright 1992 by Jutta Degener and Carsten Bormann, Technische
3 * Universitaet Berlin. See the accompanying file "COPYRIGHT" for
4 * details. THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE.
5 */
6
7/* $Header: /tmp_amd/presto/export/kbs/jutta/src/gsm/RCS/code.c,v 1.3 1996/07/02 09:59:05 jutta Exp $ */
8
9#include "config.h"
10
11
12#ifdef HAS_STDLIB_H
13#include <stdlib.h>
14#else
15# include "proto.h"
16 extern char * memcpy P((char *, char *, int));
17#endif
18
19#ifdef HAS_STRING_H
20#include <string.h>
21#endif
22
23#include "private.h"
24#include "gsm.h"
25#include "proto.h"
26
27/*
28 * 4.2 FIXED POINT IMPLEMENTATION OF THE RPE-LTP CODER
29 */
30
31void Gsm_Coder P8((S,s,LARc,Nc,bc,Mc,xmaxc,xMc),
32
33 struct gsm_state * S,
34
35 word * s, /* [0..159] samples IN */
36
37/*
38 * The RPE-LTD coder works on a frame by frame basis. The length of
39 * the frame is equal to 160 samples. Some computations are done
40 * once per frame to produce at the output of the coder the
41 * LARc[1..8] parameters which are the coded LAR coefficients and
42 * also to realize the inverse filtering operation for the entire
43 * frame (160 samples of signal d[0..159]). These parts produce at
44 * the output of the coder:
45 */
46
47 word * LARc, /* [0..7] LAR coefficients OUT */
48
49/*
50 * Procedure 4.2.11 to 4.2.18 are to be executed four times per
51 * frame. That means once for each sub-segment RPE-LTP analysis of
52 * 40 samples. These parts produce at the output of the coder:
53 */
54
55 word * Nc, /* [0..3] LTP lag OUT */
56 word * bc, /* [0..3] coded LTP gain OUT */
57 word * Mc, /* [0..3] RPE grid selection OUT */
58 word * xmaxc,/* [0..3] Coded maximum amplitude OUT */
59 word * xMc /* [13*4] normalized RPE samples OUT */
60)
61{
62 int k;
63 word * dp = S->dp0 + 120; /* [ -120...-1 ] */
64 word * dpp = dp; /* [ 0...39 ] */
65
66 static word e[50];
67
68 word so[160];
69
70 Gsm_Preprocess (S, s, so);
71 Gsm_LPC_Analysis (S, so, LARc);
72 Gsm_Short_Term_Analysis_Filter (S, LARc, so);
73
74 for (k = 0; k <= 3; k++, xMc += 13) {
75
76 Gsm_Long_Term_Predictor ( S,
77 so+k*40, /* d [0..39] IN */
78 dp, /* dp [-120..-1] IN */
79 e + 5, /* e [0..39] OUT */
80 dpp, /* dpp [0..39] OUT */
81 Nc++,
82 bc++);
83
84 Gsm_RPE_Encoding ( S,
85 e + 5, /* e ][0..39][ IN/OUT */
86 xmaxc++, Mc++, xMc );
87 /*
88 * Gsm_Update_of_reconstructed_short_time_residual_signal
89 * ( dpp, e + 5, dp );
90 */
91
92 { register int i;
93 register longword ltmp;
94 for (i = 0; i <= 39; i++)
95 dp[ i ] = GSM_ADD( e[5 + i], dpp[i] );
96 }
97 dp += 40;
98 dpp += 40;
99
100 }
101 (void)memcpy( (char *)S->dp0, (char *)(S->dp0 + 160),
102 120 * sizeof(*S->dp0) );
103}