xref: /aosp_15_r20/external/webrtc/modules/audio_coding/codecs/ilbc/enh_upsample.c (revision d9f758449e529ab9291ac668be2861e7a55c2422)
1 /*
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 "modules/audio_coding/codecs/ilbc/enh_upsample.h"
20 
21 #include "modules/audio_coding/codecs/ilbc/constants.h"
22 #include "modules/audio_coding/codecs/ilbc/defines.h"
23 
24 /*----------------------------------------------------------------*
25  * upsample finite array assuming zeros outside bounds
26  *---------------------------------------------------------------*/
27 
WebRtcIlbcfix_EnhUpsample(int32_t * useq1,int16_t * seq1)28 void WebRtcIlbcfix_EnhUpsample(
29     int32_t *useq1, /* (o) upsampled output sequence */
30     int16_t *seq1 /* (i) unupsampled sequence */
31                                 ){
32   int j;
33   int32_t *pu1, *pu11;
34   int16_t *ps, *w16tmp;
35   const int16_t *pp;
36 
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;
44     *pu11 = (*ps--) * *pp++;
45     *pu11 += (*ps--) * *pp++;
46     *pu11 += (*ps--) * *pp++;
47     pu11+=ENH_UPS0;
48     /* i = 3 */
49     pp=WebRtcIlbcfix_kEnhPolyPhaser[j]+1;
50     ps=seq1+3;
51     *pu11 = (*ps--) * *pp++;
52     *pu11 += (*ps--) * *pp++;
53     *pu11 += (*ps--) * *pp++;
54     *pu11 += (*ps--) * *pp++;
55     pu11+=ENH_UPS0;
56     /* i = 4 */
57     pp=WebRtcIlbcfix_kEnhPolyPhaser[j]+1;
58     ps=seq1+4;
59     *pu11 = (*ps--) * *pp++;
60     *pu11 += (*ps--) * *pp++;
61     *pu11 += (*ps--) * *pp++;
62     *pu11 += (*ps--) * *pp++;
63     *pu11 += (*ps--) * *pp++;
64     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++) {
84      *pu += (*ps--) * *pp++;
85      }
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;
97     *pu11 = (*ps--) * *pp++;
98     *pu11 += (*ps--) * *pp++;
99     *pu11 += (*ps--) * *pp++;
100     *pu11 += (*ps--) * *pp++;
101     pu11+=ENH_UPS0;
102     /* i = 2 */
103     pp = WebRtcIlbcfix_kEnhPolyPhaser[j]+3;
104     ps = w16tmp;
105     *pu11 = (*ps--) * *pp++;
106     *pu11 += (*ps--) * *pp++;
107     *pu11 += (*ps--) * *pp++;
108     pu11+=ENH_UPS0;
109 
110     pu1++;
111   }
112 }
113