Home | History | Annotate | Download | only in source
      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  * encode_lpc_swb.h
     13  *
     14  * This file contains declaration of functions used to
     15  * encode LPC parameters (Shape & gain) of the upper band.
     16  *
     17  */
     18 
     19 #ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_ENCODE_LPC_SWB_H_
     20 #define WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_ENCODE_LPC_SWB_H_
     21 
     22 #include "typedefs.h"
     23 #include "settings.h"
     24 #include "structs.h"
     25 
     26 
     27 /******************************************************************************
     28  * WebRtcIsac_RemoveLarMean()
     29  *
     30  * Remove the means from LAR coefficients.
     31  *
     32  * Input:
     33  *      -lar                : pointer to lar vectors. LAR vectors are
     34  *                            concatenated.
     35  *      -bandwidth          : indicates if the given LAR vectors belong
     36  *                            to SWB-12kHz or SWB-16kHz.
     37  *
     38  * Output:
     39  *      -lar                : pointer to mean-removed LAR:s.
     40  *
     41  *
     42  */
     43 WebRtc_Word16 WebRtcIsac_RemoveLarMean(
     44     double*     lar,
     45     WebRtc_Word16 bandwidth);
     46 
     47 /******************************************************************************
     48  * WebRtcIsac_DecorrelateIntraVec()
     49  *
     50  * Remove the correlation amonge the components of LAR vectors. If LAR vectors
     51  * of one frame are put in a matrix where each column is a LAR vector of a
     52  * sub-frame, then this is equivalent to multiplying the LAR matrix with
     53  * a decorrelting mtrix from left.
     54  *
     55  * Input:
     56  *      -inLar              : pointer to mean-removed LAR vecrtors.
     57  *      -bandwidth          : indicates if the given LAR vectors belong
     58  *                            to SWB-12kHz or SWB-16kHz.
     59  *
     60  * Output:
     61  *      -out                : decorrelated LAR vectors.
     62  */
     63 WebRtc_Word16 WebRtcIsac_DecorrelateIntraVec(
     64     const double* inLAR,
     65     double*       out,
     66     WebRtc_Word16   bandwidth);
     67 
     68 
     69 /******************************************************************************
     70  * WebRtcIsac_DecorrelateInterVec()
     71  *
     72  * Remover the correlation among mean-removed LAR vectors. If LAR vectors
     73  * of one frame are put in a matrix where each column is a LAR vector of a
     74  * sub-frame, then this is equivalent to multiplying the LAR matrix with
     75  * a decorrelting mtrix from right.
     76  *
     77  * Input:
     78  *      -data               : pointer to matrix of LAR vectors. The matrix
     79  *                            is stored column-wise.
     80  *      -bandwidth          : indicates if the given LAR vectors belong
     81  *                            to SWB-12kHz or SWB-16kHz.
     82  *
     83  * Output:
     84  *      -out                : decorrelated LAR vectors.
     85  */
     86 WebRtc_Word16 WebRtcIsac_DecorrelateInterVec(
     87     const double* data,
     88     double*       out,
     89     WebRtc_Word16   bandwidth);
     90 
     91 
     92 /******************************************************************************
     93  * WebRtcIsac_QuantizeUncorrLar()
     94  *
     95  * Quantize the uncorrelated parameters.
     96  *
     97  * Input:
     98  *      -data               : uncorrelated LAR vectors.
     99  *      -bandwidth          : indicates if the given LAR vectors belong
    100  *                            to SWB-12kHz or SWB-16kHz.
    101  *
    102  * Output:
    103  *      -data               : quantized version of the input.
    104  *      -idx                : pointer to quantization indices.
    105  */
    106 double WebRtcIsac_QuantizeUncorrLar(
    107     double*     data,
    108     int*        idx,
    109     WebRtc_Word16 bandwidth);
    110 
    111 
    112 /******************************************************************************
    113  * WebRtcIsac_CorrelateIntraVec()
    114  *
    115  * This is the inverse of WebRtcIsac_DecorrelateIntraVec().
    116  *
    117  * Input:
    118  *      -data               : uncorrelated parameters.
    119  *      -bandwidth          : indicates if the given LAR vectors belong
    120  *                            to SWB-12kHz or SWB-16kHz.
    121  *
    122  * Output:
    123  *      -out                : correlated parametrs.
    124  */
    125 WebRtc_Word16 WebRtcIsac_CorrelateIntraVec(
    126     const double* data,
    127     double*       out,
    128     WebRtc_Word16   bandwidth);
    129 
    130 
    131 /******************************************************************************
    132  * WebRtcIsac_CorrelateInterVec()
    133  *
    134  * This is the inverse of WebRtcIsac_DecorrelateInterVec().
    135  *
    136  * Input:
    137  *      -data
    138  *      -bandwidth          : indicates if the given LAR vectors belong
    139  *                            to SWB-12kHz or SWB-16kHz.
    140  *
    141  * Output:
    142  *      -out                : correlated parametrs.
    143  */
    144 WebRtc_Word16 WebRtcIsac_CorrelateInterVec(
    145     const double* data,
    146     double*       out,
    147     WebRtc_Word16   bandwidth);
    148 
    149 
    150 /******************************************************************************
    151  * WebRtcIsac_AddLarMean()
    152  *
    153  * This is the inverse of WebRtcIsac_RemoveLarMean()
    154  *
    155  * Input:
    156  *      -data               : pointer to mean-removed LAR:s.
    157  *      -bandwidth          : indicates if the given LAR vectors belong
    158  *                            to SWB-12kHz or SWB-16kHz.
    159  *
    160  * Output:
    161  *      -data               : pointer to LARs.
    162  */
    163 WebRtc_Word16 WebRtcIsac_AddLarMean(
    164     double*     data,
    165     WebRtc_Word16 bandwidth);
    166 
    167 
    168 /******************************************************************************
    169  * WebRtcIsac_DequantizeLpcParam()
    170  *
    171  * Get the quantized value of uncorrelated LARs given the quantization indices.
    172  *
    173  * Input:
    174  *      -idx                : pointer to quantiztion indices.
    175  *      -bandwidth          : indicates if the given LAR vectors belong
    176  *                            to SWB-12kHz or SWB-16kHz.
    177  *
    178  * Output:
    179  *      -out                : pointer to quantized values.
    180  */
    181 WebRtc_Word16 WebRtcIsac_DequantizeLpcParam(
    182     const int*  idx,
    183     double*     out,
    184     WebRtc_Word16 bandwidth);
    185 
    186 
    187 /******************************************************************************
    188  * WebRtcIsac_ToLogDomainRemoveMean()
    189  *
    190  * Transform the LPC gain to log domain then remove the mean value.
    191  *
    192  * Input:
    193  *      -lpcGain            : pointer to LPC Gain, expecting 6 LPC gains
    194  *
    195  * Output:
    196  *      -lpcGain            : mean-removed in log domain.
    197  */
    198 WebRtc_Word16 WebRtcIsac_ToLogDomainRemoveMean(
    199     double* lpGains);
    200 
    201 
    202 /******************************************************************************
    203  * WebRtcIsac_DecorrelateLPGain()
    204  *
    205  * Decorrelate LPC gains. There are 6 LPC Gains per frame. This is like
    206  * multiplying gain vector with decorrelating matrix.
    207  *
    208  * Input:
    209  *      -data               : LPC gain in log-domain with mean removed.
    210  *
    211  * Output:
    212  *      -out                : decorrelated parameters.
    213  */
    214 WebRtc_Word16 WebRtcIsac_DecorrelateLPGain(
    215     const double* data,
    216     double*       out);
    217 
    218 
    219 /******************************************************************************
    220  * WebRtcIsac_QuantizeLpcGain()
    221  *
    222  * Quantize the decorrelated log-domain gains.
    223  *
    224  * Input:
    225  *      -lpcGain            : uncorrelated LPC gains.
    226  *
    227  * Output:
    228  *      -idx                : quantization indices
    229  *      -lpcGain            : quantized value of the inpt.
    230  */
    231 double WebRtcIsac_QuantizeLpcGain(
    232     double* lpGains,
    233     int*    idx);
    234 
    235 
    236 /******************************************************************************
    237  * WebRtcIsac_DequantizeLpcGain()
    238  *
    239  * Get the quantized values given the quantization indices.
    240  *
    241  * Input:
    242  *      -idx                : pointer to quantization indices.
    243  *
    244  * Output:
    245  *      -lpcGains           : quantized values of the given parametes.
    246  */
    247 WebRtc_Word16 WebRtcIsac_DequantizeLpcGain(
    248     const int* idx,
    249     double*    lpGains);
    250 
    251 
    252 /******************************************************************************
    253  * WebRtcIsac_CorrelateLpcGain()
    254  *
    255  * This is the inverse of WebRtcIsac_DecorrelateLPGain().
    256  *
    257  * Input:
    258  *      -data               : decorrelated parameters.
    259  *
    260  * Output:
    261  *      -out                : correlated parameters.
    262  */
    263 WebRtc_Word16 WebRtcIsac_CorrelateLpcGain(
    264     const double* data,
    265     double*       out);
    266 
    267 
    268 /******************************************************************************
    269  * WebRtcIsac_AddMeanToLinearDomain()
    270  *
    271  * This is the inverse of WebRtcIsac_ToLogDomainRemoveMean().
    272  *
    273  * Input:
    274  *      -lpcGain            : LPC gain in log-domain & mean removed
    275  *
    276  * Output:
    277  *      -lpcGain            : LPC gain in normal domain.
    278  */
    279 WebRtc_Word16 WebRtcIsac_AddMeanToLinearDomain(
    280     double* lpcGains);
    281 
    282 
    283 #endif  // WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_ENCODE_LPC_SWB_H_
    284