Skip to content

Commit b86eb46

Browse files
authored
Merge pull request #435 from cmusphinx/kal-more-phones
Increase phone support to 256 and simplify bitvector operations
2 parents f6e44c6 + c3493d8 commit b86eb46

File tree

2 files changed

+8
-29
lines changed

2 files changed

+8
-29
lines changed

src/fsg_lextree.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -711,8 +711,8 @@ fsg_psubtree_init(fsg_lextree_t *lextree,
711711
n_ci = bin_mdef_n_ciphone(lextree->mdef);
712712
if (n_ci > (FSG_PNODE_CTXT_BVSZ * 32)) {
713713
E_FATAL
714-
("#phones > %d; increase FSG_PNODE_CTXT_BVSZ and recompile\n",
715-
FSG_PNODE_CTXT_BVSZ * 32);
714+
("#phones (%d) exceeds maximum supported (%d)\n",
715+
n_ci, FSG_PNODE_CTXT_BVSZ * 32);
716716
}
717717

718718
n_arc = 0;

src/fsg_lextree.h

Lines changed: 6 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,11 @@ extern "C" {
5454
#endif
5555

5656
/*
57-
* Compile-time constant determining the size of the
58-
* bitvector fsg_pnode_t.fsg_pnode_ctxt_t.bv. (See below.)
59-
* But it makes memory allocation simpler and more efficient.
60-
* Make it smaller (2) to save memory if your phoneset has less than
61-
* 64 phones.
57+
* Size of the bitvector fsg_pnode_t.fsg_pnode_ctxt_t.bv.
58+
* Each uint32 provides 32 bits, so BVSZ * 32 = max number of phones.
59+
* BVSZ=8 supports up to 256 phones, which covers all known phonesets.
6260
*/
63-
#define FSG_PNODE_CTXT_BVSZ 4
61+
#define FSG_PNODE_CTXT_BVSZ 8
6462

6563
typedef struct fsg_pnode_ctxt_s {
6664
uint32 bv[FSG_PNODE_CTXT_BVSZ];
@@ -153,31 +151,12 @@ typedef struct fsg_pnode_s {
153151

154152
#define fsg_pnode_add_ctxt(p,c) ((p)->ctxt.bv[(c)>>5] |= (1 << ((c)&0x001f)))
155153

156-
/*
157-
* The following is macroized because its called very frequently
158-
* ::: uint32 fsg_pnode_ctxt_sub (fsg_pnode_ctxt_t *src, fsg_pnode_ctxt_t *sub);
159-
*/
160154
/*
161155
* Subtract bitvector sub from bitvector src (src updated with the result).
162156
* Return 0 if result is all 0, non-zero otherwise.
157+
* Uses generic implementation to support arbitrary BVSZ values.
163158
*/
164-
165-
#if (FSG_PNODE_CTXT_BVSZ == 1)
166-
#define FSG_PNODE_CTXT_SUB(src,sub) \
167-
((src)->bv[0] = (~((sub)->bv[0]) & (src)->bv[0]))
168-
#elif (FSG_PNODE_CTXT_BVSZ == 2)
169-
#define FSG_PNODE_CTXT_SUB(src,sub) \
170-
(((src)->bv[0] = (~((sub)->bv[0]) & (src)->bv[0])) | \
171-
((src)->bv[1] = (~((sub)->bv[1]) & (src)->bv[1])))
172-
#elif (FSG_PNODE_CTXT_BVSZ == 4)
173-
#define FSG_PNODE_CTXT_SUB(src,sub) \
174-
(((src)->bv[0] = (~((sub)->bv[0]) & (src)->bv[0])) | \
175-
((src)->bv[1] = (~((sub)->bv[1]) & (src)->bv[1])) | \
176-
((src)->bv[2] = (~((sub)->bv[2]) & (src)->bv[2])) | \
177-
((src)->bv[3] = (~((sub)->bv[3]) & (src)->bv[3])))
178-
#else
179-
#define FSG_PNODE_CTXT_SUB(src,sub) fsg_pnode_ctxt_sub_generic((src),(sub))
180-
#endif
159+
#define FSG_PNODE_CTXT_SUB(src,sub) fsg_pnode_ctxt_sub_generic((src),(sub))
181160

182161
/**
183162
* Collection of lextrees for an FSG.

0 commit comments

Comments
 (0)