PocketSphinx
0.6
|
00001 /* -*- c-basic-offset: 4; indent-tabs-mode: nil -*- */ 00002 /* ==================================================================== 00003 * Copyright (c) 1999-2010 Carnegie Mellon University. All rights 00004 * reserved. 00005 * 00006 * Redistribution and use in source and binary forms, with or without 00007 * modification, are permitted provided that the following conditions 00008 * are met: 00009 * 00010 * 1. Redistributions of source code must retain the above copyright 00011 * notice, this list of conditions and the following disclaimer. 00012 * 00013 * 2. Redistributions in binary form must reproduce the above copyright 00014 * notice, this list of conditions and the following disclaimer in 00015 * the documentation and/or other materials provided with the 00016 * distribution. 00017 * 00018 * This work was supported in part by funding from the Defense Advanced 00019 * Research Projects Agency and the National Science Foundation of the 00020 * United States of America, and the CMU Sphinx Speech Consortium. 00021 * 00022 * THIS SOFTWARE IS PROVIDED BY CARNEGIE MELLON UNIVERSITY ``AS IS'' AND 00023 * ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 00024 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 00025 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY 00026 * NOR ITS EMPLOYEES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 00027 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 00028 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 00029 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 00030 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00031 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 00032 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00033 * 00034 * ==================================================================== 00035 * 00036 */ 00037 00043 #ifndef __TIED_MGAU_COMMON_H__ 00044 #define __TIED_MGAU_COMMON_H__ 00045 00046 #include <sphinxbase/logmath.h> 00047 #include <sphinxbase/fixpoint.h> 00048 00049 #define MGAU_MIXW_VERSION "1.0" /* Sphinx-3 file format version for mixw */ 00050 #define MGAU_PARAM_VERSION "1.0" /* Sphinx-3 file format version for mean/var */ 00051 #define NONE -1 00052 #define WORST_DIST (int32)(0x80000000) 00053 00055 #ifdef FIXED_POINT 00056 #define GMMSUB(a,b) \ 00057 (((a)-(b) > a) ? (INT_MIN) : ((a)-(b))) 00058 00059 #define GMMADD(a,b) \ 00060 (((a)+(b) < a) ? (INT_MAX) : ((a)+(b))) 00061 #else 00062 #define GMMSUB(a,b) ((a)-(b)) 00063 #define GMMADD(a,b) ((a)+(b)) 00064 #endif 00065 00066 #ifndef MIN 00067 #define MIN(a,b) ((a) < (b) ? (a) : (b)) 00068 #endif 00069 00070 00071 #if defined(__STDC_VERSION__) && (__STDC_VERSION__ == 199901L) 00072 #define LOGMATH_INLINE inline 00073 #elif defined(__GNUC__) 00074 #define LOGMATH_INLINE static inline 00075 #elif defined(_MSC_VER) 00076 #define LOGMATH_INLINE __inline 00077 #else 00078 #define LOGMATH_INLINE static 00079 #endif 00080 00081 /* Allocate 0..159 for negated quantized mixture weights and 0..96 for 00082 * negated normalized acoustic scores, so that the combination of the 00083 * two (for a single mixture) can never exceed 255. */ 00084 #define MAX_NEG_MIXW 159 00085 #define MAX_NEG_ASCR 96 00104 LOGMATH_INLINE int 00105 fast_logmath_add(logmath_t *lmath, int mlx, int mly) 00106 { 00107 logadd_t *t = LOGMATH_TABLE(lmath); 00108 int d, r; 00109 00110 /* d must be positive, obviously. */ 00111 if (mlx > mly) { 00112 d = (mlx - mly); 00113 r = mly; 00114 } 00115 else { 00116 d = (mly - mlx); 00117 r = mlx; 00118 } 00119 00120 return r - (((uint8 *)t->table)[d]); 00121 } 00122 00123 #endif /* __TIED_MGAU_COMMON_H__ */