This file is indexed.

/usr/include/sphinx3/subvq.h is in libs3decoder-dev 0.8-0ubuntu1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
/* -*- c-basic-offset: 4; indent-tabs-mode: nil -*- */
/* ====================================================================
 * Copyright (c) 1999-2004 Carnegie Mellon University.  All rights
 * reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer. 
 *
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in
 *    the documentation and/or other materials provided with the
 *    distribution.
 *
 * This work was supported in part by funding from the Defense Advanced 
 * Research Projects Agency and the National Science Foundation of the 
 * United States of America, and the CMU Sphinx Speech Consortium.
 *
 * THIS SOFTWARE IS PROVIDED BY CARNEGIE MELLON UNIVERSITY ``AS IS'' AND 
 * ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY
 * NOR ITS EMPLOYEES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 * ====================================================================
 *
 */
/*
 * subvq.h
 * 
 * **********************************************
 * CMU ARPA Speech Project
 *
 * Copyright (c) 1999 Carnegie Mellon University.
 * ALL RIGHTS RESERVED.
 * **********************************************
 * 
 * HISTORY
 * $Log$
 * Revision 1.1  2006/04/05  20:27:30  dhdfu
 * A Great Reorganzation of header files and executables
 * 
 * Revision 1.14  2006/02/22 17:43:32  arthchan2003
 * Merged from SPHINX3_5_2_RCI_IRII_BRANCH:
 * 1, vector_gautbl_free is not appropiate to be used in this case because it will free a certain piece of memory twice.
 * 2, Fixed dox-doc.
 *
 * Revision 1.13.4.1  2005/07/05 05:47:59  arthchan2003
 * Fixed dox-doc. struct level of documentation are included.
 *
 * Revision 1.13  2005/06/21 19:01:33  arthchan2003
 * Added $ keyword.
 *
 * Revision 1.3  2005/03/30 01:22:47  archan
 * Fixed mistakes in last updates. Add
 *
 * 
 * 20.Apr.2001  RAH (rhoughton@mediasite.com, ricky.houghton@cs.cmu.edu)
 *              Updated subvq_free () to free more allocated memory
 * 
 * 15-Dec-1999	M K Ravishankar (rkm@cs.cmu.edu) at Carnegie Mellon University
 * 		Moved subvq_t.{frm_sen_eval,frm_gau_eval} to cont_mgau.h.
 * 
 * 14-Dec-1999	M K Ravishankar (rkm@cs.cmu.edu) at Carnegie Mellon University
 * 		Added subvq_t.{frm_sen_eval,frm_gau_eval}.  Changed subvq_frame_eval to
 * 		return the normalization factor.
 * 
 * 06-Dec-1999	M K Ravishankar (rkm@cs.cmu.edu) at Carnegie Mellon University
 * 		Added subvq_subvec_eval_logs3().
 * 
 * 14-Oct-1999	M K Ravishankar (rkm@cs.cmu.edu) at Carnegie Mellon University
 * 		Changed ci_active flags input to sen_active in subvq_frame_eval().
 * 
 * 20-Jul-1999	M K Ravishankar (rkm@cs.cmu.edu) at Carnegie Mellon University
 * 		Added subvq_gautbl_eval_logs3().
 * 
 * 12-Mar-1999	M K Ravishankar (rkm@cs.cmu.edu) at Carnegie Mellon University
 * 		Started.
 */


#ifndef _S3_SUBVQ_H_
#define _S3_SUBVQ_H_

#include <cmd_ln.h>
#include <logmath.h>

#include "s3types.h"
#include "cont_mgau.h"
#include "vector.h"

/** \file subvq.h
    \brief Implementation of Sub-vector quantization.
*/
#ifdef __cplusplus
extern "C" {
#endif
#if 0
} /* Fool Emacs into not indenting things. */
#endif

/** \struct subvq_t
 * \brief Wrapper structures of sub-vector quantization
 */
typedef struct {
    arraysize_t origsize;	/**< origsize.r = #codebooks (or states) in original model;
				   origsize.c = max #codewords/codebook in original model. */
    int32 n_sv;			/**< #Subvectors */
    int32 vqsize;		/**< #Codewords in each subvector quantized mean/var table */
    int32 **featdim;		/**< featdim[s] = Original feature dimensions in subvector s */
    vector_gautbl_t *gautbl;	/**< Vector-quantized Gaussians table for each sub-vector */
    int32 ***map;		/**< map[i][j] = map from original codebook(i)/codeword(j) to
				   sequence of nearest vector quantized subvector codewords;
				   so, each map[i][j] is of length n_sv.  Finally, map is
				   LINEARIZED, so that it indexes into a 1-D array of scores
				   rather than a 2-D array (for faster access). */ 
    /* Working space used during evaluation. */
    float32 *subvec;		/**< Subvector extracted from feature vector */
    int32 **vqdist;		/**< vqdist[i][j] = score (distance) for i-th subvector compared
				   to j-th subvector-codeword */
    int32 *gauscore;		/**< Subvq-based approx. Gaussian density scores for one mixture */
    int32 *mgau_sl;		/**< Shortlist for one mixture (based on gauscore[]) */

    /* ARCHAN, 1111, 04, move the static global variables to the structure again. */
    /* RAH, 5.8.01, VQ_EVAL determines how many vectors are used to
     * compute the shortlist, for now this value is only relevant when n_sv =3.
     * Setting it to 1 means that only the CEP values are estimated, 2 means that 
     * CEP and delta values are estimated, 3 means all three are estimated.
     * Note, we must adjust the beam widths as we muck around with these.
     */

    int32 VQ_EVAL;              /** Number of sub-vector to be computed */
} subvq_t;


/**
 * SubVQ file format:
 *   VQParam #Original-Codebooks #Original-Codewords/codebook(max) -> #Subvectors #VQ-codewords
 *   Subvector 0 length <length> <feature-dim> <feature-dim> <feature-dim> ...
 *   Subvector 1 length <length> <feature-dim> <feature-dim> <feature-dim> ...
 *   ...
 *   Codebook 0
 *   Row 0 of mean/var values (interleaved) for subvector 0 codebook (in 1 line)
 *   Row 1 of above
 *   Row 2 of above
 *   ...
 *   Map 0
 *   Mappings for state 0 codewords (in original model) to codewords of this subvector codebook
 *   Mappings for state 1 codewords (in original model) to codewords of this subvector codebook
 *   Mappings for state 2 codewords (in original model) to codewords of this subvector codebook
 *   ...
 *   Repeated for each subvector codebook 1
 *   Repeated for each subvector codebook 2
 *   ...
 *   End
 *   @return initialized sub-vq
 */
subvq_t *subvq_init (const char *file,	/**< In: Subvector model file */
		     float64 varfloor,	/**< In: Floor to be applied to variance values */
		     int32 max_sv,	/**< In: Use the first so many subvectors instead of all;
					   if <0, use all */
		     mgau_model_t *g,	/**< In: Original model from
					   which this subvq model was
					   built, for
					   cross-validation; optional */
		     cmd_ln_t *config,
		     logmath_t *logmath
    );	



/** Deallocate sub-vector quantization */
void subvq_free (subvq_t *vq /**< In: A sub-vector model */
    );


/**
 * Evaluate senone scores for one frame.  If subvq model is available, for each senone, first
 * get approximate Gaussian density scores using it; obtain a shortlist of Gaussians using
 * these scores, then evaluate the shortlist exactly.  If no subvq model, evaluate senones
 * using all Gaussian densities.  Finally, scale senone scores by subtracting the best.
 * @return The normalization factor (best senone absolute score).
 */
int32 subvq_frame_eval (subvq_t *vq,	/**< In: A sub-vector model */
			mgau_model_t *g,/**< In: Exact mixture Gaussian model */
			int32 beam,	/**< In: (Logs3) threshold for selecting shortlist;
					   range = [-infinity(widest beam), 0(narrowest)] */
			float32 *feat,	/**< In: Input feature vector for this frame */
			int32 *sen_active,	/**< In: Active flags for each senone (optional).
						   If not NULL, only active ones evaluated */
			int32 *senscr /**< Out: Normalized senone scores */
    );	

/**
 * Evaluate the Mahalanobis distances between the given feature vector and each entry in the
 * given subvq codebook.  Save results, as logs3 values, in vq->vqdist[][].
 */
void subvq_gautbl_eval_logs3 (subvq_t *vq,	/**< In/Out: Reference subvq structure */
			      float32 *feat,	/**< In: Subvectors
						   extracted from this, and compared to
						   relevant subvq codewords */
			      logmath_t *logmath
    );

/**
 * Evaluate the codewords for a single given subvector sv, wrt the input feature vector.
 * Save results, as logs3 values, in vq->vqdist[sv][].
 * (Basically, like subvq_gautbl_eval_logs3, but for a single given subvector instead of all.)
 */
void subvq_subvec_eval_logs3 (subvq_t *vq,	/**< In/Out: Reference subvq structure */
			      float32 *feat,	/**< In: Input feature
						 ** subvector
						 ** extracted from
						 ** this, and compared
						 ** to relevant
						 ** codewords */

			      int32 sv,	        /**< In: ID of
						   subvector being
						   evaluated */
			      logmath_t *logmath
    );

/*
 * Based on previously computed subvq scores (Mahalanobis distances), determine the active
 * components in the given mixture (using the vq->map).
 * @return Number of candidates in the returned shortlist.
 */
int32 subvq_mgau_shortlist (subvq_t *vq,        /**< In subvq */
			    int32 m,	/**< In: GMM index */
			    int32 n,	/**< In: #Components in specified mixture */
			    int32 beam	/**< In: Threshold to select active components */
    );


/**
 * Compute the scores of a gaussian using only sum of the sub-vector scores. 
 * @return best senone score. 
 */

int32 subvq_mgau_eval (mgau_model_t *g, /**< In: Gaussian */
		       subvq_t *vq, /**< In: the SVQ */
		       int32 m, /**< In: GMM Index */
		       int32 n, /**< In :#Components in a specified mixture */
		       int32 *active /**< In:Active list of mixture */
    );

#if 0
{ /* Stop indent from complaining */
#endif
#ifdef __cplusplus
}
#endif

#endif