blob: 929c630c680e179b4fb12d53973b6d666b7c695b [file] [log] [blame]
niklase@google.com470e71d2011-07-07 08:21:25 +00001/*
2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11/******************************************************************
12
13 iLBC Speech Coder ANSI-C Source Code
14
15 WebRtcIlbcfix_EnhUpsample.c
16
17******************************************************************/
18
19#include "defines.h"
20#include "constants.h"
21
22/*----------------------------------------------------------------*
23 * upsample finite array assuming zeros outside bounds
24 *---------------------------------------------------------------*/
25
26void WebRtcIlbcfix_EnhUpsample(
pbos@webrtc.org0946a562013-04-09 00:28:06 +000027 int32_t *useq1, /* (o) upsampled output sequence */
28 int16_t *seq1 /* (i) unupsampled sequence */
niklase@google.com470e71d2011-07-07 08:21:25 +000029 ){
30 int j;
pbos@webrtc.org0946a562013-04-09 00:28:06 +000031 int32_t *pu1, *pu11;
32 int16_t *ps, *w16tmp;
33 const int16_t *pp;
niklase@google.com470e71d2011-07-07 08:21:25 +000034
35 /* filtering: filter overhangs left side of sequence */
36 pu1=useq1;
37 for (j=0;j<ENH_UPS0; j++) {
38 pu11=pu1;
39 /* i = 2 */
40 pp=WebRtcIlbcfix_kEnhPolyPhaser[j]+1;
41 ps=seq1+2;
bjornv@webrtc.orgba97ea62015-02-13 09:51:40 +000042 *pu11 = (*ps--) * *pp++;
43 *pu11 += (*ps--) * *pp++;
44 *pu11 += (*ps--) * *pp++;
niklase@google.com470e71d2011-07-07 08:21:25 +000045 pu11+=ENH_UPS0;
46 /* i = 3 */
47 pp=WebRtcIlbcfix_kEnhPolyPhaser[j]+1;
48 ps=seq1+3;
bjornv@webrtc.orgba97ea62015-02-13 09:51:40 +000049 *pu11 = (*ps--) * *pp++;
50 *pu11 += (*ps--) * *pp++;
51 *pu11 += (*ps--) * *pp++;
52 *pu11 += (*ps--) * *pp++;
niklase@google.com470e71d2011-07-07 08:21:25 +000053 pu11+=ENH_UPS0;
54 /* i = 4 */
55 pp=WebRtcIlbcfix_kEnhPolyPhaser[j]+1;
56 ps=seq1+4;
bjornv@webrtc.orgba97ea62015-02-13 09:51:40 +000057 *pu11 = (*ps--) * *pp++;
58 *pu11 += (*ps--) * *pp++;
59 *pu11 += (*ps--) * *pp++;
60 *pu11 += (*ps--) * *pp++;
61 *pu11 += (*ps--) * *pp++;
niklase@google.com470e71d2011-07-07 08:21:25 +000062 pu1++;
63 }
64
65 /* filtering: simple convolution=inner products
66 (not needed since the sequence is so short)
67 */
68
69 /* filtering: filter overhangs right side of sequence */
70
71 /* Code with loops, which is equivivalent to the expanded version below
72
73 filterlength = 5;
74 hf1 = 2;
75 for(j=0;j<ENH_UPS0; j++){
76 pu = useq1 + (filterlength-hfl)*ENH_UPS0 + j;
77 for(i=1; i<=hfl; i++){
78 *pu=0;
79 pp = polyp[j]+i;
80 ps = seq1+dim1-1;
81 for(k=0;k<filterlength-i;k++) {
bjornv@webrtc.orgba97ea62015-02-13 09:51:40 +000082 *pu += (*ps--) * *pp++;
niklase@google.com470e71d2011-07-07 08:21:25 +000083 }
84 pu+=ENH_UPS0;
85 }
86 }
87 */
88 pu1 = useq1 + 12;
89 w16tmp = seq1+4;
90 for (j=0;j<ENH_UPS0; j++) {
91 pu11 = pu1;
92 /* i = 1 */
93 pp = WebRtcIlbcfix_kEnhPolyPhaser[j]+2;
94 ps = w16tmp;
bjornv@webrtc.orgba97ea62015-02-13 09:51:40 +000095 *pu11 = (*ps--) * *pp++;
96 *pu11 += (*ps--) * *pp++;
97 *pu11 += (*ps--) * *pp++;
98 *pu11 += (*ps--) * *pp++;
niklase@google.com470e71d2011-07-07 08:21:25 +000099 pu11+=ENH_UPS0;
100 /* i = 2 */
101 pp = WebRtcIlbcfix_kEnhPolyPhaser[j]+3;
102 ps = w16tmp;
bjornv@webrtc.orgba97ea62015-02-13 09:51:40 +0000103 *pu11 = (*ps--) * *pp++;
104 *pu11 += (*ps--) * *pp++;
105 *pu11 += (*ps--) * *pp++;
niklase@google.com470e71d2011-07-07 08:21:25 +0000106 pu11+=ENH_UPS0;
107
108 pu1++;
109 }
110}