niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 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 | |
Mirko Bonadei | 06c2aa9 | 2018-02-01 15:11:41 +0100 | [diff] [blame^] | 19 | #include "modules/audio_coding/codecs/ilbc/defines.h" |
| 20 | #include "modules/audio_coding/codecs/ilbc/constants.h" |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 21 | |
| 22 | /*----------------------------------------------------------------* |
| 23 | * upsample finite array assuming zeros outside bounds |
| 24 | *---------------------------------------------------------------*/ |
| 25 | |
| 26 | void WebRtcIlbcfix_EnhUpsample( |
pbos@webrtc.org | 0946a56 | 2013-04-09 00:28:06 +0000 | [diff] [blame] | 27 | int32_t *useq1, /* (o) upsampled output sequence */ |
| 28 | int16_t *seq1 /* (i) unupsampled sequence */ |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 29 | ){ |
| 30 | int j; |
pbos@webrtc.org | 0946a56 | 2013-04-09 00:28:06 +0000 | [diff] [blame] | 31 | int32_t *pu1, *pu11; |
| 32 | int16_t *ps, *w16tmp; |
| 33 | const int16_t *pp; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 34 | |
| 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.org | ba97ea6 | 2015-02-13 09:51:40 +0000 | [diff] [blame] | 42 | *pu11 = (*ps--) * *pp++; |
| 43 | *pu11 += (*ps--) * *pp++; |
| 44 | *pu11 += (*ps--) * *pp++; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 45 | pu11+=ENH_UPS0; |
| 46 | /* i = 3 */ |
| 47 | pp=WebRtcIlbcfix_kEnhPolyPhaser[j]+1; |
| 48 | ps=seq1+3; |
bjornv@webrtc.org | ba97ea6 | 2015-02-13 09:51:40 +0000 | [diff] [blame] | 49 | *pu11 = (*ps--) * *pp++; |
| 50 | *pu11 += (*ps--) * *pp++; |
| 51 | *pu11 += (*ps--) * *pp++; |
| 52 | *pu11 += (*ps--) * *pp++; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 53 | pu11+=ENH_UPS0; |
| 54 | /* i = 4 */ |
| 55 | pp=WebRtcIlbcfix_kEnhPolyPhaser[j]+1; |
| 56 | ps=seq1+4; |
bjornv@webrtc.org | ba97ea6 | 2015-02-13 09:51:40 +0000 | [diff] [blame] | 57 | *pu11 = (*ps--) * *pp++; |
| 58 | *pu11 += (*ps--) * *pp++; |
| 59 | *pu11 += (*ps--) * *pp++; |
| 60 | *pu11 += (*ps--) * *pp++; |
| 61 | *pu11 += (*ps--) * *pp++; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 62 | 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.org | ba97ea6 | 2015-02-13 09:51:40 +0000 | [diff] [blame] | 82 | *pu += (*ps--) * *pp++; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 83 | } |
| 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.org | ba97ea6 | 2015-02-13 09:51:40 +0000 | [diff] [blame] | 95 | *pu11 = (*ps--) * *pp++; |
| 96 | *pu11 += (*ps--) * *pp++; |
| 97 | *pu11 += (*ps--) * *pp++; |
| 98 | *pu11 += (*ps--) * *pp++; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 99 | pu11+=ENH_UPS0; |
| 100 | /* i = 2 */ |
| 101 | pp = WebRtcIlbcfix_kEnhPolyPhaser[j]+3; |
| 102 | ps = w16tmp; |
bjornv@webrtc.org | ba97ea6 | 2015-02-13 09:51:40 +0000 | [diff] [blame] | 103 | *pu11 = (*ps--) * *pp++; |
| 104 | *pu11 += (*ps--) * *pp++; |
| 105 | *pu11 += (*ps--) * *pp++; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 106 | pu11+=ENH_UPS0; |
| 107 | |
| 108 | pu1++; |
| 109 | } |
| 110 | } |