Go to the source code of this file.
Data Structures | |
struct | BMALLOC_BASE |
Information of allocated memory block for mybmalloc(). More... | |
Defines | |
#define | MYBMALLOC_BLOCK_SIZE 10000 |
Memory block size in bytes for mybmalloc(). | |
Functions | |
char * | getl (char *, int, FILE *) |
Read one line from file that has been opened by fopen_readfile(). | |
char * | getl_fp (char *, int, FILE *) |
Read one line from file pointer. | |
char * | getl_fd (char *, int, int) |
Read one line from a file descriptor. | |
char * | getl_sd (char *, int, int) |
Read one line from a socket descriptor. | |
char * | get_line_from_stdin (char *buf, int buflen, char *prompt) |
Get one file name from stdin with a prompt . | |
FILE * | fopen_readfile (char *) |
Open a file with zlib. | |
int | fclose_readfile (FILE *) |
Close a file previously opened by fopen_readfile(). | |
FILE * | fopen_writefile (char *) |
Open or create a file for writing (no compression supported),. | |
int | fclose_writefile (FILE *) |
Close file previously opened by open_writefile(). | |
size_t | myfread (void *ptr, size_t size, size_t n, FILE *fp) |
Read data from input stream opened by fopen_readfile(). | |
size_t | myfwrite (void *ptr, size_t size, size_t n, FILE *fp) |
Write data. | |
int | myfgetc (FILE *fp) |
Read one character from input stream opened by fopen_readfile(). | |
int | myfeof (FILE *fp) |
Test if reached end of file, for files opened by fopen_readfile(). | |
int | myfrewind (FILE *fp) |
Seek to the first of the file. | |
void * | mybmalloc2 (unsigned int size, BMALLOC_BASE **list) |
Another version of memory block allocation, used for tree lexicon. | |
char * | mybstrdup2 (char *, BMALLOC_BASE **list) |
String duplication using mybmalloc2(). | |
void | mybfree2 (BMALLOC_BASE **list) |
Free all memories allocated by mybmalloc2(). | |
void * | mymalloc (int) |
Allocate a memory, as the same as malloc. | |
void * | myrealloc (void *, int) |
Re-allocate memory area, keeping the existing data, as the same as realloc. | |
void * | mycalloc (int, int) |
Allocate memory area and set it to zero, as the same as calloc. | |
void | swap_sample_bytes (SP16 *buf, int len) |
Byte swapping of 16bit audio samples. | |
void | swap_bytes (char *buf, size_t unitbyte, int unitnum) |
Generic byte-swapping functions for any size of unit. | |
void | jlog_set_output (FILE *fp) |
Set file pointer to output the log. | |
FILE * | jlog_get_fp () |
Return the current file pointer to output log. | |
void | jlog (char *format,...) |
Output a normal message to log. | |
int | jlog_flush () |
Flush text message. | |
char * | mystrtok_quotation (char *str, char *delim, int left_paren, int right_paren, int mode) |
Generic function to extract tokens from strings, with quotation handling. | |
char * | mystrtok_quote (char *str, char *delim) |
Extract tokens considering quotation by double quotation mark. | |
char * | mystrtok (char *str, char *delim) |
Extract tokens, not considering quotation, just as the same as strtok. | |
char * | mystrtok_movetonext (char *str, char *delim) |
Just move to the beginning of the next token, without modifying the str. | |
void | confout (FILE *strm) |
Output all information of this libsent library. | |
void | confout_version (FILE *strm) |
Output version of this libsent library. | |
void | confout_audio (FILE *strm) |
Output audio configuration of this libsent library. | |
void | confout_lm (FILE *strm) |
Output language model configuration of this libsent library. | |
void | confout_am (FILE *strm) |
Output acoustic model configuration of this libsent library. | |
void | confout_lib (FILE *strm) |
Output about linked libraries of this libsent library. | |
void | confout_process (FILE *strm) |
Output about process handling of this libsent library. |
This file contains definitions for common utility functions: text reading and parsing, compressed file input, memory allocation, byte order changing, common printf function (j_printf etc.) and so on.
Definition in file util.h.
#define MYBMALLOC_BLOCK_SIZE 10000 |
Memory block size in bytes for mybmalloc().
mybmalloc() allocate memory per big block to reduce memory management overhead. This value sets the block size to be allocated. Smaller value may leads to finer granularity, but overhead may increase. Larger value may result in reduction of overhead, but too much memory can be allocated for a small memory requirement.
Definition at line 50 of file util.h.
Referenced by mybmalloc_set_param().
char* getl | ( | char * | buf, | |
int | maxlen, | |||
FILE * | fp | |||
) |
Read one line from file that has been opened by fopen_readfile().
Blank line will be skipped.
buf | [out] data buffer | |
maxlen | [in] maximum length of above | |
fp | [in] file pointer or gzFile pointer |
Definition at line 53 of file readfile.c.
Referenced by add_bigram(), add_unigram(), get_total_info(), ngram_read_arpa(), rddfa(), rdhmmlist(), read_token(), set_ngram(), set_unigram(), voca_load_htkdict(), and voca_load_wordlist().
char* getl_fp | ( | char * | buf, | |
int | maxlen, | |||
FILE * | fp | |||
) |
Read one line from file pointer.
Blank line will be skipped.
buf | [out] data buffer | |
maxlen | [in] maximum length of above | |
fp | [in] file pointer |
Definition at line 86 of file readfile.c.
Referenced by adin_file_begin(), htk_config_file_parse(), main_recognition_stream_loop(), and multigram_add_prefix_filelist().
char* getl_fd | ( | char * | buf, | |
int | maxlen, | |||
int | fd | |||
) |
Read one line from a file descriptor.
Blank line will be skipped.
buf | [out] data buffer | |
maxlen | [in] maximum length of above | |
fd | [in] file descriptor |
Definition at line 114 of file readfile.c.
Referenced by rddfa_fd(), and voca_load_htkdict_fd().
char* getl_sd | ( | char * | buf, | |
int | maxlen, | |||
int | sd | |||
) |
Read one line from a socket descriptor.
Blank line will be skipped.
buf | [out] data buffer | |
maxlen | [in] maximum length of above | |
sd | [in] socket descpritor |
Definition at line 152 of file readfile.c.
Referenced by rddfa_sd(), and voca_load_htkdict_sd().
char* get_line_from_stdin | ( | char * | buf, | |
int | buflen, | |||
char * | prompt | |||
) |
Get one file name from stdin with a prompt .
Blank line is omitted.
buf | [out] buffer to hold input text line | |
buflen | [in] length of the buffer | |
prompt | [in] prompt string |
Definition at line 193 of file readfile.c.
Referenced by adin_file_begin(), main(), and main_recognition_stream_loop().
FILE* fopen_readfile | ( | char * | filename | ) |
Open a file with zlib.
filename | [in] file name to open |
Definition at line 55 of file gzfile.c.
Referenced by adin_file_open(), CMN_load_from_file(), init_dfa(), init_hmminfo(), init_ngram_arpa(), init_ngram_arpa_additional(), init_ngram_bin(), init_voca(), init_wordlist(), new_SS_load_from_file(), and rdparam().
int fclose_readfile | ( | FILE * | fp | ) |
Close a file previously opened by fopen_readfile().
fp | [in] gzFile pointer |
Definition at line 73 of file gzfile.c.
Referenced by adin_file_close(), adin_file_open(), CMN_load_from_file(), init_dfa(), init_hmminfo(), init_ngram_arpa(), init_ngram_arpa_additional(), init_ngram_bin(), init_voca(), init_wordlist(), new_SS_load_from_file(), rdparam(), and setup_wav().
FILE* fopen_writefile | ( | char * | filename | ) |
Open or create a file for writing (no compression supported),.
filename | [in] filename |
Definition at line 326 of file gzfile.c.
Referenced by wrwav_open().
int fclose_writefile | ( | FILE * | fp | ) |
Close file previously opened by open_writefile().
fp | [in] file pointer |
Definition at line 345 of file gzfile.c.
Referenced by wrwav_close().
size_t myfread | ( | void * | ptr, | |
size_t | size, | |||
size_t | n, | |||
FILE * | fp | |||
) |
Read data from input stream opened by fopen_readfile().
ptr | [out] data buffer | |
size | [in] size of unit in bytes | |
n | [in] number of unit to be read | |
fp | [in] gzFile pointer |
Definition at line 93 of file gzfile.c.
Referenced by adin_file_open(), adin_file_read(), adin_stdin_read(), myread(), and rdnfunc().
size_t myfwrite | ( | void * | ptr, | |
size_t | size, | |||
size_t | n, | |||
FILE * | fp | |||
) |
int myfgetc | ( | FILE * | fp | ) |
Read one character from input stream opened by fopen_readfile().
fp | [in] gzFile pointer |
Definition at line 112 of file gzfile.c.
Referenced by rdn_strfunc().
int myfeof | ( | FILE * | fp | ) |
Test if reached end of file, for files opened by fopen_readfile().
fp | [in] gzFile pointer. |
Definition at line 127 of file gzfile.c.
Referenced by adin_file_read().
int myfrewind | ( | FILE * | fp | ) |
void* mybmalloc2 | ( | unsigned int | size, | |
BMALLOC_BASE ** | list | |||
) |
Another version of memory block allocation, used for tree lexicon.
size | [in] memory size to be allocated | |
list | [i/o] total memory management information (will be updated here) |
Definition at line 84 of file mybmalloc.c.
Referenced by add_ac(), add_to_error(), bt_new(), bt_relocate_rw(), calc_tied_mix_extend(), dens_new(), dens_read(), hmm_add_physical_to_logical(), hmm_add_pseudo_phones_sub(), htk_hmmdata_new(), htk_hmmdata_read(), make_hmm_basephone_list(), mybstrdup2(), outprob_cache_extend(), param_alloc(), rd_data(), rd_dens(), rd_state(), rd_tmix(), rd_trans(), rd_var(), rdhmmlist(), rdn_strfunc(), state_new(), state_read(), tmix_create_codebook_index(), tmix_read(), trans_new(), trans_read(), var_new(), var_read(), voca_load_htkdict_line(), voca_load_wordlist_line(), wchmm_add_word(), and wchmm_duplicate_state().
char* mybstrdup2 | ( | char * | s, | |
BMALLOC_BASE ** | list | |||
) |
String duplication using mybmalloc2().
s | [in] string to be duplicated | |
list | [i/o] total memory management information pointer |
Definition at line 122 of file mybmalloc.c.
Referenced by rdhmmdef(), rdhmmlist(), and tmix_read().
void mybfree2 | ( | BMALLOC_BASE ** | list | ) |
Free all memories allocated by mybmalloc2().
list | [i/o] total memory management information (will be cleaned here) |
Definition at line 138 of file mybmalloc.c.
Referenced by bt_free(), bt_prepare(), calc_tied_mix_free(), hmminfo_free(), outprob_cache_free(), param_free_content(), wchmm_free(), and word_info_free().
void* mymalloc | ( | int | size | ) |
Allocate a memory, as the same as malloc.
size | [in] required size in bytes. |
Definition at line 41 of file mymalloc.c.
Referenced by add_arc(), add_bigram(), add_successor(), add_to_error(), add_unigram(), adin_cut_callback_store_buffer(), adin_initialize(), adin_mic_standby(), adin_setup_param(), adin_thread_create(), build_gsset(), build_state2gs(), calc_tied_mix_extend(), calc_tied_mix_init(), cdset_new(), CMN_realtime_new(), CMN_realtime_update(), cn_build_wordlist(), cn_new(), config_file_parse(), dfa_append(), dfa_find_pause_word(), dfa_info_new(), dfa_pause_word_append(), dfa_state_init(), do_align(), expand_env(), filepath(), gmm_gprune_safe_init(), gmm_init(), gms_gprune_init(), gms_init(), gms_prepare(), gprune_beam_init(), gprune_heu_init(), gprune_none_init(), gprune_safe_init(), graph_make_order(), hmminfo_new(), init_count_zc_e(), InitFBank(), j_add_option(), j_jconf_am_new(), j_jconf_lm_new(), j_jconf_new(), j_jconf_search_new(), j_launch_recognition_instance(), j_mfcccalc_new(), j_process_am_new(), j_process_lm_new(), j_recog_new(), j_recogprocess_new(), make_costbl_hamming(), make_costbl_makemfcc(), make_fft_table(), make_phseq(), make_sintbl_wcep(), make_successor_list(), make_terminfo(), malloc_dfa_cp(), malloc_wordtrellis(), max_successor_cache_init(), multigram_add(), multigram_add_gramlist(), multigram_add_prefix_filelist(), mybmalloc2(), new_make_word_hmm_with_lm(), new_node(), new_param(), new_SS_calculate(), new_SS_load_from_file(), new_str2phseq(), new_str2wordseq(), newnode(), ngram_compact_context(), ngram_info_new(), ngram_make_lookup_tree(), nw_malloc(), opt_parse(), outprob_cache_extend(), outprob_cd_nbest_init(), param_str2code(), phoneme_rev_align(), rd_dens(), rd_state(), rd_tmix(), rd_trans(), rd_var(), rddfa_line(), rdhmmlist(), read_param(), read_token(), realloc_dfa_cp(), RealTimeInit(), RealTimePipeLine(), regist_cdset(), result_sentence_malloc(), select_param_kind(), set_ngram(), set_unigram(), state_rev_align(), terminfo_append(), test_expand_triphone(), tmix_create_codebook_index(), useropt_new(), viterbi_segment(), voca_load_htkdict_line(), voca_load_wordlist_line(), wchmm_duplicate_leafnode(), wchmm_init(), wchmm_new(), winfo_init(), WMP_deltabuf_new(), word_info_new(), word_rev_align(), wordgraph_adjust_boundary_sub(), wordgraph_depth_cut(), wordgraph_new(), wordgraph_sort_and_annotate_id(), wt_dens(), wt_state(), wt_tmix(), wt_trans(), and wt_var().
void* myrealloc | ( | void * | ptr, | |
int | size | |||
) |
Re-allocate memory area, keeping the existing data, as the same as realloc.
ptr | [in] memory pointer to be re-allocated | |
size | [in] required new size in bytes |
Definition at line 60 of file mymalloc.c.
Referenced by adin_cut_callback_store_buffer(), calc_tied_mix_extend(), CMN_realtime_update(), cn_add_wg(), config_file_parse(), dfa_pause_word_append(), dfa_state_expand(), expand_env(), new_str2phseq(), new_str2wordseq(), ngram_compact_context(), nw_expand(), outprob_cache_extend(), RealTimePipeLine(), regist_cdset(), shrink_successor(), terminfo_append(), voca_load_htkdict_line(), voca_load_wordlist_line(), wchmm_extend(), wchmm_extend_startnode(), winfo_expand(), wordgraph_add_leftword(), and wordgraph_add_rightword().
void* mycalloc | ( | int | nelem, | |
int | elsize | |||
) |
Allocate memory area and set it to zero, as the same as calloc.
nelem | [in] size of element in bytes | |
elsize | [in] number of elements to allocate |
Definition at line 79 of file mymalloc.c.
Referenced by CMN().
void swap_sample_bytes | ( | SP16 * | buf, | |
int | len | |||
) |
Byte swapping of 16bit audio samples.
buf | [i/o] data buffer | |
len | [in] length of above |
Definition at line 59 of file endian.c.
Referenced by adin_file_read(), adin_mic_read(), adin_stdin_read(), adin_tcpip_read(), NA_read(), and wrsamp().
void swap_bytes | ( | char * | buf, | |
size_t | unitbyte, | |||
int | unitnum | |||
) |
void jlog_set_output | ( | FILE * | fp | ) |
FILE* jlog_get_fp | ( | ) |
Return the current file pointer to output log.
Definition at line 65 of file jlog.c.
Referenced by check_hmm_limit(), make_dfa_voca_ref(), print_engine_info(), and wordgraph_remove_context().
void jlog | ( | char * | fmt, | |
... | ||||
) |
Output a normal message to log.
fmt | [in] format string, like printf. | |
... | [in] variable length argument like printf. |
Definition at line 80 of file jlog.c.
Referenced by accept_from(), add_bigram(), add_unigram(), adin_cut(), adin_cut_callback_store_buffer(), adin_file_begin(), adin_file_close(), adin_file_open(), adin_file_read(), adin_file_standby(), adin_initialize(), adin_initialize_user(), adin_mic_begin(), adin_mic_end(), adin_mic_read(), adin_mic_standby(), adin_netaudio_read(), adin_setup_all(), adin_stdin_begin(), adin_stdin_read(), adin_tcpip_begin(), adin_tcpip_end(), adin_tcpip_read(), adin_tcpip_send_pause(), adin_tcpip_send_resume(), adin_tcpip_send_terminate(), adin_tcpip_standby(), adin_thread_create(), adjust_sc_index(), aptree_remove_entry(), build_state2gs(), callback_add_core(), callback_delete(), callback_exec(), callback_exec_adin(), callback_list_error(), charconv_iconv_setup(), charconv_libjcode_setup(), charconv_win32(), charconv_win32_setup(), check_format(), check_header(), check_hmm_limit(), check_hmm_options(), check_wchmm(), checkpath(), clear_stocker(), CMN_load_from_file(), CMN_save_to_file(), codebook_add(), compaction_successor(), config_file_parse(), cpair_append(), create_mfcc_calc_instances(), decode_end(), decode_proceed(), dens_add(), detect_end_of_segment(), dfa_pause_word_append(), dfa_symbol_lookup(), do_align(), expand_env(), extract_cpair(), fclose_readfile(), finalize_segment(), fopen_readfile(), fopen_writefile(), get_dens_data(), get_state_data(), get_total_info(), get_trans_data(), get_var_data(), getl_fd(), getl_sd(), gmm_init(), gmm_proceed(), gms_init(), graph_make_order(), guess_abs_e_location(), guess_basenum(), guess_if_cd_hmm(), hmm_add_physical_to_logical(), hmm_add_pseudo_phones(), hmm_add_pseudo_phones_sub(), hmm_check(), htk_config_file_parse(), htk_hmm_has_several_arc_on_edge(), htk_hmm_set_pause_model(), htk_hmmdata_add(), init_dfa(), init_hmminfo(), init_ngram_arpa(), init_ngram_arpa_additional(), init_ngram_bin(), init_voca(), init_wordlist(), initialize_dict(), initialize_GMM(), initialize_GSHMM(), initialize_HMM(), j_add_option(), j_create_instance_from_jconf(), j_final_fusion(), j_get_amconf_by_id(), j_get_amconf_by_name(), j_get_lmconf_by_id(), j_get_lmconf_by_name(), j_get_searchconf_by_id(), j_get_searchconf_by_name(), j_jconf_am_regist(), j_jconf_finalize(), j_jconf_lm_regist(), j_jconf_search_regist(), j_launch_recognition_instance(), j_load_all(), j_load_am(), j_load_lm(), j_mfcccalc_new(), j_process_activate(), j_process_activate_by_id(), j_process_add_lm(), j_process_am_remove(), j_process_deactivate(), j_process_deactivate_by_id(), j_process_lm_remove(), j_process_remove(), list_error(), make_base_phone(), make_connection(), make_connection_unix(), make_costbl_hamming(), make_costbl_makemfcc(), make_dfa_voca_ref(), make_fft_table(), make_log_tbl(), make_ngram_ref(), make_sintbl_wcep(), make_successor_list(), make_voca_ref(), mark_word_edge(), merge_contexts(), multigram_activate(), multigram_add(), multigram_add_prefix_filelist(), multigram_add_prefix_list(), multigram_add_words_to_grammar(), multigram_append_to_global(), multigram_build(), multigram_deactivate(), multigram_delete(), multigram_exec_activate(), multigram_exec_delete(), multigram_get_grammar_by_id(), multigram_get_grammar_by_name(), multigram_read_file_and_add(), multigram_rebuild_wchmm(), multigram_update(), mycalloc(), myfread(), mymalloc(), myread(), myrealloc(), NA_standby(), new_make_word_hmm_with_lm(), new_SS_load_from_file(), new_str2phseq(), new_str2wordseq(), next_arg(), ngram_compact_context(), ngram_nextwords(), ngram_prob(), ngram_read_arpa(), ngram_read_bin(), ngram_write_bin(), opt_parse(), param_alloc(), param_check_and_adjust(), param_qualstr2code(), param_strip_zero(), print_engine_info(), print_format(), print_jconf_overview(), put_all_in_stack(), rd(), rd_data(), rd_dens(), rd_header(), rd_para(), rd_state(), rd_tmix(), rd_trans(), rd_var(), rddfa_line(), rderr(), rdhmmdef(), rdhmmlist(), rdn_strfunc(), rdnfunc(), read_binhmm(), read_global_opt(), read_param(), ready_as_server(), RealTimeCMNUpdate(), RealTimeInit(), RealTimeParam(), RealTimePipeLine(), RealTimePipeLinePrepare(), regist_cdset(), remove_cdset(), reset_count_zc_e(), scan_word(), select_param_vmark(), set_beam_width(), set_ngram(), set_terminal_words(), set_unigram(), set_unknown_id(), setup_wav(), state_add(), store_result_pass2(), strip_zero(), swap_leftword(), swap_rightword(), tmix_create_codebook_index(), trans_add(), trans_ok_p(), useropt_exec(), var_add(), var_read(), viterbi_segment(), voca_load_htkdict_line(), voca_load_wordlist_line(), voca_lookup_wid(), Wav2MFCC(), wav2mfcc(), wchmm_add_word(), winfo_expand(), wordgraph_add_leftword(), wordgraph_add_rightword(), wordgraph_adjust_boundary(), wordgraph_adjust_boundary_sub(), wordgraph_check_and_add_leftword(), wordgraph_check_and_add_rightword(), wordgraph_depth_cut(), wordgraph_new(), wordgraph_purge_leaf_nodes(), wordgraph_remove_context(), write_binhmm(), write_header(), wrtfunc(), wrwav_close(), wt(), wt_data(), wt_dens(), wt_state(), wt_tmix(), wt_trans(), and wt_var().
int jlog_flush | ( | ) |
char* mystrtok_quotation | ( | char * | str, | |
char * | delim, | |||
int | left_paren, | |||
int | right_paren, | |||
int | mode | |||
) |
Generic function to extract tokens from strings, with quotation handling.
The usage is as the same as strtok.
str | [i/o] source string, or NULL when this is a continuous call from previous call. Will be truncated in this function. | |
delim | [in] string to specify the delimiters. | |
left_paren | [in] left brace | |
right_paren | [in] right brace | |
mode | [in] if 1, just move to the beginning of next token |
Definition at line 51 of file mystrtok.c.
Referenced by mystrtok(), mystrtok_movetonext(), mystrtok_quote(), voca_load_htkdict_line(), and voca_load_wordlist_line().
char* mystrtok_quote | ( | char * | str, | |
char * | delim | |||
) |
Extract tokens considering quotation by double quotation mark.
str | [i/o] source string, will be truncated. | |
delim | [in] string of all token delimiters |
Definition at line 107 of file mystrtok.c.
Referenced by read_token(), voca_load_htkdict_line(), and voca_load_wordlist_line().
char* mystrtok | ( | char * | str, | |
char * | delim | |||
) |
Extract tokens, not considering quotation, just as the same as strtok.
str | [i/o] source string, will be truncated. | |
delim | [in] string of all token delimiters |
Definition at line 121 of file mystrtok.c.
Referenced by voca_load_htkdict_line(), and voca_load_wordlist_line().
char* mystrtok_movetonext | ( | char * | str, | |
char * | delim | |||
) |
Just move to the beginning of the next token, without modifying the str.
str | [i/o] source string, will be truncated. | |
delim | [in] string of all token delimiters |
Definition at line 135 of file mystrtok.c.
Referenced by voca_load_htkdict_line(), and voca_load_wordlist_line().
void confout | ( | FILE * | strm | ) |
Output all information of this libsent library.
strm | [in] file pointer to output |
Definition at line 136 of file confout.c.
Referenced by j_put_library_defs().
void confout_version | ( | FILE * | strm | ) |
void confout_audio | ( | FILE * | strm | ) |
void confout_lm | ( | FILE * | strm | ) |
void confout_am | ( | FILE * | strm | ) |
void confout_lib | ( | FILE * | strm | ) |
void confout_process | ( | FILE * | strm | ) |