blob: cd3d0a4db1f1f3309f1e5045143eeb40536d18c4 [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
Timothy Gu31117832020-12-18 22:25:57 -080019#include "modules/audio_coding/codecs/ilbc/enh_upsample.h"
20
Mirko Bonadei06c2aa92018-02-01 15:11:41 +010021#include "modules/audio_coding/codecs/ilbc/constants.h"
Timothy Gu31117832020-12-18 22:25:57 -080022#include "modules/audio_coding/codecs/ilbc/defines.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000023
24/*----------------------------------------------------------------*
25 * upsample finite array assuming zeros outside bounds
26 *---------------------------------------------------------------*/
27
28void WebRtcIlbcfix_EnhUpsample(
pbos@webrtc.org0946a562013-04-09 00:28:06 +000029 int32_t *useq1, /* (o) upsampled output sequence */
30 int16_t *seq1 /* (i) unupsampled sequence */
niklase@google.com470e71d2011-07-07 08:21:25 +000031 ){
32 int j;
pbos@webrtc.org0946a562013-04-09 00:28:06 +000033 int32_t *pu1, *pu11;
34 int16_t *ps, *w16tmp;
35 const int16_t *pp;
niklase@google.com470e71d2011-07-07 08:21:25 +000036
37 /* filtering: filter overhangs left side of sequence */
38 pu1=useq1;
39 for (j=0;j<ENH_UPS0; j++) {
40 pu11=pu1;
41 /* i = 2 */
42 pp=WebRtcIlbcfix_kEnhPolyPhaser[j]+1;
43 ps=seq1+2;
bjornv@webrtc.orgba97ea62015-02-13 09:51:40 +000044 *pu11 = (*ps--) * *pp++;
45 *pu11 += (*ps--) * *pp++;
46 *pu11 += (*ps--) * *pp++;
niklase@google.com470e71d2011-07-07 08:21:25 +000047 pu11+=ENH_UPS0;
48 /* i = 3 */
49 pp=WebRtcIlbcfix_kEnhPolyPhaser[j]+1;
50 ps=seq1+3;
bjornv@webrtc.orgba97ea62015-02-13 09:51:40 +000051 *pu11 = (*ps--) * *pp++;
52 *pu11 += (*ps--) * *pp++;
53 *pu11 += (*ps--) * *pp++;
54 *pu11 += (*ps--) * *pp++;
niklase@google.com470e71d2011-07-07 08:21:25 +000055 pu11+=ENH_UPS0;
56 /* i = 4 */
57 pp=WebRtcIlbcfix_kEnhPolyPhaser[j]+1;
58 ps=seq1+4;
bjornv@webrtc.orgba97ea62015-02-13 09:51:40 +000059 *pu11 = (*ps--) * *pp++;
60 *pu11 += (*ps--) * *pp++;
61 *pu11 += (*ps--) * *pp++;
62 *pu11 += (*ps--) * *pp++;
63 *pu11 += (*ps--) * *pp++;
niklase@google.com470e71d2011-07-07 08:21:25 +000064 pu1++;
65 }
66
67 /* filtering: simple convolution=inner products
68 (not needed since the sequence is so short)
69 */
70
71 /* filtering: filter overhangs right side of sequence */
72
73 /* Code with loops, which is equivivalent to the expanded version below
74
75 filterlength = 5;
76 hf1 = 2;
77 for(j=0;j<ENH_UPS0; j++){
78 pu = useq1 + (filterlength-hfl)*ENH_UPS0 + j;
79 for(i=1; i<=hfl; i++){
80 *pu=0;
81 pp = polyp[j]+i;
82 ps = seq1+dim1-1;
83 for(k=0;k<filterlength-i;k++) {
bjornv@webrtc.orgba97ea62015-02-13 09:51:40 +000084 *pu += (*ps--) * *pp++;
niklase@google.com470e71d2011-07-07 08:21:25 +000085 }
86 pu+=ENH_UPS0;
87 }
88 }
89 */
90 pu1 = useq1 + 12;
91 w16tmp = seq1+4;
92 for (j=0;j<ENH_UPS0; j++) {
93 pu11 = pu1;
94 /* i = 1 */
95 pp = WebRtcIlbcfix_kEnhPolyPhaser[j]+2;
96 ps = w16tmp;
bjornv@webrtc.orgba97ea62015-02-13 09:51:40 +000097 *pu11 = (*ps--) * *pp++;
98 *pu11 += (*ps--) * *pp++;
99 *pu11 += (*ps--) * *pp++;
100 *pu11 += (*ps--) * *pp++;
niklase@google.com470e71d2011-07-07 08:21:25 +0000101 pu11+=ENH_UPS0;
102 /* i = 2 */
103 pp = WebRtcIlbcfix_kEnhPolyPhaser[j]+3;
104 ps = w16tmp;
bjornv@webrtc.orgba97ea62015-02-13 09:51:40 +0000105 *pu11 = (*ps--) * *pp++;
106 *pu11 += (*ps--) * *pp++;
107 *pu11 += (*ps--) * *pp++;
niklase@google.com470e71d2011-07-07 08:21:25 +0000108 pu11+=ENH_UPS0;
109
110 pu1++;
111 }
112}