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_FilteredCbVecs.c
16 
17 ******************************************************************/
18 
19 #include "defines.h"
20 #include "constants.h"
21 
22 /*----------------------------------------------------------------*
23  *  Construct an additional codebook vector by filtering the
24  *  initial codebook buffer. This vector is then used to expand
25  *  the codebook with an additional section.
26  *---------------------------------------------------------------*/
27 
WebRtcIlbcfix_FilteredCbVecs(int16_t * cbvectors,int16_t * CBmem,size_t lMem,size_t samples)28 void WebRtcIlbcfix_FilteredCbVecs(
29     int16_t *cbvectors, /* (o) Codebook vector for the higher section */
30     int16_t *CBmem,  /* (i) Codebook memory that is filtered to create a
31                                            second CB section */
32     size_t lMem,  /* (i) Length of codebook memory */
33     size_t samples    /* (i) Number of samples to filter */
34                                   ) {
35 
36   /* Set up the memory, start with zero state */
37   WebRtcSpl_MemSetW16(CBmem+lMem, 0, CB_HALFFILTERLEN);
38   WebRtcSpl_MemSetW16(CBmem-CB_HALFFILTERLEN, 0, CB_HALFFILTERLEN);
39   WebRtcSpl_MemSetW16(cbvectors, 0, lMem-samples);
40 
41   /* Filter to obtain the filtered CB memory */
42 
43   WebRtcSpl_FilterMAFastQ12(
44       CBmem+CB_HALFFILTERLEN+lMem-samples, cbvectors+lMem-samples,
45       (int16_t*)WebRtcIlbcfix_kCbFiltersRev, CB_FILTERLEN, samples);
46 
47   return;
48 }
49