1 /* Copyright (C) 2002 Jean-Marc Valin & David Rowe */
2 /**
3    @file cb_search.h
4    @brief Overlapped codebook search
5 */
6 /*
7    Redistribution and use in source and binary forms, with or without
8    modification, are permitted provided that the following conditions
9    are met:
10 
11    - Redistributions of source code must retain the above copyright
12    notice, this list of conditions and the following disclaimer.
13 
14    - Redistributions in binary form must reproduce the above copyright
15    notice, this list of conditions and the following disclaimer in the
16    documentation and/or other materials provided with the distribution.
17 
18    - Neither the name of the Xiph.org Foundation nor the names of its
19    contributors may be used to endorse or promote products derived from
20    this software without specific prior written permission.
21 
22    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23    ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24    LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25    A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR
26    CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
27    EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
28    PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
29    PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
30    LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
31    NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
32    SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 */
34 
35 #ifndef CB_SEARCH_H
36 #define CB_SEARCH_H
37 
38 #include <speex/speex_bits.h>
39 #include "arch.h"
40 
41 /** Split codebook parameters. */
42 typedef struct split_cb_params {
43    int     subvect_size;
44    int     nb_subvect;
45    const signed char  *shape_cb;
46    int     shape_bits;
47    int     have_sign;
48 } split_cb_params;
49 
50 
51 void split_cb_search_shape_sign(
52 spx_word16_t target[],             /* target vector */
53 spx_coef_t ak[],                /* LPCs for this subframe */
54 spx_coef_t awk1[],              /* Weighted LPCs for this subframe */
55 spx_coef_t awk2[],              /* Weighted LPCs for this subframe */
56 const void *par,                /* Codebook/search parameters */
57 int   p,                        /* number of LPC coeffs */
58 int   nsf,                      /* number of samples in subframe */
59 spx_sig_t *exc,
60 spx_word16_t *r,
61 SpeexBits *bits,
62 char *stack,
63 int   complexity,
64 int   update_target
65 );
66 
67 void split_cb_shape_sign_unquant(
68 spx_sig_t *exc,
69 const void *par,                /* non-overlapping codebook */
70 int   nsf,                      /* number of samples in subframe */
71 SpeexBits *bits,
72 char *stack,
73 spx_int32_t *seed
74 );
75 
76 
77 void noise_codebook_quant(
78 spx_word16_t target[],             /* target vector */
79 spx_coef_t ak[],                /* LPCs for this subframe */
80 spx_coef_t awk1[],              /* Weighted LPCs for this subframe */
81 spx_coef_t awk2[],              /* Weighted LPCs for this subframe */
82 const void *par,                /* Codebook/search parameters */
83 int   p,                        /* number of LPC coeffs */
84 int   nsf,                      /* number of samples in subframe */
85 spx_sig_t *exc,
86 spx_word16_t *r,
87 SpeexBits *bits,
88 char *stack,
89 int   complexity,
90 int   update_target
91 );
92 
93 
94 void noise_codebook_unquant(
95 spx_sig_t *exc,
96 const void *par,                /* non-overlapping codebook */
97 int   nsf,                      /* number of samples in subframe */
98 SpeexBits *bits,
99 char *stack,
100 spx_int32_t *seed
101 );
102 
103 #endif
104