49 #include <sphinxbase/fixpoint.h>
50 #include <sphinxbase/listelem_alloc.h>
69 #define MAX_N_FRAMES MAX_INT32
73 #define SENSCR_SHIFT 10
84 #define WORST_SCORE ((int)0xE0000000)
90 #define TMAT_WORST_SCORE (-255)
160 #define HMM_MAX_NSTATE 5
186 #define hmm_context(h) (h)->ctx
187 #define hmm_is_mpx(h) (h)->mpx
189 #define hmm_in_score(h) (h)->score[0]
190 #define hmm_score(h,st) (h)->score[st]
191 #define hmm_out_score(h) (h)->out_score
193 #define hmm_in_history(h) (h)->history[0]
194 #define hmm_history(h,st) (h)->history[st]
195 #define hmm_out_history(h) (h)->out_history
197 #define hmm_bestscore(h) (h)->bestscore
198 #define hmm_frame(h) (h)->frame
199 #define hmm_mpx_ssid(h,st) (h)->senid[st]
200 #define hmm_nonmpx_ssid(h) (h)->ssid
201 #define hmm_ssid(h,st) (hmm_is_mpx(h) \
202 ? hmm_mpx_ssid(h,st) : hmm_nonmpx_ssid(h))
203 #define hmm_mpx_senid(h,st) (hmm_mpx_ssid(h,st) == BAD_SENID \
204 ? BAD_SENID : (h)->ctx->sseq[hmm_mpx_ssid(h,st)][st])
205 #define hmm_nonmpx_senid(h,st) ((h)->senid[st])
206 #define hmm_senid(h,st) (hmm_is_mpx(h) \
207 ? hmm_mpx_senid(h,st) : hmm_nonmpx_senid(h,st))
208 #define hmm_senscr(h,st) (hmm_senid(h,st) == BAD_SENID \
210 : -(h)->ctx->senscore[hmm_senid(h,st)])
211 #define hmm_tmatid(h) (h)->tmatid
212 #define hmm_tprob(h,i,j) (-(h)->ctx->tp[hmm_tmatid(h)][i][j])
213 #define hmm_n_emit_state(h) ((h)->n_emit_state)
214 #define hmm_n_state(h) ((h)->n_emit_state + 1)
221 int16
const *senscore,
222 uint16 *
const *sseq);
227 #define hmm_context_set_senscore(ctx, senscr) ((ctx)->senscore = (senscr))
269 int32 histid,
int frame);
uint16 senid[HMM_MAX_NSTATE]
Senone IDs (non-MPX) or sequence IDs (MPX)
int32 hmm_dump_vit_eval(hmm_t *hmm, FILE *fp)
Like hmm_vit_eval, but dump HMM state and relevant senscr to fp first, for debugging;.
void * udata
Whatever you feel like, gosh.
void hmm_init(hmm_context_t *ctx, hmm_t *hmm, int mpx, int ssid, int tmatid)
Populate a previously-allocated HMM structure, allocating internal data.
An individual HMM among the HMM search space.
int32 * st_sen_scr
Temporary array of senone scores (for some topologies).
listelem_alloc_t * mpx_ssid_alloc
Allocator for senone sequence ID arrays.
void hmm_deinit(hmm_t *hmm)
Free an HMM structure, releasing internal data (but not the HMM structure itself).
Binary format model definition files, with support for heterogeneous topologies and variable-size N-p...
int32 out_score
Score for non-emitting exit state.
int32 history[HMM_MAX_NSTATE]
History indices for emitting states.
uint8 mpx
Is this HMM multiplex? (hoisted for speed)
#define HMM_MAX_NSTATE
Hard-coded limit on the number of emitting states.
uint16 *const * sseq
Senone sequence mapping.
int32 hmm_vit_eval(hmm_t *hmm)
Viterbi evaluation of given HMM.
void hmm_normalize(hmm_t *h, int32 bestscr)
Renormalize the scores in this HMM based on the given best score.
hmm_context_t * hmm_context_init(int32 n_emit_state, uint8 **const *tp, int16 const *senscore, uint16 *const *sseq)
Create an HMM context.
uint16 ssid
Senone sequence ID (for non-MPX)
int32 bestscore
Best [emitting] state score in current frame (for pruning).
Shared information between a set of HMMs.
int32 out_history
History index for non-emitting exit state.
void hmm_enter(hmm_t *h, int32 score, int32 histid, int frame)
Enter an HMM with the given path score and history ID.
void hmm_dump(hmm_t *h, FILE *fp)
For debugging, dump the whole HMM out.
void hmm_clear(hmm_t *h)
Reset the states of the HMM to the invalid condition.
int16 tmatid
Transition matrix ID (see hmm_context_t).
hmm_context_t * ctx
Shared context data for this HMM.
int32 frame_idx_t
Type for frame index values.
int32 score[HMM_MAX_NSTATE]
State scores for emitting states.
void hmm_clear_scores(hmm_t *h)
Reset the scores of the HMM.
void hmm_context_free(hmm_context_t *ctx)
Free an HMM context.
uint8 n_emit_state
Number of emitting states (hoisted for speed)
int16 const * senscore
State emission scores senscore[senid] (negated scaled logs3 values).
uint8 **const * tp
State transition scores tp[id][from][to] (logs3 values).
int32 n_emit_state
Number of emitting states in this set of HMMs.
frame_idx_t frame
Frame in which this HMM was last active; <0 if inactive.