Home | History | Annotate | Download | only in ilbc
      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 "defines.h"
     20 #include "constants.h"
     21 
     22 /*----------------------------------------------------------------*
     23  * upsample finite array assuming zeros outside bounds
     24  *---------------------------------------------------------------*/
     25 
     26 void WebRtcIlbcfix_EnhUpsample(
     27     int32_t *useq1, /* (o) upsampled output sequence */
     28     int16_t *seq1 /* (i) unupsampled sequence */
     29                                 ){
     30   int j;
     31   int32_t *pu1, *pu11;
     32   int16_t *ps, *w16tmp;
     33   const int16_t *pp;
     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;
     42     (*pu11) = WEBRTC_SPL_MUL_16_16(*ps--,*pp++);
     43     (*pu11) += WEBRTC_SPL_MUL_16_16(*ps--,*pp++);
     44     (*pu11) += WEBRTC_SPL_MUL_16_16(*ps--,*pp++);
     45     pu11+=ENH_UPS0;
     46     /* i = 3 */
     47     pp=WebRtcIlbcfix_kEnhPolyPhaser[j]+1;
     48     ps=seq1+3;
     49     (*pu11) = WEBRTC_SPL_MUL_16_16(*ps--,*pp++);
     50     (*pu11) += WEBRTC_SPL_MUL_16_16(*ps--,*pp++);
     51     (*pu11) += WEBRTC_SPL_MUL_16_16(*ps--,*pp++);
     52     (*pu11) += WEBRTC_SPL_MUL_16_16(*ps--,*pp++);
     53     pu11+=ENH_UPS0;
     54     /* i = 4 */
     55     pp=WebRtcIlbcfix_kEnhPolyPhaser[j]+1;
     56     ps=seq1+4;
     57     (*pu11) = WEBRTC_SPL_MUL_16_16(*ps--,*pp++);
     58     (*pu11) += WEBRTC_SPL_MUL_16_16(*ps--,*pp++);
     59     (*pu11) += WEBRTC_SPL_MUL_16_16(*ps--,*pp++);
     60     (*pu11) += WEBRTC_SPL_MUL_16_16(*ps--,*pp++);
     61     (*pu11) += WEBRTC_SPL_MUL_16_16(*ps--,*pp++);
     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++) {
     82      *pu += WEBRTC_SPL_MUL_16_16(*ps--, *pp++);
     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;
     95     (*pu11) = WEBRTC_SPL_MUL_16_16(*ps--, *pp++);
     96     (*pu11) += WEBRTC_SPL_MUL_16_16(*ps--, *pp++);
     97     (*pu11) += WEBRTC_SPL_MUL_16_16(*ps--, *pp++);
     98     (*pu11) += WEBRTC_SPL_MUL_16_16(*ps--, *pp++);
     99     pu11+=ENH_UPS0;
    100     /* i = 2 */
    101     pp = WebRtcIlbcfix_kEnhPolyPhaser[j]+3;
    102     ps = w16tmp;
    103     (*pu11) = WEBRTC_SPL_MUL_16_16(*ps--, *pp++);
    104     (*pu11) += WEBRTC_SPL_MUL_16_16(*ps--, *pp++);
    105     (*pu11) += WEBRTC_SPL_MUL_16_16(*ps--, *pp++);
    106     pu11+=ENH_UPS0;
    107 
    108     pu1++;
    109   }
    110 }
    111