Browse Source

cleanup: reduce variable scopes in synthdata.c

master
Juho Hiltunen 2 years ago
parent
commit
f23ff88755
1 changed files with 17 additions and 20 deletions
  1. 17
    20
      src/libespeak-ng/synthdata.c

+ 17
- 20
src/libespeak-ng/synthdata.c View File

espeak_ng_STATUS LoadPhData(int *srate, espeak_ng_ERROR_CONTEXT *context) espeak_ng_STATUS LoadPhData(int *srate, espeak_ng_ERROR_CONTEXT *context)
{ {
int ix; int ix;
int n_phonemes;
int version; int version;
int length = 0; int length = 0;
int rate; int rate;
p += 4; p += 4;


for (ix = 0; ix < n_phoneme_tables; ix++) { for (ix = 0; ix < n_phoneme_tables; ix++) {
n_phonemes = p[0];
int n_phonemes = p[0];
phoneme_tab_list[ix].n_phonemes = p[0]; phoneme_tab_list[ix].n_phonemes = p[0];
phoneme_tab_list[ix].includes = p[1]; phoneme_tab_list[ix].includes = p[1];
p += 4; p += 4;
int LookupPhonemeString(const char *string) int LookupPhonemeString(const char *string)
{ {
int ix; int ix;
unsigned char c;
unsigned int mnem; unsigned int mnem;


// Pack up to 4 characters into a word // Pack up to 4 characters into a word
mnem = 0; mnem = 0;
for (ix = 0; ix < 4; ix++) { for (ix = 0; ix < 4; ix++) {
if (string[ix] == 0) break; if (string[ix] == 0) break;
c = string[ix];
unsigned char c = string[ix];
mnem |= (c << (ix*8)); mnem |= (c << (ix*8));
} }


int seq_break; int seq_break;
frameref_t *frames; frameref_t *frames;
int length1; int length1;
int length_std;
int length_factor;
SPECT_SEQ *seq, *seq2; SPECT_SEQ *seq, *seq2;
SPECT_SEQK *seqk, *seqk2; SPECT_SEQK *seqk, *seqk2;
frame_t *frame; frame_t *frame;
} }


if (length1 > 0) { if (length1 > 0) {
int length_factor;
if (which == 2) { if (which == 2) {
// adjust the length of the main part to match the standard length specified for the vowel // adjust the length of the main part to match the standard length specified for the vowel
// less the front part of the vowel and any added suffix // less the front part of the vowel and any added suffix


length_std = fmt_params->std_length + seq_len_adjust - 45;
int length_std = fmt_params->std_length + seq_len_adjust - 45;
if (length_std < 10) if (length_std < 10)
length_std = 10; length_std = 10;
if (plist->synthflags & SFLAG_LENGTHEN) if (plist->synthflags & SFLAG_LENGTHEN)
{ {
int ix; int ix;
int includes; int includes;
int ph_code;
PHONEME_TAB *phtab; PHONEME_TAB *phtab;


if ((includes = phoneme_tab_list[number].includes) > 0) { if ((includes = phoneme_tab_list[number].includes) > 0) {
// now add the phonemes from this table // now add the phonemes from this table
phtab = phoneme_tab_list[number].phoneme_tab_ptr; phtab = phoneme_tab_list[number].phoneme_tab_ptr;
for (ix = 0; ix < phoneme_tab_list[number].n_phonemes; ix++) { for (ix = 0; ix < phoneme_tab_list[number].n_phonemes; ix++) {
ph_code = phtab[ix].code;
int ph_code = phtab[ix].code;
phoneme_tab[ph_code] = &phtab[ix]; phoneme_tab[ph_code] = &phtab[ix];
if (ph_code > n_phoneme_tab) { if (ph_code > n_phoneme_tab) {
memset(&phoneme_tab[n_phoneme_tab+1], 0, (ph_code - (n_phoneme_tab+1)) * sizeof(*phoneme_tab)); memset(&phoneme_tab[n_phoneme_tab+1], 0, (ph_code - (n_phoneme_tab+1)) * sizeof(*phoneme_tab));


static bool InterpretCondition(Translator *tr, int control, PHONEME_LIST *plist, unsigned short *p_prog, WORD_PH_DATA *worddata) static bool InterpretCondition(Translator *tr, int control, PHONEME_LIST *plist, unsigned short *p_prog, WORD_PH_DATA *worddata)
{ {
int which;
int ix;
unsigned int data; unsigned int data;
int instn; int instn;
int instn2; int instn2;
bool check_endtype = false;
PHONEME_TAB *ph;
PHONEME_LIST *plist_this;


// instruction: 2xxx, 3xxx // instruction: 2xxx, 3xxx


instn2 = instn >> 8; instn2 = instn >> 8;


if (instn2 < 14) { if (instn2 < 14) {
PHONEME_LIST *plist_this;
plist_this = plist; plist_this = plist;
which = (instn2) % 7;
int which = (instn2) % 7;


if (which == 6) { if (which == 6) {
// the 'which' code is in the next instruction // the 'which' code is in the next instruction
return false; return false;
} }


bool check_endtype = false;
switch (which) switch (which)
{ {
case 0: // prevPh case 0: // prevPh
check_endtype = true; check_endtype = true;
break; break;
case 9: // next3PhW case 9: // next3PhW
for (ix = 1; ix <= 3; ix++) {
for (int ix = 1; ix <= 3; ix++) {
if (plist[ix].sourceix) if (plist[ix].sourceix)
return false; return false;
} }
// "change phonemes" pass // "change phonemes" pass
plist->ph = phoneme_tab[plist->phcode]; plist->ph = phoneme_tab[plist->phcode];
} }
PHONEME_TAB *ph;
ph = plist->ph; ph = plist->ph;


if (instn2 < 7) { if (instn2 < 7) {


static void SwitchOnVowelType(PHONEME_LIST *plist, PHONEME_DATA *phdata, unsigned short **p_prog, int instn_type) static void SwitchOnVowelType(PHONEME_LIST *plist, PHONEME_DATA *phdata, unsigned short **p_prog, int instn_type)
{ {
unsigned short *prog;
int voweltype; int voweltype;
signed char x;


if (instn_type == 2) { if (instn_type == 2) {
phdata->pd_control |= pd_FORNEXTPH; phdata->pd_control |= pd_FORNEXTPH;


voweltype -= phonVOWELTYPES; voweltype -= phonVOWELTYPES;
if ((voweltype >= 0) && (voweltype < 6)) { if ((voweltype >= 0) && (voweltype < 6)) {
unsigned short *prog;
signed char x;

prog = *p_prog + voweltype*2; prog = *p_prog + voweltype*2;
phdata->sound_addr[instn_type] = (((prog[1] & 0xf) << 16) + prog[2]) * 4; phdata->sound_addr[instn_type] = (((prog[1] & 0xf) << 16) + prog[2]) * 4;
x = (prog[1] >> 4) & 0xff; x = (prog[1] >> 4) & 0xff;


PHONEME_TAB *ph; PHONEME_TAB *ph;
unsigned short *prog; unsigned short *prog;
unsigned short instn;
int instn2;
int or_flag; int or_flag;
bool truth; bool truth;
bool truth2; bool truth2;
end_flag = 0; end_flag = 0;


for (prog = &phoneme_index[ph->program]; end_flag != 1; prog++) { for (prog = &phoneme_index[ph->program]; end_flag != 1; prog++) {
unsigned short instn;
int instn2;

instn = *prog; instn = *prog;
instn2 = (instn >> 8) & 0xf; instn2 = (instn >> 8) & 0xf;



Loading…
Cancel
Save