xref: /aosp_15_r20/external/webrtc/modules/audio_coding/codecs/ilbc/index_conv_enc.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  IiLBC Speech Coder ANSI-C Source Code
14 
15  WebRtcIlbcfix_IndexConvEnc.c
16 
17 ******************************************************************/
18 
19 #include "modules/audio_coding/codecs/ilbc/index_conv_enc.h"
20 
21 #include "modules/audio_coding/codecs/ilbc/defines.h"
22 
23 /*----------------------------------------------------------------*
24  *  Convert the codebook indexes to make the search easier
25  *---------------------------------------------------------------*/
26 
WebRtcIlbcfix_IndexConvEnc(int16_t * index)27 void WebRtcIlbcfix_IndexConvEnc(
28     int16_t *index   /* (i/o) Codebook indexes */
29                                 ){
30   int k;
31 
32   for (k=4;k<6;k++) {
33     /* Readjust the second and third codebook index so that it is
34        packetized into 7 bits (before it was put in lag-wise the same
35        way as for the first codebook which uses 8 bits)
36     */
37     if ((index[k]>=108)&&(index[k]<172)) {
38       index[k]-=64;
39     } else if (index[k]>=236) {
40       index[k]-=128;
41     } else {
42       /* ERROR */
43     }
44   }
45 }
46