blob: c1f04d2287c8d8a1fc087bc9b288eb097d61cf88 [file] [log] [blame]
niklase@google.com470e71d2011-07-07 08:21:25 +00001/*
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_SplitVq.c
16
17******************************************************************/
18
Timothy Gu31117832020-12-18 22:25:57 -080019#include "modules/audio_coding/codecs/ilbc/split_vq.h"
20
Mirko Bonadei06c2aa92018-02-01 15:11:41 +010021#include "modules/audio_coding/codecs/ilbc/constants.h"
Timothy Gu31117832020-12-18 22:25:57 -080022#include "modules/audio_coding/codecs/ilbc/defines.h"
Mirko Bonadei06c2aa92018-02-01 15:11:41 +010023#include "modules/audio_coding/codecs/ilbc/vq3.h"
24#include "modules/audio_coding/codecs/ilbc/vq4.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000025
26/*----------------------------------------------------------------*
27 * split vector quantization
28 *---------------------------------------------------------------*/
29
30void WebRtcIlbcfix_SplitVq(
pbos@webrtc.org0946a562013-04-09 00:28:06 +000031 int16_t *qX, /* (o) the quantized vector in Q13 */
32 int16_t *index, /* (o) a vector of indexes for all vector
niklase@google.com470e71d2011-07-07 08:21:25 +000033 codebooks in the split */
pbos@webrtc.org0946a562013-04-09 00:28:06 +000034 int16_t *X, /* (i) the vector to quantize */
35 int16_t *CB, /* (i) the quantizer codebook in Q13 */
36 int16_t *dim, /* (i) the dimension of X and qX */
37 int16_t *cbsize /* (i) the number of vectors in the codebook */
niklase@google.com470e71d2011-07-07 08:21:25 +000038 ) {
39
pbos@webrtc.org0946a562013-04-09 00:28:06 +000040 int16_t *qXPtr, *indexPtr, *CBPtr, *XPtr;
niklase@google.com470e71d2011-07-07 08:21:25 +000041
42 /* Quantize X with the 3 vectror quantization tables */
43
44 qXPtr=qX;
45 indexPtr=index;
46 CBPtr=CB;
47 XPtr=X;
48 WebRtcIlbcfix_Vq3(qXPtr, indexPtr, CBPtr, XPtr, cbsize[0]);
49
50 qXPtr+=3;
51 indexPtr+=1;
52 CBPtr+=(dim[0]*cbsize[0]);
53 XPtr+=3;
54 WebRtcIlbcfix_Vq3(qXPtr, indexPtr, CBPtr, XPtr, cbsize[1]);
55
56 qXPtr+=3;
57 indexPtr+=1;
58 CBPtr+=(dim[1]*cbsize[1]);
59 XPtr+=3;
60 WebRtcIlbcfix_Vq4(qXPtr, indexPtr, CBPtr, XPtr, cbsize[2]);
61
62 return;
63}