/* HTS_Stream_load_pdf: load pdf */ static HTS_Boolean HTS_Stream_load_pdf(HTS_Stream * stream, HTS_File ** fp, int ntree, int interpolation_size) { int i; HTS_Boolean result = TRUE; /* initialize */ stream->interpolation_size = interpolation_size; stream->model = (HTS_Model *) HTS_calloc(interpolation_size, sizeof(HTS_Model)); /* load pdfs */ for (i = 0; i < stream->interpolation_size; i++) { HTS_Model_initialize(&stream->model[i]); if (HTS_Model_load_pdf(&stream->model[i], fp[i], ntree, &stream->msd_flag) == FALSE) result = FALSE; } if (result == FALSE) { HTS_Stream_clear(stream); return FALSE; } /* check */ for (i = 1; i < stream->interpolation_size; i++) { if (stream->model[0].vector_length != stream->model[1].vector_length) { HTS_error(1, "HTS_Stream_load_pdf: # of states are different in between given modelsets.\n"); HTS_Stream_clear(stream); return FALSE; } } /* set */ stream->vector_length = stream->model[0].vector_length; return TRUE; }
/* HTS_ModelSet_clear: free model set */ void HTS_ModelSet_clear(HTS_ModelSet * ms) { int i; HTS_Stream_clear(&ms->duration); if (ms->stream) { for (i = 0; i < ms->nstream; i++) HTS_Stream_clear(&ms->stream[i]); HTS_free(ms->stream); } if (ms->gv) { for (i = 0; i < ms->nstream; i++) HTS_Stream_clear(&ms->gv[i]); HTS_free(ms->gv); } HTS_Model_clear(&ms->gv_switch); HTS_ModelSet_initialize(ms, -1); }
/* HTS_Stream_load_pdf_and_tree: load PDFs and trees */ static HTS_Boolean HTS_Stream_load_pdf_and_tree(HTS_Stream * stream, HTS_File ** pdf_fp, HTS_File ** tree_fp, int interpolation_size) { int i; HTS_Boolean result = TRUE; /* initialize */ stream->interpolation_size = interpolation_size; stream->model = (HTS_Model *) HTS_calloc(interpolation_size, sizeof(HTS_Model)); /* load */ for (i = 0; i < stream->interpolation_size; i++) { if (!pdf_fp[i]) { HTS_error(1, "HTS_Stream_load_pdf_and_tree: File for duration PDFs is not specified.\n"); HTS_Stream_clear(stream); return FALSE; } if (!tree_fp[i]) { HTS_error(1, "HTS_Stream_load_pdf_and_tree: File for duration trees is not specified.\n"); HTS_Stream_clear(stream); return FALSE; } HTS_Model_initialize(&stream->model[i]); result = HTS_Model_load_tree(&stream->model[i], tree_fp[i]); if (result == FALSE) { HTS_Stream_clear(stream); return FALSE; } result = HTS_Model_load_pdf(&stream->model[i], pdf_fp[i], stream->model[i].ntree, &stream->msd_flag); if (result == FALSE) { HTS_Stream_clear(stream); return FALSE; } } /* check */ for (i = 1; i < stream->interpolation_size; i++) if (stream->model[0].vector_length != stream->model[i].vector_length) { HTS_error(1, "HTS_Stream_load_pdf_and_tree: Vector sizes of state output vectors are different in between given modelsets.\n"); HTS_Stream_clear(stream); return FALSE; } /* set */ stream->vector_length = stream->model[0].vector_length; return TRUE; }