summaryrefslogtreecommitdiffstats
path: root/media/libstagefright/codecs/amrwbenc/src/pred_lt4.c
blob: 8404cf9d4d5c618813721b8da634863f1e659820 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
/*
 ** Copyright 2003-2010, VisualOn, Inc.
 **
 ** Licensed under the Apache License, Version 2.0 (the "License");
 ** you may not use this file except in compliance with the License.
 ** You may obtain a copy of the License at
 **
 **     http://www.apache.org/licenses/LICENSE-2.0
 **
 ** Unless required by applicable law or agreed to in writing, software
 ** distributed under the License is distributed on an "AS IS" BASIS,
 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 ** See the License for the specific language governing permissions and
 ** limitations under the License.
 */

/***********************************************************************
*      File: pred_lt4.c                                                *
*                                                                      *
*      Description: Compute the result of long term prediction with    *
*      fractional interpolation of resolution 1/4                      *
*      on return exc[0..L_subr-1] contains the interpolated signal     *
*      (adaptive codebook excitation)                                  *
*                                                                      *
************************************************************************/

#include "typedef.h"
#include "basic_op.h"

#define UP_SAMP      4
#define L_INTERPOL2  16

/* 1/4 resolution interpolation filter (-3 dB at 0.856*fs/2) in Q14 */

Word16 inter4_2[4][32] =
{
	{0,-2,4,-2,-10,38,-88,165,-275,424,-619,871,-1207,1699,-2598,5531,14031,-2147,780,-249,
	-16,153,-213,226,-209,175,-133,91,-55,28,-10,2},

	{1,-7,19,-33,47,-52,43,-9,-60,175,-355,626,-1044,1749,-3267,10359,10359,-3267,1749,-1044,
	626,-355,175,-60,-9,43,-52,47,-33,19, -7, 1},

	{2,-10,28,-55,91,-133,175,-209,226,-213,153,-16,-249,780,-2147,14031,5531,-2598,1699,-1207,
	871,-619,424,-275,165,-88,38,-10,-2,4,-2,0},

	{1,-7,22,-49,92,-153,231,-325,431,-544,656,-762,853,-923,968,15401,968,-923,853,-762,
	656,-544,431,-325,231,-153,92,-49,22,-7, 1, 0}

};

void Pred_lt4(
		Word16 exc[],                         /* in/out: excitation buffer */
		Word16 T0,                            /* input : integer pitch lag */
		Word16 frac,                          /* input : fraction of lag   */
		Word16 L_subfr                        /* input : subframe size     */
	     )
{
	Word16 j, k, *x;
	Word32 L_sum;
	Word16 *ptr, *ptr1;
	Word16 *ptr2;

	x = exc - T0;
	frac = -frac;
	if (frac < 0)
	{
		frac += UP_SAMP;
		x--;
	}
	x -= 15;                                     /* x = L_INTERPOL2 - 1 */
	k = 3 - frac;                                /* k = UP_SAMP - 1 - frac */

	ptr2 = &(inter4_2[k][0]);
	for (j = 0; j < L_subfr; j++)
	{
		ptr = ptr2;
		ptr1 = x;
		L_sum  = vo_mult32((*ptr1++), (*ptr++));
		L_sum += vo_mult32((*ptr1++), (*ptr++));
		L_sum += vo_mult32((*ptr1++), (*ptr++));
		L_sum += vo_mult32((*ptr1++), (*ptr++));
		L_sum += vo_mult32((*ptr1++), (*ptr++));
		L_sum += vo_mult32((*ptr1++), (*ptr++));
		L_sum += vo_mult32((*ptr1++), (*ptr++));
		L_sum += vo_mult32((*ptr1++), (*ptr++));
		L_sum += vo_mult32((*ptr1++), (*ptr++));
		L_sum += vo_mult32((*ptr1++), (*ptr++));
		L_sum += vo_mult32((*ptr1++), (*ptr++));
		L_sum += vo_mult32((*ptr1++), (*ptr++));
		L_sum += vo_mult32((*ptr1++), (*ptr++));
		L_sum += vo_mult32((*ptr1++), (*ptr++));
		L_sum += vo_mult32((*ptr1++), (*ptr++));
		L_sum += vo_mult32((*ptr1++), (*ptr++));
		L_sum += vo_mult32((*ptr1++), (*ptr++));
		L_sum += vo_mult32((*ptr1++), (*ptr++));
		L_sum += vo_mult32((*ptr1++), (*ptr++));
		L_sum += vo_mult32((*ptr1++), (*ptr++));
		L_sum += vo_mult32((*ptr1++), (*ptr++));
		L_sum += vo_mult32((*ptr1++), (*ptr++));
		L_sum += vo_mult32((*ptr1++), (*ptr++));
		L_sum += vo_mult32((*ptr1++), (*ptr++));
		L_sum += vo_mult32((*ptr1++), (*ptr++));
		L_sum += vo_mult32((*ptr1++), (*ptr++));
		L_sum += vo_mult32((*ptr1++), (*ptr++));
		L_sum += vo_mult32((*ptr1++), (*ptr++));
		L_sum += vo_mult32((*ptr1++), (*ptr++));
		L_sum += vo_mult32((*ptr1++), (*ptr++));
		L_sum += vo_mult32((*ptr1++), (*ptr++));
		L_sum += vo_mult32((*ptr1++), (*ptr++));

		L_sum = L_shl2(L_sum, 2);
		exc[j] = extract_h(L_add(L_sum, 0x8000));
		x++;
	}

	return;
}