diff options
author | The Android Open Source Project <initial-contribution@android.com> | 2009-02-10 15:44:00 -0800 |
---|---|---|
committer | The Android Open Source Project <initial-contribution@android.com> | 2009-02-10 15:44:00 -0800 |
commit | 2f8ec03aa4809cec2b0944ca9bf1c7783e11b4ae (patch) | |
tree | 529ac21af6907441041545b76eaaaa13d9e8640e | |
parent | 21208dbbe2608ae45b8c4a50d83e353880dc491f (diff) | |
download | srec-2f8ec03aa4809cec2b0944ca9bf1c7783e11b4ae.tar.gz |
auto import from //branches/cupcake/...@130745
39 files changed, 1766 insertions, 2191 deletions
diff --git a/audio/AudioIn/UNIX/src/audioinwrapper.cpp b/audio/AudioIn/UNIX/src/audioinwrapper.cpp index 39360a3..bf35aa6 100644 --- a/audio/AudioIn/UNIX/src/audioinwrapper.cpp +++ b/audio/AudioIn/UNIX/src/audioinwrapper.cpp @@ -47,54 +47,6 @@ static struct timeval buffer_save_audio; #endif -// #define MEASURE_SAMPLE_TIMES 1 - -#ifdef MEASURE_SAMPLE_TIMES -#include <sys/time.h> -#include <stdio.h> -#include <string.h> - - -#define MAX_SAMPLES_TO_MEASURE 500 - -static long sample_buffers_received = 0; -static long total_samples_received = 0; -static long samples_in_buffer [MAX_SAMPLES_TO_MEASURE]; -static long seconds_buffer_received [MAX_SAMPLES_TO_MEASURE]; -static long micro_seconds_buffer_received [MAX_SAMPLES_TO_MEASURE]; -static struct timeval buffer_received_time; - -static void AudioIn_Log_Samples_Received ( void ); - -static void AudioIn_Log_Samples_Received ( void ) - { - FILE *log_file; - char file_name [256]; - char log_buffer [256]; - long loop_counter; - - if ( sample_buffers_received > 0 ) - { - gettimeofday ( &buffer_received_time, NULL ); - sprintf ( file_name, "aud_in_%ld_%ld.txt", buffer_received_time.tv_sec, buffer_received_time.tv_usec ); - log_file = fopen ( file_name, "w" ); - - if ( log_file != NULL ) - { - for ( loop_counter = 0; loop_counter < sample_buffers_received; loop_counter++ ) - { - sprintf ( log_buffer, "%ld %ld %ld %ld\n", loop_counter + 1, samples_in_buffer [loop_counter], - seconds_buffer_received [loop_counter], micro_seconds_buffer_received [loop_counter] ); - fwrite ( log_buffer, 1, strlen ( log_buffer ), log_file ); - } - fclose ( log_file ); - } - sample_buffers_received = 0; - } - } -#endif - - extern "C" { @@ -157,9 +109,6 @@ int AudioClose(void) #if defined(USE_DEV_EAC_FILE) return close(audiofd); #else - #ifdef MEASURE_SAMPLE_TIMES - AudioIn_Log_Samples_Received ( ); - #endif record->stop(); delete record; #ifdef SAVE_RAW_AUDIO @@ -185,18 +134,6 @@ int AudioRead(short *buffer, int frame_count) } n /= sizeof(short); } - #ifdef MEASURE_SAMPLE_TIMES - if ( sample_buffers_received < MAX_SAMPLES_TO_MEASURE ) - { - gettimeofday ( &buffer_received_time, NULL ); - seconds_buffer_received [sample_buffers_received] = buffer_received_time.tv_sec; - micro_seconds_buffer_received [sample_buffers_received] = buffer_received_time.tv_usec; - samples_in_buffer [sample_buffers_received] = n; - total_samples_received += n; - sample_buffers_received++; - } - #endif - #ifdef SAVE_RAW_AUDIO if ( n > 0 ) fwrite ( buffer, 2, n, audio_data ); diff --git a/portable/include/PFile.h b/portable/include/PFile.h index 1ae8605..5438c68 100644 --- a/portable/include/PFile.h +++ b/portable/include/PFile.h @@ -119,7 +119,7 @@ typedef struct PFile_t * an error occurs. * @return ESR_INVALID_ARGUMENT if self is null; ESR_WRITE_ERROR if a writing error occurs */ - ESR_ReturnCode(*write)(struct PFile_t* self, void* buffer, size_t size, size_t* count); + ESR_ReturnCode(*write)(struct PFile_t* self, const void* buffer, size_t size, size_t* count); /** * Flushes a PFile. @@ -464,7 +464,7 @@ PORTABLE_API size_t pfread(void* buffer, size_t size, size_t count, PFile* strea * @param stream See fwrite() * @return see fwrite() */ -PORTABLE_API size_t pfwrite(void* buffer, size_t size, size_t count, PFile* stream); +PORTABLE_API size_t pfwrite(const void* buffer, size_t size, size_t count, PFile* stream); /** * Backwards compatible fclose(). diff --git a/portable/include/pmemory.h b/portable/include/pmemory.h index 58716ad..4c09c83 100644 --- a/portable/include/pmemory.h +++ b/portable/include/pmemory.h @@ -11,7 +11,7 @@ * * * Unless required by applicable law or agreed to in writing, software * * distributed under the License is distributed on an 'AS IS' BASIS, * - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * * See the License for the specific language governing permissions and * * limitations under the License. * * * @@ -22,7 +22,7 @@ -#define PMEM_MAP_TRACE +/* #define PMEM_MAP_TRACE */ #include "PortPrefix.h" #include "ptypes.h" @@ -47,6 +47,40 @@ */ #define _STR(x) _VAL(x) +#ifndef offsetof +#define offsetof(type, member) ((size_t) &(((type *)0)->member)) +#endif + +/** + * \<static_cast\> implementation for C. + */ +#define STATIC_CAST(self, subClass, member) ((subClass*) (((char*) self) - (offsetof(subClass, member)))) + + +#define USE_STDLIB_MALLOC + +#ifdef USE_STDLIB_MALLOC + +#define MALLOC(n, tag) malloc(n) +#define CALLOC(m, n, tag) calloc(m, n) +#define CALLOC_CLR(m, n, tag) calloc(m, n) +#define REALLOC(p, n) realloc(p, n) +#define FREE(p) free(p) +#define NEW(type, tag) ((type*)MALLOC(sizeof(type), tag)) +#define NEW_ARRAY(type, n, tag) ((type*)CALLOC(n, sizeof(type), tag)) + +#define PMemInit() ESR_SUCCESS +#define PMemShutdown() ESR_SUCCESS +#define PMemSetLogFile(f) ESR_NOT_SUPPORTED +#define PMemDumpLogFile() ESR_NOT_SUPPORTED +#define PMemSetLogEnabled(b) ESR_NOT_SUPPORTED +#define PMemLogFree(p) (free(p), ESR_SUCCESS) +#define PMemReport(f) ESR_NOT_SUPPORTED +#define PMemorySetPoolSize(n) ESR_NOT_SUPPORTED +#define PMemoryGetPoolSize(p) ESR_NOT_SUPPORTED + +#else + #ifdef DISABLE_MALLOC #define malloc #error #define calloc #error @@ -54,21 +88,12 @@ #define free #error #endif -#ifndef offsetof -#define offsetof(type, member) ((size_t) &(((type *)0)->member)) -#endif - /* * PMEM_MAP_TRACE is not defined by default. * It is up to user to define PMEM_MAP_TRACE; * define in either makefile or here for test purpose. */ -/** - * \<static_cast\> implementation for C. - */ -#define STATIC_CAST(self, subClass, member) ((subClass*) (((char*) self) - (offsetof(subClass, member)))) - #ifdef PMEM_MAP_TRACE /** * Portable malloc() @@ -307,3 +332,5 @@ PORTABLE_API ESR_ReturnCode PMemoryGetPoolSize(size_t *size); */ #endif + +#endif diff --git a/portable/src/ESR_ReturnCode.c b/portable/src/ESR_ReturnCode.c index 539ff24..aed93ca 100644 --- a/portable/src/ESR_ReturnCode.c +++ b/portable/src/ESR_ReturnCode.c @@ -11,7 +11,7 @@ * * * Unless required by applicable law or agreed to in writing, software * * distributed under the License is distributed on an 'AS IS' BASIS, * - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * * See the License for the specific language governing permissions and * * limitations under the License. * * * @@ -21,123 +21,37 @@ #include "ESR_ReturnCode.h" -#define RETURNCODE_COUNT 28 -static LCHAR* rcStringMapping[RETURNCODE_COUNT+1] = - { - L("ESR_SUCCESS"), - L("ESR_CONTINUE_PROCESSING"), - L("ESR_FATAL_ERROR"), - L("ESR_BUFFER_OVERFLOW"), - L("ESR_OPEN_ERROR"), - L("ESR_ALREADY_OPEN"), - L("ESR_CLOSE_ERROR"), - L("ESR_ALREADY_CLOSED"), - L("ESR_READ_ERROR"), - L("ESR_WRITE_ERROR"), - L("ESR_FLUSH_ERROR"), - L("ESR_SEEK_ERROR"), - L("ESR_OUT_OF_MEMORY"), - L("ESR_ARGUMENT_OUT_OF_BOUNDS"), - L("ESR_NO_MATCH_ERROR"), - L("ESR_INVALID_ARGUMENT"), - L("ESR_NOT_SUPPORTED"), - L("ESR_INVALID_STATE"), - L("ESR_THREAD_CREATION_ERROR"), - L("ESR_IDENTIFIER_COLLISION"), - L("ESR_TIMED_OUT"), - L("ESR_INVALID_RESULT_TYPE"), - L("ESR_NOT_IMPLEMENTED"), - L("ESR_CONNECTION_RESET_BY_PEER"), - L("ESR_PROCESS_CREATE_ERROR"), - L("ESR_TTS_NO_ENGINE"), - L("ESR_MUTEX_CREATION_ERROR"), - L("ESR_DEADLOCK"), - L("invalid return code") /* must remain last element for ESR_rc2str() to function */ - }; - const LCHAR* ESR_rc2str(const ESR_ReturnCode rc) { - if (rc >= RETURNCODE_COUNT) - return rcStringMapping[RETURNCODE_COUNT]; - return rcStringMapping[rc]; + switch (rc) { + case ESR_SUCCESS: return L("ESR_SUCCESS"); + case ESR_CONTINUE_PROCESSING: return L("ESR_CONTINUE_PROCESSING"); + case ESR_FATAL_ERROR: return L("ESR_FATAL_ERROR"); + case ESR_BUFFER_OVERFLOW: return L("ESR_BUFFER_OVERFLOW"); + case ESR_OPEN_ERROR: return L("ESR_OPEN_ERROR"); + case ESR_ALREADY_OPEN: return L("ESR_ALREADY_OPEN"); + case ESR_CLOSE_ERROR: return L("ESR_CLOSE_ERROR"); + case ESR_ALREADY_CLOSED: return L("ESR_ALREADY_CLOSED"); + case ESR_READ_ERROR: return L("ESR_READ_ERROR"); + case ESR_WRITE_ERROR: return L("ESR_WRITE_ERROR"); + case ESR_FLUSH_ERROR: return L("ESR_FLUSH_ERROR"); + case ESR_SEEK_ERROR: return L("ESR_SEEK_ERROR"); + case ESR_OUT_OF_MEMORY: return L("ESR_OUT_OF_MEMORY"); + case ESR_ARGUMENT_OUT_OF_BOUNDS: return L("ESR_ARGUMENT_OUT_OF_BOUNDS"); + case ESR_NO_MATCH_ERROR: return L("ESR_NO_MATCH_ERROR"); + case ESR_INVALID_ARGUMENT: return L("ESR_INVALID_ARGUMENT"); + case ESR_NOT_SUPPORTED: return L("ESR_NOT_SUPPORTED"); + case ESR_INVALID_STATE: return L("ESR_INVALID_STATE"); + case ESR_THREAD_CREATION_ERROR: return L("ESR_THREAD_CREATION_ERROR"); + case ESR_IDENTIFIER_COLLISION: return L("ESR_IDENTIFIER_COLLISION"); + case ESR_TIMED_OUT: return L("ESR_TIMED_OUT"); + case ESR_INVALID_RESULT_TYPE: return L("ESR_INVALID_RESULT_TYPE"); + case ESR_NOT_IMPLEMENTED: return L("ESR_NOT_IMPLEMENTED"); + case ESR_CONNECTION_RESET_BY_PEER: return L("ESR_CONNECTION_RESET_BY_PEER"); + case ESR_PROCESS_CREATE_ERROR: return L("ESR_PROCESS_CREATE_ERROR"); + case ESR_TTS_NO_ENGINE: return L("ESR_TTS_NO_ENGINE"); + case ESR_MUTEX_CREATION_ERROR: return L("ESR_MUTEX_CREATION_ERROR"); + case ESR_DEADLOCK: return L("ESR_DEADLOCK"); + }; + return L("invalid return code"); } - - -#ifdef _WIN32 -__declspec(thread) unsigned long stackEnd = 0; -__declspec(thread) unsigned long stackBeginMin = LONG_MAX; - -#include "plog.h" - -#ifdef __cplusplus -extern "C" -#endif - - void __declspec(naked) _cdecl _penter(void) -{ - _asm - { - pushad - mov ebp, esp - } - - { - unsigned long espBuffer; - - _asm - { - mov espBuffer, esp - } - if (espBuffer > stackEnd) - stackEnd = espBuffer; - //printf("\nThread=%d,-addressStack-begin=%lu\n", GetCurrentThreadId(), espBuffer); - } - - _asm - { - popad - ret - } -} - -void __declspec(naked) _cdecl _pexit(void) -{ - _asm - { - pushad - mov ebp, esp - } - - { - unsigned long stackBegin; - - _asm - { - sub esp, 4 - mov stackBegin, esp - } - - if (stackBegin < stackBeginMin) - { - stackBeginMin = stackBegin; - if (stackEnd - stackBegin > 20*1000) - printf("*****************************\nThread %d, Maximum stack usage=%lu\n*******************************\n", GetCurrentThreadId(), (stackEnd - stackBeginMin)); - } - /* - if (stackEnd - stackBegin > 15*1000) - printf("\nThread=%d,Stack-size=%lu\n", GetCurrentThreadId(), (stackEnd - stackBegin)); - */ - - _asm - { - add esp, 4 - } - } - - _asm - { - popad - ret - } -} -#endif diff --git a/portable/src/PFile.c b/portable/src/PFile.c index 06e1317..9320846 100644 --- a/portable/src/PFile.c +++ b/portable/src/PFile.c @@ -366,7 +366,7 @@ size_t pfread(void* buffer, size_t size, size_t count, PFile* stream) return count; } -size_t pfwrite(void* buffer, size_t size, size_t count, PFile* stream) +size_t pfwrite(const void* buffer, size_t size, size_t count, PFile* stream) { ESR_ReturnCode rc; diff --git a/portable/src/PFileWrap.c b/portable/src/PFileWrap.c index d7dddfe..b2fa53a 100644 --- a/portable/src/PFileWrap.c +++ b/portable/src/PFileWrap.c @@ -70,7 +70,7 @@ ESR_ReturnCode PFileRead ( PFile *self, void *buffer, size_t size, size_t *count -ESR_ReturnCode PFileWrite ( PFile *self, void *buffer, size_t size, size_t *count ) +ESR_ReturnCode PFileWrite ( PFile *self, const void *buffer, size_t size, size_t *count ) { ESR_ReturnCode write_status; size_t items_written; @@ -301,7 +301,7 @@ size_t pfread ( void *buffer, size_t size, size_t count, PFile *stream ) -size_t pfwrite ( void *buffer, size_t size, size_t count, PFile *stream ) +size_t pfwrite ( const void *buffer, size_t size, size_t count, PFile *stream ) { ESR_ReturnCode rc; diff --git a/portable/src/pcrc.c b/portable/src/pcrc.c index a178fd8..6f31f08 100644 --- a/portable/src/pcrc.c +++ b/portable/src/pcrc.c @@ -69,7 +69,7 @@ static unsigned int crcTable[] = 0xafb010b1, 0xab710d06, 0xa6322bdf, 0xa2f33668, 0xbcb4666d, 0xb8757bda, 0xb5365d03, 0xb1f740b4 }; -#elif (UINT_MAX >= 0xFFFFU)*/ +#elif (UINT_MAX >= 0xFFFFU) /* use CRC-16 on machine with [16..32[ bits integer. */ #define WIDTH 16 diff --git a/portable/src/pmemory.c b/portable/src/pmemory.c index f00427d..4718eab 100644 --- a/portable/src/pmemory.c +++ b/portable/src/pmemory.c @@ -11,7 +11,7 @@ * * * Unless required by applicable law or agreed to in writing, software * * distributed under the License is distributed on an 'AS IS' BASIS, * - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * * See the License for the specific language governing permissions and * * limitations under the License. * * * @@ -29,6 +29,8 @@ #include "pmemory_ext.h" #include "pmutex.h" +#ifndef USE_STDLIB_MALLOC + #undef malloc #undef calloc #undef realloc @@ -124,14 +126,14 @@ static ESR_ReturnCode getStackTrace(LCHAR* stackTrace, size_t* len) { ESR_BOOL isInit; ESR_ReturnCode rc; - + rc = PStackTraceIsInitialized(&isInit); if (rc == ESR_SUCCESS && isInit) { LCHAR* index; size_t bufferLen = *len; size_t i; - + rc = PStackTraceGetValue(stackTrace, &bufferLen); if (rc == ESR_SUCCESS) { @@ -175,7 +177,7 @@ static int getIndex(const LCHAR *key) unsigned int crc = ~pcrcComputeString(key); int initialIdx = (int)(crc % MAX_MEM_TAG); int idx = initialIdx; - + for (;;) { if (gMemoryMap[idx].tag == NULL) @@ -193,14 +195,14 @@ static int getIndex(const LCHAR *key) #endif return idx; } - + if (gMemoryMap[idx].crc == crc && LSTRCMP(gMemoryMap[idx].tag, key) == 0) { /* found a matching slot, return it */ return idx; } - + if (++idx == MAX_MEM_TAG) { /* Look at next slot and wrap around. */ @@ -218,7 +220,7 @@ ESR_ReturnCode PMemorySetPoolSize(size_t size) #if defined(PORTABLE_DINKUM_MEM_MGR) || defined(PORTABLE_FIXED_SIZE_MEM_BLOCK_SCHEME) if (gNbInit > 0) return ESR_INVALID_STATE; - + gMemPoolSize = size; return ESR_SUCCESS; #else @@ -244,12 +246,12 @@ ESR_ReturnCode PMemoryGetPoolSize(size_t *size) ESR_ReturnCode PMemInit(void) { ESR_ReturnCode init_status; - + if (gNbInit > 0) return ESR_INVALID_STATE; - + init_status = createMutex(&memMutex, ESR_FALSE); - + if (init_status == ESR_SUCCESS) { ++gNbInit; @@ -281,10 +283,12 @@ ESR_ReturnCode PMemInit(void) deleteMutex(&memMutex); } +#ifdef PMEM_MAP_TRACE // Initialize global static variables gCurAlloc = 0; gMaxAlloc = 0; - +#endif + return (init_status); } @@ -298,7 +302,7 @@ ESR_ReturnCode PMemShutdown(void) #ifdef PMEM_MAP_TRACE size_t i; #endif - + if (gNbInit == 0) return ESR_INVALID_STATE; if (gNbInit == 1) @@ -316,7 +320,7 @@ ESR_ReturnCode PMemShutdown(void) deleteMutex(&memMutex); } gNbInit--; - + return ESR_SUCCESS; } @@ -324,27 +328,27 @@ ESR_ReturnCode PMemSetLogFile(PFile* file) { if (gNbInit == 0) return ESR_INVALID_STATE; - + lockMutex(&memMutex); gFile = file; unlockMutex(&memMutex); - + return ESR_SUCCESS; } ESR_ReturnCode PMemDumpLogFile(void) { ESR_ReturnCode rc; - + if (gNbInit == 0) return ESR_INVALID_STATE; - + lockMutex(&memMutex); if (gFile != NULL) { /* Hide gFile from memory report */ /* CHK(rc, gFile->hideMemoryAllocation(gFile));*/ - + rc = PMemReport(gFile); if (rc != ESR_SUCCESS) { @@ -375,7 +379,7 @@ ESR_ReturnCode PMemSetLogEnabled(ESR_BOOL value) lockMutex(&memMutex); isLogEnabled = value; unlockMutex(&memMutex); - + return ESR_SUCCESS; } @@ -388,12 +392,12 @@ ESR_ReturnCode PMemLogFree(void* ptr) #if PMEM_STACKTRACE && PMEM_LOG_LOWLEVEL ESR_ReturnCode rc; #endif - + if (ptr == NULL || gNbInit == 0) return ESR_SUCCESS; - + lockMutex(&memMutex); - + data = (MemoryData*)(((unsigned char*) ptr) - sizeof(MemoryData)); #ifdef PMEM_MAP_TRACE e = gMemoryMap + data->index; @@ -402,10 +406,10 @@ ESR_ReturnCode PMemLogFree(void* ptr) { passert(e->curAlloc >= data->size); e->curAlloc -= data->size; - + passert(gCurAlloc >= data->size); gCurAlloc -= data->size; - + data->size = 0; } #if PMEM_STACKTRACE @@ -428,7 +432,7 @@ ESR_ReturnCode PMemLogFree(void* ptr) #if PMEM_STACKTRACE LCHAR stackTrace[P_MAX_STACKTRACE]; size_t len = P_MAX_STACKTRACE; - + rc = getStackTrace(stackTrace, &len); if (rc != ESR_SUCCESS) { @@ -442,7 +446,7 @@ ESR_ReturnCode PMemLogFree(void* ptr) } #endif /* PMEM_LOG_LOWLEVEL */ #endif /* PMEM_MAP_TRACE */ - + unlockMutex(&memMutex); return ESR_SUCCESS; #if PMEM_STACKTRACE && PMEM_LOG_LOWLEVEL @@ -469,7 +473,7 @@ ESR_ReturnCode PMemReport(PFile* file) #if PMEM_STACKTRACE MemoryData* data; #endif - + if (gNbInit == 0) return ESR_INVALID_STATE; if (file == NULL) @@ -478,7 +482,7 @@ ESR_ReturnCode PMemReport(PFile* file) if (file == NULL) return ESR_SUCCESS; } - + lockMutex(&memMutex); #ifdef PMEM_MAP_TRACE if (gFile != NULL) @@ -492,9 +496,9 @@ ESR_ReturnCode PMemReport(PFile* file) pfprintf(gFile, L("pmem|-|0|corrupt|%d|\n"), i); } } - + pfprintf(file, L("%-52s %10s %15s\n"), L("Memory tag"), L("Cur. Alloc"), L("Max. Alloc")); - + for (i = 0, e = gMemoryMap; i < MAX_MEM_TAG; ++i, ++e) { if (e->tag == NULL) @@ -505,7 +509,7 @@ ESR_ReturnCode PMemReport(PFile* file) else { len = LSTRLEN(e->tag); - + if (len > TAG_SIZE - 1) { LSTRCPY(truncatedTag, TAG_PREFIX); @@ -524,7 +528,7 @@ ESR_ReturnCode PMemReport(PFile* file) { LCHAR stackTrace[P_MAX_STACKTRACE]; LCHAR* index; - + LSTRCPY(stackTrace, data->stackTrace); index = stackTrace; while (index) @@ -547,7 +551,7 @@ ESR_ReturnCode PMemReport(PFile* file) /* not support */ #endif /* PMEM_MAP_TRACE */ unlockMutex(&memMutex); - + return ESR_SUCCESS; } /* @@ -579,17 +583,17 @@ void *pmalloc(size_t nbBytes) ESR_BOOL isInit; ESR_ReturnCode rc; #endif - + if (gNbInit == 0) return NULL; - + lockMutex(&memMutex); - + #ifdef PMEM_MAP_TRACE if (tag == NULL) tag = file; passert(tag != NULL); - + idx = getIndex(tag); if (idx == -1) { @@ -606,7 +610,7 @@ void *pmalloc(size_t nbBytes) } #endif actualSize = sizeof(MemoryData) + nbBytes; - + data = (MemoryData *) malloc(actualSize); if (data == NULL) { @@ -616,7 +620,7 @@ void *pmalloc(size_t nbBytes) */ goto CLEANUP; } - + #ifdef PMEM_MAP_TRACE data->index = idx; #if PMEM_STACKTRACE @@ -643,9 +647,9 @@ void *pmalloc(size_t nbBytes) else data->stackTrace = NULL; #endif - + e = gMemoryMap + idx; - + #if PMEM_STACKTRACE if (e->last != NULL) e->last->next = data; @@ -656,7 +660,7 @@ void *pmalloc(size_t nbBytes) e->first = data; #endif #endif - + if (isLogEnabled) { data->size = actualSize; @@ -664,7 +668,7 @@ void *pmalloc(size_t nbBytes) e->curAlloc += actualSize; if (e->maxAlloc < e->curAlloc) e->maxAlloc = e->curAlloc; - + gCurAlloc += actualSize; if (gMaxAlloc < gCurAlloc) gMaxAlloc = gCurAlloc; @@ -672,12 +676,12 @@ void *pmalloc(size_t nbBytes) } else data->size = 0; - + result = (void*)(data + 1); - + #if PMEM_LOG_LOWLEVEL if (gFile != NULL && isLogEnabled) - + if (gFile != NULL) { #if PMEM_STACKTRACE @@ -687,7 +691,7 @@ void *pmalloc(size_t nbBytes) #endif /* PMEM_STACKTRACE */ } #endif /* PMEM_LOG_LOWLEVEL */ - + CLEANUP: unlockMutex(&memMutex); return result; @@ -746,10 +750,10 @@ void *prealloc(void *ptr, size_t newSize) MemoryData* oldLast; #endif ESR_BOOL bMalloc = ESR_FALSE; - + if (gNbInit == 0) return NULL; - + if (newSize == 0 && ptr != NULL) { #ifdef PMEM_MAP_TRACE @@ -767,9 +771,9 @@ void *prealloc(void *ptr, size_t newSize) return pmalloc(newSize); #endif } - + lockMutex(&memMutex); - + oldData = (MemoryData *)(((unsigned char *) ptr) - sizeof(MemoryData)); oldSize = oldData->size; passert(oldSize >= 0); @@ -781,7 +785,7 @@ void *prealloc(void *ptr, size_t newSize) #ifdef PMEM_MAP_TRACE e = gMemoryMap + oldData->index; #endif - + actualSize = newSize + sizeof(MemoryData); if (oldSize != actualSize) { @@ -811,7 +815,7 @@ void *prealloc(void *ptr, size_t newSize) { newData = oldData; } - + #ifdef PMEM_MAP_TRACE if (newData != NULL && bMalloc) { @@ -820,12 +824,12 @@ void *prealloc(void *ptr, size_t newSize) e->curAlloc += actualSize - oldSize; if (e->maxAlloc < e->curAlloc) e->maxAlloc = e->curAlloc; - + gCurAlloc += actualSize - oldSize; if (gMaxAlloc < gCurAlloc) gMaxAlloc = gCurAlloc; } - + #if PMEM_STACKTRACE newData->stackTrace = oldStackTrace; newData->next = oldNext; @@ -841,13 +845,13 @@ void *prealloc(void *ptr, size_t newSize) #endif } #endif - + if (newData != NULL) { newData->size = actualSize; result = (void*)(newData + 1); } - + #if PMEM_LOG_LOWLEVEL if (gFile != NULL && isLogEnabled) { @@ -855,7 +859,7 @@ void *prealloc(void *ptr, size_t newSize) LCHAR stackTrace[P_MAX_STACKTRACE]; size_t len = P_MAX_STACKTRACE; ESR_ReturnCode rc; - + rc = getStackTrace(stackTrace, &len); if (rc != ESR_SUCCESS) { @@ -868,7 +872,7 @@ void *prealloc(void *ptr, size_t newSize) #endif /* PMEM_STACKTRACE */ } #endif /* PMEM_LOG_LOWLEVEL */ - + unlockMutex(&memMutex); return result; #if PMEM_STACKTRACE && PMEM_LOG_LOWLEVEL @@ -890,9 +894,9 @@ void pfree(void* ptr) #endif if (ptr == NULL || gNbInit == 0) return; - + lockMutex(&memMutex); - + data = (MemoryData*)(((unsigned char*) ptr) - sizeof(MemoryData)); #ifdef PMEM_MAP_TRACE passert(data->index >= 0 && data->index <= MAX_MEM_TAG); @@ -901,7 +905,7 @@ void pfree(void* ptr) { passert(e->curAlloc >= data->size); e->curAlloc -= data->size; - + passert(gCurAlloc >= data->size); gCurAlloc -= data->size; } @@ -926,7 +930,7 @@ void pfree(void* ptr) LCHAR stackTrace[P_MAX_STACKTRACE]; size_t len = P_MAX_STACKTRACE; ESR_ReturnCode rc; - + rc = getStackTrace(stackTrace, &len); if (rc != ESR_SUCCESS) { @@ -944,7 +948,7 @@ void pfree(void* ptr) data->stackTrace = NULL; #endif /* PMEM_STACKTRACE */ #endif - + free(data); unlockMutex(&memMutex); #if PMEM_STACKTRACE && PMEM_LOG_LOWLEVEL @@ -952,5 +956,7 @@ CLEANUP: unlockMutex(&memMutex); return; #endif - + } + +#endif diff --git a/seti/sltsEngine/src/SWIslts.c b/seti/sltsEngine/src/SWIslts.c index 6a24b00..0fdcecc 100644 --- a/seti/sltsEngine/src/SWIslts.c +++ b/seti/sltsEngine/src/SWIslts.c @@ -52,14 +52,14 @@ typedef struct SLTS_PhoneMap_t{ #define INF_SILENCE_OPTIONAL (const char *)"&" -const int g_numPhones = 5; -const SLTS_PhoneMap g_aPhoneMap[] = { +static const SLTS_PhoneMap g_aPhoneMap[] = { {"PS", "&"}, {"SS0", ""}, {"SS1", ""}, {"SS2", ""}, {"WS", "&"} }; +static const int g_numPhones = sizeof(g_aPhoneMap) / sizeof(g_aPhoneMap[0]); #ifdef USE_STATIC_SLTS #define MAX_INPUT_LEN 255 @@ -184,7 +184,7 @@ SWISLTS_FNEXPORT SWIsltsResult SWIsltsClose(SWIsltsHand hLts) /* send phones to internal buffer */ SWISLTS_FNEXPORT SWIsltsResult SWIsltsTextToPhone(SWIsltsHand hLts, const char *text, - char **output_phone_string, + char *output_phone_string[], int *output_phone_len, int max_phone_len) { @@ -265,15 +265,14 @@ SWISLTS_FNEXPORT SWIsltsResult SWIsltsTextToPhone(SWIsltsHand hLts, return nRes; } -static LCHAR g_PHONE_STRING[MAX_PRON_LEN][MAX_PHONE_LEN]; - SWISLTS_FNEXPORT SWIsltsResult SWIsltsG2PGetWordTranscriptions(SWIsltsHand hLts, const char *text, SWIsltsTranscription **ppTranscriptions, int *pnNbrOfTranscriptions) { SWIsltsResult nRes = SWIsltsSuccess; - LCHAR * phone_string[MAX_PRON_LEN]; + char PHONE_STRING[MAX_PRON_LEN][MAX_PHONE_LEN]; + char * phone_string[MAX_PRON_LEN]; SLTS_Engine * pEng = (SLTS_Engine *)hLts; int i; int num_phones = 0; @@ -283,7 +282,7 @@ SWISLTS_FNEXPORT SWIsltsResult SWIsltsG2PGetWordTranscriptions(SWIsltsHand hLts, LCHAR * pBlock = NULL; for( i = 0; i < MAX_PRON_LEN; i++ ) { - phone_string[i] = g_PHONE_STRING[i]; + phone_string[i] = PHONE_STRING[i]; } nRes = SWIsltsTextToPhone(hLts, text, phone_string, &num_phones, MAX_PRON_LEN); @@ -331,12 +330,6 @@ SWISLTS_FNEXPORT SWIsltsResult SWIsltsG2PGetWordTranscriptions(SWIsltsHand hLts, CLEAN_UP: - for( i = 0; i < MAX_PRON_LEN; i++ ) { - if( phone_string[i] != NULL ) { - FREE(phone_string[i]); - } - } - *ppTranscriptions = NULL; *pnNbrOfTranscriptions = 0; diff --git a/seti/sltsEngine/src/run_seq_lts.c b/seti/sltsEngine/src/run_seq_lts.c index 255a296..1d9fb05 100644 --- a/seti/sltsEngine/src/run_seq_lts.c +++ b/seti/sltsEngine/src/run_seq_lts.c @@ -1796,22 +1796,10 @@ void *lts_alloc(int num, int size) } #else -#ifndef __SYMBIAN32__ -static int total_alloc = 0; -#endif void *lts_alloc(int num, int size) { void *p; -#ifndef __SYMBIAN32__ - total_alloc += num * size; -#endif p = CALLOC(num, size, MTAG); - /* -#ifndef __SYMBIAN32__ - pfprintf(PSTDOUT,"LTS Alloc %d X %d p %x tot %d\n", num, size, p, total_alloc); -#endif - */ - return p; } #endif /* USE_STATIC_SLTS */ diff --git a/shared/src/ESR_Locale.c b/shared/src/ESR_Locale.c index 2fb2680..148eb00 100644 --- a/shared/src/ESR_Locale.c +++ b/shared/src/ESR_Locale.c @@ -11,7 +11,7 @@ * * * Unless required by applicable law or agreed to in writing, software * * distributed under the License is distributed on an 'AS IS' BASIS, * - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * * See the License for the specific language governing permissions and * * limitations under the License. * * * @@ -22,78 +22,39 @@ #include "plog.h" #include "LCHAR.h" -#define LOCALE_COUNT 9 -static LCHAR* localeStringMapping[LOCALE_COUNT+1] = - { - L("ESR_LOCALE_EN_US"), - L("ESR_LOCALE_FR_FR"), - L("ESR_LOCALE_DE_DE"), - L("ESR_LOCALE_EN_GB"), - L("ESR_LOCALE_IT_IT"), - L("ESR_LOCALE_NL_NL"), - L("ESR_LOCALE_PT_PT"), - L("ESR_LOCALE_ES_ES"), - L("ESR_LOCALE_JA_JP"), - L("invalid locale code") /* must remain last element for ESR_locale2str() to function */ - }; - + LCHAR* ESR_locale2str(const ESR_Locale locale) { - if (locale >= LOCALE_COUNT) - return localeStringMapping[LOCALE_COUNT]; - return localeStringMapping[locale]; + switch (locale) { + case ESR_LOCALE_EN_US: return L("ESR_LOCALE_EN_US"); + case ESR_LOCALE_FR_FR: return L("ESR_LOCALE_FR_FR"); + case ESR_LOCALE_DE_DE: return L("ESR_LOCALE_DE_DE"); + case ESR_LOCALE_EN_GB: return L("ESR_LOCALE_EN_GB"); + case ESR_LOCALE_IT_IT: return L("ESR_LOCALE_IT_IT"); + case ESR_LOCALE_NL_NL: return L("ESR_LOCALE_NL_NL"); + case ESR_LOCALE_PT_PT: return L("ESR_LOCALE_PT_PT"); + case ESR_LOCALE_ES_ES: return L("ESR_LOCALE_ES_ES"); + case ESR_LOCALE_JA_JP: return L("ESR_LOCALE_JA_JP"); + } + return L("invalid locale code"); } ESR_ReturnCode ESR_str2locale(const LCHAR* str, ESR_Locale* locale) { - int result; - - if (lstrcasecmp(str, L("EN-US"), &result) == ESR_SUCCESS && !result) - { - *locale = ESR_LOCALE_EN_US; - return ESR_SUCCESS; - } - else if (lstrcasecmp(str, L("FR-FR"), &result) == ESR_SUCCESS && !result) - { - *locale = ESR_LOCALE_FR_FR; - return ESR_SUCCESS; - } - else if (lstrcasecmp(str, L("DE-DE"), &result) == ESR_SUCCESS && !result) - { - *locale = ESR_LOCALE_DE_DE; - return ESR_SUCCESS; - } - else if (lstrcasecmp(str, L("EN-GB"), &result) == ESR_SUCCESS && !result) - { - *locale = ESR_LOCALE_EN_GB; - return ESR_SUCCESS; - } - else if (lstrcasecmp(str, L("JA-JP"), &result) == ESR_SUCCESS && !result) - { - *locale = ESR_LOCALE_JA_JP; - return ESR_SUCCESS; - } - else if (lstrcasecmp(str, L("PT-PT"), &result) == ESR_SUCCESS && !result) - { - *locale = ESR_LOCALE_PT_PT; - return ESR_SUCCESS; - } - else if (lstrcasecmp(str, L("ES-ES"), &result) == ESR_SUCCESS && !result) - { - *locale = ESR_LOCALE_ES_ES; - return ESR_SUCCESS; - } - else if (lstrcasecmp(str, L("IT-IT"), &result) == ESR_SUCCESS && !result) - { - *locale = ESR_LOCALE_IT_IT; - return ESR_SUCCESS; - } - else if (lstrcasecmp(str, L("NL-NL"), &result) == ESR_SUCCESS && !result) - { - *locale = ESR_LOCALE_NL_NL; + int rtn = 0; + if (!lstrcasecmp(str, L("EN-US"), &rtn) && !rtn) *locale = ESR_LOCALE_EN_US; + else if (!lstrcasecmp(str, L("FR-FR"), &rtn) && !rtn) *locale = ESR_LOCALE_FR_FR; + else if (!lstrcasecmp(str, L("DE-DE"), &rtn) && !rtn) *locale = ESR_LOCALE_DE_DE; + else if (!lstrcasecmp(str, L("EN-GB"), &rtn) && !rtn) *locale = ESR_LOCALE_EN_GB; + else if (!lstrcasecmp(str, L("IT-IT"), &rtn) && !rtn) *locale = ESR_LOCALE_IT_IT; + else if (!lstrcasecmp(str, L("NL-NL"), &rtn) && !rtn) *locale = ESR_LOCALE_NL_NL; + else if (!lstrcasecmp(str, L("PT-PT"), &rtn) && !rtn) *locale = ESR_LOCALE_PT_PT; + else if (!lstrcasecmp(str, L("ES-ES"), &rtn) && !rtn) *locale = ESR_LOCALE_ES_ES; + else if (!lstrcasecmp(str, L("JA-JP"), &rtn) && !rtn) *locale = ESR_LOCALE_JA_JP; + else { + PLogError(L("no locale defined for %s"), str); + return ESR_INVALID_ARGUMENT; + } return ESR_SUCCESS; - } - PLogError(L("no locale defined for %s"), str); - return ESR_INVALID_ARGUMENT; } diff --git a/srec/AcousticState/include/SR_AcousticState.h b/srec/AcousticState/include/SR_AcousticState.h index 5b8e57d..a2f54b2 100644 --- a/srec/AcousticState/include/SR_AcousticState.h +++ b/srec/AcousticState/include/SR_AcousticState.h @@ -1,7 +1,7 @@ /*---------------------------------------------------------------------------* - * SR_AcousticState.h * + * SR_AcousticState.h * * * - * Copyright 2007, 2008 Nuance Communciations, Inc. * + * Copyright 2007, 2008 Nuance Communciations, Inc. * * * * Licensed under the Apache License, Version 2.0 (the 'License'); * * you may not use this file except in compliance with the License. * @@ -11,7 +11,7 @@ * * * Unless required by applicable law or agreed to in writing, software * * distributed under the License is distributed on an 'AS IS' BASIS, * - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * * See the License for the specific language governing permissions and * * limitations under the License. * * * @@ -77,7 +77,7 @@ typedef struct SR_AcousticState_t * @param param_string contains data from the recognizer * @return ESR_INVALID_ARGUMENT if recognizer is null */ - ESR_ReturnCode(*get)(SR_Recognizer* recognizer, const LCHAR **param_string ); + ESR_ReturnCode(*get)(SR_Recognizer* recognizer, LCHAR *param_string, size_t* len ); /** * Sets an AcousticState from a string. * @@ -147,7 +147,7 @@ SREC_ACOUSTICSTATE_API ESR_ReturnCode SR_AcousticStateSave(SR_Recognizer* recogn */ SREC_ACOUSTICSTATE_API ESR_ReturnCode SR_AcousticStateReset(SR_Recognizer* recognizer); SREC_ACOUSTICSTATE_API ESR_ReturnCode SR_AcousticStateSet ( SR_Recognizer* recognizer, const LCHAR *param_string ); -SREC_ACOUSTICSTATE_API ESR_ReturnCode SR_AcousticStateGet ( SR_Recognizer* recognizer, const LCHAR **param_string ); +SREC_ACOUSTICSTATE_API ESR_ReturnCode SR_AcousticStateGet ( SR_Recognizer* recognizer, LCHAR *param_string, size_t* len ); /** * @} */ diff --git a/srec/AcousticState/include/SR_AcousticStateImpl.h b/srec/AcousticState/include/SR_AcousticStateImpl.h index 5c4d7b0..b66c1a9 100644 --- a/srec/AcousticState/include/SR_AcousticStateImpl.h +++ b/srec/AcousticState/include/SR_AcousticStateImpl.h @@ -1,7 +1,7 @@ /*---------------------------------------------------------------------------* - * SR_AcousticStateImpl.h * + * SR_AcousticStateImpl.h * * * - * Copyright 2007, 2008 Nuance Communciations, Inc. * + * Copyright 2007, 2008 Nuance Communciations, Inc. * * * * Licensed under the Apache License, Version 2.0 (the 'License'); * * you may not use this file except in compliance with the License. * @@ -11,7 +11,7 @@ * * * Unless required by applicable law or agreed to in writing, software * * distributed under the License is distributed on an 'AS IS' BASIS, * - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * * See the License for the specific language governing permissions and * * limitations under the License. * * * @@ -70,7 +70,7 @@ SREC_ACOUSTICSTATE_API ESR_ReturnCode SR_AcousticStateSetImpl(SR_Recognizer* rec /** * Default implementation. */ -SREC_ACOUSTICSTATE_API ESR_ReturnCode SR_AcousticStateGetImpl(SR_Recognizer* recognizer, const LCHAR **param_string ); +SREC_ACOUSTICSTATE_API ESR_ReturnCode SR_AcousticStateGetImpl(SR_Recognizer* recognizer, LCHAR *param_string, size_t* len ); /** * Default implementation. */ diff --git a/srec/AcousticState/src/AcousticState.c b/srec/AcousticState/src/AcousticState.c index b9eb6e2..089041c 100644 --- a/srec/AcousticState/src/AcousticState.c +++ b/srec/AcousticState/src/AcousticState.c @@ -1,7 +1,7 @@ /*---------------------------------------------------------------------------* - * AcousticState.c * + * AcousticState.c * * * - * Copyright 2007, 2008 Nuance Communciations, Inc. * + * Copyright 2007, 2008 Nuance Communciations, Inc. * * * * Licensed under the Apache License, Version 2.0 (the 'License'); * * you may not use this file except in compliance with the License. * @@ -11,7 +11,7 @@ * * * Unless required by applicable law or agreed to in writing, software * * distributed under the License is distributed on an 'AS IS' BASIS, * - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * * See the License for the specific language governing permissions and * * limitations under the License. * * * @@ -25,42 +25,42 @@ SREC_ACOUSTICSTATE_API ESR_ReturnCode SR_AcousticStateReset(SR_Recognizer* recognizer) { SR_RecognizerImpl* impl; - + if (recognizer == NULL) { PLogError(L("ESR_INVALID_ARGUMENT")); return ESR_INVALID_ARGUMENT; } impl = (SR_RecognizerImpl*) recognizer; - + return impl->acousticState->reset(recognizer); } SREC_ACOUSTICSTATE_API ESR_ReturnCode SR_AcousticStateLoad(SR_Recognizer* recognizer, const LCHAR* filename) { SR_RecognizerImpl* impl; - + if (recognizer == NULL) { PLogError(L("ESR_INVALID_ARGUMENT")); return ESR_INVALID_ARGUMENT; } impl = (SR_RecognizerImpl*) recognizer; - + return impl->acousticState->load(recognizer, filename); } SREC_ACOUSTICSTATE_API ESR_ReturnCode SR_AcousticStateSave(SR_Recognizer* recognizer, const LCHAR* filename) { SR_RecognizerImpl* impl; - + if (recognizer == NULL) { PLogError(L("ESR_INVALID_ARGUMENT")); return ESR_INVALID_ARGUMENT; } impl = (SR_RecognizerImpl*) recognizer; - + return impl->acousticState->save(recognizer, filename); } @@ -68,30 +68,30 @@ SREC_ACOUSTICSTATE_API ESR_ReturnCode SR_AcousticStateSave(SR_Recognizer* recogn SREC_ACOUSTICSTATE_API ESR_ReturnCode SR_AcousticStateSet ( SR_Recognizer* recognizer, const LCHAR *param_string ) { SR_RecognizerImpl* impl; - + if (recognizer == NULL) { PLogError(L("ESR_INVALID_ARGUMENT")); return ESR_INVALID_ARGUMENT; } impl = (SR_RecognizerImpl*) recognizer; - + return impl->acousticState->set ( recognizer, param_string ); } -SREC_ACOUSTICSTATE_API ESR_ReturnCode SR_AcousticStateGet ( SR_Recognizer* recognizer, const LCHAR **param_string ) +SREC_ACOUSTICSTATE_API ESR_ReturnCode SR_AcousticStateGet ( SR_Recognizer* recognizer, LCHAR *param_string, size_t* len ) { SR_RecognizerImpl* impl; - + if (recognizer == NULL) { PLogError(L("ESR_INVALID_ARGUMENT")); return ESR_INVALID_ARGUMENT; } impl = (SR_RecognizerImpl*) recognizer; - - return impl->acousticState->get ( recognizer, param_string ); + + return impl->acousticState->get ( recognizer, param_string, len ); } diff --git a/srec/AcousticState/src/AcousticStateImpl.c b/srec/AcousticState/src/AcousticStateImpl.c index c9359ee..9ffece4 100644 --- a/srec/AcousticState/src/AcousticStateImpl.c +++ b/srec/AcousticState/src/AcousticStateImpl.c @@ -1,7 +1,7 @@ /*---------------------------------------------------------------------------* - * AcousticStateImpl.c * + * AcousticStateImpl.c * * * - * Copyright 2007, 2008 Nuance Communciations, Inc. * + * Copyright 2007, 2008 Nuance Communciations, Inc. * * * * Licensed under the Apache License, Version 2.0 (the 'License'); * * you may not use this file except in compliance with the License. * @@ -11,7 +11,7 @@ * * * Unless required by applicable law or agreed to in writing, software * * distributed under the License is distributed on an 'AS IS' BASIS, * - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * * See the License for the specific language governing permissions and * * limitations under the License. * * * @@ -28,7 +28,7 @@ ESR_ReturnCode SR_AcousticStateCreateImpl(SR_Recognizer* recognizer) { SR_AcousticStateImpl* impl; SR_RecognizerImpl* recogImpl = (SR_RecognizerImpl*) recognizer; - + if (recogImpl == NULL) { PLogError(L("ESR_INVALID_ARGUMENT")); @@ -40,31 +40,31 @@ ESR_ReturnCode SR_AcousticStateCreateImpl(SR_Recognizer* recognizer) PLogError(L("ESR_OUT_OF_MEMORY")); return ESR_OUT_OF_MEMORY; } - + impl->Interface.load = &SR_AcousticStateLoadImpl; impl->Interface.save = &SR_AcousticStateSaveImpl; impl->Interface.destroy = &SR_AcousticStateDestroyImpl; impl->Interface.reset = &SR_AcousticStateResetImpl; impl->Interface.set = &SR_AcousticStateSetImpl; impl->Interface.get = &SR_AcousticStateGetImpl; - + recogImpl->acousticState = &impl->Interface; return ESR_SUCCESS; } -ESR_ReturnCode SR_AcousticStateGetImpl(SR_Recognizer* self, const LCHAR **param_string ) +ESR_ReturnCode SR_AcousticStateGetImpl(SR_Recognizer* self, LCHAR *param_string, size_t* len ) { SR_RecognizerImpl* recogImpl = (SR_RecognizerImpl*) self; - - return CA_GetCMSParameters(recogImpl->wavein, param_string ); + + return CA_GetCMSParameters(recogImpl->wavein, param_string, len ); } ESR_ReturnCode SR_AcousticStateSetImpl(SR_Recognizer* self, const LCHAR *param_string ) { SR_RecognizerImpl* recogImpl = (SR_RecognizerImpl*) self; - + return CA_SetCMSParameters(recogImpl->wavein, param_string ); } @@ -73,7 +73,7 @@ ESR_ReturnCode SR_AcousticStateDestroyImpl(SR_Recognizer* recognizer) { SR_RecognizerImpl* recogImpl = (SR_RecognizerImpl*) recognizer; SR_AcousticStateImpl* impl = (SR_AcousticStateImpl*) recogImpl->acousticState; - + FREE(impl); return ESR_SUCCESS; } @@ -88,7 +88,7 @@ ESR_ReturnCode SR_AcousticStateResetImpl(SR_Recognizer* recognizer) ESR_ReturnCode SR_AcousticStateLoadImpl(SR_Recognizer* self, const LCHAR* filename) { SR_RecognizerImpl* recogImpl = (SR_RecognizerImpl*) self; - + CA_ReLoadCMSParameters(recogImpl->wavein, filename); return ESR_SUCCESS; } diff --git a/srec/EventLog/src/EventLogImpl.c b/srec/EventLog/src/EventLogImpl.c index c5150fb..90c0d87 100644 --- a/srec/EventLog/src/EventLogImpl.c +++ b/srec/EventLog/src/EventLogImpl.c @@ -455,11 +455,11 @@ ESR_ReturnCode logIt(SR_EventLogImpl *impl, LCHAR* evtt, LCHAR* log_record, size struct tm *ct, ct_r; LCHAR header[128], header2[64]; PTimeStamp timestamp; - static size_t sizeof_LCHAR = sizeof(LCHAR); - static LCHAR* bar = "|"; - static LCHAR* nl = "\n"; + const size_t sizeof_LCHAR = sizeof(LCHAR); + const LCHAR* bar = "|"; + const LCHAR* nl = "\n"; size_t i, len; - LCHAR* toWrite[5]; + const LCHAR* toWrite[5]; toWrite[0] = header; toWrite[1] = bar; diff --git a/srec/Recognizer/src/RecognizerImpl.c b/srec/Recognizer/src/RecognizerImpl.c index 054d567..f64a1db 100644 --- a/srec/Recognizer/src/RecognizerImpl.c +++ b/srec/Recognizer/src/RecognizerImpl.c @@ -17,13 +17,6 @@ * * *---------------------------------------------------------------------------*/ -/*#define SREC_MEASURE_LATENCY 1*/ - -#ifdef SREC_MEASURE_LATENCY -#include <sys/time.h> - -struct timeval latency_start; -#endif #include "ESR_Session.h" #include "ESR_SessionTypeImpl.h" @@ -62,49 +55,6 @@ struct timeval latency_start; #define SUFFIX_WORD "-pau2-" #define SUFFIX_WORD_LEN 6 -#ifdef MEASURE_SAMPLE_TIMES -#include <sys/time.h> -#include <stdio.h> - -#define MAX_SAMPLES_TO_MEASURE 500 - -static long sample_buffers_received = 0; -static long total_samples_received = 0; -static long samples_in_buffer [MAX_SAMPLES_TO_MEASURE]; -static long seconds_buffer_received [MAX_SAMPLES_TO_MEASURE]; -static long micro_seconds_buffer_received [MAX_SAMPLES_TO_MEASURE]; -static struct timeval buffer_received_time; - -static void SR_Recognizer_Log_Samples_Received ( void ); - -static void SR_Recognizer_Log_Samples_Received ( void ) -{ - FILE *log_file; - char file_name [256]; - char log_buffer [256]; - long loop_counter; - - if ( sample_buffers_received > 0 ) - { - gettimeofday ( &buffer_received_time, NULL ); - sprintf ( file_name, "reco_recvd_%ld_%ld.txt", buffer_received_time.tv_sec, buffer_received_time.tv_usec ); - log_file = fopen ( file_name, "w" ); - - if ( log_file != NULL ) - { - for ( loop_counter = 0; loop_counter < sample_buffers_received; loop_counter++ ) - { - sprintf ( log_buffer, "%ld %ld %ld %ld\n", loop_counter + 1, samples_in_buffer [loop_counter], - seconds_buffer_received [loop_counter], micro_seconds_buffer_received [loop_counter] ); - fwrite ( log_buffer, 1, strlen ( log_buffer ), log_file ); - } - fclose ( log_file ); - } - sample_buffers_received = 0; - } - } -#endif - static ESR_ReturnCode SR_Recognizer_Reset_Buffers ( SR_RecognizerImpl *impl ); @@ -1115,10 +1065,6 @@ ESR_ReturnCode SR_RecognizerStopImpl(SR_Recognizer* self) SR_AcousticModelsImpl* modelsImpl; ESR_ReturnCode rc; -#ifdef MEASURE_SAMPLE_TIMES - SR_Recognizer_Log_Samples_Received ( ); -#endif - PLOG_DBG_API_ENTER(); if (!impl->isStarted) { @@ -1775,18 +1721,6 @@ ESR_ReturnCode SR_RecognizerPutAudioImpl(SR_Recognizer* self, asr_int16_t* buffe int rcBufWrite; size_t nbWritten; -#ifdef MEASURE_SAMPLE_TIMES - if ( sample_buffers_received < MAX_SAMPLES_TO_MEASURE ) - { - gettimeofday ( &buffer_received_time, NULL ); - seconds_buffer_received [sample_buffers_received] = buffer_received_time.tv_sec; - micro_seconds_buffer_received [sample_buffers_received] = buffer_received_time.tv_usec; - samples_in_buffer [sample_buffers_received] = *bufferSize; - total_samples_received += *bufferSize; - sample_buffers_received++; - } -#endif - if (isLast == ESR_FALSE && (buffer == NULL || bufferSize == NULL)) { PLogError(L("ESR_INVALID_ARGUMENT")); @@ -3422,11 +3356,6 @@ MOVE_TO_NEXT_STATE: rc = detectEndOfSpeech(impl, status, type, impl->result); if (rc != ESR_CONTINUE_PROCESSING) { -#ifdef SREC_MEASURE_LATENCY - gettimeofday ( &latency_start, NULL ); - printf ( "Start Time : %ld Seconds %ld Microseconds\n", latency_start.tv_sec, latency_start.tv_usec ); -#endif - /* End of speech detected */ return rc; } @@ -3448,10 +3377,6 @@ MOVE_TO_NEXT_STATE: rc = detectEndOfSpeech(impl, status, type, impl->result); if (rc != ESR_CONTINUE_PROCESSING) { -#ifdef SREC_MEASURE_LATENCY - gettimeofday ( &latency_start, NULL ); - printf ( "Start Time : %ld Seconds %ld Microseconds\n", latency_start.tv_sec, latency_start.tv_usec ); -#endif /* End of speech detected */ return rc; } diff --git a/srec/Semproc/include/SR_SymbolTable.h b/srec/Semproc/include/SR_SymbolTable.h index 392f5a4..bf1ba97 100644 --- a/srec/Semproc/include/SR_SymbolTable.h +++ b/srec/Semproc/include/SR_SymbolTable.h @@ -114,7 +114,7 @@ ESR_ReturnCode ST_Copy(SymbolTable* self, HashMap* dst); * @param key the key for the entry * @param value the value for the entry (associated with key) */ -SREC_SEMPROC_API ESR_ReturnCode ST_putKeyValue(SymbolTable* self, LCHAR* key, LCHAR* value); +SREC_SEMPROC_API ESR_ReturnCode ST_putKeyValue(SymbolTable* self, const LCHAR* key, const LCHAR* value); /** * Retrieve a value associated with the key @@ -122,7 +122,7 @@ SREC_SEMPROC_API ESR_ReturnCode ST_putKeyValue(SymbolTable* self, LCHAR* key, LC * @param key the key for the entry * @param value pointer to buffer for the storing result */ -SREC_SEMPROC_API ESR_ReturnCode ST_getKeyValue(SymbolTable* self, LCHAR* key, LCHAR** value); +SREC_SEMPROC_API ESR_ReturnCode ST_getKeyValue(SymbolTable* self, const LCHAR* key, LCHAR** value); /** * Ask for a new sot in the symbol table @@ -145,7 +145,7 @@ SREC_SEMPROC_API ESR_ReturnCode ST_reset_all(SymbolTable* self); * @param key the key for the entry * @param value the value for the entry (associated with key) */ -SREC_SEMPROC_API ESR_ReturnCode ST_putSpecialKeyValue(SymbolTable* self, const LCHAR* key, const LCHAR* value); +SREC_SEMPROC_API ESR_ReturnCode ST_putSpecialKeyValue(SymbolTable* self, const const LCHAR* key, const LCHAR* value); #endif /* __SYMBOL_TABLE_H */ diff --git a/srec/Semproc/src/SemanticProcessorImpl.c b/srec/Semproc/src/SemanticProcessorImpl.c index f44a3aa..b63417f 100644 --- a/srec/Semproc/src/SemanticProcessorImpl.c +++ b/srec/Semproc/src/SemanticProcessorImpl.c @@ -1,7 +1,7 @@ /*---------------------------------------------------------------------------* - * SemanticProcessorImpl.c * + * SemanticProcessorImpl.c * * * - * Copyright 2007, 2008 Nuance Communciations, Inc. * + * Copyright 2007, 2008 Nuance Communciations, Inc. * * * * Licensed under the Apache License, Version 2.0 (the 'License'); * * you may not use this file except in compliance with the License. * @@ -11,7 +11,7 @@ * * * Unless required by applicable law or agreed to in writing, software * * distributed under the License is distributed on an 'AS IS' BASIS, * - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * * See the License for the specific language governing permissions and * * limitations under the License. * * * @@ -43,13 +43,16 @@ typedef struct sem_partial_path_t } sem_partial_path; -static sem_partial_path sem_partial_paths[MAX_SEM_PARTIAL_PATHS]; -static sem_partial_path* sem_partial_path_freelist; #define DEBUG_CPF 0 #if DEBUG_CPF static arc_token* debug_base_arc_token = 0; static int debug_depth = 0; -const char* spaces(int n) { static char sp[1280]; int i; for(i=0;i<n;i++) sp[i]=' '; sp[i]=0; return &sp[0]; } +static const char* spaces(int n) { + const char* sp = " "; + int nsp = strlen(sp); + if (n > nsp) n = nsp; + return sp + nsp - n; +} #endif /** @@ -77,166 +80,166 @@ static const LCHAR* WORD_NOT_FOUND = L("word_not_found"); /** * Initialize the list of partial paths */ -ESR_ReturnCode sem_partial_path_list_init(); -sem_partial_path* sem_partial_path_create(); -ESR_ReturnCode sem_partial_path_free(sem_partial_path* path); -void sem_partial_path_print(sem_partial_path* path, sem_partial_path* paths, int npaths, wordmap* ilabels); +static ESR_ReturnCode sem_partial_path_list_init(sem_partial_path* heap, int nheap); +static sem_partial_path* sem_partial_path_create(sem_partial_path* heap); +static ESR_ReturnCode sem_partial_path_free(sem_partial_path* heap, sem_partial_path* path); +static void sem_partial_path_print(sem_partial_path* path, sem_partial_path* paths, int npaths, wordmap* ilabels); /** * Look up the word string given the id */ -const LCHAR* lookUpWord(SR_SemanticGraphImpl* semgraph, wordID wdid); +static const LCHAR* lookUpWord(SR_SemanticGraphImpl* semgraph, wordID wdid); /** * Look up the actual script string given the label */ -const LCHAR* lookUpScript(SR_SemanticGraphImpl* semgraph, const LCHAR* script_label); +static const LCHAR* lookUpScript(SR_SemanticGraphImpl* semgraph, const LCHAR* script_label); /** * Recursively accumulate the scripts */ -ESR_ReturnCode accumulate_scripts(SR_SemanticGraphImpl* semgraph, script_list* scripts, sem_partial_path* path_root); +static ESR_ReturnCode accumulate_scripts(SR_SemanticGraphImpl* semgraph, script_list* scripts, sem_partial_path* path_root); -ESR_ReturnCode interpretScripts(SR_SemanticProcessorImpl* semproc, LCHAR* scripts, SR_SemanticResult** result); +static ESR_ReturnCode interpretScripts(SR_SemanticProcessorImpl* semproc, LCHAR* scripts, SR_SemanticResult** result); ESR_ReturnCode SR_SemanticProcessorCreate(SR_SemanticProcessor** self) { - SR_SemanticProcessorImpl* impl; - ESR_ReturnCode rc; - - if (self == NULL) - { - PLogError(L("ESR_INVALID_ARGUMENT")); - return ESR_INVALID_ARGUMENT; - } - impl = NEW(SR_SemanticProcessorImpl, MTAG); - if (impl == NULL) - { - PLogError(L("ESR_OUT_OF_MEMORY")); - return ESR_OUT_OF_MEMORY; - } - if ((rc = LA_Init(&impl->analyzer)) != ESR_SUCCESS) - goto CLEANUP; - if ((rc = EP_Init(&impl->parser)) != ESR_SUCCESS) - goto CLEANUP; - if ((rc = ST_Init(&impl->symtable)) != ESR_SUCCESS) - goto CLEANUP; - if ((rc = EE_Init(&impl->eval)) != ESR_SUCCESS) - goto CLEANUP; - impl->acc_scripts = MALLOC(sizeof(LCHAR) * MAX_SCRIPT_LEN, NULL); - if (impl->acc_scripts == NULL) - { - rc = ESR_OUT_OF_MEMORY; - PLogError(ESR_rc2str(rc)); - goto CLEANUP; - } - - impl->Interface.destroy = &SR_SemanticProcessor_Destroy; - impl->Interface.checkParse = &SR_SemanticProcessor_CheckParse; - impl->Interface.checkParseByWordID = &SR_SemanticProcessor_CheckParseByWordID; - impl->Interface.setParam = &SR_SemanticProcessor_SetParam; - impl->Interface.flush = &SR_SemanticProcessor_Flush; - - - *self = (SR_SemanticProcessor*) impl; - return ESR_SUCCESS; + SR_SemanticProcessorImpl* impl; + ESR_ReturnCode rc; + + if (self == NULL) + { + PLogError(L("ESR_INVALID_ARGUMENT")); + return ESR_INVALID_ARGUMENT; + } + impl = NEW(SR_SemanticProcessorImpl, MTAG); + if (impl == NULL) + { + PLogError(L("ESR_OUT_OF_MEMORY")); + return ESR_OUT_OF_MEMORY; + } + if ((rc = LA_Init(&impl->analyzer)) != ESR_SUCCESS) + goto CLEANUP; + if ((rc = EP_Init(&impl->parser)) != ESR_SUCCESS) + goto CLEANUP; + if ((rc = ST_Init(&impl->symtable)) != ESR_SUCCESS) + goto CLEANUP; + if ((rc = EE_Init(&impl->eval)) != ESR_SUCCESS) + goto CLEANUP; + impl->acc_scripts = MALLOC(sizeof(LCHAR) * MAX_SCRIPT_LEN, NULL); + if (impl->acc_scripts == NULL) + { + rc = ESR_OUT_OF_MEMORY; + PLogError(ESR_rc2str(rc)); + goto CLEANUP; + } + + impl->Interface.destroy = &SR_SemanticProcessor_Destroy; + impl->Interface.checkParse = &SR_SemanticProcessor_CheckParse; + impl->Interface.checkParseByWordID = &SR_SemanticProcessor_CheckParseByWordID; + impl->Interface.setParam = &SR_SemanticProcessor_SetParam; + impl->Interface.flush = &SR_SemanticProcessor_Flush; + + + *self = (SR_SemanticProcessor*) impl; + return ESR_SUCCESS; CLEANUP: - impl->Interface.destroy(&impl->Interface); - return rc; + impl->Interface.destroy(&impl->Interface); + return rc; } ESR_ReturnCode SR_SemanticProcessor_Destroy(SR_SemanticProcessor* self) { - SR_SemanticProcessorImpl* impl = (SR_SemanticProcessorImpl*) self; - - if (self == NULL) - { - PLogError(L("ESR_INVALID_ARGUMENT")); - return ESR_INVALID_ARGUMENT; - } - - LA_Free(impl->analyzer); - EP_Free(impl->parser); - ST_Free(impl->symtable); - EE_Free(impl->eval); - if (impl->acc_scripts != NULL) - { - FREE(impl->acc_scripts); - impl->acc_scripts = NULL; - } - FREE(impl); - - return ESR_SUCCESS; + SR_SemanticProcessorImpl* impl = (SR_SemanticProcessorImpl*) self; + + if (self == NULL) + { + PLogError(L("ESR_INVALID_ARGUMENT")); + return ESR_INVALID_ARGUMENT; + } + + LA_Free(impl->analyzer); + EP_Free(impl->parser); + ST_Free(impl->symtable); + EE_Free(impl->eval); + if (impl->acc_scripts != NULL) + { + FREE(impl->acc_scripts); + impl->acc_scripts = NULL; + } + FREE(impl); + + return ESR_SUCCESS; } ESR_ReturnCode append_with_check(LCHAR** dst, const LCHAR src, const LCHAR* end) { - if (*dst < end) - { - **dst = src; - ++(*dst); - return ESR_SUCCESS; - } - PLogError(L("ESR_BUFFER_OVERFLOW")); - return ESR_BUFFER_OVERFLOW; + if (*dst < end) + { + **dst = src; + ++(*dst); + return ESR_SUCCESS; + } + PLogError(L("ESR_BUFFER_OVERFLOW")); + return ESR_BUFFER_OVERFLOW; } -const LCHAR* LSTRNCHR2(const LCHAR* text, LCHAR c, LCHAR c2, size_t len) +static const LCHAR* LSTRNCHR2(const LCHAR* text, LCHAR c, LCHAR c2, size_t len) { - for (; *text != c && *text != c2 && len > 0 && *text; text++, len--) - ; - if (len) return text; - else return NULL; + for (; *text != c && *text != c2 && len > 0 && *text; text++, len--) + ; + if (len) return text; + else return NULL; } -size_t get_next_token_len(const char* expr) +static size_t get_next_token_len(const char* expr) { - const char *p; - - if (IS_OPERATOR(expr)) - { - return 1; - } - else if (*expr == ';') - { - return 1; - } - else if (*expr == '\'') - { - /* a literal */ - for (p = expr; *p != '\0'; p++) + const char *p; + + if (IS_OPERATOR(expr)) { - if (*p == '\\' && *(p + 1) == '\'') - { - ++p; - continue; - } - if (p > expr && *p == '\'') - { - ++p; - break; - } + return 1; } - return p -expr; - } - else - { - for (p = expr; *p != '\0'; p++) + else if (*expr == ';') { - if (*p == '(') - { - ++p; - break; - } - else if (IS_OPERATOR(p) || *p == ';') - { - break; - } + return 1; + } + else if (*expr == '\'') + { + /* a literal */ + for (p = expr; *p != '\0'; p++) + { + if (*p == '\\' && *(p + 1) == '\'') + { + ++p; + continue; + } + if (p > expr && *p == '\'') + { + ++p; + break; + } + } + return p -expr; + } + else + { + for (p = expr; *p != '\0'; p++) + { + if (*p == '(') + { + ++p; + break; + } + else if (IS_OPERATOR(p) || *p == ';') + { + break; + } + } + return p -expr; } - return p -expr; - } } #define firstWord(transcription) transcription @@ -244,842 +247,835 @@ size_t get_next_token_len(const char* expr) /* assumption is that transcription has been prepared (word split by NULL, transcription ends with double NULL */ -ESR_ReturnCode checkpath_forwardByWordID(SR_SemanticGraphImpl* semgraph, - arc_token* atoken_start, - sem_partial_path *pp, - const wordID* wordIDs) +static ESR_ReturnCode checkpath_forwardByWordID(SR_SemanticGraphImpl* semgraph, + sem_partial_path* heap, + arc_token* atoken_start, + sem_partial_path *pp, + const wordID* wordIDs) { - // This is a recursive function that could go 10 levels deep on the stack so we save memory by making sure - // we place as few variables as possible on the stack. - union saveMemory_t - { - ESR_ReturnCode rc; arc_token* atok_use; - } saveMemory; - - sem_partial_path* pp_branch; - arc_token* atok; - const wordID* currentWord = wordIDs; - - /***************** - * Recursive Part (operate on the next arc or the branch) - *****************/ - for (atok = atoken_start; atok; atok = ARC_TOKEN_PTR(semgraph->arc_token_list, atok->next_token_index)) - { + sem_partial_path* pp_branch; + arc_token* atok; + const wordID* currentWord = wordIDs; + + /***************** + * Recursive Part (operate on the next arc or the branch) + *****************/ + for (atok = atoken_start; atok; atok = ARC_TOKEN_PTR(semgraph->arc_token_list, atok->next_token_index)) + { #if DEBUG_CPF - printf("%strying arc %d %p ilabel%d(%s) olabel %d\n", spaces(debug_depth), atok-debug_base_arc_token, atok, - atok->ilabel, atok->ilabel!=MAXwordID?semgraph->ilabels->words[atok->ilabel]:"max", atok->olabel); + printf("%strying arc %d %p ilabel%d(%s) olabel %d\n", spaces(debug_depth), atok-debug_base_arc_token, atok, + atok->ilabel, atok->ilabel!=MAXwordID?semgraph->ilabels->words[atok->ilabel]:"max", atok->olabel); #endif - saveMemory.atok_use = NULL; - currentWord = wordIDs; - - if (atok->ilabel < semgraph->ilabels->num_slots && atok->ilabel != WORD_EPSILON_LABEL && - wordmap_whether_in_rule(semgraph->ilabels, *currentWord, atok->ilabel)) - { - /* atok->ilabel is the slotid */ - saveMemory.atok_use = arc_tokens_find_ilabel(semgraph->arc_token_list, semgraph->arcs_for_slot[atok->ilabel], *currentWord); - if (!saveMemory.atok_use) - { - arc_token* a; - PLogError(L("ESR_INVALID_STATE: finding wdid %d in slot %d"), *currentWord, atok->ilabel); - for (a = semgraph->arcs_for_slot[atok->ilabel]; 0 && a; a = ARC_TOKEN_PTR(semgraph->arc_token_list, a->next_token_index)) + atok_use = NULL; + currentWord = wordIDs; + + if (atok->ilabel < semgraph->ilabels->num_slots && atok->ilabel != WORD_EPSILON_LABEL && + wordmap_whether_in_rule(semgraph->ilabels, *currentWord, atok->ilabel)) + { + /* atok->ilabel is the slotid */ + atok_use = arc_tokens_find_ilabel(semgraph->arc_token_list, semgraph->arcs_for_slot[atok->ilabel], *currentWord); + if (!atok_use) + { + arc_token* a; + PLogError(L("ESR_INVALID_STATE: finding wdid %d in slot %d"), *currentWord, atok->ilabel); + for (a = semgraph->arcs_for_slot[atok->ilabel]; 0 && a; a = ARC_TOKEN_PTR(semgraph->arc_token_list, a->next_token_index)) + { + PLogError(L("a %x ilabel %d olabel %d"), a, a->ilabel, a->olabel); + } + return ESR_INVALID_STATE; + } + else + ++currentWord; + } + else if (*currentWord != MAXwordID && atok->ilabel == *currentWord) { - PLogError(L("a %x ilabel %d olabel %d"), a, a->ilabel, a->olabel); + ++currentWord; + atok_use = atok; } - return ESR_INVALID_STATE; - } - else - ++currentWord; - } - else if (*currentWord != MAXwordID && atok->ilabel == *currentWord) - { - ++currentWord; - saveMemory.atok_use = atok; - } - else if (atok->ilabel == WORD_EPSILON_LABEL) /* more eps transitions */ - saveMemory.atok_use = atok; - - if (saveMemory.atok_use == NULL) - continue; - else { - arc_token* atokfna = ARC_TOKEN_PTR(semgraph->arc_token_list, atok->first_next_arc); - pp_branch = sem_partial_path_create(); - + else if (atok->ilabel == WORD_EPSILON_LABEL) /* more eps transitions */ + atok_use = atok; + + if (atok_use == NULL) + continue; + else { + arc_token* atokfna = ARC_TOKEN_PTR(semgraph->arc_token_list, atok->first_next_arc); + pp_branch = sem_partial_path_create(heap); + #if DEBUG_CPF - printf("%smatched arc %d %p ilabel%d(%s) olabel %d\n", spaces(debug_depth), atok-debug_base_arc_token, atok, - atok->ilabel, semgraph->ilabels->words[atok->ilabel], atok->olabel); + printf("%smatched arc %d %p ilabel%d(%s) olabel %d\n", spaces(debug_depth), atok-debug_base_arc_token, atok, + atok->ilabel, semgraph->ilabels->words[atok->ilabel], atok->olabel); #endif - - if (!pp_branch) - return ESR_INVALID_STATE; - pp->next = pp_branch; - pp->arc_for_pp = saveMemory.atok_use; - - if (atok->first_next_arc == ARC_TOKEN_NULL && *currentWord == MAXwordID) - return ESR_SUCCESS; - else if (atokfna && atokfna->ilabel==MAXwordID && atokfna->olabel==MAXwordID && *currentWord==MAXwordID) - return ESR_SUCCESS; - else - { + + if (!pp_branch) + return ESR_INVALID_STATE; + pp->next = pp_branch; + pp->arc_for_pp = atok_use; + + if (atok->first_next_arc == ARC_TOKEN_NULL && *currentWord == MAXwordID) + return ESR_SUCCESS; + else if (atokfna && atokfna->ilabel==MAXwordID && atokfna->olabel==MAXwordID && *currentWord==MAXwordID) + return ESR_SUCCESS; + else + { #if DEBUG_CPF - sem_partial_path_print(pp_branch, &sem_partial_paths[0], MAX_SEM_PARTIAL_PATHS, semgraph->ilabels); - debug_depth += 2; + sem_partial_path_print(pp_branch, &sem_partial_paths[0], MAX_SEM_PARTIAL_PATHS, semgraph->ilabels); + debug_depth += 2; #endif - saveMemory.rc = checkpath_forwardByWordID(semgraph, atokfna, pp_branch, currentWord); + ESR_ReturnCode rc = checkpath_forwardByWordID(semgraph, heap, atokfna, pp_branch, currentWord); #if DEBUG_CPF - debug_depth -= 2; + debug_depth -= 2; #endif - if (saveMemory.rc == ESR_SUCCESS) - return saveMemory.rc; - else if (saveMemory.rc == ESR_INVALID_STATE) - { - /* if out-of-memory of other problem, then just abort */ - return ESR_INVALID_STATE; - } - else - { - /* need to uncharge through epsilons, until pp->next==pp_branch */ - // sem_partial_path* qq = pp->next; - sem_partial_path_free(pp->next); - pp->arc_for_pp = NULL; - // for (qq = pp->next; qq != pp_branch; qq = qq->next) sem_partial_path_free(qq); - pp->next = NULL; - } - } - } + if (rc == ESR_SUCCESS) + return ESR_SUCCESS; + else if (rc == ESR_INVALID_STATE) + { + /* if out-of-memory of other problem, then just abort */ + return ESR_INVALID_STATE; + } + else + { + /* need to uncharge through epsilons, until pp->next==pp_branch */ + // sem_partial_path* qq = pp->next; + sem_partial_path_free(heap, pp->next); + pp->arc_for_pp = NULL; + // for (qq = pp->next; qq != pp_branch; qq = qq->next) sem_partial_path_free(qq); + pp->next = NULL; + } + } + } #if DEBUG_CPF - printf("%sdone trying arc %d %p ilabel%d(%s) olabel %d\n", spaces(debug_depth), atok-debug_base_arc_token, atok, - atok->ilabel, semgraph->ilabels->words[atok->ilabel], atok->olabel); + printf("%sdone trying arc %d %p ilabel%d(%s) olabel %d\n", spaces(debug_depth), atok-debug_base_arc_token, atok, + atok->ilabel, semgraph->ilabels->words[atok->ilabel], atok->olabel); #endif - } /* end for atok .. */ - return ESR_NO_MATCH_ERROR; + } /* end for atok .. */ + return ESR_NO_MATCH_ERROR; } -ESR_ReturnCode checkpath_forward(SR_SemanticGraphImpl* semgraph, - arc_token* atoken_start, - sem_partial_path *pp, - const LCHAR* transcription) +static ESR_ReturnCode checkpath_forward(SR_SemanticGraphImpl* semgraph, + sem_partial_path* heap, + arc_token* atoken_start, + sem_partial_path *pp, + const LCHAR* transcription) { - union saveMemory_t - { - ESR_ReturnCode rc; arc_token* atok_use; - } saveMemory; - wordID wdID; - sem_partial_path* pp_branch; - arc_token* atok; - const LCHAR* transp; - - /*****************/ - /* Recursive Part (operate on the next arc or the branch)*/ - /*****************/ - for (atok = atoken_start; atok; atok = ARC_TOKEN_PTR(semgraph->arc_token_list, atok->next_token_index)) + wordID wdID; + sem_partial_path* pp_branch; + arc_token* atok; + const LCHAR* transp; + + /*****************/ + /* Recursive Part (operate on the next arc or the branch)*/ + /*****************/ + for (atok = atoken_start; atok; atok = ARC_TOKEN_PTR(semgraph->arc_token_list, atok->next_token_index)) { #if DEBUG_CPF - printf("%strying arc %d %p ilabel%d(%s) olabel %d\n", spaces(debug_depth), atok-debug_base_arc_token, atok, - atok->ilabel, atok->ilabel!=MAXwordID?semgraph->ilabels->words[atok->ilabel]:"max", atok->olabel); + printf("%strying arc %d %p ilabel%d(%s) olabel %d\n", spaces(debug_depth), atok-debug_base_arc_token, atok, + atok->ilabel, atok->ilabel!=MAXwordID?semgraph->ilabels->words[atok->ilabel]:"max", atok->olabel); #endif - saveMemory.atok_use = NULL; - transp = transcription; - wdID = wordmap_find_index(semgraph->ilabels, firstWord(transp)); - - if (atok->ilabel < semgraph->ilabels->num_slots && atok->ilabel != WORD_EPSILON_LABEL && - wordmap_whether_in_rule(semgraph->ilabels, wdID, atok->ilabel)) - { - /* atok->ilabel is the slotid */ - saveMemory.atok_use = arc_tokens_find_ilabel(semgraph->arc_token_list, semgraph->arcs_for_slot[atok->ilabel], wdID); - if (!saveMemory.atok_use) - { - arc_token* a; - PLogError(L("ESR_INVALID_STATE: finding wdid %d in slot %d"), wdID, atok->ilabel); - for (a = semgraph->arcs_for_slot[atok->ilabel]; 0 && a; a = ARC_TOKEN_PTR(semgraph->arc_token_list, a->next_token_index)) - { - PLogError(L("a %x ilabel %d olabel %d"), a, a->ilabel, a->olabel); - } - return ESR_INVALID_STATE; - } - else { - transp = nextWord(transp); - wdID = wordmap_find_index(semgraph->ilabels, firstWord(transp)); - } - } - else if (wdID != MAXwordID && atok->ilabel == wdID) - { - transp = nextWord(transp); - wdID = wordmap_find_index(semgraph->ilabels, firstWord(transp)); - saveMemory.atok_use = atok; - } - else if (atok->ilabel == WORD_EPSILON_LABEL) /* more eps transitions */ - saveMemory.atok_use = atok; - - if (saveMemory.atok_use == NULL) - continue; - else { - arc_token* atokfna = ARC_TOKEN_PTR(semgraph->arc_token_list, atok->first_next_arc); - pp_branch = sem_partial_path_create(); + atok_use = NULL; + transp = transcription; + wdID = wordmap_find_index(semgraph->ilabels, firstWord(transp)); + + if (atok->ilabel < semgraph->ilabels->num_slots && atok->ilabel != WORD_EPSILON_LABEL && + wordmap_whether_in_rule(semgraph->ilabels, wdID, atok->ilabel)) + { + /* atok->ilabel is the slotid */ + atok_use = arc_tokens_find_ilabel(semgraph->arc_token_list, semgraph->arcs_for_slot[atok->ilabel], wdID); + if (!atok_use) + { + arc_token* a; + PLogError(L("ESR_INVALID_STATE: finding wdid %d in slot %d"), wdID, atok->ilabel); + for (a = semgraph->arcs_for_slot[atok->ilabel]; 0 && a; a = ARC_TOKEN_PTR(semgraph->arc_token_list, a->next_token_index)) + { + PLogError(L("a %x ilabel %d olabel %d"), a, a->ilabel, a->olabel); + } + return ESR_INVALID_STATE; + } + else { + transp = nextWord(transp); + wdID = wordmap_find_index(semgraph->ilabels, firstWord(transp)); + } + } + else if (wdID != MAXwordID && atok->ilabel == wdID) + { + transp = nextWord(transp); + wdID = wordmap_find_index(semgraph->ilabels, firstWord(transp)); + atok_use = atok; + } + else if (atok->ilabel == WORD_EPSILON_LABEL) /* more eps transitions */ + atok_use = atok; + + if (atok_use == NULL) + continue; + else { + arc_token* atokfna = ARC_TOKEN_PTR(semgraph->arc_token_list, atok->first_next_arc); + pp_branch = sem_partial_path_create(heap); #if DEBUG_CPF - printf("%smatched arc %d %p ilabel%d(%s) olabel %d\n", spaces(debug_depth), atok-debug_base_arc_token, atok, - atok->ilabel, semgraph->ilabels->words[atok->ilabel], atok->olabel); + printf("%smatched arc %d %p ilabel%d(%s) olabel %d\n", spaces(debug_depth), atok-debug_base_arc_token, atok, + atok->ilabel, semgraph->ilabels->words[atok->ilabel], atok->olabel); #endif - if (!pp_branch) - return ESR_INVALID_STATE; - pp->next = pp_branch; - pp->arc_for_pp = saveMemory.atok_use; - if (atok->first_next_arc==ARC_TOKEN_NULL && *transp==0) - return ESR_SUCCESS; - else if (atokfna && atokfna->ilabel==MAXwordID && atokfna->olabel==MAXwordID && *transp==0) - return ESR_SUCCESS; - else - { + if (!pp_branch) + return ESR_INVALID_STATE; + pp->next = pp_branch; + pp->arc_for_pp = atok_use; + if (atok->first_next_arc==ARC_TOKEN_NULL && *transp==0) + return ESR_SUCCESS; + else if (atokfna && atokfna->ilabel==MAXwordID && atokfna->olabel==MAXwordID && *transp==0) + return ESR_SUCCESS; + else + { #if DEBUG_CPF - sem_partial_path_print(pp_branch, &sem_partial_paths[0], MAX_SEM_PARTIAL_PATHS, semgraph->ilabels); - debug_depth += 2; + sem_partial_path_print(pp_branch, &sem_partial_paths[0], MAX_SEM_PARTIAL_PATHS, semgraph->ilabels); + debug_depth += 2; #endif - saveMemory.rc = checkpath_forward(semgraph, atokfna, pp_branch, transp); + ESR_ReturnCode rc = checkpath_forward(semgraph, heap, atokfna, pp_branch, transp); #if DEBUG_CPF - debug_depth -= 2; + debug_depth -= 2; #endif - if (saveMemory.rc == ESR_SUCCESS) - return saveMemory.rc; - else if (saveMemory.rc == ESR_INVALID_STATE) - { - /* if out-of-memory of other problem, then just abort */ - return ESR_INVALID_STATE; - } - else - { - /* need to uncharge through epsilons, until pp->next==pp_branch */ - // sem_partial_path* qq = pp->next; - sem_partial_path_free(pp->next); - pp->arc_for_pp = NULL; - // for (qq = pp->next; qq != pp_branch; qq = qq->next) sem_partial_path_free(qq); - pp->next = NULL; - } - } - } + if (rc == ESR_SUCCESS) + return rc; + else if (rc == ESR_INVALID_STATE) + { + /* if out-of-memory of other problem, then just abort */ + return ESR_INVALID_STATE; + } + else + { + /* need to uncharge through epsilons, until pp->next==pp_branch */ + // sem_partial_path* qq = pp->next; + sem_partial_path_free(heap, pp->next); + pp->arc_for_pp = NULL; + // for (qq = pp->next; qq != pp_branch; qq = qq->next) sem_partial_path_free(qq); + pp->next = NULL; + } + } + } #if DEBUG_CPF - printf("%sdone trying arc %d %p ilabel%d(%s) olabel %d\n", spaces(debug_depth), atok-debug_base_arc_token, atok, - atok->ilabel, semgraph->ilabels->words[atok->ilabel], atok->olabel); + printf("%sdone trying arc %d %p ilabel%d(%s) olabel %d\n", spaces(debug_depth), atok-debug_base_arc_token, atok, + atok->ilabel, semgraph->ilabels->words[atok->ilabel], atok->olabel); #endif } /* end for atok .. */ - return ESR_NO_MATCH_ERROR; + return ESR_NO_MATCH_ERROR; } /** * Parse the graph */ ESR_ReturnCode SR_SemanticProcessor_CheckParseByWordID(SR_SemanticProcessor* self, - SR_SemanticGraph* graph, - wordID* wordIDs, - SR_SemanticResult** results, - size_t* resultCount) + SR_SemanticGraph* graph, + wordID* wordIDs, + SR_SemanticResult** results, + size_t* resultCount) { - sem_partial_path *path_root; - script_list raw_scripts_buf; - LCHAR lhs[MAX_STRING_LEN]; - LCHAR meaning[MAX_STRING_LEN]; /* special key */ - LCHAR ruleName[32]; - size_t i, j, size, resultIdx; - LCHAR* dst = NULL; - LCHAR* p; - size_t tokenLen = 0; - const LCHAR* src; - HashMap* hashmap = NULL; - ESR_ReturnCode rc; - ESR_BOOL containsKey; - SR_SemanticProcessorImpl* semproc = (SR_SemanticProcessorImpl*) self; - SR_SemanticGraphImpl* semgraph = (SR_SemanticGraphImpl*) graph; - - LSTRCPY(ruleName, L("")); - CHKLOG(rc, sem_partial_path_list_init()); - path_root = sem_partial_path_create(); - if (!path_root) - { - rc = ESR_INVALID_STATE; - goto CLEANUP; - } - - /** - * Parse the graph - */ - rc = checkpath_forwardByWordID(semgraph, &semgraph->arc_token_list[0], path_root, - wordIDs); - if (rc == ESR_NO_MATCH_ERROR) - { - *resultCount = 0; - return ESR_SUCCESS; /* did not parse */ - } - else if (rc == ESR_SUCCESS) - { - if (*resultCount > 0) - *resultCount = 1; - else + sem_partial_path *path_root; + script_list raw_scripts_buf; + LCHAR lhs[MAX_STRING_LEN]; + LCHAR meaning[MAX_STRING_LEN]; /* special key */ + LCHAR ruleName[32]; + size_t i, j, size, resultIdx; + LCHAR* dst = NULL; + LCHAR* p; + size_t tokenLen = 0; + const LCHAR* src; + HashMap* hashmap = NULL; + ESR_ReturnCode rc; + ESR_BOOL containsKey; + sem_partial_path heap[MAX_SEM_PARTIAL_PATHS]; + SR_SemanticProcessorImpl* semproc = (SR_SemanticProcessorImpl*) self; + SR_SemanticGraphImpl* semgraph = (SR_SemanticGraphImpl*) graph; + + LSTRCPY(ruleName, L("")); + CHKLOG(rc, sem_partial_path_list_init(heap, sizeof(heap)/sizeof(heap[0]))); + path_root = sem_partial_path_create(heap); + if (!path_root) { - /** - * If the array to hold the results is not big enough, - * then tell the user right away by returning ESR_BUFFER_OVERFLOW - with the size required returned in resultCount */ - rc = ESR_BUFFER_OVERFLOW; - PLogError(ESR_rc2str(rc)); - goto CLEANUP; + rc = ESR_INVALID_STATE; + goto CLEANUP; } - } - else if (rc == ESR_INVALID_STATE) - goto CLEANUP; - -#if DEBUG_CPF - sem_partial_path_print(path_root, &sem_partial_paths[0], MAX_SEM_PARTIAL_PATHS,semgraph->ilabels); -#endif - - /* create the array of Semantic Result Pointers */ - for (resultIdx = 0; resultIdx < *resultCount; resultIdx++) - { - raw_scripts_buf.num_scripts = 0; - for (i = 0; i < MAX_SCRIPTS; i++) + + /** + * Parse the graph + */ + rc = checkpath_forwardByWordID(semgraph, heap, &semgraph->arc_token_list[0], path_root, + wordIDs); + if (rc == ESR_NO_MATCH_ERROR) { - raw_scripts_buf.list[i].expression = 0; - raw_scripts_buf.list[i].ruleName = 0; + *resultCount = 0; + return ESR_SUCCESS; /* did not parse */ } - - /* - * Go through the partial paths which were successful and accumulate the scripts - * that you encountered (BUGGY) - */ - CHKLOG(rc, accumulate_scripts(semgraph, &raw_scripts_buf, path_root)); - CHKLOG(rc, sem_partial_path_free(path_root)); - - /*pfprintf(PSTDOUT,"Accumulated scripts\n");*/ - - /* - * Prepare the scripts for processing, in other words, make them "nice". - * What I mean by making them nice is to do stuff like: - * - * if ruleName is: root} - * expression is: meaning='hello';meaning=meaning+' '+'world'; - * - * what I want to accumulate is - * root.meaning='hello';root.meaning=root.meaning+' '+'world'; - * - * I am basically replacing END_SCOPE_MARKER with '.' and inserting 'root.' - * before every lhs identifier. - * - */ - for (dst = &semproc->acc_scripts[0], semproc->acc_scripts[0] = '\0', i = 0; i < raw_scripts_buf.num_scripts; ++i) + else if (rc == ESR_SUCCESS) { - if (raw_scripts_buf.list[i].ruleName && raw_scripts_buf.list[i].expression && - raw_scripts_buf.list[i].ruleName != WORD_NOT_FOUND && - raw_scripts_buf.list[i].expression != WORD_NOT_FOUND) - { - if (!LSTRCMP(raw_scripts_buf.list[i].expression, L(";"))) - continue; - /* set the rule name in a temporary buffer and in the dst */ - src = raw_scripts_buf.list[i].ruleName; - p = ruleName; - while (*src && *src != END_SCOPE_MARKER) /* trim off the trailing closing brace END_SCOPE_MARKER */ - { - CHKLOG(rc, append_with_check(&dst, *src, &semproc->acc_scripts[MAX_SCRIPT_LEN-1])); - CHKLOG(rc, append_with_check(&p, *src, &ruleName[31])); - ++src; - } - - - /* put a dot after the rule name, and before the lhs */ - CHKLOG(rc, append_with_check(&dst, L('.'), &semproc->acc_scripts[MAX_SCRIPT_LEN-1])); - CHKLOG(rc, append_with_check(&p, L('.'), &ruleName[31])); - - /* terminate the ruleName string */ - CHKLOG(rc, append_with_check(&p, 0, &ruleName[31])); - - /* append the rest of the expression */ - src = raw_scripts_buf.list[i].expression; - - while (ESR_TRUE) + if (*resultCount > 0) + *resultCount = 1; + else { - /* get the LHS identifier, append to dst, and store temporarily - in lhs buffer*/ - p = lhs; - while (*src && *src != '=') - { - CHKLOG(rc, append_with_check(&dst, *src, &semproc->acc_scripts[MAX_SCRIPT_LEN-1])); - CHKLOG(rc, append_with_check(&p, *src, &lhs[MAX_STRING_LEN-1])); - ++src; - } - /* terminate the lhs string */ - CHKLOG(rc, append_with_check(&p, 0, &lhs[MAX_STRING_LEN-1])); - - /* prepend every occurrence of the LHS identifier with 'ruleName.'*/ - for (; *src && *src != ';'; src += tokenLen) - { - const LCHAR* p2; - - tokenLen = get_next_token_len(src); - if (IS_LOCAL_IDENTIFIER(src, tokenLen) /* || !LSTRCMP(token, lhs) */) - { - /* use p to copy stuff now */ - p = ruleName; - while (*p) - { - /* prepend the rule name to the identifier */ - CHKLOG(rc, append_with_check(&dst, *p, &semproc->acc_scripts[MAX_SCRIPT_LEN-1])); - ++p; - } - } - for (p2 = src; p2 < src + tokenLen; ++p2) - CHKLOG(rc, append_with_check(&dst, *p2, &semproc->acc_scripts[MAX_SCRIPT_LEN-1])); - - } - - /* - * In an expression there may be several statements, each perhaps with a - * new LHS identifier - */ - - /* skip extra semicolons */ - while (*src == ';') - ++src; - /* skip whitespace */ - while (isspace(*src)) - ++src; - - if (!*src) - { - /* if end of the expression */ - /* terminate the eScript expression properly */ - CHKLOG(rc, append_with_check(&dst, L(';'), &semproc->acc_scripts[MAX_SCRIPT_LEN-1])); - *dst = '\0';/* terminate the string, DO NOT DO ++ !!! possibility of next loop iteration - which will concatenate to the dst string */ - break; - } - else - { - /* concat a single semi-colon */ - CHKLOG(rc, append_with_check(&dst, L(';'), &semproc->acc_scripts[MAX_SCRIPT_LEN-1])); - p = ruleName; - while (*p) - { - /* prepend the rule name for the new statement */ - CHKLOG(rc, append_with_check(&dst, *p, &semproc->acc_scripts[MAX_SCRIPT_LEN-1])); - ++p; - } - } + /** + * If the array to hold the results is not big enough, + * then tell the user right away by returning ESR_BUFFER_OVERFLOW + with the size required returned in resultCount */ + rc = ESR_BUFFER_OVERFLOW; + PLogError(ESR_rc2str(rc)); + goto CLEANUP; } - } } - if (0) PLogMessage( L("Accumulated Scripts for:\n%s"), semproc->acc_scripts); - if (&results[resultIdx] != NULL) /* SemanticResultImpl assumed to have been created externally */ - interpretScripts(semproc, semproc->acc_scripts, &results[resultIdx]); - - /** - * Fill in the 'meaning', if it is not there - * map 'ROOT.meaning' to 'meaning' - * - * NOTE: I am reusing some vars even though the names are a little bit inappropriate. - */ - hashmap = ((SR_SemanticResultImpl*)results[resultIdx])->results; - - LSTRCPY(meaning, L("meaning")); - CHKLOG(rc, hashmap->containsKey(hashmap, meaning, &containsKey)); - if (!containsKey) + else if (rc == ESR_INVALID_STATE) + goto CLEANUP; + +#if DEBUG_CPF + sem_partial_path_print(path_root, &sem_partial_paths[0], MAX_SEM_PARTIAL_PATHS,semgraph->ilabels); +#endif + + /* create the array of Semantic Result Pointers */ + for (resultIdx = 0; resultIdx < *resultCount; resultIdx++) { - LSTRCPY(meaning, ruleName); /* the last rule name encountered is always the root */ - LSTRCAT(meaning, L("meaning")); - CHKLOG(rc, hashmap->containsKey(hashmap, meaning, &containsKey)); - - if (containsKey) - { - CHKLOG(rc, hashmap->get(hashmap, meaning, (void **)&p)); - /* create a new memory location to hold the meaning... not the same as the other cause - I do not want memory destroy problems */ - /* add one more space */ - dst = MALLOC(sizeof(LCHAR) * (LSTRLEN(p) + 1), L("semproc.meaning")); - if (dst == NULL) + raw_scripts_buf.num_scripts = 0; + for (i = 0; i < MAX_SCRIPTS; i++) { - rc = ESR_OUT_OF_MEMORY; - PLogError(ESR_rc2str(rc)); - goto CLEANUP; + raw_scripts_buf.list[i].expression = 0; + raw_scripts_buf.list[i].ruleName = 0; } - LSTRCPY(dst, p); - rc = hashmap->put(hashmap, L("meaning"), dst); - if (rc != ESR_SUCCESS) + + /* + * Go through the partial paths which were successful and accumulate the scripts + * that you encountered (BUGGY) + */ + CHKLOG(rc, accumulate_scripts(semgraph, &raw_scripts_buf, path_root)); + CHKLOG(rc, sem_partial_path_free(heap, path_root)); + + /*pfprintf(PSTDOUT,"Accumulated scripts\n");*/ + + /* + * Prepare the scripts for processing, in other words, make them "nice". + * What I mean by making them nice is to do stuff like: + * + * if ruleName is: root} + * expression is: meaning='hello';meaning=meaning+' '+'world'; + * + * what I want to accumulate is + * root.meaning='hello';root.meaning=root.meaning+' '+'world'; + * + * I am basically replacing END_SCOPE_MARKER with '.' and inserting 'root.' + * before every lhs identifier. + * + */ + for (dst = &semproc->acc_scripts[0], semproc->acc_scripts[0] = '\0', i = 0; i < raw_scripts_buf.num_scripts; ++i) { - FREE(dst); - PLogError(ESR_rc2str(rc)); - goto CLEANUP; + if (raw_scripts_buf.list[i].ruleName && raw_scripts_buf.list[i].expression && + raw_scripts_buf.list[i].ruleName != WORD_NOT_FOUND && + raw_scripts_buf.list[i].expression != WORD_NOT_FOUND) + { + if (!LSTRCMP(raw_scripts_buf.list[i].expression, L(";"))) + continue; + /* set the rule name in a temporary buffer and in the dst */ + src = raw_scripts_buf.list[i].ruleName; + p = ruleName; + while (*src && *src != END_SCOPE_MARKER) /* trim off the trailing closing brace END_SCOPE_MARKER */ + { + CHKLOG(rc, append_with_check(&dst, *src, &semproc->acc_scripts[MAX_SCRIPT_LEN-1])); + CHKLOG(rc, append_with_check(&p, *src, &ruleName[31])); + ++src; + } + + + /* put a dot after the rule name, and before the lhs */ + CHKLOG(rc, append_with_check(&dst, L('.'), &semproc->acc_scripts[MAX_SCRIPT_LEN-1])); + CHKLOG(rc, append_with_check(&p, L('.'), &ruleName[31])); + + /* terminate the ruleName string */ + CHKLOG(rc, append_with_check(&p, 0, &ruleName[31])); + + /* append the rest of the expression */ + src = raw_scripts_buf.list[i].expression; + + while (ESR_TRUE) + { + /* get the LHS identifier, append to dst, and store temporarily + in lhs buffer*/ + p = lhs; + while (*src && *src != '=') + { + CHKLOG(rc, append_with_check(&dst, *src, &semproc->acc_scripts[MAX_SCRIPT_LEN-1])); + CHKLOG(rc, append_with_check(&p, *src, &lhs[MAX_STRING_LEN-1])); + ++src; + } + /* terminate the lhs string */ + CHKLOG(rc, append_with_check(&p, 0, &lhs[MAX_STRING_LEN-1])); + + /* prepend every occurrence of the LHS identifier with 'ruleName.'*/ + for (; *src && *src != ';'; src += tokenLen) + { + const LCHAR* p2; + + tokenLen = get_next_token_len(src); + if (IS_LOCAL_IDENTIFIER(src, tokenLen) /* || !LSTRCMP(token, lhs) */) + { + /* use p to copy stuff now */ + p = ruleName; + while (*p) + { + /* prepend the rule name to the identifier */ + CHKLOG(rc, append_with_check(&dst, *p, &semproc->acc_scripts[MAX_SCRIPT_LEN-1])); + ++p; + } + } + for (p2 = src; p2 < src + tokenLen; ++p2) + CHKLOG(rc, append_with_check(&dst, *p2, &semproc->acc_scripts[MAX_SCRIPT_LEN-1])); + + } + + /* + * In an expression there may be several statements, each perhaps with a + * new LHS identifier + */ + + /* skip extra semicolons */ + while (*src == ';') + ++src; + /* skip whitespace */ + while (isspace(*src)) + ++src; + + if (!*src) + { + /* if end of the expression */ + /* terminate the eScript expression properly */ + CHKLOG(rc, append_with_check(&dst, L(';'), &semproc->acc_scripts[MAX_SCRIPT_LEN-1])); + *dst = '\0';/* terminate the string, DO NOT DO ++ !!! possibility of next loop iteration + which will concatenate to the dst string */ + break; + } + else + { + /* concat a single semi-colon */ + CHKLOG(rc, append_with_check(&dst, L(';'), &semproc->acc_scripts[MAX_SCRIPT_LEN-1])); + p = ruleName; + while (*p) + { + /* prepend the rule name for the new statement */ + CHKLOG(rc, append_with_check(&dst, *p, &semproc->acc_scripts[MAX_SCRIPT_LEN-1])); + ++p; + } + } + } + } } - dst = NULL; - } - else - { - /* - * No meaning was provided, so just concat all the values that are associated with the ROOT rule - * (key name begins with ROOT) - */ - meaning[0] = 0; - CHKLOG(rc, hashmap->getSize(hashmap, &size)); - for (j = 0; j < size; j++) + if (0) PLogMessage( L("Accumulated Scripts for:\n%s"), semproc->acc_scripts); + if (&results[resultIdx] != NULL) /* SemanticResultImpl assumed to have been created externally */ + interpretScripts(semproc, semproc->acc_scripts, &results[resultIdx]); + + /** + * Fill in the 'meaning', if it is not there + * map 'ROOT.meaning' to 'meaning' + * + * NOTE: I am reusing some vars even though the names are a little bit inappropriate. + */ + hashmap = ((SR_SemanticResultImpl*)results[resultIdx])->results; + + LSTRCPY(meaning, L("meaning")); + CHKLOG(rc, hashmap->containsKey(hashmap, meaning, &containsKey)); + if (!containsKey) { - CHKLOG(rc, hashmap->getKeyAtIndex(hashmap, j, &p)); - if (LSTRSTR(p, ruleName) == p) /* key name begins with root ruleName */ - { - CHKLOG(rc, hashmap->get(hashmap, p, (void **)&dst)); - if (meaning[0] != 0) /* separate vals with space */ + LSTRCPY(meaning, ruleName); /* the last rule name encountered is always the root */ + LSTRCAT(meaning, L("meaning")); + CHKLOG(rc, hashmap->containsKey(hashmap, meaning, &containsKey)); + + if (containsKey) { - if (LSTRLEN(meaning) + 1 < MAX_STRING_LEN) - LSTRCAT(meaning, L(" ")); - /* chopping the meaning is harmless */ + CHKLOG(rc, hashmap->get(hashmap, meaning, (void **)&p)); + /* create a new memory location to hold the meaning... not the same as the other cause + I do not want memory destroy problems */ + /* add one more space */ + dst = MALLOC(sizeof(LCHAR) * (LSTRLEN(p) + 1), L("semproc.meaning")); + if (dst == NULL) + { + rc = ESR_OUT_OF_MEMORY; + PLogError(ESR_rc2str(rc)); + goto CLEANUP; + } + LSTRCPY(dst, p); + rc = hashmap->put(hashmap, L("meaning"), dst); + if (rc != ESR_SUCCESS) + { + FREE(dst); + PLogError(ESR_rc2str(rc)); + goto CLEANUP; + } + dst = NULL; } - if (LSTRLEN(meaning) + LSTRLEN(dst) < MAX_STRING_LEN) + else { - /* strcat a max of 32 chars */ - LCHAR* p, *pp; - for (pp = &meaning[0]; *pp != 0; pp++) ; /* scan to the end */ - for (p = dst; *p != 0 && p - dst < 32;) *pp++ = *p++; /* catenate up to 32 chars */ - *pp++ = 0; /* null terminate */ - /* LSTRCAT(meaning,dst); */ + /* + * No meaning was provided, so just concat all the values that are associated with the ROOT rule + * (key name begins with ROOT) + */ + meaning[0] = 0; + CHKLOG(rc, hashmap->getSize(hashmap, &size)); + for (j = 0; j < size; j++) + { + CHKLOG(rc, hashmap->getKeyAtIndex(hashmap, j, &p)); + if (LSTRSTR(p, ruleName) == p) /* key name begins with root ruleName */ + { + CHKLOG(rc, hashmap->get(hashmap, p, (void **)&dst)); + if (meaning[0] != 0) /* separate vals with space */ + { + if (LSTRLEN(meaning) + 1 < MAX_STRING_LEN) + LSTRCAT(meaning, L(" ")); + /* chopping the meaning is harmless */ + } + if (LSTRLEN(meaning) + LSTRLEN(dst) < MAX_STRING_LEN) + { + /* strcat a max of 32 chars */ + LCHAR* p, *pp; + for (pp = &meaning[0]; *pp != 0; pp++) ; /* scan to the end */ + for (p = dst; *p != 0 && p - dst < 32;) *pp++ = *p++; /* catenate up to 32 chars */ + *pp++ = 0; /* null terminate */ + /* LSTRCAT(meaning,dst); */ + } + /* chopping the meaning is harmless */ + } + } + if (meaning[0] != 0) + { + dst = MALLOC(sizeof(LCHAR) * (LSTRLEN(meaning) + 1), L("semproc.meaning")); + if (dst == NULL) + { + rc = ESR_OUT_OF_MEMORY; + PLogError(ESR_rc2str(rc)); + goto CLEANUP; + } + LSTRCPY(dst, meaning); + rc = hashmap->put(hashmap, L("meaning"), dst); + if (rc != ESR_SUCCESS) + { + FREE(dst); + PLogError(ESR_rc2str(rc)); + goto CLEANUP; + } + dst = NULL; + } } - /* chopping the meaning is harmless */ - } } - if (meaning[0] != 0) - { - dst = MALLOC(sizeof(LCHAR) * (LSTRLEN(meaning) + 1), L("semproc.meaning")); - if (dst == NULL) - { - rc = ESR_OUT_OF_MEMORY; - PLogError(ESR_rc2str(rc)); - goto CLEANUP; - } - LSTRCPY(dst, meaning); - rc = hashmap->put(hashmap, L("meaning"), dst); - if (rc != ESR_SUCCESS) - { - FREE(dst); - PLogError(ESR_rc2str(rc)); - goto CLEANUP; - } - dst = NULL; - } - } } - } - - return ESR_SUCCESS; + + return ESR_SUCCESS; CLEANUP: - return rc; + return rc; } /** * Parse the graph */ ESR_ReturnCode SR_SemanticProcessor_CheckParse(SR_SemanticProcessor* self, - SR_SemanticGraph* graph, - const LCHAR* transcription, - SR_SemanticResult** results, - size_t* resultCount) + SR_SemanticGraph* graph, + const LCHAR* transcription, + SR_SemanticResult** results, + size_t* resultCount) { - sem_partial_path *path_root; - script_list raw_scripts_buf; - LCHAR acc_scripts[MAX_SCRIPT_LEN]; /* the accumulated scripts */ - LCHAR lhs[MAX_STRING_LEN]; - LCHAR meaning[MAX_STRING_LEN]; /* special key */ - LCHAR ruleName[MAX_STRING_LEN]; - LCHAR prepared_transcription[MAX_STRING_LEN+1]; /*for final double null */ - size_t i, j, size, resultIdx; - LCHAR* dst = NULL; - LCHAR* p = NULL; - size_t tokenLen = 0; - const LCHAR* src; - HashMap* hashmap = NULL; - ESR_ReturnCode rc; - ESR_BOOL containsKey; - SR_SemanticProcessorImpl* semproc = (SR_SemanticProcessorImpl*) self; - SR_SemanticGraphImpl* semgraph = (SR_SemanticGraphImpl*) graph; - - LSTRCPY(ruleName, L("")); - CHKLOG(rc, sem_partial_path_list_init()); - path_root = sem_partial_path_create(); - if (!path_root) - { - rc = ESR_INVALID_STATE; - goto CLEANUP; - } - - /** - * prepare the transcription for processing - * split words by inserting NULL - * term by inserting double NULL at end - */ - for (i = 0; transcription[i] && i < MAX_STRING_LEN - 2; i++) - { - if (transcription[i] == L(' ')) - prepared_transcription[i] = 0; - else - prepared_transcription[i] = transcription[i]; - } - prepared_transcription[i] = prepared_transcription[i+1] = 0; /* double null */ - - /** - * Parse the graph - */ + sem_partial_path *path_root; + script_list raw_scripts_buf; + LCHAR acc_scripts[MAX_SCRIPT_LEN]; /* the accumulated scripts */ + LCHAR lhs[MAX_STRING_LEN]; + LCHAR meaning[MAX_STRING_LEN]; /* special key */ + LCHAR ruleName[MAX_STRING_LEN]; + LCHAR prepared_transcription[MAX_STRING_LEN+1]; /*for final double null */ + size_t i, j, size, resultIdx; + LCHAR* dst = NULL; + LCHAR* p = NULL; + size_t tokenLen = 0; + const LCHAR* src; + HashMap* hashmap = NULL; + ESR_ReturnCode rc; + ESR_BOOL containsKey; + sem_partial_path heap[MAX_SEM_PARTIAL_PATHS]; + SR_SemanticProcessorImpl* semproc = (SR_SemanticProcessorImpl*) self; + SR_SemanticGraphImpl* semgraph = (SR_SemanticGraphImpl*) graph; + + LSTRCPY(ruleName, L("")); + CHKLOG(rc, sem_partial_path_list_init(heap, sizeof(heap)/sizeof(heap[0]))); + path_root = sem_partial_path_create(heap); + if (!path_root) + { + rc = ESR_INVALID_STATE; + goto CLEANUP; + } + + /** + * prepare the transcription for processing + * split words by inserting NULL + * term by inserting double NULL at end + */ + for (i = 0; transcription[i] && i < MAX_STRING_LEN - 2; i++) + { + if (transcription[i] == L(' ')) + prepared_transcription[i] = 0; + else + prepared_transcription[i] = transcription[i]; + } + prepared_transcription[i] = prepared_transcription[i+1] = 0; /* double null */ + + /** + * Parse the graph + */ #if DEBUG_CPF - debug_base_arc_token = &semgraph->arc_token_list[0]; - debug_depth = 0; + debug_base_arc_token = &semgraph->arc_token_list[0]; + debug_depth = 0; #endif - rc = checkpath_forward(semgraph, &semgraph->arc_token_list[0], path_root, prepared_transcription); - if (rc == ESR_NO_MATCH_ERROR) - { - *resultCount = 0; - return ESR_SUCCESS; /* did not parse */ - } - else if (rc == ESR_SUCCESS) - { - if (*resultCount > 0) - *resultCount = 1; - else + rc = checkpath_forward(semgraph, heap, &semgraph->arc_token_list[0], path_root, prepared_transcription); + if (rc == ESR_NO_MATCH_ERROR) { - /** - * If the array to hold the results is not big enough, - * then tell the user right away by returning ESR_BUFFER_OVERFLOW - with the size required returned in resultCount */ - rc = ESR_BUFFER_OVERFLOW; - PLogError(ESR_rc2str(rc)); - goto CLEANUP; + *resultCount = 0; + return ESR_SUCCESS; /* did not parse */ } - } - else if (rc == ESR_INVALID_STATE) - goto CLEANUP; - - /* create the array of Semantic Result Pointers */ - for (resultIdx = 0; resultIdx < *resultCount; resultIdx++) - { - raw_scripts_buf.num_scripts = 0; - for (i = 0; i < MAX_SCRIPTS; i++) + else if (rc == ESR_SUCCESS) { - raw_scripts_buf.list[i].expression = 0; - raw_scripts_buf.list[i].ruleName = 0; + if (*resultCount > 0) + *resultCount = 1; + else + { + /** + * If the array to hold the results is not big enough, + * then tell the user right away by returning ESR_BUFFER_OVERFLOW + with the size required returned in resultCount */ + rc = ESR_BUFFER_OVERFLOW; + PLogError(ESR_rc2str(rc)); + goto CLEANUP; + } } - - /* - * Go through the partial paths which were successful and accumulate the scripts - * that you encountered (BUGGY) - */ - CHKLOG(rc, accumulate_scripts(semgraph, &raw_scripts_buf, path_root)); - CHKLOG(rc, sem_partial_path_free(path_root)); - - /*pfprintf(PSTDOUT,"Accumulated scripts\n");*/ - - /* - * Prepare the scripts for processing, in other words, make them "nice". - * What I mean by making them nice is to do stuff like: - * - * if ruleName is: root} - * expression is: meaning='hello';meaning=meaning+' '+'world'; - * - * what I want to accumulate is - * root.meaning='hello';root.meaning=root.meaning+' '+'world'; - * - * I am basically replacing END_SCOPE_MARKER with '.' and inserting 'root.' - * before every lhs identifier. - * - */ - for (dst = &acc_scripts[0], acc_scripts[0] = '\0', i = 0; i < raw_scripts_buf.num_scripts; ++i) + else if (rc == ESR_INVALID_STATE) + goto CLEANUP; + + /* create the array of Semantic Result Pointers */ + for (resultIdx = 0; resultIdx < *resultCount; resultIdx++) { - if (raw_scripts_buf.list[i].ruleName && raw_scripts_buf.list[i].expression && - raw_scripts_buf.list[i].ruleName != WORD_NOT_FOUND && - raw_scripts_buf.list[i].expression != WORD_NOT_FOUND) - { - if (!LSTRCMP(raw_scripts_buf.list[i].expression, L(";"))) - continue; - /* set the rule name in a temporary buffer and in the dst */ - src = raw_scripts_buf.list[i].ruleName; - p = ruleName; - /* trim off the trailing closing brace END_SCOPE_MARKER */ - while (*src && *src != END_SCOPE_MARKER) + raw_scripts_buf.num_scripts = 0; + for (i = 0; i < MAX_SCRIPTS; i++) { - CHKLOG(rc, append_with_check(&dst, *src, &acc_scripts[MAX_SCRIPT_LEN-1])); - CHKLOG(rc, append_with_check(&p, *src, &ruleName[MAX_STRING_LEN-1])); - ++src; + raw_scripts_buf.list[i].expression = 0; + raw_scripts_buf.list[i].ruleName = 0; } - - - /* put a dot after the rule name, and before the lhs */ - CHKLOG(rc, append_with_check(&dst, L('.'), &acc_scripts[MAX_SCRIPT_LEN-1])); - CHKLOG(rc, append_with_check(&p, L('.'), &ruleName[MAX_STRING_LEN-1])); - - /* terminate the ruleName string */ - CHKLOG(rc, append_with_check(&p, 0, &ruleName[MAX_STRING_LEN-1])); - - /* append the rest of the expression */ - src = raw_scripts_buf.list[i].expression; - - while (ESR_TRUE) + + /* + * Go through the partial paths which were successful and accumulate the scripts + * that you encountered (BUGGY) + */ + CHKLOG(rc, accumulate_scripts(semgraph, &raw_scripts_buf, path_root)); + CHKLOG(rc, sem_partial_path_free(heap, path_root)); + + /*pfprintf(PSTDOUT,"Accumulated scripts\n");*/ + + /* + * Prepare the scripts for processing, in other words, make them "nice". + * What I mean by making them nice is to do stuff like: + * + * if ruleName is: root} + * expression is: meaning='hello';meaning=meaning+' '+'world'; + * + * what I want to accumulate is + * root.meaning='hello';root.meaning=root.meaning+' '+'world'; + * + * I am basically replacing END_SCOPE_MARKER with '.' and inserting 'root.' + * before every lhs identifier. + * + */ + for (dst = &acc_scripts[0], acc_scripts[0] = '\0', i = 0; i < raw_scripts_buf.num_scripts; ++i) { - /* get the LHS identifier, append to dst, and store temporarily - in lhs buffer*/ - p = lhs; - while (*src && *src != '=') - { - CHKLOG(rc, append_with_check(&dst, *src, &acc_scripts[MAX_SCRIPT_LEN-1])); - CHKLOG(rc, append_with_check(&p, *src, &lhs[MAX_STRING_LEN-1])); - ++src; - } - /* terminate the lhs string */ - CHKLOG(rc, append_with_check(&p, 0, &lhs[MAX_STRING_LEN-1])); - - /* prepend every occurrence of the LHS identifier with 'ruleName.'*/ - for (; *src && *src != ';'; src += tokenLen) - { - const LCHAR* p2; - - tokenLen = get_next_token_len(src); - if (IS_LOCAL_IDENTIFIER(src, tokenLen) /* || !LSTRCMP(token, lhs) */) + if (raw_scripts_buf.list[i].ruleName && raw_scripts_buf.list[i].expression && + raw_scripts_buf.list[i].ruleName != WORD_NOT_FOUND && + raw_scripts_buf.list[i].expression != WORD_NOT_FOUND) { - /* use p to copy stuff now */ - p = ruleName; - while (*p) - { - /* prepend the rule name to the identifier */ - CHKLOG(rc, append_with_check(&dst, *p, &acc_scripts[MAX_SCRIPT_LEN-1])); - ++p; - } - } - for (p2 = src; p2 < src + tokenLen; ++p2) - CHKLOG(rc, append_with_check(&dst, *p2, &acc_scripts[MAX_SCRIPT_LEN-1])); - } - - /* - * In an expression there may be several statements, each perhaps with a - * new LHS identifier - */ - - while (*src == ';') - ++src; /* skip the double triple... semi-colons*/ - - if (!*src) - { - /* if end of the expression */ - /* terminate the eScript expression properly */ - CHKLOG(rc, append_with_check(&dst, L(';'), &acc_scripts[MAX_SCRIPT_LEN-1])); - *dst = '\0';/* terminate the string, DO NOT DO ++ !!! possibility of next loop iteration + if (!LSTRCMP(raw_scripts_buf.list[i].expression, L(";"))) + continue; + /* set the rule name in a temporary buffer and in the dst */ + src = raw_scripts_buf.list[i].ruleName; + p = ruleName; + /* trim off the trailing closing brace END_SCOPE_MARKER */ + while (*src && *src != END_SCOPE_MARKER) + { + CHKLOG(rc, append_with_check(&dst, *src, &acc_scripts[MAX_SCRIPT_LEN-1])); + CHKLOG(rc, append_with_check(&p, *src, &ruleName[MAX_STRING_LEN-1])); + ++src; + } + + + /* put a dot after the rule name, and before the lhs */ + CHKLOG(rc, append_with_check(&dst, L('.'), &acc_scripts[MAX_SCRIPT_LEN-1])); + CHKLOG(rc, append_with_check(&p, L('.'), &ruleName[MAX_STRING_LEN-1])); + + /* terminate the ruleName string */ + CHKLOG(rc, append_with_check(&p, 0, &ruleName[MAX_STRING_LEN-1])); + + /* append the rest of the expression */ + src = raw_scripts_buf.list[i].expression; + + while (ESR_TRUE) + { + /* get the LHS identifier, append to dst, and store temporarily in lhs buffer*/ + p = lhs; + while (*src && *src != '=') + { + CHKLOG(rc, append_with_check(&dst, *src, &acc_scripts[MAX_SCRIPT_LEN-1])); + CHKLOG(rc, append_with_check(&p, *src, &lhs[MAX_STRING_LEN-1])); + ++src; + } + /* terminate the lhs string */ + CHKLOG(rc, append_with_check(&p, 0, &lhs[MAX_STRING_LEN-1])); + + /* prepend every occurrence of the LHS identifier with 'ruleName.'*/ + for (; *src && *src != ';'; src += tokenLen) + { + const LCHAR* p2; + + tokenLen = get_next_token_len(src); + if (IS_LOCAL_IDENTIFIER(src, tokenLen) /* || !LSTRCMP(token, lhs) */) + { + /* use p to copy stuff now */ + p = ruleName; + while (*p) + { + /* prepend the rule name to the identifier */ + CHKLOG(rc, append_with_check(&dst, *p, &acc_scripts[MAX_SCRIPT_LEN-1])); + ++p; + } + } + for (p2 = src; p2 < src + tokenLen; ++p2) + CHKLOG(rc, append_with_check(&dst, *p2, &acc_scripts[MAX_SCRIPT_LEN-1])); + } + + /* + * In an expression there may be several statements, each perhaps with a + * new LHS identifier + */ + + while (*src == ';') + ++src; /* skip the double triple... semi-colons*/ + + if (!*src) + { + /* if end of the expression */ + /* terminate the eScript expression properly */ + CHKLOG(rc, append_with_check(&dst, L(';'), &acc_scripts[MAX_SCRIPT_LEN-1])); + *dst = '\0';/* terminate the string, DO NOT DO ++ !!! possibility of next loop iteration which will concatenate to the dst string */ - break; - } - else - { - /* concat a single semi-colon */ - CHKLOG(rc, append_with_check(&dst, L(';'), &acc_scripts[MAX_SCRIPT_LEN-1])); - p = ruleName; - while (*p) - { - /* prepend the rule name for the new statement */ - CHKLOG(rc, append_with_check(&dst, *p, &acc_scripts[MAX_SCRIPT_LEN-1])); - ++p; + break; + } + else + { + /* concat a single semi-colon */ + CHKLOG(rc, append_with_check(&dst, L(';'), &acc_scripts[MAX_SCRIPT_LEN-1])); + p = ruleName; + while (*p) + { + /* prepend the rule name for the new statement */ + CHKLOG(rc, append_with_check(&dst, *p, &acc_scripts[MAX_SCRIPT_LEN-1])); + ++p; + } + } + } } - } } - } - } #if defined( SREC_ENGINE_VERBOSE_LOGGING) - PLogMessage(L("Accumulated Scripts for (%s):\n%s"), transcription, acc_scripts); + PLogMessage(L("Accumulated Scripts for (%s):\n%s"), transcription, acc_scripts); #endif - if (&results[resultIdx] != NULL) /* SemanticResultImpl assumed to have been created externally */ - interpretScripts(semproc, acc_scripts, &results[resultIdx]); - - /** - * Fill in the 'meaning', if it is not there - * map 'ROOT.meaning' to 'meaning' - * - * NOTE: I am reusing some vars even though the names are a little bit inappropriate. - */ - hashmap = ((SR_SemanticResultImpl*)results[resultIdx])->results; - - LSTRCPY(meaning, L("meaning")); - CHKLOG(rc, hashmap->containsKey(hashmap, meaning, &containsKey)); - if (!containsKey) - { - LSTRCPY(meaning, ruleName); /* the last rule name encountered is always the root */ - LSTRCAT(meaning, L("meaning")); - CHKLOG(rc, hashmap->containsKey(hashmap, meaning, &containsKey)); - - if (containsKey) - { - CHKLOG(rc, hashmap->get(hashmap, meaning, (void **)&p)); - /* create a new memory location to hold the meaning... not the same as the other cause - I do not want memory destroy problems */ - /* add one more space */ - dst = MALLOC(sizeof(LCHAR) * (LSTRLEN(p) + 1), L("semproc.meaning")); - if (dst == NULL) - { - rc = ESR_OUT_OF_MEMORY; - PLogError(ESR_rc2str(rc)); - goto CLEANUP; - } - LSTRCPY(dst, p); - CHKLOG(rc, hashmap->put(hashmap, L("meaning"), dst)); - dst = NULL; - } - else - /* absolutely no meaning was provided, so just concat all the values that are associated - * with the ROOT rule (key name begins with ROOT) */ - { - meaning[0] = 0; - CHKLOG(rc, hashmap->getSize(hashmap, &size)); - for (j = 0; j < size; j++) - { - CHKLOG(rc, hashmap->getKeyAtIndex(hashmap, j, &p)); - if (LSTRSTR(p, ruleName) == p) /* key name begins with root ruleName */ - { - CHKLOG(rc, hashmap->get(hashmap, p, (void **)&dst)); - if (meaning[0] != 0) /* separate vals with space */ - LSTRCAT(meaning, L(" ")); - LSTRCAT(meaning, dst); - } - } - if (meaning[0] != 0) + if (&results[resultIdx] != NULL) /* SemanticResultImpl assumed to have been created externally */ + interpretScripts(semproc, acc_scripts, &results[resultIdx]); + + /** + * Fill in the 'meaning', if it is not there + * map 'ROOT.meaning' to 'meaning' + * + * NOTE: I am reusing some vars even though the names are a little bit inappropriate. + */ + hashmap = ((SR_SemanticResultImpl*)results[resultIdx])->results; + + LSTRCPY(meaning, L("meaning")); + CHKLOG(rc, hashmap->containsKey(hashmap, meaning, &containsKey)); + if (!containsKey) { - dst = MALLOC(sizeof(LCHAR) * (LSTRLEN(meaning) + 1), L("semproc.meaning")); - if (dst == NULL) - { - rc = ESR_OUT_OF_MEMORY; - PLogError(ESR_rc2str(rc)); - goto CLEANUP; - } - LSTRCPY(dst, meaning); - CHKLOG(rc, hashmap->put(hashmap, L("meaning"), dst)); - dst = NULL; + LSTRCPY(meaning, ruleName); /* the last rule name encountered is always the root */ + LSTRCAT(meaning, L("meaning")); + CHKLOG(rc, hashmap->containsKey(hashmap, meaning, &containsKey)); + + if (containsKey) + { + CHKLOG(rc, hashmap->get(hashmap, meaning, (void **)&p)); + /* create a new memory location to hold the meaning... not the same as the other cause + I do not want memory destroy problems */ + /* add one more space */ + dst = MALLOC(sizeof(LCHAR) * (LSTRLEN(p) + 1), L("semproc.meaning")); + if (dst == NULL) + { + rc = ESR_OUT_OF_MEMORY; + PLogError(ESR_rc2str(rc)); + goto CLEANUP; + } + LSTRCPY(dst, p); + CHKLOG(rc, hashmap->put(hashmap, L("meaning"), dst)); + dst = NULL; + } + else + /* absolutely no meaning was provided, so just concat all the values that are associated + * with the ROOT rule (key name begins with ROOT) */ + { + meaning[0] = 0; + CHKLOG(rc, hashmap->getSize(hashmap, &size)); + for (j = 0; j < size; j++) + { + CHKLOG(rc, hashmap->getKeyAtIndex(hashmap, j, &p)); + if (LSTRSTR(p, ruleName) == p) /* key name begins with root ruleName */ + { + CHKLOG(rc, hashmap->get(hashmap, p, (void **)&dst)); + if (meaning[0] != 0) /* separate vals with space */ + LSTRCAT(meaning, L(" ")); + LSTRCAT(meaning, dst); + } + } + if (meaning[0] != 0) + { + dst = MALLOC(sizeof(LCHAR) * (LSTRLEN(meaning) + 1), L("semproc.meaning")); + if (dst == NULL) + { + rc = ESR_OUT_OF_MEMORY; + PLogError(ESR_rc2str(rc)); + goto CLEANUP; + } + LSTRCPY(dst, meaning); + CHKLOG(rc, hashmap->put(hashmap, L("meaning"), dst)); + dst = NULL; + } + } } - } } - } - - return ESR_SUCCESS; + + return ESR_SUCCESS; CLEANUP: - if (dst != NULL) FREE(dst); - return rc; + if (dst != NULL) FREE(dst); + return rc; } /** * After parsing, interpret the acumulated scripts */ -ESR_ReturnCode interpretScripts(SR_SemanticProcessorImpl* semproc, LCHAR* scripts, SR_SemanticResult** result) +static ESR_ReturnCode interpretScripts(SR_SemanticProcessorImpl* semproc, + LCHAR* scripts, SR_SemanticResult** result) { - ESR_ReturnCode rc; - SR_SemanticResultImpl** impl = (SR_SemanticResultImpl**) result; - - if ((rc = LA_Analyze(semproc->analyzer, scripts)) == ESR_SUCCESS) - { - /**************************** - * If all goes well, then the result - * will be written to the HashMap provided - ****************************/ - if ((rc = EP_parse(semproc->parser, semproc->analyzer, semproc->symtable, semproc->eval, &((*impl)->results))) != ESR_SUCCESS) - pfprintf(PSTDOUT, "Semantic Result: Error (%s) could not interpret\n", ESR_rc2str(rc)); - } - return rc; + ESR_ReturnCode rc; + SR_SemanticResultImpl** impl = (SR_SemanticResultImpl**) result; + + if ((rc = LA_Analyze(semproc->analyzer, scripts)) == ESR_SUCCESS) + { + /**************************** + * If all goes well, then the result + * will be written to the HashMap provided + ****************************/ + if ((rc = EP_parse(semproc->parser, semproc->analyzer, semproc->symtable, semproc->eval, &((*impl)->results))) != ESR_SUCCESS) + pfprintf(PSTDOUT, "Semantic Result: Error (%s) could not interpret\n", ESR_rc2str(rc)); + } + return rc; } @@ -1090,237 +1086,237 @@ ESR_ReturnCode interpretScripts(SR_SemanticProcessorImpl* semproc, LCHAR* script /* PartialPath stuff */ /***************************************************************/ -ESR_ReturnCode sem_partial_path_list_init() +static ESR_ReturnCode sem_partial_path_list_init(sem_partial_path* heap, int nheap) { - /* nobody refers to me, therefore I am free */ - int i; - for (i = 0; i < MAX_SEM_PARTIAL_PATHS - 1; i++) - sem_partial_paths[i].next = &sem_partial_paths[i+1]; - sem_partial_paths[i].next = 0; - sem_partial_path_freelist = &sem_partial_paths[0]; - return ESR_SUCCESS; + int i; + for (i = 0; i < MAX_SEM_PARTIAL_PATHS - 1; i++) + heap[i].next = &heap[i+1]; + heap[i].next = 0; + return ESR_SUCCESS; } -sem_partial_path* sem_partial_path_create() +static sem_partial_path* sem_partial_path_create(sem_partial_path* heap) { - sem_partial_path* path; - if (sem_partial_path_freelist == NULL) - { - /* PLogError() is dangerous here, because the stack is very deep */ - pfprintf(PSTDERR, "sem_partial_path_create() no more partial paths available (limit=%d)\n", MAX_SEM_PARTIAL_PATHS); - return NULL; - } - - path = sem_partial_path_freelist; - sem_partial_path_freelist = sem_partial_path_freelist->next; - - path->next = NULL; - path->arc_for_pp = NULL; - return path; + sem_partial_path* path = heap->next; + if (path == NULL) + { + /* PLogError() is dangerous here, because the stack is very deep */ + pfprintf(PSTDERR, "sem_partial_path_create() no more partial paths available (limit=%d)\n", MAX_SEM_PARTIAL_PATHS); + return NULL; + } + + heap->next = path->next; + + path->next = NULL; + path->arc_for_pp = NULL; + return path; } #if DEBUG_CPF -void sem_partial_path_print(sem_partial_path* path, sem_partial_path* paths, int npaths, wordmap* ilabels) +static void sem_partial_path_print(sem_partial_path* path, + sem_partial_path* paths, int npaths, wordmap* ilabels) { - int i; - sem_partial_path* frompath = 0; - arc_token* a; - - if (!path) - { - printf("--- END ---\n"); - return; - } - printf("path %p arc %d %p ", path, (path->arc_for_pp-debug_base_arc_token), - path->arc_for_pp); - if ((a = path->arc_for_pp) != NULL) - { - printf(" ilabel %d(%s) olabel %d\n", - a->ilabel, ilabels->words[a->ilabel], - a->olabel); - } - else - { - printf("\n"); - } - printf(" from "); - for (i = 0; i < npaths; i++) - { - if (paths[i].next == path) + int i; + sem_partial_path* frompath = 0; + arc_token* a; + + if (!path) + { + printf("--- END ---\n"); + return; + } + printf("path %p arc %d %p ", path, (path->arc_for_pp-debug_base_arc_token), + path->arc_for_pp); + if ((a = path->arc_for_pp) != NULL) + { + printf(" ilabel %d(%s) olabel %d\n", + a->ilabel, ilabels->words[a->ilabel], + a->olabel); + } + else { - frompath = &paths[i]; - break; + printf("\n"); } - } - if (1)sem_partial_path_print(frompath, paths, npaths, ilabels); + printf(" from "); + for (i = 0; i < npaths; i++) + { + if (paths[i].next == path) + { + frompath = &paths[i]; + break; + } + } + if (1)sem_partial_path_print(frompath, paths, npaths, ilabels); } #endif -ESR_ReturnCode sem_partial_path_free(sem_partial_path* path) +static ESR_ReturnCode sem_partial_path_free(sem_partial_path* heap, sem_partial_path* path) { - path->next = sem_partial_path_freelist; - sem_partial_path_freelist = path; - return ESR_SUCCESS; + path->next = heap->next; + heap->next = path; + return ESR_SUCCESS; } /***********************************************************************/ -const LCHAR* lookUpWord(SR_SemanticGraphImpl* semgraph, wordID wdid) +static const LCHAR* lookUpWord(SR_SemanticGraphImpl* semgraph, wordID wdid) { - int wdID = wdid; - int mid_offset, upper_offset; - wordmap* mid_words; - wordmap* upper_words; - - if (wdID < 0 || wdID >= MAXwordID) + int wdID = wdid; + int mid_offset, upper_offset; + wordmap* mid_words; + wordmap* upper_words; + + if (wdID < 0 || wdID >= MAXwordID) + return WORD_NOT_FOUND; + + if (semgraph->scopes_olabel_offset < semgraph->script_olabel_offset) + { + mid_offset = semgraph->scopes_olabel_offset; + mid_words = semgraph->scopes_olabels; + upper_offset = semgraph->script_olabel_offset; + upper_words = semgraph->scripts; + } + else + { + mid_offset = semgraph->script_olabel_offset; + mid_words = semgraph->scripts; + upper_offset = semgraph->scopes_olabel_offset; + upper_words = semgraph->scopes_olabels; + } + + if (wdID < mid_offset && wdID < semgraph->ilabels->num_words) + { + return semgraph->ilabels->words[wdID]; + } + else if (wdID >= mid_offset && wdID < upper_offset) + { + wdID -= mid_offset; + if (wdID >= 0 && wdID < mid_words->num_words) + return mid_words->words[wdID]; + } + else if (wdID >= upper_offset && wdID < MAXwordID) + { + wdID -= upper_offset; + if (wdID >= 0 && wdID < upper_words->num_words) + return upper_words->words[wdID]; + } + return WORD_NOT_FOUND; - - if (semgraph->scopes_olabel_offset < semgraph->script_olabel_offset) - { - mid_offset = semgraph->scopes_olabel_offset; - mid_words = semgraph->scopes_olabels; - upper_offset = semgraph->script_olabel_offset; - upper_words = semgraph->scripts; - } - else - { - mid_offset = semgraph->script_olabel_offset; - mid_words = semgraph->scripts; - upper_offset = semgraph->scopes_olabel_offset; - upper_words = semgraph->scopes_olabels; - } - - if (wdID < mid_offset && wdID < semgraph->ilabels->num_words) - { - return semgraph->ilabels->words[wdID]; - } - else if (wdID >= mid_offset && wdID < upper_offset) - { - wdID -= mid_offset; - if (wdID >= 0 && wdID < mid_words->num_words) - return mid_words->words[wdID]; - } - else if (wdID >= upper_offset && wdID < MAXwordID) - { - wdID -= upper_offset; - if (wdID >= 0 && wdID < upper_words->num_words) - return upper_words->words[wdID]; - } - - return WORD_NOT_FOUND; } -const LCHAR* lookUpScript(SR_SemanticGraphImpl* semgraph, const LCHAR* script_label) +static const LCHAR* lookUpScript(SR_SemanticGraphImpl* semgraph, const LCHAR* script_label) { - size_t index; - - index = atoi(&script_label[1]); /* skip the prepended '_' */ - - if (index > semgraph->scripts->num_words) - return WORD_NOT_FOUND; - else - return semgraph->scripts->words[index]; + size_t index; + + index = atoi(&script_label[1]); /* skip the prepended '_' */ + + if (index > semgraph->scripts->num_words) + return WORD_NOT_FOUND; + else + return semgraph->scripts->words[index]; } PINLINE ESR_BOOL isnum(const LCHAR* str) { - if (!str || !*str) - return ESR_FALSE; - - while (*str) - { - if (!isdigit(*str)) - return ESR_FALSE; - str++; - } - return ESR_TRUE; + if (!str || !*str) + return ESR_FALSE; + + while (*str) + { + if (!isdigit(*str)) + return ESR_FALSE; + str++; + } + return ESR_TRUE; } -ESR_ReturnCode accumulate_scripts(SR_SemanticGraphImpl* semgraph, script_list* scripts, sem_partial_path* path) +static ESR_ReturnCode accumulate_scripts(SR_SemanticGraphImpl* semgraph, + script_list* scripts, sem_partial_path* path) { - size_t scope = 0; - arc_token* atok; - sem_partial_path* p; - const LCHAR* word; - size_t j; - ESR_ReturnCode rc; - - for (p = path; p != NULL; p = p->next) - { - atok = p->arc_for_pp; - if (atok == NULL) - continue; - else if (atok->ilabel == WORD_EPSILON_LABEL && atok->olabel == WORD_EPSILON_LABEL) - continue; - else if (atok->olabel != WORD_EPSILON_LABEL) + size_t scope = 0; + arc_token* atok; + sem_partial_path* p; + const LCHAR* word; + size_t j; + ESR_ReturnCode rc; + + for (p = path; p != NULL; p = p->next) { - LCHAR* _tMp; - word = lookUpWord(semgraph, atok->olabel); - - if ( IS_BEGIN_SCOPE(word)) - ++scope; - else if ( IS_END_SCOPE(word) ) - { - j = scripts->num_scripts; - do - { - if (scripts->list[j].ruleName == (LCHAR*) scope) /* just an ID */ - scripts->list[j].ruleName = word; - --j; - } - while (j != (size_t) - 1); - if (scope > 0) - --scope; - else - { - rc = ESR_INVALID_STATE; - PLogError(L("ESR_INVALID_STATE: Tried popping scope when it was zero")); - goto CLEANUP; - } - } - else - { - /* make sure it is actually a script */ - if (wordmap_find_index(semgraph->scripts, word) != MAXwordID) + atok = p->arc_for_pp; + if (atok == NULL) + continue; + else if (atok->ilabel == WORD_EPSILON_LABEL && atok->olabel == WORD_EPSILON_LABEL) + continue; + else if (atok->olabel != WORD_EPSILON_LABEL) { - MEMCHK(rc, scripts->num_scripts, MAX_SCRIPTS); - scripts->list[scripts->num_scripts].expression = word; - scripts->list[scripts->num_scripts].ruleName = (LCHAR*) scope; /* just an ID */ - ++scripts->num_scripts; + LCHAR* _tMp; + word = lookUpWord(semgraph, atok->olabel); + + if ( IS_BEGIN_SCOPE(word)) + ++scope; + else if ( IS_END_SCOPE(word) ) + { + j = scripts->num_scripts; + do + { + if (scripts->list[j].ruleName == (LCHAR*) scope) /* just an ID */ + scripts->list[j].ruleName = word; + --j; + } + while (j != (size_t) - 1); + if (scope > 0) + --scope; + else + { + rc = ESR_INVALID_STATE; + PLogError(L("ESR_INVALID_STATE: Tried popping scope when it was zero")); + goto CLEANUP; + } + } + else + { + /* make sure it is actually a script */ + if (wordmap_find_index(semgraph->scripts, word) != MAXwordID) + { + MEMCHK(rc, scripts->num_scripts, MAX_SCRIPTS); + scripts->list[scripts->num_scripts].expression = word; + scripts->list[scripts->num_scripts].ruleName = (LCHAR*) scope; /* just an ID */ + ++scripts->num_scripts; + } + /* else ignore */ + } } - /* else ignore */ - } } - } - return ESR_SUCCESS; + return ESR_SUCCESS; CLEANUP: - return rc; + return rc; } -ESR_ReturnCode SR_SemanticProcessor_SetParam(SR_SemanticProcessor* self, const LCHAR* key, const LCHAR* value) +ESR_ReturnCode SR_SemanticProcessor_SetParam(SR_SemanticProcessor* self, + const LCHAR* key, const LCHAR* value) { - SR_SemanticProcessorImpl* impl = (SR_SemanticProcessorImpl*) self; - - if (self == NULL || key == NULL || value == NULL) - { - PLogError(L("ESR_INVALID_ARGUMENT")); - return ESR_INVALID_ARGUMENT; - } - - return ST_putSpecialKeyValue(impl->symtable, key, value); - + SR_SemanticProcessorImpl* impl = (SR_SemanticProcessorImpl*) self; + + if (self == NULL || key == NULL || value == NULL) + { + PLogError(L("ESR_INVALID_ARGUMENT")); + return ESR_INVALID_ARGUMENT; + } + + return ST_putSpecialKeyValue(impl->symtable, key, value); + } ESR_ReturnCode SR_SemanticProcessor_Flush(SR_SemanticProcessor* self) { - SR_SemanticProcessorImpl* impl = (SR_SemanticProcessorImpl*) self; - - if (self == NULL) - { - PLogError(L("ESR_INVALID_ARGUMENT")); - return ESR_INVALID_ARGUMENT; - } - return ST_reset_all(impl->symtable); + SR_SemanticProcessorImpl* impl = (SR_SemanticProcessorImpl*) self; + + if (self == NULL) + { + PLogError(L("ESR_INVALID_ARGUMENT")); + return ESR_INVALID_ARGUMENT; + } + return ST_reset_all(impl->symtable); } diff --git a/srec/Semproc/src/SymbolTable.c b/srec/Semproc/src/SymbolTable.c index 9d37877..c00a6a1 100644 --- a/srec/Semproc/src/SymbolTable.c +++ b/srec/Semproc/src/SymbolTable.c @@ -24,8 +24,6 @@ static const char* MTAG = __FILE__; -static LCHAR undefined_symbol[] = UNDEFINED_SYMBOL; - ESR_ReturnCode ST_Init(SymbolTable **ptr) { ESR_ReturnCode rc; @@ -78,7 +76,7 @@ CLEANUP: return rc; } -ESR_ReturnCode ST_putKeyValue(SymbolTable* self, LCHAR* key, LCHAR* value) +ESR_ReturnCode ST_putKeyValue(SymbolTable* self, const LCHAR* key, const LCHAR* value) { Symbol* symbol; LCHAR* buf; @@ -148,7 +146,7 @@ ESR_ReturnCode ST_Copy(SymbolTable* self, HashMap* dst) return ESR_SUCCESS; } -ESR_ReturnCode ST_getKeyValue(SymbolTable* self, LCHAR* key, LCHAR** value) +ESR_ReturnCode ST_getKeyValue(SymbolTable* self, const LCHAR* key, LCHAR** value) { ESR_ReturnCode rc; LCHAR *dot; @@ -191,7 +189,7 @@ ESR_ReturnCode ST_getKeyValue(SymbolTable* self, LCHAR* key, LCHAR** value) } } - *value = undefined_symbol; + *value = UNDEFINED_SYMBOL; return ESR_SUCCESS; } diff --git a/srec/Vocabulary/include/SR_Vocabulary.h b/srec/Vocabulary/include/SR_Vocabulary.h index 1a499f3..5488647 100644 --- a/srec/Vocabulary/include/SR_Vocabulary.h +++ b/srec/Vocabulary/include/SR_Vocabulary.h @@ -1,7 +1,7 @@ /*---------------------------------------------------------------------------* - * SR_Vocabulary.h * + * SR_Vocabulary.h * * * - * Copyright 2007, 2008 Nuance Communciations, Inc. * + * Copyright 2007, 2008 Nuance Communciations, Inc. * * * * Licensed under the Apache License, Version 2.0 (the 'License'); * * you may not use this file except in compliance with the License. * @@ -11,7 +11,7 @@ * * * Unless required by applicable law or agreed to in writing, software * * distributed under the License is distributed on an 'AS IS' BASIS, * - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * * See the License for the specific language governing permissions and * * limitations under the License. * * * @@ -47,7 +47,7 @@ typedef struct SR_Vocabulary_t * @param filename File to write to */ ESR_ReturnCode(*save)(struct SR_Vocabulary_t* self, const LCHAR* filename); - + /** * Returns phonetic representation of word. * @@ -58,7 +58,7 @@ typedef struct SR_Vocabulary_t * ESR_BUFFER_OVERFLOW, the required length is returned in this variable. */ ESR_ReturnCode(*getPronunciation)(struct SR_Vocabulary_t* self, const LCHAR* word, LCHAR* pronunciation, size_t* len); - + /** * Returns vocabulary locale. * @@ -66,7 +66,7 @@ typedef struct SR_Vocabulary_t * @param locale [out] Vocabulary locale */ ESR_ReturnCode(*getLanguage)(struct SR_Vocabulary_t* self, ESR_Locale* locale); - + /** * Destroys a Vocabulary. * @@ -158,8 +158,7 @@ SREC_VOCABULARY_API ESR_ReturnCode SR_VocabularyGetPronunciation(SR_Vocabulary* */ /* To-Do: the following functions need to be removed. The functions are still used in SR_NameTag.dll */ -SREC_VOCABULARY_API ESR_ReturnCode SR_Vocabulary_etiinf_conv_multichar(ESR_Locale locale, const LCHAR* i, LCHAR* output, size_t max_len); -SREC_VOCABULARY_API ESR_ReturnCode SR_Vocabulary_etiinf_conv_from_multichar(ESR_Locale locale, LCHAR* input, LCHAR* output); -SREC_VOCABULARY_API ESR_ReturnCode SR_Vocabulary_etiinf_init_multichar(ESR_Locale locale); +SREC_VOCABULARY_API ESR_ReturnCode SR_Vocabulary_etiinf_conv_multichar(ESR_Locale locale, const LCHAR* input, LCHAR* output, size_t max_len); +SREC_VOCABULARY_API ESR_ReturnCode SR_Vocabulary_etiinf_conv_from_multichar(ESR_Locale locale, const LCHAR* input, LCHAR* output); #endif /* __SR_VOCABULARY_H */ diff --git a/srec/Vocabulary/src/Vocabulary.c b/srec/Vocabulary/src/Vocabulary.c index 6ae252c..cffe312 100644 --- a/srec/Vocabulary/src/Vocabulary.c +++ b/srec/Vocabulary/src/Vocabulary.c @@ -1,7 +1,7 @@ /*---------------------------------------------------------------------------* - * Vocabulary.c * + * Vocabulary.c * * * - * Copyright 2007, 2008 Nuance Communciations, Inc. * + * Copyright 2007, 2008 Nuance Communciations, Inc. * * * * Licensed under the Apache License, Version 2.0 (the 'License'); * * you may not use this file except in compliance with the License. * @@ -11,7 +11,7 @@ * * * Unless required by applicable law or agreed to in writing, software * * distributed under the License is distributed on an 'AS IS' BASIS, * - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * * See the License for the specific language governing permissions and * * limitations under the License. * * * @@ -36,7 +36,7 @@ ESR_ReturnCode SR_VocabularyCreate(ESR_Locale locale, SR_Vocabulary** self) #ifdef USE_TTP /* impl->ttp_lang should be set to the current language before G2P is created */ rc = SR_CreateG2P(Interface); - if (rc != ESR_SUCCESS) + if (rc != ESR_SUCCESS) { SR_VocabularyDestroyImpl(Interface); goto CLEANUP; @@ -105,69 +105,14 @@ ESR_ReturnCode SR_VocabularyGetPronunciation(SR_Vocabulary* self, const LCHAR* w /**************************** * ETI to INFINITIVE Phoneme conversion stuff */ -#define DICTIONARY_HANDLE void -#define MAX_ESR_LOCALES 16 -#define MAX_LENGTH P_PATH_MAX -static SR_Vocabulary* g_etiinf_pronguesser[MAX_ESR_LOCALES]; -const char* g_etiinf_multichar[MAX_ESR_LOCALES][256]; -static int initted = 0; -static int portable_initted = 0; -ESR_ReturnCode SR_Vocabulary_etiinf_conv_multichar(ESR_Locale locale, const LCHAR* i, LCHAR* output, size_t max_len) -{ - const LCHAR** m; - - //if (locale < 0) - // return ESR_INVALID_ARGUMENT; - - m = g_etiinf_multichar[locale]; - - for (*output='\0'; *i; ++i) - { - strcat(output, m[(int)*i]); - if (*(i+1)) - strcat(output, " "); - } - return ESR_SUCCESS; -} +static const int CH_MAX = 128; -ESR_ReturnCode SR_Vocabulary_etiinf_conv_from_multichar(ESR_Locale locale, LCHAR* input, LCHAR* output) +static ESR_ReturnCode getTable(ESR_Locale locale, const LCHAR* m[]) { + int i; + for(i = 0; i< CH_MAX; i++) m[i] = ""; - ESR_ReturnCode rc; - size_t i; - const LCHAR** m; - - //if (locale < 0) - // return 1; - - CHKLOG(rc, SR_Vocabulary_etiinf_init_multichar(locale)); - m = g_etiinf_multichar[locale]; - - for (i=0; i<256; ++i) - { - if (m[i] && !LSTRCMP(m[i], input)) - { - *output = (LCHAR) i; - return ESR_SUCCESS; - } - } - return ESR_NO_MATCH_ERROR; - CLEANUP: - return rc; -} - -ESR_ReturnCode SR_Vocabulary_etiinf_init_multichar(ESR_Locale locale) -{ - size_t i; - const LCHAR** m; - - //if (locale<0) - // return 1; - - m = &g_etiinf_multichar[locale][0]; - for(i=0;i<255;i++) m[i] = ""; - switch (locale) { case ESR_LOCALE_EN_US: @@ -221,15 +166,15 @@ ESR_ReturnCode SR_Vocabulary_etiinf_init_multichar(ESR_Locale locale) m['6']="ii"; m['t']="t"; m['u']="UU"; m['w']="w"; m['y']="y"; break; case ESR_LOCALE_NL_NL: - m['S']="S"; m['a']="a"; m['N']="nK"; m['d']="d"; m['E']="E"; - m['2']="ep"; m['j']="j"; m['y']="y"; m['Z']="Z"; m['u']="u"; - m['1']="AA"; m['k']="k"; m['g']="g"; m['t']="t"; m['e']="e"; - m['J']="jnk"; m['v']="v"; m['s']="s"; m['^']="ENV"; m['b']="b"; - m['I']="I"; m['G']="G"; m['z']="z"; m['w']="w"; m['$']="$"; - m['r']="r"; m['x']="x"; m['h']="h"; m['f']="f"; m['i']="i"; - m['A']="A"; m['6']="A%t"; m['O']="O"; m['n']="n"; m['3']="Ei"; - m['#']="sil"; m['m']="m"; m['8']="O%t"; m['l']="l"; m['4']="yy"; - m['p']="p"; m['5']="Au"; m['o']="o"; + m['S']="S"; m['a']="a"; m['N']="nK"; m['d']="d"; m['E']="E"; + m['2']="ep"; m['j']="j"; m['y']="y"; m['Z']="Z"; m['u']="u"; + m['1']="AA"; m['k']="k"; m['g']="g"; m['t']="t"; m['e']="e"; + m['J']="jnk"; m['v']="v"; m['s']="s"; m['^']="ENV"; m['b']="b"; + m['I']="I"; m['G']="G"; m['z']="z"; m['w']="w"; m['$']="$"; + m['r']="r"; m['x']="x"; m['h']="h"; m['f']="f"; m['i']="i"; + m['A']="A"; m['6']="A%t"; m['O']="O"; m['n']="n"; m['3']="Ei"; + m['#']="sil"; m['m']="m"; m['8']="O%t"; m['l']="l"; m['4']="yy"; + m['p']="p"; m['5']="Au"; m['o']="o"; break; case ESR_LOCALE_IT_IT: m['@']="uu"; m['A']="AI"; m['C']="ci"; m['E']="EI"; m['J']="jnk"; @@ -259,126 +204,38 @@ ESR_ReturnCode SR_Vocabulary_etiinf_init_multichar(ESR_Locale locale) break; } m['#']="iwt"; m['&']="&"; - + return ESR_SUCCESS; } -ESR_Locale SR_Vocabulary_etiinf_get_locale_or_exit(const LCHAR* language) - { - LCHAR local_chars[4]; - - /* language string comes from userdict/language.c, eg: en.us */ - local_chars [0] = (char)tolower(language[0]); - local_chars [1] = (char)tolower(language[1]); - local_chars [2] = (char)tolower(language[2]); - local_chars [3] = (char)tolower(language[3]); - - if ( memcmp ( local_chars, "enus", 4 ) == 0 ) - return ESR_LOCALE_EN_US; - else if ( ( memcmp ( local_chars, "enuk", 4 ) == 0 ) || ( memcmp ( local_chars, "engb", 4 ) == 0 ) ) - return ESR_LOCALE_EN_GB; - else if ( memcmp ( local_chars, "frfr", 4 ) == 0 ) - return ESR_LOCALE_FR_FR; - else if ( memcmp ( local_chars, "dede", 4 ) == 0 ) - return ESR_LOCALE_DE_DE; - else if ( memcmp ( local_chars, "ptpt", 4 ) == 0 ) - return ESR_LOCALE_PT_PT; - else if ( memcmp ( local_chars, "nlnl", 4 ) == 0 ) - return ESR_LOCALE_NL_NL; - else if ( memcmp ( local_chars, "itit", 4 ) == 0 ) - return ESR_LOCALE_IT_IT; - else if ( memcmp ( local_chars, "eses", 4 ) == 0 ) - return ESR_LOCALE_ES_ES; - else - { - PLogError(L("ESR_NOT_IMPLEMENTED (error getting locale for language '%s')"), language); - return ESR_NOT_IMPLEMENTED; - } - } - -ESR_ReturnCode SR_Vocabulary_etiinf_get_phonemes(const char *input, /* word to generate pronunciations for */ - const char* language, - DICTIONARY_HANDLE *h, /* dictionary to search, in addition to table above */ - char **output_array, /* buffer to store pronunciations */ - unsigned int *num_prons, /* number of prounciations to be returned */ - unsigned int max_len, /* the length of each buffer line */ - unsigned int max_prons, /* maximum number of pronunciations allowed */ - void *text_to_phoneme_data) /* text to phoneme data */ +ESR_ReturnCode SR_Vocabulary_etiinf_conv_multichar(ESR_Locale locale, const LCHAR* single, LCHAR* multi, size_t max_len) { - LCHAR raw_output[MAX_LENGTH]; - size_t len; - int stat; - LCHAR *output = output_array[0]; /* will only generate one pronunciation from the rules */ - ESR_ReturnCode rc; - ESR_Locale locale; - - locale = SR_Vocabulary_etiinf_get_locale_or_exit(language); - - raw_output[0] = '\0'; - *num_prons = 1; - - if (initted == 0) - { - PLogError(L("DICT: NAV rules called but not initialized")); - *output = '\0'; - return ESR_FATAL_ERROR; - } + const LCHAR* m[CH_MAX]; - /*PTHREAD_INIT_PRIVATE( pthread_key, pglobals, sizeof (GLOBALS), NULL );*/ + ESR_ReturnCode rc = getTable(locale, m); + if (rc != ESR_SUCCESS) return rc; - len = MAX_LENGTH; - stat = (int)SR_VocabularyGetPronunciation( g_etiinf_pronguesser[locale], input, - raw_output, &len); - if(stat != 0) - { - PLogError(L("DICT: SR_VocabularyGetPronunciation() failed")); - return ESR_FATAL_ERROR; - } - else - { - /* convert the phoneme to multi char representation */ - rc = SR_Vocabulary_etiinf_conv_multichar(locale, raw_output, output, max_len); - if (rc!=ESR_SUCCESS) - { - PLogError(L("DICT: failed to multichar output of SR_VocabularyGetPronounciation() %s"), raw_output); - return rc; - } - } - return ESR_SUCCESS; + for (*multi='\0'; *single; ++single) + { + LSTRCAT(multi, m[(int)*single]); + if (*(single+1)) LSTRCAT(multi, " "); + } + return ESR_SUCCESS; } -ESR_ReturnCode SR_Vocabulary_etiinf_destroy_pronguesser( const char* language) +ESR_ReturnCode SR_Vocabulary_etiinf_conv_from_multichar(ESR_Locale locale, const LCHAR* multi, LCHAR* single) { - if (portable_initted == 1) - PMemShutdown(); - portable_initted = 0; - return ESR_SUCCESS; -} + const LCHAR* m[CH_MAX]; + int i; -ESR_ReturnCode SR_Vocabulary_etiinf_init_pronguesser( const char* language) -{ - size_t i,j; - ESR_ReturnCode rc; - ESR_Locale locale; + ESR_ReturnCode rc = getTable(locale, m); + if (rc != ESR_SUCCESS) return rc; - if (!portable_initted) - { - rc = PMemInit(); - if (rc!=ESR_SUCCESS) - return rc; - for (i=0; i<MAX_ESR_LOCALES; ++i) - g_etiinf_pronguesser[i] = 0; - for (i=0; i<MAX_ESR_LOCALES; ++i) - for (j=0; j<255; ++j) - g_etiinf_multichar[i][j] = 0; - portable_initted = 1; - } - - locale = SR_Vocabulary_etiinf_get_locale_or_exit(language); - - CHKLOG(rc, SR_VocabularyCreate(locale, &g_etiinf_pronguesser[locale])); - CHKLOG(rc, SR_Vocabulary_etiinf_init_multichar(locale)); - return ESR_SUCCESS; - CLEANUP: - return rc; + for (i = 0; i < CH_MAX; i++) { + if (!LSTRCMP(m[i], multi)) { + *single = (LCHAR)i; + return ESR_SUCCESS; + } + } + return ESR_NO_MATCH_ERROR; } diff --git a/srec/Vocabulary/src/VocabularyImpl.c b/srec/Vocabulary/src/VocabularyImpl.c index 159ac4d..76b90ee 100644 --- a/srec/Vocabulary/src/VocabularyImpl.c +++ b/srec/Vocabulary/src/VocabularyImpl.c @@ -1,7 +1,7 @@ /*---------------------------------------------------------------------------* - * VocabularyImpl.c * + * VocabularyImpl.c * * * - * Copyright 2007, 2008 Nuance Communciations, Inc. * + * Copyright 2007, 2008 Nuance Communciations, Inc. * * * * Licensed under the Apache License, Version 2.0 (the 'License'); * * you may not use this file except in compliance with the License. * @@ -11,7 +11,7 @@ * * * Unless required by applicable law or agreed to in writing, software * * distributed under the License is distributed on an 'AS IS' BASIS, * - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * * See the License for the specific language governing permissions and * * limitations under the License. * * * @@ -37,17 +37,8 @@ static PINLINE LCHAR* get_next_word(LCHAR* curr, LCHAR* end); static ESR_ReturnCode run_ttt(const LCHAR *input_sentence, LCHAR *output_sentence, int *text_length); #define MAX_NUM_PRONS 4 -LCHAR* LSTRDUP(const LCHAR* src) -{ - int len = LSTRLEN(src); - LCHAR* dst = CALLOC( (len+1), sizeof(LCHAR), "srec.Vocabulary.LSTRDUP"); - LSTRCPY( dst,src); - return dst; -} -void LSTRFREE( LCHAR* src) -{ - FREE(src); -} +#define LSTRDUP(src) LSTRCPY(CALLOC(LSTRLEN(src)+1, sizeof(LCHAR), "srec.Vocabulary.LSTRDUP"), (src)) +#define LSTRFREE(src) FREE(src) /** * Creates a new vocabulary but does not set the locale. @@ -63,7 +54,7 @@ ESR_ReturnCode SR_CreateG2P(SR_Vocabulary* self) LCHAR szG2PDataFile[P_PATH_MAX]; size_t len = P_PATH_MAX; ESR_BOOL bG2P = ESR_TRUE; - + rc = ESR_SessionGetBool ( L("G2P.Available"), &bG2P ); if ( rc != ESR_SUCCESS ) { @@ -75,7 +66,7 @@ ESR_ReturnCode SR_CreateG2P(SR_Vocabulary* self) impl->hSlts = NULL; return ESR_SUCCESS; } - + rc = ESR_SessionGetLCHAR ( L("G2P.Data"), szG2PDataFile, &len ); if ( rc != ESR_SUCCESS ) { @@ -88,27 +79,27 @@ ESR_ReturnCode SR_CreateG2P(SR_Vocabulary* self) PLogError(L("ESR_FATAL_ERROR: ESR_SessionPrefixWithBaseDirectory() - G2P.Data fails with return code %d\n"), rc); return rc; } - + res = SWIsltsInit(); - if (res == SWIsltsSuccess) + if (res == SWIsltsSuccess) { /* data_file: en-US-ttp.data */ res = SWIsltsOpen(&(impl->hSlts), szG2PDataFile); - if (res != SWIsltsSuccess) + if (res != SWIsltsSuccess) { PLogError(L("ESR_FATAL_ERROR: SWIsltsOpen( ) fails with return code %d\n"), res); FREE(impl); return ESR_FATAL_ERROR; } } - else + else { PLogError(L("ESR_FATAL_ERROR: SWIsltsInit( ) fails with return code %d\n"), res); FREE(impl); return ESR_FATAL_ERROR; } return rc; -} +} ESR_ReturnCode SR_DestroyG2P(SR_Vocabulary* self) { @@ -116,7 +107,7 @@ ESR_ReturnCode SR_DestroyG2P(SR_Vocabulary* self) SWIsltsResult res = SWIsltsSuccess; SR_VocabularyImpl * impl = (SR_VocabularyImpl*) self; ESR_BOOL bG2P = ESR_TRUE; - + rc = ESR_SessionGetBool ( L("G2P.Available"), &bG2P ); if ( rc != ESR_SUCCESS ) { @@ -127,18 +118,18 @@ ESR_ReturnCode SR_DestroyG2P(SR_Vocabulary* self) { return ESR_SUCCESS; } - + res = SWIsltsClose(impl->hSlts); - if (res == SWIsltsSuccess) + if (res == SWIsltsSuccess) { res = SWIsltsTerm(); - if (res != SWIsltsSuccess) + if (res != SWIsltsSuccess) { PLogError(L("ESR_FATAL_ERROR: SWIsltsTerm( ) fails with return code %d\n"), res); rc = ESR_FATAL_ERROR; } } - else + else { PLogError(L("ESR_FATAL_ERROR: SWIsltsClose( ) fails with return code %d\n"), res); rc = ESR_FATAL_ERROR; @@ -155,7 +146,7 @@ ESR_ReturnCode SR_DestroyG2P(SR_Vocabulary* self) ESR_ReturnCode SR_VocabularyCreateImpl(SR_Vocabulary** self) { SR_VocabularyImpl* impl; - + if (self==NULL) { PLogError(L("ESR_INVALID_ARGUMENT")); @@ -167,13 +158,13 @@ ESR_ReturnCode SR_VocabularyCreateImpl(SR_Vocabulary** self) PLogError(L("ESR_OUT_OF_MEMORY")); return ESR_OUT_OF_MEMORY; } - + impl->Interface.save = &SR_VocabularySaveImpl; impl->Interface.getPronunciation = &SR_VocabularyGetPronunciationImpl; impl->Interface.getLanguage = &SR_VocabularyGetLanguageImpl; impl->Interface.destroy = &SR_VocabularyDestroyImpl; impl->vocabulary = NULL; - + *self = (SR_Vocabulary*) impl; impl->hSlts = NULL; return ESR_SUCCESS; @@ -182,11 +173,11 @@ ESR_ReturnCode SR_VocabularyCreateImpl(SR_Vocabulary** self) ESR_ReturnCode SR_VocabularyDestroyImpl(SR_Vocabulary* self) { SR_VocabularyImpl* impl = (SR_VocabularyImpl*) self; - + #ifdef USE_TTP SR_DestroyG2P(self); #endif - + if (impl->vocabulary!=NULL) { CA_UnloadDictionary(impl->vocabulary); @@ -212,18 +203,18 @@ ESR_ReturnCode sr_vocabularyloadimpl_for_real(SR_VocabularyImpl* impl) PLogError(ESR_rc2str(rc)); goto CLEANUP; } - + CHKLOG(rc, ESR_SessionExists(&sessionExists)); - + if (sessionExists) { LSTRCPY(vocabulary, impl->filename); len = P_PATH_MAX; CHKLOG(rc, ESR_SessionPrefixWithBaseDirectory(vocabulary, &len)); } - else + else LSTRCPY(vocabulary, impl->filename); - + CA_LoadDictionary(impl->vocabulary, vocabulary, L(""), &impl->locale); if(impl->vocabulary->is_loaded == False /*(booldata)*/ ) { CHKLOG(rc, ESR_INVALID_ARGUMENT); @@ -246,20 +237,20 @@ ESR_ReturnCode SR_VocabularyLoadImpl(const LCHAR* filename, SR_Vocabulary** self SR_Vocabulary* Interface; SR_VocabularyImpl* impl; ESR_ReturnCode rc; - + CHK(rc, SR_VocabularyCreateImpl(&Interface)); impl = (SR_VocabularyImpl*) Interface; #if DO_DEFER_LOADING_UNTIL_LOOKUPS impl->vocabulary = NULL; impl->ttp_lang = NULL; - impl->filename = LSTRDUP( filename); + impl->filename = LSTRDUP( filename); impl->locale = ESR_LOCALE_EN_US; // default really impl->hSlts = NULL; #else impl->filename = LSTRDUP( filename); - CHKLOG( rc, sr_vocabularyloadimpl_for_real( impl)); + CHKLOG( rc, sr_vocabularyloadimpl_for_real( impl)); #endif - + *self = Interface; return ESR_SUCCESS; CLEANUP: @@ -277,12 +268,12 @@ ESR_ReturnCode SR_VocabularySaveImpl(SR_Vocabulary* self, const LCHAR* filename) /* we split the string on all non-alphanum and "'" which is handled below */ #define LSINGLEQUOTE L('\'') -int split_on_nonalphanum(LCHAR* toSplit, LCHAR** end, const ESR_Locale locale) +int split_on_nonalphanum(LCHAR* toSplit, LCHAR** end, const ESR_Locale locale) { int nsplits = 0; - LCHAR* _next = toSplit; - while(*_next) - { + LCHAR* _next = toSplit; + while(*_next) + { do { if(*_next == LSINGLEQUOTE && locale == ESR_LOCALE_EN_US) { if(_next[1] != 't' && _next[1] != 's') break; @@ -292,27 +283,27 @@ int split_on_nonalphanum(LCHAR* toSplit, LCHAR** end, const ESR_Locale locale) if(!*_next || !LISALNUM(*_next)) break; *_next++; } while(1); - // FORMERLY: while(*_next && LISALNUM(*_next)) _next++; + // FORMERLY: while(*_next && LISALNUM(*_next)) _next++; - /* check if I am at the last word or not */ - if(*_next) - { - *_next = 0; /* replace split_char with '\0' the word */ + /* check if I am at the last word or not */ + if(*_next) + { + *_next = 0; /* replace split_char with '\0' the word */ nsplits++; - _next++; /* point to first char of next word */ + _next++; /* point to first char of next word */ *end = _next; /* we'll be push forward later, if there's content here!*/ - } - else - *end = _next; - } + } + else + *end = _next; + } return nsplits; } -void join(LCHAR* toJoin, LCHAR* end, LCHAR join_char) +void join(LCHAR* toJoin, LCHAR* end, LCHAR join_char) { LCHAR* _next; - for(_next = toJoin; _next<end; _next++) - if(*_next == 0) *_next = join_char; + for(_next = toJoin; _next<end; _next++) + if(*_next == 0) *_next = join_char; } size_t get_num_prons( const LCHAR* word_prons, const LCHAR** word_pron_ptr, int max_num_prons) @@ -327,10 +318,10 @@ size_t get_num_prons( const LCHAR* word_prons, const LCHAR** word_pron_ptr, int return num_prons; } -/* This function is used from multi-word phrases, such as "mike smith". We - build up the pronunication of the phrase, by appending the pronunciation +/* This function is used from multi-word phrases, such as "mike smith". We + build up the pronunication of the phrase, by appending the pronunciation of each word. We need to handle the cases of multiple prons for "mike" - and multiple prons for "smith". For simple cases we try to run faster + and multiple prons for "smith". For simple cases we try to run faster code. */ int append_to_each_with_joiner( LCHAR* phrase_prons, const LCHAR* word_prons, const LCHAR joiner, size_t max_len, size_t* len) @@ -343,7 +334,7 @@ int append_to_each_with_joiner( LCHAR* phrase_prons, const LCHAR* word_prons, co size_t nword_prons = get_num_prons( word_prons, (const LCHAR**)word_pron_ptr, MAX_NUM_PRONS); max_dst = phrase_prons+max_len-3; - if( nword_prons == 0) + if( nword_prons == 0) return 0; else if(nphrase_prons == 0) { for(src=word_prons,dst=phrase_prons; src && *src; ) { @@ -369,7 +360,7 @@ int append_to_each_with_joiner( LCHAR* phrase_prons, const LCHAR* word_prons, co size_t i,j; LCHAR *phrase_pron_dups[MAX_NUM_PRONS]; LCHAR *dst_good_end = phrase_prons+1; - for(i=0;i<nphrase_prons; i++) + for(i=0;i<nphrase_prons; i++) phrase_pron_dups[i] = LSTRDUP( phrase_pron_ptr[i]); dst = phrase_prons; for(i=0;i<nphrase_prons; i++) { @@ -405,12 +396,12 @@ PINLINE LCHAR* get_next_word(LCHAR* curr, LCHAR* end) /* For each word in a phrase (words separated by spaces) - + if the complete word is in the dictionary return pron - else + else if the word contains '_', split the word into parts - and check if parts are in the dictionary. + and check if parts are in the dictionary. if none of the parts are in the dictionary, reassemble the parts and pass the whole thing to TTP else @@ -421,16 +412,16 @@ ESR_ReturnCode SR_VocabularyGetPronunciationImpl(SR_Vocabulary* self, const LCHA SR_VocabularyImpl* impl = (SR_VocabularyImpl*) self; /* copy of phrase */ LCHAR copy_of_phrase[MAX_PRON_LEN]; - + /* pointer to curr phoneme output */ LCHAR* curr_phoneme = pronunciation; // size_t pronunciation_len = *len; - + ESR_ReturnCode nEsrRes = ESR_SUCCESS; int text_length; size_t len; int nsplits; - + #ifdef USE_TTP SWIsltsResult res = SWIsltsSuccess; SWIsltsTranscription *pTranscriptions = NULL; @@ -441,33 +432,33 @@ ESR_ReturnCode SR_VocabularyGetPronunciationImpl(SR_Vocabulary* self, const LCHA LCHAR* p_infpron; LCHAR* curr; /* pointer to current word */ LCHAR* end = 0; /* pointer to end of phrase */ - + if(self == NULL || phrase == NULL) { PLogError(L("ESR_INVALID_ARGUMENT")); return ESR_INVALID_ARGUMENT; } - + if( LSTRLEN(phrase) >= MAX_PRON_LEN) return ESR_ARGUMENT_OUT_OF_BOUNDS; #if DO_DEFER_LOADING_UNTIL_LOOKUPS if( impl->vocabulary == NULL) { - CHKLOG( nEsrRes, sr_vocabularyloadimpl_for_real( impl)); + CHKLOG( nEsrRes, sr_vocabularyloadimpl_for_real( impl)); } #endif - - /* by default, check the whole word entry first (regardless of underscores) */ + + /* by default, check the whole word entry first (regardless of underscores) */ if( CA_GetEntryInDictionary(impl->vocabulary, phrase, pronunciation, (int*)&len, MAX_PRON_LEN)) { // len includes the final null, but not the double-null - *pronunciation_len = LSTRLEN(pronunciation)+1; + *pronunciation_len = LSTRLEN(pronunciation)+1; // look for double-null terminator - while( pronunciation[ (*pronunciation_len)] != L('\0')) + while( pronunciation[ (*pronunciation_len)] != L('\0')) *pronunciation_len += LSTRLEN( pronunciation + (*pronunciation_len)) + 1; - + return ESR_SUCCESS; } - + /*************************/ /* split digit strings */ text_length = MAX_PRON_LEN; @@ -477,56 +468,56 @@ ESR_ReturnCode SR_VocabularyGetPronunciationImpl(SR_Vocabulary* self, const LCHA PLogError(L("ESR_FATAL_ERROR: run_ttt( ) fails with return code %d\n"), nEsrRes); return nEsrRes; } - - len = 0; + + len = 0; *curr_phoneme = L('\0'); if( *pronunciation_len>=12) curr_phoneme[1] = L('\0'); else return ESR_INVALID_ARGUMENT; - + /*************************/ /* split into word parts */ nsplits = split_on_nonalphanum(copy_of_phrase, &end, impl->locale); - + /******************************************************/ - /* if none of the words are found in the dictionary, then + /* if none of the words are found in the dictionary, then reassemble and get the TTP pron for the whole thing */ curr=get_first_word(copy_of_phrase,end); /* check if there are any valid characters at all */ - if(!curr || !*curr) + if(!curr || !*curr) return ESR_INVALID_ARGUMENT; /* now loop over all words in the phrase */ for( ; *curr; curr = get_next_word(curr,end)) - { + { LCHAR* squote = NULL; p_infpron = infpron; - - /* by default, check the whole word entry first (regardless of LSINGLEQUOTE) */ + + /* by default, check the whole word entry first (regardless of LSINGLEQUOTE) */ if(CA_GetEntryInDictionary(impl->vocabulary, curr, p_infpron, (int*)&len, MAX_PRON_LEN)) { /* concatenate, and insert join_char between words */ append_to_each_with_joiner( pronunciation, p_infpron, OPTSILENCE_CODE, MAX_PRON_LEN, &len); } - else { - p_infpron[0] = 0; - /* if this is English AND we're dealing with a quote (possessive or a + else { + p_infpron[0] = 0; + /* if this is English AND we're dealing with a quote (possessive or a contraction), then we use the dictionary for the stuff before the - quote, and use the TTP to find out what single phoneme should + quote, and use the TTP to find out what single phoneme should correspond the the thing after the quote ('s' or 't'). This keeps - the code clean (no phoneme codes here), and maps 's' to 's' or 'z' + the code clean (no phoneme codes here), and maps 's' to 's' or 'z' with the intelligence of the G2P engine */ - if( impl->locale == ESR_LOCALE_EN_US) { + if( impl->locale == ESR_LOCALE_EN_US) { if( (squote=LSTRCHR(curr,LSINGLEQUOTE))==NULL) {} else { *squote = L('\0'); // temporary if( CA_GetEntryInDictionary(impl->vocabulary, curr, p_infpron, (int*)&len, MAX_PRON_LEN)) { - } else + } else p_infpron[0] = 0; *squote = LSINGLEQUOTE; // undo temporary } } #ifdef USE_TTP pTranscriptions = NULL; - if (impl->hSlts) + if (impl->hSlts) { res = SWIsltsG2PGetWordTranscriptions(impl->hSlts, curr, &pTranscriptions, &nNbrOfTranscriptions); if (res != SWIsltsSuccess) { @@ -546,7 +537,7 @@ ESR_ReturnCode SR_VocabularyGetPronunciationImpl(SR_Vocabulary* self, const LCHA #if defined(SREC_ENGINE_VERBOSE_LOGGING) PLogError("L: used G2P for %s", curr); #endif - + } if (pTranscriptions) { res = SWIsltsG2PFreeWordTranscriptions(impl->hSlts, pTranscriptions); @@ -568,9 +559,9 @@ ESR_ReturnCode SR_VocabularyGetPronunciationImpl(SR_Vocabulary* self, const LCHA #endif } /* multi-word phrase */ } /* loop over words in phrase */ - len = LSTRLEN(pronunciation)+1; + len = LSTRLEN(pronunciation)+1; // look for double-null terminator - while( pronunciation[ len] != L('\0')) + while( pronunciation[ len] != L('\0')) len += LSTRLEN( pronunciation + len) + 1; *pronunciation_len = len; nEsrRes = ESR_SUCCESS; @@ -581,25 +572,25 @@ ESR_ReturnCode SR_VocabularyGetPronunciationImpl(SR_Vocabulary* self, const LCHA ESR_ReturnCode SR_VocabularyGetLanguageImpl(SR_Vocabulary* self, ESR_Locale* locale) { SR_VocabularyImpl* impl = (SR_VocabularyImpl*) self; - + *locale = impl->locale; return ESR_SUCCESS; } -/* simple text normalization rountine for splitting up any digit string */ +/* simple text normalization rountine for splitting up any digit string */ static ESR_ReturnCode run_ttt(const LCHAR *input_sentence, LCHAR *output_sentence, int *text_length) { ESR_ReturnCode nRes = ESR_SUCCESS; int num_out = 0; int max_text_length = *text_length / sizeof(LCHAR) - 1; ESR_BOOL bDigit = False; - + while (*input_sentence != L('\0')) { if (num_out + 2 >= max_text_length) { nRes = ESR_FATAL_ERROR; goto CLEAN_UP; } - + if (L('0') <= *input_sentence && *input_sentence <= L('9')) { if (num_out > 0 && !LISSPACE(output_sentence[num_out-1]) ) { // put 1 space before digits @@ -623,16 +614,16 @@ static ESR_ReturnCode run_ttt(const LCHAR *input_sentence, LCHAR *output_sentenc bDigit = False; } input_sentence++; - if( LISSPACE(output_sentence[num_out-1])) + if( LISSPACE(output_sentence[num_out-1])) while(LISSPACE(*input_sentence )) input_sentence++; // remove repeated spaces } - + output_sentence[num_out] = L('\0'); *text_length = num_out * sizeof(LCHAR); return ESR_SUCCESS; - + CLEAN_UP: - + *output_sentence = L('\0'); *text_length = 0; return nRes; diff --git a/srec/ca/cnfd_scr.c b/srec/ca/cnfd_scr.c index ec7bbd3..2c3ed5f 100644 --- a/srec/ca/cnfd_scr.c +++ b/srec/ca/cnfd_scr.c @@ -31,7 +31,7 @@ #if USE_CONFIDENCE_SCORER #ifdef SREC_ENGINE_VERBOSE_LOGGING -static const char* conf_feature_names[12] = +static const char* const conf_feature_names[12] = { "gdiff", "sd", "sd13", "spf", "abs", "gdiffpf", "gv" }; #endif @@ -82,7 +82,7 @@ void CA_FreeConfidenceScorer(CA_ConfidenceScorer* hConfidenceScorer) int CA_LoadConfidenceScorer(CA_ConfidenceScorer* hConfidenceScorer) { - static const char* names[NUM_CONF_FEATURES] = { + static char const * const names[NUM_CONF_FEATURES] = { "gdiff", "sd", "sd13", diff --git a/srec/cfront/ca_cms.c b/srec/cfront/ca_cms.c index c21d284..d748792 100644 --- a/srec/cfront/ca_cms.c +++ b/srec/cfront/ca_cms.c @@ -1,7 +1,7 @@ /*---------------------------------------------------------------------------* - * ca_cms.c * + * ca_cms.c * * * - * Copyright 2007, 2008 Nuance Communciations, Inc. * + * Copyright 2007, 2008 Nuance Communciations, Inc. * * * * Licensed under the Apache License, Version 2.0 (the 'License'); * * you may not use this file except in compliance with the License. * @@ -11,7 +11,7 @@ * * * Unless required by applicable law or agreed to in writing, software * * distributed under the License is distributed on an 'AS IS' BASIS, * - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * * See the License for the specific language governing permissions and * * limitations under the License. * * * @@ -56,12 +56,12 @@ ESR_ReturnCode CA_SetCMSParameters ( CA_Wave *hWave, const LCHAR *param_string ) } -ESR_ReturnCode CA_GetCMSParameters ( CA_Wave *hWave, const LCHAR **param_string ) +ESR_ReturnCode CA_GetCMSParameters ( CA_Wave *hWave, LCHAR *param_string, size_t* len ) { ESR_ReturnCode get_status; if ( hWave != NULL ) - get_status = swicms_get_cmn ( hWave->data.channel->swicms, param_string ); + get_status = swicms_get_cmn ( hWave->data.channel->swicms, param_string, len ); else get_status = ESR_INVALID_STATE; return ( get_status ); @@ -88,7 +88,7 @@ void CA_SaveCMSParameters(CA_Wave *hWave, const char *basename) } -void CA_LoadCMSParameters(CA_Wave *hWave, char *basename, +void CA_LoadCMSParameters(CA_Wave *hWave, const char *basename, CA_FrontendInputParams *hFrontArgs) { TRY_CA_EXCEPT @@ -96,12 +96,12 @@ void CA_LoadCMSParameters(CA_Wave *hWave, char *basename, ASSERT(hWave); /* ASSERT (basename); */ ASSERT(hFrontArgs); - + if (hWave->is_configuredForAgc == True) SERVICE_ERROR(CONFIGURED_CMS_AND_AGC); if (hWave->is_attached == True) SERVICE_ERROR(ATTACHED_CMS_AND_AGC); - + hWave->data.channel->channorm = create_channel_normalization(); /* load_channel_parameters (basename, hWave->data.channel->channorm); not used anymore, rather we spec this is the parfile directly */ @@ -115,7 +115,7 @@ void CA_LoadCMSParameters(CA_Wave *hWave, char *basename, #endif hFrontArgs->forget_factor); hWave->data.channel->mel_dim = hFrontArgs->mel_dim; /* TODO: more checks */ - + hWave->data.channel->swicms = (swicms_norm_info*)CALLOC(1, sizeof(swicms_norm_info), "cfront.swicms"); if( swicms_init(hWave->data.channel->swicms) ) SERVICE_ERROR(UNEXPECTED_DATA_ERROR); @@ -136,18 +136,18 @@ void CA_ClearCMSParameters(CA_Wave *hWave) #else int dim = hWave->data.channel->mel_dim; #endif - + ASSERT(hWave); if (hWave->is_configuredForAgc == False) SERVICE_ERROR(UNCONFIGURED_CMS_AND_AGC); if (hWave->is_attached == True) SERVICE_ERROR(ATTACHED_CMS_AND_AGC); - + clear_channel_normalization(hWave->data.channel->spchchan, dim); destroy_channel_normalization(hWave->data.channel->channorm); hWave->data.channel->channorm = NULL; hWave->is_configuredForAgc = False; - + FREE(hWave->data.channel->swicms); BEG_CATCH_CA_EXCEPT; END_CATCH_CA_EXCEPT(hWave); @@ -158,7 +158,7 @@ void CA_AttachCMStoUtterance(CA_Wave *hWave, CA_Utterance *hUtt) /* Link the utt's spchchan to the wave object's. This is checked in AGC fn to ensure that the correct Utt & Wave objects have been supplied. */ - + TRY_CA_EXCEPT ASSERT(hUtt); ASSERT(hWave); @@ -166,7 +166,7 @@ void CA_AttachCMStoUtterance(CA_Wave *hWave, CA_Utterance *hUtt) SERVICE_ERROR(UNCONFIGURED_CMS_AND_AGC); if (hWave->is_attached == True) SERVICE_ERROR(ATTACHED_CMS_AND_AGC); - + ASSERT(hWave->data.channel->channorm); hUtt->data.gen_utt.spchchan = hWave->data.channel->spchchan; hUtt->data.gen_utt.channorm = hWave->data.channel->channorm; @@ -204,7 +204,7 @@ void CA_DetachCMSfromUtterance(CA_Wave *hWave, CA_Utterance *hUtt) { TRY_CA_EXCEPT ASSERT(hWave); - + if (hWave->is_configuredForAgc == False) SERVICE_ERROR(UNCONFIGURED_CMS_AND_AGC); if (hUtt && hUtt->data.gen_utt.do_channorm == False) @@ -217,12 +217,12 @@ void CA_DetachCMSfromUtterance(CA_Wave *hWave, CA_Utterance *hUtt) log_report("Mismatched channel and utterance\n"); SERVICE_ERROR(BAD_CHANNEL); } /* TODO: find a better code */ - + hUtt->data.gen_utt.channorm = NULL; hUtt->data.gen_utt.spchchan = NULL; hUtt->data.gen_utt.do_channorm = False; hWave->is_attached = False; - + return; BEG_CATCH_CA_EXCEPT; END_CATCH_CA_EXCEPT(hWave) @@ -231,12 +231,12 @@ void CA_DetachCMSfromUtterance(CA_Wave *hWave, CA_Utterance *hUtt) void CA_CalculateCMSParameters(CA_Wave *hWave) { TRY_CA_EXCEPT - + if (hWave->is_configuredForAgc == False) SERVICE_ERROR(UNCONFIGURED_CMS_AND_AGC); if (hWave->is_attached == False) SERVICE_ERROR(UNATTACHED_CMS_AND_AGC); - + estimate_normalization_parameters(hWave->data.channel->channorm, hWave->data.channel->spchchan, #if NORM_IN_IMELDA /* TODO: find appropriate number */ diff --git a/srec/cfront/cheldsp4.c b/srec/cfront/cheldsp4.c index c94db42..6f359da 100644 --- a/srec/cfront/cheldsp4.c +++ b/srec/cfront/cheldsp4.c @@ -11,7 +11,7 @@ * * * Unless required by applicable law or agreed to in writing, software * * distributed under the License is distributed on an 'AS IS' BASIS, * - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * * See the License for the specific language governing permissions and * * limitations under the License. * * * @@ -59,24 +59,26 @@ #define RASTA_CONSTANT 0.85 #endif -static void regress(cepdata *rg, cepdata *cp_buf, unsigned short frmind, +static void regress(cepdata *rg, const cepdata *cp_buf, unsigned short frmind, int mel_dim); -static void dd_regress(cepdata *dd, cepdata *cp_buf, unsigned short frmind, +static void dd_regress(cepdata *dd, const cepdata *cp_buf, unsigned short frmind, int mel_dim); -static void scale_data(front_cep *cepobj, featdata *rpram, featdata *pram1, - featdata *pram2, featdata *ddpram, cepdata *rast, - cepdata *cep, cepdata *rcep, cepdata *ddcep); -static void pack_frame(front_cep *cepobj, featdata *dest_frame, - featdata *rasta_data, featdata *mel_data, - featdata *del_data, featdata *deldel_data); +static void scale_data(const front_cep *cepobj, const featdata *rpram, featdata *pram1, + featdata *pram2, featdata *ddpram, const cepdata *rast, + const cepdata *cep, const cepdata *rcep, const cepdata *ddcep); +static void pack_frame(const front_cep *cepobj, featdata *dest_frame, + const featdata *rasta_data, const featdata *mel_data, + const featdata *del_data, const featdata *deldel_data); -static void regress(cepdata *rg, cepdata*cp_buf, unsigned short frmind, +static void regress(cepdata *rg, const cepdata*cp_buf, unsigned short frmind, int mel_dim) { int i, j, d; - cepdata val, *cpt; + cepdata val; + const cepdata* cpt; + /* static cepdata a = (cepdata) 0.0; if (a == (cepdata) 0.0) @@ -85,6 +87,9 @@ static void regress(cepdata *rg, cepdata*cp_buf, unsigned short frmind, a += j * j; a *= (cepdata) 2.0; } + */ + /* replace above code with the following constant */ + cepdata a = (DELTA * (DELTA + 1) * (2 * DELTA + 1) / 6) * 2; d = DELTA; if (frmind < Q2 - 1) { @@ -104,13 +109,15 @@ static void regress(cepdata *rg, cepdata*cp_buf, unsigned short frmind, } return; } -cepdata deldel[] = {2, 0, -1, -2, -1, 0, 2}; /* delta - delta */ -void dd_regress(cepdata *dd, cepdata *cp_buf, unsigned short frmind, int mel_dim) +static const cepdata deldel[] = {2, 0, -1, -2, -1, 0, 2}; /* delta - delta */ + +void dd_regress(cepdata *dd, const cepdata *cp_buf, unsigned short frmind, int mel_dim) /* ** Computes ALL delta delta mel cep pars. BP 8/96 */ { int i, j, d; - cepdata val, *cpt; + cepdata val; + const cepdata *cpt; d = DELTA; if (frmind < Q2 - 1) @@ -142,9 +149,9 @@ void dd_regress(cepdata *dd, cepdata *cp_buf, unsigned short frmind, int mel_dim } -static void scale_data(front_cep *cepobj, featdata *rpram, featdata *pram1, - featdata *pram2, featdata *ddpram, cepdata *rast, - cepdata *cep, cepdata *rcep, cepdata *ddcep) +static void scale_data(const front_cep *cepobj, const featdata *rpram, featdata *pram1, + featdata *pram2, featdata *ddpram, const cepdata *rast, + const cepdata *cep, const cepdata *rcep, const cepdata *ddcep) { size_t i; bigdata a; @@ -185,9 +192,9 @@ static void scale_data(front_cep *cepobj, featdata *rpram, featdata *pram1, return; } -static void pack_frame(front_cep *cepobj, featdata *dest_frame, - featdata *rasta_data, featdata *mel_data, - featdata *del_data, featdata *deldel_data) +static void pack_frame(const front_cep *cepobj, featdata *dest_frame, + const featdata *rasta_data, const featdata *mel_data, + const featdata *del_data, const featdata *deldel_data) { size_t ii, cnt; diff --git a/srec/cfront/log_tabl.c b/srec/cfront/log_tabl.c index 33239ae..03da961 100644 --- a/srec/cfront/log_tabl.c +++ b/srec/cfront/log_tabl.c @@ -11,7 +11,7 @@ * * * Unless required by applicable law or agreed to in writing, software * * distributed under the License is distributed on an 'AS IS' BASIS, * - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * * See the License for the specific language governing permissions and * * limitations under the License. * * * @@ -35,18 +35,20 @@ #include "sh_down.h" /* #define PRINT_SOME_CODE(fMt,aRg1) printf(fMt,aRg1) */ -#define PRINT_SOME_CODE(fMt,aRg1) +#define PRINT_SOME_CODE(fMt,aRg1) /* values for default case, num_bits 12 */ #define DO_USE_LOGTAB__TABLE ( logtab->size == 4096 && LOG_SCALE == 1024) -static int logtab__table[4097] = { 0, 0, 710, 1125, 1420, 1648, 1835, 1993, 2129, 2250, 2358, 2455, 2545, 2627, 2702, 2773, 2839, 2901, 2960, 3015, 3068, 3118, 3165, 3211, 3254, 3296, 3336, 3375, 3412, 3448, 3483, 3516, 3549, 3580, 3611, 3641, 3670, 3698, 3725, 3751, 3777, 3803, 3827, 3851, 3875, 3898, 3921, 3943, 3964, 3985, 4006, 4026, 4046, 4066, 4085, 4104, 4122, 4140, 4158, 4175, 4193, 4210, 4226, 4243, 4259, 4275, 4290, 4306, 4321, 4336, 4350, 4365, 4379, 4393, 4407, 4421, 4435, 4448, 4461, 4474, 4487, 4500, 4512, 4525, 4537, 4549, 4561, 4573, 4585, 4596, 4608, 4619, 4630, 4641, 4652, 4663, 4674, 4685, 4695, 4705, 4716, 4726, 4736, 4746, 4756, 4766, 4775, 4785, 4795, 4804, 4813, 4823, 4832, 4841, 4850, 4859, 4868, 4876, 4885, 4894, 4902, 4911, 4919, 4928, 4936, 4944, 4952, 4960, 4968, 4976, 4984, 4992, 5000, 5008, 5015, 5023, 5031, 5038, 5046, 5053, 5060, 5068, 5075, 5082, 5089, 5096, 5103, 5110, 5117, 5124, 5131, 5138, 5144, 5151, 5158, 5164, 5171, 5178, 5184, 5191, 5197, 5203, 5210, 5216, 5222, 5228, 5235, 5241, 5247, 5253, 5259, 5265, 5271, 5277, 5283, 5289, 5295, 5300, 5306, 5312, 5318, 5323, 5329, 5335, 5340, 5346, 5351, 5357, 5362, 5368, 5373, 5378, 5384, 5389, 5394, 5400, 5405, 5410, 5415, 5420, 5425, 5431, 5436, 5441, 5446, 5451, 5456, 5461, 5466, 5471, 5475, 5480, 5485, 5490, 5495, 5500, 5504, 5509, 5514, 5518, 5523, 5528, 5532, 5537, 5542, 5546, 5551, 5555, 5560, 5564, 5569, 5573, 5577, 5582, 5586, 5591, 5595, 5599, 5604, 5608, 5612, 5616, 5621, 5625, 5629, 5633, 5637, 5642, 5646, 5650, 5654, 5658, 5662, 5666, 5670, 5674, 5678, 5682, 5686, 5690, 5694, 5698, 5702, 5706, 5710, 5714, 5718, 5721, 5725, 5729, 5733, 5737, 5740, 5744, 5748, 5752, 5755, 5759, 5763, 5766, 5770, 5774, 5777, 5781, 5785, 5788, 5792, 5795, 5799, 5802, 5806, 5809, 5813, 5816, 5820, 5823, 5827, 5830, 5834, 5837, 5841, 5844, 5847, 5851, 5854, 5858, 5861, 5864, 5868, 5871, 5874, 5878, 5881, 5884, 5887, 5891, 5894, 5897, 5900, 5904, 5907, 5910, 5913, 5916, 5919, 5923, 5926, 5929, 5932, 5935, 5938, 5941, 5944, 5948, 5951, 5954, 5957, 5960, 5963, 5966, 5969, 5972, 5975, 5978, 5981, 5984, 5987, 5990, 5993, 5996, 5999, 6001, 6004, 6007, 6010, 6013, 6016, 6019, 6022, 6025, 6027, 6030, 6033, 6036, 6039, 6041, 6044, 6047, 6050, 6053, 6055, 6058, 6061, 6064, 6066, 6069, 6072, 6075, 6077, 6080, 6083, 6085, 6088, 6091, 6093, 6096, 6099, 6101, 6104, 6107, 6109, 6112, 6115, 6117, 6120, 6122, 6125, 6128, 6130, 6133, 6135, 6138, 6140, 6143, 6145, 6148, 6151, 6153, 6156, 6158, 6161, 6163, 6166, 6168, 6170, 6173, 6175, 6178, 6180, 6183, 6185, 6188, 6190, 6193, 6195, 6197, 6200, 6202, 6205, 6207, 6209, 6212, 6214, 6216, 6219, 6221, 6224, 6226, 6228, 6231, 6233, 6235, 6238, 6240, 6242, 6244, 6247, 6249, 6251, 6254, 6256, 6258, 6260, 6263, 6265, 6267, 6269, 6272, 6274, 6276, 6278, 6281, 6283, 6285, 6287, 6289, 6292, 6294, 6296, 6298, 6300, 6303, 6305, 6307, 6309, 6311, 6313, 6316, 6318, 6320, 6322, 6324, 6326, 6328, 6330, 6333, 6335, 6337, 6339, 6341, 6343, 6345, 6347, 6349, 6351, 6353, 6356, 6358, 6360, 6362, 6364, 6366, 6368, 6370, 6372, 6374, 6376, 6378, 6380, 6382, 6384, 6386, 6388, 6390, 6392, 6394, 6396, 6398, 6400, 6402, 6404, 6406, 6408, 6410, 6412, 6414, 6416, 6418, 6420, 6421, 6423, 6425, 6427, 6429, 6431, 6433, 6435, 6437, 6439, 6441, 6443, 6444, 6446, 6448, 6450, 6452, 6454, 6456, 6458, 6459, 6461, 6463, 6465, 6467, 6469, 6471, 6472, 6474, 6476, 6478, 6480, 6482, 6483, 6485, 6487, 6489, 6491, 6493, 6494, 6496, 6498, 6500, 6502, 6503, 6505, 6507, 6509, 6510, 6512, 6514, 6516, 6518, 6519, 6521, 6523, 6525, 6526, 6528, 6530, 6532, 6533, 6535, 6537, 6538, 6540, 6542, 6544, 6545, 6547, 6549, 6550, 6552, 6554, 6556, 6557, 6559, 6561, 6562, 6564, 6566, 6567, 6569, 6571, 6572, 6574, 6576, 6577, 6579, 6581, 6582, 6584, 6586, 6587, 6589, 6591, 6592, 6594, 6596, 6597, 6599, 6600, 6602, 6604, 6605, 6607, 6609, 6610, 6612, 6613, 6615, 6617, 6618, 6620, 6621, 6623, 6625, 6626, 6628, 6629, 6631, 6632, 6634, 6636, 6637, 6639, 6640, 6642, 6643, 6645, 6647, 6648, 6650, 6651, 6653, 6654, 6656, 6657, 6659, 6660, 6662, 6663, 6665, 6667, 6668, 6670, 6671, 6673, 6674, 6676, 6677, 6679, 6680, 6682, 6683, 6685, 6686, 6688, 6689, 6691, 6692, 6694, 6695, 6697, 6698, 6699, 6701, 6702, 6704, 6705, 6707, 6708, 6710, 6711, 6713, 6714, 6716, 6717, 6718, 6720, 6721, 6723, 6724, 6726, 6727, 6729, 6730, 6731, 6733, 6734, 6736, 6737, 6739, 6740, 6741, 6743, 6744, 6746, 6747, 6748, 6750, 6751, 6753, 6754, 6755, 6757, 6758, 6760, 6761, 6762, 6764, 6765, 6767, 6768, 6769, 6771, 6772, 6773, 6775, 6776, 6778, 6779, 6780, 6782, 6783, 6784, 6786, 6787, 6788, 6790, 6791, 6793, 6794, 6795, 6797, 6798, 6799, 6801, 6802, 6803, 6805, 6806, 6807, 6809, 6810, 6811, 6813, 6814, 6815, 6816, 6818, 6819, 6820, 6822, 6823, 6824, 6826, 6827, 6828, 6830, 6831, 6832, 6833, 6835, 6836, 6837, 6839, 6840, 6841, 6842, 6844, 6845, 6846, 6848, 6849, 6850, 6851, 6853, 6854, 6855, 6856, 6858, 6859, 6860, 6862, 6863, 6864, 6865, 6867, 6868, 6869, 6870, 6872, 6873, 6874, 6875, 6877, 6878, 6879, 6880, 6882, 6883, 6884, 6885, 6886, 6888, 6889, 6890, 6891, 6893, 6894, 6895, 6896, 6897, 6899, 6900, 6901, 6902, 6904, 6905, 6906, 6907, 6908, 6910, 6911, 6912, 6913, 6914, 6916, 6917, 6918, 6919, 6920, 6921, 6923, 6924, 6925, 6926, 6927, 6929, 6930, 6931, 6932, 6933, 6934, 6936, 6937, 6938, 6939, 6940, 6941, 6943, 6944, 6945, 6946, 6947, 6948, 6950, 6951, 6952, 6953, 6954, 6955, 6957, 6958, 6959, 6960, 6961, 6962, 6963, 6965, 6966, 6967, 6968, 6969, 6970, 6971, 6972, 6974, 6975, 6976, 6977, 6978, 6979, 6980, 6981, 6983, 6984, 6985, 6986, 6987, 6988, 6989, 6990, 6991, 6993, 6994, 6995, 6996, 6997, 6998, 6999, 7000, 7001, 7003, 7004, 7005, 7006, 7007, 7008, 7009, 7010, 7011, 7012, 7013, 7015, 7016, 7017, 7018, 7019, 7020, 7021, 7022, 7023, 7024, 7025, 7026, 7027, 7029, 7030, 7031, 7032, 7033, 7034, 7035, 7036, 7037, 7038, 7039, 7040, 7041, 7042, 7043, 7044, 7046, 7047, 7048, 7049, 7050, 7051, 7052, 7053, 7054, 7055, 7056, 7057, 7058, 7059, 7060, 7061, 7062, 7063, 7064, 7065, 7066, 7067, 7068, 7069, 7070, 7071, 7073, 7074, 7075, 7076, 7077, 7078, 7079, 7080, 7081, 7082, 7083, 7084, 7085, 7086, 7087, 7088, 7089, 7090, 7091, 7092, 7093, 7094, 7095, 7096, 7097, 7098, 7099, 7100, 7101, 7102, 7103, 7104, 7105, 7106, 7107, 7108, 7109, 7110, 7111, 7112, 7113, 7114, 7115, 7116, 7117, 7118, 7119, 7120, 7121, 7122, 7123, 7124, 7124, 7125, 7126, 7127, 7128, 7129, 7130, 7131, 7132, 7133, 7134, 7135, 7136, 7137, 7138, 7139, 7140, 7141, 7142, 7143, 7144, 7145, 7146, 7147, 7148, 7149, 7150, 7150, 7151, 7152, 7153, 7154, 7155, 7156, 7157, 7158, 7159, 7160, 7161, 7162, 7163, 7164, 7165, 7166, 7166, 7167, 7168, 7169, 7170, 7171, 7172, 7173, 7174, 7175, 7176, 7177, 7178, 7179, 7179, 7180, 7181, 7182, 7183, 7184, 7185, 7186, 7187, 7188, 7189, 7190, 7191, 7191, 7192, 7193, 7194, 7195, 7196, 7197, 7198, 7199, 7200, 7201, 7201, 7202, 7203, 7204, 7205, 7206, 7207, 7208, 7209, 7210, 7210, 7211, 7212, 7213, 7214, 7215, 7216, 7217, 7218, 7218, 7219, 7220, 7221, 7222, 7223, 7224, 7225, 7226, 7226, 7227, 7228, 7229, 7230, 7231, 7232, 7233, 7233, 7234, 7235, 7236, 7237, 7238, 7239, 7240, 7240, 7241, 7242, 7243, 7244, 7245, 7246, 7246, 7247, 7248, 7249, 7250, 7251, 7252, 7253, 7253, 7254, 7255, 7256, 7257, 7258, 7259, 7259, 7260, 7261, 7262, 7263, 7264, 7264, 7265, 7266, 7267, 7268, 7269, 7270, 7270, 7271, 7272, 7273, 7274, 7275, 7275, 7276, 7277, 7278, 7279, 7280, 7281, 7281, 7282, 7283, 7284, 7285, 7286, 7286, 7287, 7288, 7289, 7290, 7291, 7291, 7292, 7293, 7294, 7295, 7295, 7296, 7297, 7298, 7299, 7300, 7300, 7301, 7302, 7303, 7304, 7304, 7305, 7306, 7307, 7308, 7309, 7309, 7310, 7311, 7312, 7313, 7313, 7314, 7315, 7316, 7317, 7317, 7318, 7319, 7320, 7321, 7322, 7322, 7323, 7324, 7325, 7326, 7326, 7327, 7328, 7329, 7330, 7330, 7331, 7332, 7333, 7334, 7334, 7335, 7336, 7337, 7337, 7338, 7339, 7340, 7341, 7341, 7342, 7343, 7344, 7345, 7345, 7346, 7347, 7348, 7348, 7349, 7350, 7351, 7352, 7352, 7353, 7354, 7355, 7356, 7356, 7357, 7358, 7359, 7359, 7360, 7361, 7362, 7362, 7363, 7364, 7365, 7366, 7366, 7367, 7368, 7369, 7369, 7370, 7371, 7372, 7372, 7373, 7374, 7375, 7376, 7376, 7377, 7378, 7379, 7379, 7380, 7381, 7382, 7382, 7383, 7384, 7385, 7385, 7386, 7387, 7388, 7388, 7389, 7390, 7391, 7391, 7392, 7393, 7394, 7394, 7395, 7396, 7397, 7397, 7398, 7399, 7400, 7400, 7401, 7402, 7403, 7403, 7404, 7405, 7406, 7406, 7407, 7408, 7409, 7409, 7410, 7411, 7411, 7412, 7413, 7414, 7414, 7415, 7416, 7417, 7417, 7418, 7419, 7420, 7420, 7421, 7422, 7422, 7423, 7424, 7425, 7425, 7426, 7427, 7428, 7428, 7429, 7430, 7430, 7431, 7432, 7433, 7433, 7434, 7435, 7435, 7436, 7437, 7438, 7438, 7439, 7440, 7441, 7441, 7442, 7443, 7443, 7444, 7445, 7446, 7446, 7447, 7448, 7448, 7449, 7450, 7450, 7451, 7452, 7453, 7453, 7454, 7455, 7455, 7456, 7457, 7458, 7458, 7459, 7460, 7460, 7461, 7462, 7462, 7463, 7464, 7465, 7465, 7466, 7467, 7467, 7468, 7469, 7469, 7470, 7471, 7472, 7472, 7473, 7474, 7474, 7475, 7476, 7476, 7477, 7478, 7478, 7479, 7480, 7481, 7481, 7482, 7483, 7483, 7484, 7485, 7485, 7486, 7487, 7487, 7488, 7489, 7489, 7490, 7491, 7491, 7492, 7493, 7494, 7494, 7495, 7496, 7496, 7497, 7498, 7498, 7499, 7500, 7500, 7501, 7502, 7502, 7503, 7504, 7504, 7505, 7506, 7506, 7507, 7508, 7508, 7509, 7510, 7510, 7511, 7512, 7512, 7513, 7514, 7514, 7515, 7516, 7516, 7517, 7518, 7518, 7519, 7520, 7520, 7521, 7522, 7522, 7523, 7524, 7524, 7525, 7526, 7526, 7527, 7528, 7528, 7529, 7530, 7530, 7531, 7532, 7532, 7533, 7533, 7534, 7535, 7535, 7536, 7537, 7537, 7538, 7539, 7539, 7540, 7541, 7541, 7542, 7543, 7543, 7544, 7545, 7545, 7546, 7546, 7547, 7548, 7548, 7549, 7550, 7550, 7551, 7552, 7552, 7553, 7554, 7554, 7555, 7555, 7556, 7557, 7557, 7558, 7559, 7559, 7560, 7561, 7561, 7562, 7562, 7563, 7564, 7564, 7565, 7566, 7566, 7567, 7568, 7568, 7569, 7569, 7570, 7571, 7571, 7572, 7573, 7573, 7574, 7574, 7575, 7576, 7576, 7577, 7578, 7578, 7579, 7579, 7580, 7581, 7581, 7582, 7583, 7583, 7584, 7584, 7585, 7586, 7586, 7587, 7588, 7588, 7589, 7589, 7590, 7591, 7591, 7592, 7593, 7593, 7594, 7594, 7595, 7596, 7596, 7597, 7597, 7598, 7599, 7599, 7600, 7601, 7601, 7602, 7602, 7603, 7604, 7604, 7605, 7605, 7606, 7607, 7607, 7608, 7608, 7609, 7610, 7610, 7611, 7611, 7612, 7613, 7613, 7614, 7614, 7615, 7616, 7616, 7617, 7618, 7618, 7619, 7619, 7620, 7621, 7621, 7622, 7622, 7623, 7624, 7624, 7625, 7625, 7626, 7626, 7627, 7628, 7628, 7629, 7629, 7630, 7631, 7631, 7632, 7632, 7633, 7634, 7634, 7635, 7635, 7636, 7637, 7637, 7638, 7638, 7639, 7640, 7640, 7641, 7641, 7642, 7642, 7643, 7644, 7644, 7645, 7645, 7646, 7647, 7647, 7648, 7648, 7649, 7650, 7650, 7651, 7651, 7652, 7652, 7653, 7654, 7654, 7655, 7655, 7656, 7656, 7657, 7658, 7658, 7659, 7659, 7660, 7661, 7661, 7662, 7662, 7663, 7663, 7664, 7665, 7665, 7666, 7666, 7667, 7667, 7668, 7669, 7669, 7670, 7670, 7671, 7671, 7672, 7673, 7673, 7674, 7674, 7675, 7675, 7676, 7677, 7677, 7678, 7678, 7679, 7679, 7680, 7681, 7681, 7682, 7682, 7683, 7683, 7684, 7684, 7685, 7686, 7686, 7687, 7687, 7688, 7688, 7689, 7690, 7690, 7691, 7691, 7692, 7692, 7693, 7693, 7694, 7695, 7695, 7696, 7696, 7697, 7697, 7698, 7698, 7699, 7700, 7700, 7701, 7701, 7702, 7702, 7703, 7703, 7704, 7705, 7705, 7706, 7706, 7707, 7707, 7708, 7708, 7709, 7710, 7710, 7711, 7711, 7712, 7712, 7713, 7713, 7714, 7715, 7715, 7716, 7716, 7717, 7717, 7718, 7718, 7719, 7719, 7720, 7721, 7721, 7722, 7722, 7723, 7723, 7724, 7724, 7725, 7725, 7726, 7726, 7727, 7728, 7728, 7729, 7729, 7730, 7730, 7731, 7731, 7732, 7732, 7733, 7733, 7734, 7735, 7735, 7736, 7736, 7737, 7737, 7738, 7738, 7739, 7739, 7740, 7740, 7741, 7742, 7742, 7743, 7743, 7744, 7744, 7745, 7745, 7746, 7746, 7747, 7747, 7748, 7748, 7749, 7749, 7750, 7751, 7751, 7752, 7752, 7753, 7753, 7754, 7754, 7755, 7755, 7756, 7756, 7757, 7757, 7758, 7758, 7759, 7759, 7760, 7761, 7761, 7762, 7762, 7763, 7763, 7764, 7764, 7765, 7765, 7766, 7766, 7767, 7767, 7768, 7768, 7769, 7769, 7770, 7770, 7771, 7771, 7772, 7773, 7773, 7774, 7774, 7775, 7775, 7776, 7776, 7777, 7777, 7778, 7778, 7779, 7779, 7780, 7780, 7781, 7781, 7782, 7782, 7783, 7783, 7784, 7784, 7785, 7785, 7786, 7786, 7787, 7787, 7788, 7788, 7789, 7789, 7790, 7790, 7791, 7791, 7792, 7792, 7793, 7794, 7794, 7795, 7795, 7796, 7796, 7797, 7797, 7798, 7798, 7799, 7799, 7800, 7800, 7801, 7801, 7802, 7802, 7803, 7803, 7804, 7804, 7805, 7805, 7806, 7806, 7807, 7807, 7808, 7808, 7809, 7809, 7810, 7810, 7811, 7811, 7812, 7812, 7813, 7813, 7814, 7814, 7815, 7815, 7816, 7816, 7817, 7817, 7818, 7818, 7819, 7819, 7820, 7820, 7821, 7821, 7822, 7822, 7823, 7823, 7823, 7824, 7824, 7825, 7825, 7826, 7826, 7827, 7827, 7828, 7828, 7829, 7829, 7830, 7830, 7831, 7831, 7832, 7832, 7833, 7833, 7834, 7834, 7835, 7835, 7836, 7836, 7837, 7837, 7838, 7838, 7839, 7839, 7840, 7840, 7841, 7841, 7842, 7842, 7843, 7843, 7843, 7844, 7844, 7845, 7845, 7846, 7846, 7847, 7847, 7848, 7848, 7849, 7849, 7850, 7850, 7851, 7851, 7852, 7852, 7853, 7853, 7854, 7854, 7855, 7855, 7855, 7856, 7856, 7857, 7857, 7858, 7858, 7859, 7859, 7860, 7860, 7861, 7861, 7862, 7862, 7863, 7863, 7864, 7864, 7864, 7865, 7865, 7866, 7866, 7867, 7867, 7868, 7868, 7869, 7869, 7870, 7870, 7871, 7871, 7872, 7872, 7873, 7873, 7873, 7874, 7874, 7875, 7875, 7876, 7876, 7877, 7877, 7878, 7878, 7879, 7879, 7880, 7880, 7880, 7881, 7881, 7882, 7882, 7883, 7883, 7884, 7884, 7885, 7885, 7886, 7886, 7886, 7887, 7887, 7888, 7888, 7889, 7889, 7890, 7890, 7891, 7891, 7892, 7892, 7892, 7893, 7893, 7894, 7894, 7895, 7895, 7896, 7896, 7897, 7897, 7898, 7898, 7898, 7899, 7899, 7900, 7900, 7901, 7901, 7902, 7902, 7903, 7903, 7903, 7904, 7904, 7905, 7905, 7906, 7906, 7907, 7907, 7908, 7908, 7908, 7909, 7909, 7910, 7910, 7911, 7911, 7912, 7912, 7913, 7913, 7913, 7914, 7914, 7915, 7915, 7916, 7916, 7917, 7917, 7917, 7918, 7918, 7919, 7919, 7920, 7920, 7921, 7921, 7922, 7922, 7922, 7923, 7923, 7924, 7924, 7925, 7925, 7926, 7926, 7926, 7927, 7927, 7928, 7928, 7929, 7929, 7930, 7930, 7930, 7931, 7931, 7932, 7932, 7933, 7933, 7934, 7934, 7934, 7935, 7935, 7936, 7936, 7937, 7937, 7938, 7938, 7938, 7939, 7939, 7940, 7940, 7941, 7941, 7941, 7942, 7942, 7943, 7943, 7944, 7944, 7945, 7945, 7945, 7946, 7946, 7947, 7947, 7948, 7948, 7948, 7949, 7949, 7950, 7950, 7951, 7951, 7952, 7952, 7952, 7953, 7953, 7954, 7954, 7955, 7955, 7955, 7956, 7956, 7957, 7957, 7958, 7958, 7958, 7959, 7959, 7960, 7960, 7961, 7961, 7961, 7962, 7962, 7963, 7963, 7964, 7964, 7964, 7965, 7965, 7966, 7966, 7967, 7967, 7967, 7968, 7968, 7969, 7969, 7970, 7970, 7970, 7971, 7971, 7972, 7972, 7973, 7973, 7973, 7974, 7974, 7975, 7975, 7976, 7976, 7976, 7977, 7977, 7978, 7978, 7979, 7979, 7979, 7980, 7980, 7981, 7981, 7981, 7982, 7982, 7983, 7983, 7984, 7984, 7984, 7985, 7985, 7986, 7986, 7987, 7987, 7987, 7988, 7988, 7989, 7989, 7989, 7990, 7990, 7991, 7991, 7992, 7992, 7992, 7993, 7993, 7994, 7994, 7994, 7995, 7995, 7996, 7996, 7997, 7997, 7997, 7998, 7998, 7999, 7999, 7999, 8000, 8000, 8001, 8001, 8002, 8002, 8002, 8003, 8003, 8004, 8004, 8004, 8005, 8005, 8006, 8006, 8006, 8007, 8007, 8008, 8008, 8009, 8009, 8009, 8010, 8010, 8011, 8011, 8011, 8012, 8012, 8013, 8013, 8013, 8014, 8014, 8015, 8015, 8016, 8016, 8016, 8017, 8017, 8018, 8018, 8018, 8019, 8019, 8020, 8020, 8020, 8021, 8021, 8022, 8022, 8022, 8023, 8023, 8024, 8024, 8024, 8025, 8025, 8026, 8026, 8026, 8027, 8027, 8028, 8028, 8028, 8029, 8029, 8030, 8030, 8030, 8031, 8031, 8032, 8032, 8033, 8033, 8033, 8034, 8034, 8035, 8035, 8035, 8036, 8036, 8037, 8037, 8037, 8038, 8038, 8039, 8039, 8039, 8040, 8040, 8040, 8041, 8041, 8042, 8042, 8042, 8043, 8043, 8044, 8044, 8044, 8045, 8045, 8046, 8046, 8046, 8047, 8047, 8048, 8048, 8048, 8049, 8049, 8050, 8050, 8050, 8051, 8051, 8052, 8052, 8052, 8053, 8053, 8054, 8054, 8054, 8055, 8055, 8056, 8056, 8056, 8057, 8057, 8057, 8058, 8058, 8059, 8059, 8059, 8060, 8060, 8061, 8061, 8061, 8062, 8062, 8063, 8063, 8063, 8064, 8064, 8065, 8065, 8065, 8066, 8066, 8066, 8067, 8067, 8068, 8068, 8068, 8069, 8069, 8070, 8070, 8070, 8071, 8071, 8071, 8072, 8072, 8073, 8073, 8073, 8074, 8074, 8075, 8075, 8075, 8076, 8076, 8077, 8077, 8077, 8078, 8078, 8078, 8079, 8079, 8080, 8080, 8080, 8081, 8081, 8081, 8082, 8082, 8083, 8083, 8083, 8084, 8084, 8085, 8085, 8085, 8086, 8086, 8086, 8087, 8087, 8088, 8088, 8088, 8089, 8089, 8089, 8090, 8090, 8091, 8091, 8091, 8092, 8092, 8093, 8093, 8093, 8094, 8094, 8094, 8095, 8095, 8096, 8096, 8096, 8097, 8097, 8097, 8098, 8098, 8099, 8099, 8099, 8100, 8100, 8100, 8101, 8101, 8102, 8102, 8102, 8103, 8103, 8103, 8104, 8104, 8105, 8105, 8105, 8106, 8106, 8106, 8107, 8107, 8108, 8108, 8108, 8109, 8109, 8109, 8110, 8110, 8111, 8111, 8111, 8112, 8112, 8112, 8113, 8113, 8114, 8114, 8114, 8115, 8115, 8115, 8116, 8116, 8116, 8117, 8117, 8118, 8118, 8118, 8119, 8119, 8119, 8120, 8120, 8121, 8121, 8121, 8122, 8122, 8122, 8123, 8123, 8123, 8124, 8124, 8125, 8125, 8125, 8126, 8126, 8126, 8127, 8127, 8128, 8128, 8128, 8129, 8129, 8129, 8130, 8130, 8130, 8131, 8131, 8132, 8132, 8132, 8133, 8133, 8133, 8134, 8134, 8134, 8135, 8135, 8136, 8136, 8136, 8137, 8137, 8137, 8138, 8138, 8138, 8139, 8139, 8140, 8140, 8140, 8141, 8141, 8141, 8142, 8142, 8142, 8143, 8143, 8143, 8144, 8144, 8145, 8145, 8145, 8146, 8146, 8146, 8147, 8147, 8147, 8148, 8148, 8149, 8149, 8149, 8150, 8150, 8150, 8151, 8151, 8151, 8152, 8152, 8152, 8153, 8153, 8154, 8154, 8154, 8155, 8155, 8155, 8156, 8156, 8156, 8157, 8157, 8157, 8158, 8158, 8158, 8159, 8159, 8160, 8160, 8160, 8161, 8161, 8161, 8162, 8162, 8162, 8163, 8163, 8163, 8164, 8164, 8165, 8165, 8165, 8166, 8166, 8166, 8167, 8167, 8167, 8168, 8168, 8168, 8169, 8169, 8169, 8170, 8170, 8170, 8171, 8171, 8172, 8172, 8172, 8173, 8173, 8173, 8174, 8174, 8174, 8175, 8175, 8175, 8176, 8176, 8176, 8177, 8177, 8177, 8178, 8178, 8179, 8179, 8179, 8180, 8180, 8180, 8181, 8181, 8181, 8182, 8182, 8182, 8183, 8183, 8183, 8184, 8184, 8184, 8185, 8185, 8185, 8186, 8186, 8187, 8187, 8187, 8188, 8188, 8188, 8189, 8189, 8189, 8190, 8190, 8190, 8191, 8191, 8191, 8192, 8192, 8192, 8193, 8193, 8193, 8194, 8194, 8194, 8195, 8195, 8195, 8196, 8196, 8196, 8197, 8197, 8197, 8198, 8198, 8199, 8199, 8199, 8200, 8200, 8200, 8201, 8201, 8201, 8202, 8202, 8202, 8203, 8203, 8203, 8204, 8204, 8204, 8205, 8205, 8205, 8206, 8206, 8206, 8207, 8207, 8207, 8208, 8208, 8208, 8209, 8209, 8209, 8210, 8210, 8210, 8211, 8211, 8211, 8212, 8212, 8212, 8213, 8213, 8213, 8214, 8214, 8214, 8215, 8215, 8215, 8216, 8216, 8216, 8217, 8217, 8217, 8218, 8218, 8218, 8219, 8219, 8219, 8220, 8220, 8220, 8221, 8221, 8221, 8222, 8222, 8222, 8223, 8223, 8223, 8224, 8224, 8224, 8225, 8225, 8225, 8226, 8226, 8226, 8227, 8227, 8227, 8228, 8228, 8228, 8229, 8229, 8229, 8230, 8230, 8230, 8231, 8231, 8231, 8232, 8232, 8232, 8233, 8233, 8233, 8234, 8234, 8234, 8235, 8235, 8235, 8236, 8236, 8236, 8237, 8237, 8237, 8238, 8238, 8238, 8239, 8239, 8239, 8240, 8240, 8240, 8241, 8241, 8241, 8242, 8242, 8242, 8243, 8243, 8243, 8244, 8244, 8244, 8245, 8245, 8245, 8246, 8246, 8246, 8247, 8247, 8247, 8248, 8248, 8248, 8248, 8249, 8249, 8249, 8250, 8250, 8250, 8251, 8251, 8251, 8252, 8252, 8252, 8253, 8253, 8253, 8254, 8254, 8254, 8255, 8255, 8255, 8256, 8256, 8256, 8257, 8257, 8257, 8258, 8258, 8258, 8259, 8259, 8259, 8259, 8260, 8260, 8260, 8261, 8261, 8261, 8262, 8262, 8262, 8263, 8263, 8263, 8264, 8264, 8264, 8265, 8265, 8265, 8266, 8266, 8266, 8267, 8267, 8267, 8267, 8268, 8268, 8268, 8269, 8269, 8269, 8270, 8270, 8270, 8271, 8271, 8271, 8272, 8272, 8272, 8273, 8273, 8273, 8274, 8274, 8274, 8274, 8275, 8275, 8275, 8276, 8276, 8276, 8277, 8277, 8277, 8278, 8278, 8278, 8279, 8279, 8279, 8280, 8280, 8280, 8280, 8281, 8281, 8281, 8282, 8282, 8282, 8283, 8283, 8283, 8284, 8284, 8284, 8285, 8285, 8285, 8286, 8286, 8286, 8286, 8287, 8287, 8287, 8288, 8288, 8288, 8289, 8289, 8289, 8290, 8290, 8290, 8291, 8291, 8291, 8291, 8292, 8292, 8292, 8293, 8293, 8293, 8294, 8294, 8294, 8295, 8295, 8295, 8295, 8296, 8296, 8296, 8297, 8297, 8297, 8298, 8298, 8298, 8299, 8299, 8299, 8300, 8300, 8300, 8300, 8301, 8301, 8301, 8302, 8302, 8302, 8303, 8303, 8303, 8304, 8304, 8304, 8304, 8305, 8305, 8305, 8306, 8306, 8306, 8307, 8307, 8307, 8308, 8308, 8308, 8308, 8309, 8309, 8309, 8310, 8310, 8310, 8311, 8311, 8311, 8312, 8312, 8312, 8312, 8313, 8313, 8313, 8314, 8314, 8314, 8315, 8315, 8315, 8315, 8316, 8316, 8316, 8317, 8317, 8317, 8318, 8318, 8318, 8319, 8319, 8319, 8319, 8320, 8320, 8320, 8321, 8321, 8321, 8322, 8322, 8322, 8322, 8323, 8323, 8323, 8324, 8324, 8324, 8325, 8325, 8325, 8325, 8326, 8326, 8326, 8327, 8327, 8327, 8328, 8328, 8328, 8328, 8329, 8329, 8329, 8330, 8330, 8330, 8331, 8331, 8331, 8331, 8332, 8332, 8332, 8333, 8333, 8333, 8334, 8334, 8334, 8334, 8335, 8335, 8335, 8336, 8336, 8336, 8337, 8337, 8337, 8337, 8338, 8338, 8338, 8339, 8339, 8339, 8340, 8340, 8340, 8340, 8341, 8341, 8341, 8342, 8342, 8342, 8343, 8343, 8343, 8343, 8344, 8344, 8344, 8345, 8345, 8345, 8345, 8346, 8346, 8346, 8347, 8347, 8347, 8348, 8348, 8348, 8348, 8349, 8349, 8349, 8350, 8350, 8350, 8351, 8351, 8351, 8351, 8352, 8352, 8352, 8353, 8353, 8353, 8353, 8354, 8354, 8354, 8355, 8355, 8355, 8355, 8356, 8356, 8356, 8357, 8357, 8357, 8358, 8358, 8358, 8358, 8359, 8359, 8359, 8360, 8360, 8360, 8360, 8361, 8361, 8361, 8362, 8362, 8362, 8362, 8363, 8363, 8363, 8364, 8364, 8364, 8365, 8365, 8365, 8365, 8366, 8366, 8366, 8367, 8367, 8367, 8367, 8368, 8368, 8368, 8369, 8369, 8369, 8369, 8370, 8370, 8370, 8371, 8371, 8371, 8371, 8372, 8372, 8372, 8373, 8373, 8373, 8373, 8374, 8374, 8374, 8375, 8375, 8375, 8376, 8376, 8376, 8376, 8377, 8377, 8377, 8378, 8378, 8378, 8378, 8379, 8379, 8379, 8380, 8380, 8380, 8380, 8381, 8381, 8381, 8382, 8382, 8382, 8382, 8383, 8383, 8383, 8384, 8384, 8384, 8384, 8385, 8385, 8385, 8386, 8386, 8386, 8386, 8387, 8387, 8387, 8387, 8388, 8388, 8388, 8389, 8389, 8389, 8389, 8390, 8390, 8390, 8391, 8391, 8391, 8391, 8392, 8392, 8392, 8393, 8393, 8393, 8393, 8394, 8394, 8394, 8395, 8395, 8395, 8395, 8396, 8396, 8396, 8397, 8397, 8397, 8397, 8398, 8398, 8398, 8399, 8399, 8399, 8399, 8400, 8400, 8400, 8400, 8401, 8401, 8401, 8402, 8402, 8402, 8402, 8403, 8403, 8403, 8404, 8404, 8404, 8404, 8405, 8405, 8405, 8405, 8406, 8406, 8406, 8407, 8407, 8407, 8407, 8408, 8408, 8408, 8409, 8409, 8409, 8409, 8410, 8410, 8410, 8411, 8411, 8411, 8411, 8412, 8412, 8412, 8412, 8413, 8413, 8413, 8414, 8414, 8414, 8414, 8415, 8415, 8415, 8415, 8416, 8416, 8416, 8417, 8417, 8417, 8417, 8418, 8418, 8418, 8419, 8419, 8419, 8419, 8420, 8420, 8420, 8420, 8421, 8421, 8421, 8422, 8422, 8422, 8422, 8423, 8423, 8423, 8423, 8424, 8424, 8424, 8425, 8425, 8425, 8425, 8426, 8426, 8426, 8426, 8427, 8427, 8427, 8428, 8428, 8428, 8428, 8429, 8429, 8429, 8429, 8430, 8430, 8430, 8431, 8431, 8431, 8431, 8432, 8432, 8432, 8432, 8433, 8433, 8433, 8434, 8434, 8434, 8434, 8435, 8435, 8435, 8435, 8436, 8436, 8436, 8437, 8437, 8437, 8437, 8438, 8438, 8438, 8438, 8439, 8439, 8439, 8440, 8440, 8440, 8440, 8441, 8441, 8441, 8441, 8442, 8442, 8442, 8442, 8443, 8443, 8443, 8444, 8444, 8444, 8444, 8445, 8445, 8445, 8445, 8446, 8446, 8446, 8446, 8447, 8447, 8447, 8448, 8448, 8448, 8448, 8449, 8449, 8449, 8449, 8450, 8450, 8450, 8451, 8451, 8451, 8451, 8452, 8452, 8452, 8452, 8453, 8453, 8453, 8453, 8454, 8454, 8454, 8455, 8455, 8455, 8455, 8456, 8456, 8456, 8456, 8457, 8457, 8457, 8457, 8458, 8458, 8458, 8458, 8459, 8459, 8459, 8460, 8460, 8460, 8460, 8461, 8461, 8461, 8461, 8462, 8462, 8462, 8462, 8463, 8463, 8463, 8463, 8464, 8464, 8464, 8465, 8465, 8465, 8465, 8466, 8466, 8466, 8466, 8467, 8467, 8467, 8467, 8468, 8468, 8468, 8468, 8469, 8469, 8469, 8470, 8470, 8470, 8470, 8471, 8471, 8471, 8471, 8472, 8472, 8472, 8472, 8473, 8473, 8473, 8473, 8474, 8474, 8474, 8475, 8475, 8475, 8475, 8476, 8476, 8476, 8476, 8477, 8477, 8477, 8477, 8478, 8478, 8478, 8478, 8479, 8479, 8479, 8479, 8480, 8480, 8480, 8480, 8481, 8481, 8481, 8482, 8482, 8482, 8482, 8483, 8483, 8483, 8483, 8484, 8484, 8484, 8484, 8485, 8485, 8485, 8485, 8486, 8486, 8486, 8486, 8487, 8487, 8487, 8487, 8488, 8488, 8488, 8488, 8489, 8489, 8489, 8490, 8490, 8490, 8490, 8491, 8491, 8491, 8491, 8492, 8492, 8492, 8492, 8493, 8493, 8493, 8493, 8494, 8494, 8494, 8494, 8495, 8495, 8495, 8495, 8496, 8496, 8496, 8496, 8497, 8497, 8497, 8497, 8498, 8498, 8498, 8498, 8499, 8499, 8499, 8499, 8500, 8500, 8500, 8501, 8501, 8501, 8501, 8502, 8502, 8502, 8502, 8503, 8503, 8503, 8503, 8504, 8504, 8504, 8504, 8505, 8505, 8505, 8505, 8506, 8506, 8506, 8506, 8507, 8507, 8507, 8507, 8508, 8508, 8508, 8508, 8509, 8509, 8509, 8509, 8510, 8510, 8510, 8510, 8511, 8511, 8511, 8511, 8512, 8512, 8512, 8512, 8513, 8513, 8513, 8513, 8514, 8514, 8514, 8514, 8515, 8515, 8515, 8515, 8516, 8516, 8516, 8516, 8517, 8517, 8517, 8517 }; /*0*/ +static const int logtab__table[4097] = { + 0, 0, 710, 1125, 1420, 1648, 1835, 1993, 2129, 2250, 2358, 2455, 2545, 2627, 2702, 2773, 2839, 2901, 2960, 3015, 3068, 3118, 3165, 3211, 3254, 3296, 3336, 3375, 3412, 3448, 3483, 3516, 3549, 3580, 3611, 3641, 3670, 3698, 3725, 3751, 3777, 3803, 3827, 3851, 3875, 3898, 3921, 3943, 3964, 3985, 4006, 4026, 4046, 4066, 4085, 4104, 4122, 4140, 4158, 4175, 4193, 4210, 4226, 4243, 4259, 4275, 4290, 4306, 4321, 4336, 4350, 4365, 4379, 4393, 4407, 4421, 4435, 4448, 4461, 4474, 4487, 4500, 4512, 4525, 4537, 4549, 4561, 4573, 4585, 4596, 4608, 4619, 4630, 4641, 4652, 4663, 4674, 4685, 4695, 4705, 4716, 4726, 4736, 4746, 4756, 4766, 4775, 4785, 4795, 4804, 4813, 4823, 4832, 4841, 4850, 4859, 4868, 4876, 4885, 4894, 4902, 4911, 4919, 4928, 4936, 4944, 4952, 4960, 4968, 4976, 4984, 4992, 5000, 5008, 5015, 5023, 5031, 5038, 5046, 5053, 5060, 5068, 5075, 5082, 5089, 5096, 5103, 5110, 5117, 5124, 5131, 5138, 5144, 5151, 5158, 5164, 5171, 5178, 5184, 5191, 5197, 5203, 5210, 5216, 5222, 5228, 5235, 5241, 5247, 5253, 5259, 5265, 5271, 5277, 5283, 5289, 5295, 5300, 5306, 5312, 5318, 5323, 5329, 5335, 5340, 5346, 5351, 5357, 5362, 5368, 5373, 5378, 5384, 5389, 5394, 5400, 5405, 5410, 5415, 5420, 5425, 5431, 5436, 5441, 5446, 5451, 5456, 5461, 5466, 5471, 5475, 5480, 5485, 5490, 5495, 5500, 5504, 5509, 5514, 5518, 5523, 5528, 5532, 5537, 5542, 5546, 5551, 5555, 5560, 5564, 5569, 5573, 5577, 5582, 5586, 5591, 5595, 5599, 5604, 5608, 5612, 5616, 5621, 5625, 5629, 5633, 5637, 5642, 5646, 5650, 5654, 5658, 5662, 5666, 5670, 5674, 5678, 5682, 5686, 5690, 5694, 5698, 5702, 5706, 5710, 5714, 5718, 5721, 5725, 5729, 5733, 5737, 5740, 5744, 5748, 5752, 5755, 5759, 5763, 5766, 5770, 5774, 5777, 5781, 5785, 5788, 5792, 5795, 5799, 5802, 5806, 5809, 5813, 5816, 5820, 5823, 5827, 5830, 5834, 5837, 5841, 5844, 5847, 5851, 5854, 5858, 5861, 5864, 5868, 5871, 5874, 5878, 5881, 5884, 5887, 5891, 5894, 5897, 5900, 5904, 5907, 5910, 5913, 5916, 5919, 5923, 5926, 5929, 5932, 5935, 5938, 5941, 5944, 5948, 5951, 5954, 5957, 5960, 5963, 5966, 5969, 5972, 5975, 5978, 5981, 5984, 5987, 5990, 5993, 5996, 5999, 6001, 6004, 6007, 6010, 6013, 6016, 6019, 6022, 6025, 6027, 6030, 6033, 6036, 6039, 6041, 6044, 6047, 6050, 6053, 6055, 6058, 6061, 6064, 6066, 6069, 6072, 6075, 6077, 6080, 6083, 6085, 6088, 6091, 6093, 6096, 6099, 6101, 6104, 6107, 6109, 6112, 6115, 6117, 6120, 6122, 6125, 6128, 6130, 6133, 6135, 6138, 6140, 6143, 6145, 6148, 6151, 6153, 6156, 6158, 6161, 6163, 6166, 6168, 6170, 6173, 6175, 6178, 6180, 6183, 6185, 6188, 6190, 6193, 6195, 6197, 6200, 6202, 6205, 6207, 6209, 6212, 6214, 6216, 6219, 6221, 6224, 6226, 6228, 6231, 6233, 6235, 6238, 6240, 6242, 6244, 6247, 6249, 6251, 6254, 6256, 6258, 6260, 6263, 6265, 6267, 6269, 6272, 6274, 6276, 6278, 6281, 6283, 6285, 6287, 6289, 6292, 6294, 6296, 6298, 6300, 6303, 6305, 6307, 6309, 6311, 6313, 6316, 6318, 6320, 6322, 6324, 6326, 6328, 6330, 6333, 6335, 6337, 6339, 6341, 6343, 6345, 6347, 6349, 6351, 6353, 6356, 6358, 6360, 6362, 6364, 6366, 6368, 6370, 6372, 6374, 6376, 6378, 6380, 6382, 6384, 6386, 6388, 6390, 6392, 6394, 6396, 6398, 6400, 6402, 6404, 6406, 6408, 6410, 6412, 6414, 6416, 6418, 6420, 6421, 6423, 6425, 6427, 6429, 6431, 6433, 6435, 6437, 6439, 6441, 6443, 6444, 6446, 6448, 6450, 6452, 6454, 6456, 6458, 6459, 6461, 6463, 6465, 6467, 6469, 6471, 6472, 6474, 6476, 6478, 6480, 6482, 6483, 6485, 6487, 6489, 6491, 6493, 6494, 6496, 6498, 6500, 6502, 6503, 6505, 6507, 6509, 6510, 6512, 6514, 6516, 6518, 6519, 6521, 6523, 6525, 6526, 6528, 6530, 6532, 6533, 6535, 6537, 6538, 6540, 6542, 6544, 6545, 6547, 6549, 6550, 6552, 6554, 6556, 6557, 6559, 6561, 6562, 6564, 6566, 6567, 6569, 6571, 6572, 6574, 6576, 6577, 6579, 6581, 6582, 6584, 6586, 6587, 6589, 6591, 6592, 6594, 6596, 6597, 6599, 6600, 6602, 6604, 6605, 6607, 6609, 6610, 6612, 6613, 6615, 6617, 6618, 6620, 6621, 6623, 6625, 6626, 6628, 6629, 6631, 6632, 6634, 6636, 6637, 6639, 6640, 6642, 6643, 6645, 6647, 6648, 6650, 6651, 6653, 6654, 6656, 6657, 6659, 6660, 6662, 6663, 6665, 6667, 6668, 6670, 6671, 6673, 6674, 6676, 6677, 6679, 6680, 6682, 6683, 6685, 6686, 6688, 6689, 6691, 6692, 6694, 6695, 6697, 6698, 6699, 6701, 6702, 6704, 6705, 6707, 6708, 6710, 6711, 6713, 6714, 6716, 6717, 6718, 6720, 6721, 6723, 6724, 6726, 6727, 6729, 6730, 6731, 6733, 6734, 6736, 6737, 6739, 6740, 6741, 6743, 6744, 6746, 6747, 6748, 6750, 6751, 6753, 6754, 6755, 6757, 6758, 6760, 6761, 6762, 6764, 6765, 6767, 6768, 6769, 6771, 6772, 6773, 6775, 6776, 6778, 6779, 6780, 6782, 6783, 6784, 6786, 6787, 6788, 6790, 6791, 6793, 6794, 6795, 6797, 6798, 6799, 6801, 6802, 6803, 6805, 6806, 6807, 6809, 6810, 6811, 6813, 6814, 6815, 6816, 6818, 6819, 6820, 6822, 6823, 6824, 6826, 6827, 6828, 6830, 6831, 6832, 6833, 6835, 6836, 6837, 6839, 6840, 6841, 6842, 6844, 6845, 6846, 6848, 6849, 6850, 6851, 6853, 6854, 6855, 6856, 6858, 6859, 6860, 6862, 6863, 6864, 6865, 6867, 6868, 6869, 6870, 6872, 6873, 6874, 6875, 6877, 6878, 6879, 6880, 6882, 6883, 6884, 6885, 6886, 6888, 6889, 6890, 6891, 6893, 6894, 6895, 6896, 6897, 6899, 6900, 6901, 6902, 6904, 6905, 6906, 6907, 6908, 6910, 6911, 6912, 6913, 6914, 6916, 6917, 6918, 6919, 6920, 6921, 6923, 6924, 6925, 6926, 6927, 6929, 6930, 6931, 6932, 6933, 6934, 6936, 6937, 6938, 6939, 6940, 6941, 6943, 6944, 6945, 6946, 6947, 6948, 6950, 6951, 6952, 6953, 6954, 6955, 6957, 6958, 6959, 6960, 6961, 6962, 6963, 6965, 6966, 6967, 6968, 6969, 6970, 6971, 6972, 6974, 6975, 6976, 6977, 6978, 6979, 6980, 6981, 6983, 6984, 6985, 6986, 6987, 6988, 6989, 6990, 6991, 6993, 6994, 6995, 6996, 6997, 6998, 6999, 7000, 7001, 7003, 7004, 7005, 7006, 7007, 7008, 7009, 7010, 7011, 7012, 7013, 7015, 7016, 7017, 7018, 7019, 7020, 7021, 7022, 7023, 7024, 7025, 7026, 7027, 7029, 7030, 7031, 7032, 7033, 7034, 7035, 7036, 7037, 7038, 7039, 7040, 7041, 7042, 7043, 7044, 7046, 7047, 7048, 7049, 7050, 7051, 7052, 7053, 7054, 7055, 7056, 7057, 7058, 7059, 7060, 7061, 7062, 7063, 7064, 7065, 7066, 7067, 7068, 7069, 7070, 7071, 7073, 7074, 7075, 7076, 7077, 7078, 7079, 7080, 7081, 7082, 7083, 7084, 7085, 7086, 7087, 7088, 7089, 7090, 7091, 7092, 7093, 7094, 7095, 7096, 7097, 7098, 7099, 7100, 7101, 7102, 7103, 7104, 7105, 7106, 7107, 7108, 7109, 7110, 7111, 7112, 7113, 7114, 7115, 7116, 7117, 7118, 7119, 7120, 7121, 7122, 7123, 7124, 7124, 7125, 7126, 7127, 7128, 7129, 7130, 7131, 7132, 7133, 7134, 7135, 7136, 7137, 7138, 7139, 7140, 7141, 7142, 7143, 7144, 7145, 7146, 7147, 7148, 7149, 7150, 7150, 7151, 7152, 7153, 7154, 7155, 7156, 7157, 7158, 7159, 7160, 7161, 7162, 7163, 7164, 7165, 7166, 7166, 7167, 7168, 7169, 7170, 7171, 7172, 7173, 7174, 7175, 7176, 7177, 7178, 7179, 7179, 7180, 7181, 7182, 7183, 7184, 7185, 7186, 7187, 7188, 7189, 7190, 7191, 7191, 7192, 7193, 7194, 7195, 7196, 7197, 7198, 7199, 7200, 7201, 7201, 7202, 7203, 7204, 7205, 7206, 7207, 7208, 7209, 7210, 7210, 7211, 7212, 7213, 7214, 7215, 7216, 7217, 7218, 7218, 7219, 7220, 7221, 7222, 7223, 7224, 7225, 7226, 7226, 7227, 7228, 7229, 7230, 7231, 7232, 7233, 7233, 7234, 7235, 7236, 7237, 7238, 7239, 7240, 7240, 7241, 7242, 7243, 7244, 7245, 7246, 7246, 7247, 7248, 7249, 7250, 7251, 7252, 7253, 7253, 7254, 7255, 7256, 7257, 7258, 7259, 7259, 7260, 7261, 7262, 7263, 7264, 7264, 7265, 7266, 7267, 7268, 7269, 7270, 7270, 7271, 7272, 7273, 7274, 7275, 7275, 7276, 7277, 7278, 7279, 7280, 7281, 7281, 7282, 7283, 7284, 7285, 7286, 7286, 7287, 7288, 7289, 7290, 7291, 7291, 7292, 7293, 7294, 7295, 7295, 7296, 7297, 7298, 7299, 7300, 7300, 7301, 7302, 7303, 7304, 7304, 7305, 7306, 7307, 7308, 7309, 7309, 7310, 7311, 7312, 7313, 7313, 7314, 7315, 7316, 7317, 7317, 7318, 7319, 7320, 7321, 7322, 7322, 7323, 7324, 7325, 7326, 7326, 7327, 7328, 7329, 7330, 7330, 7331, 7332, 7333, 7334, 7334, 7335, 7336, 7337, 7337, 7338, 7339, 7340, 7341, 7341, 7342, 7343, 7344, 7345, 7345, 7346, 7347, 7348, 7348, 7349, 7350, 7351, 7352, 7352, 7353, 7354, 7355, 7356, 7356, 7357, 7358, 7359, 7359, 7360, 7361, 7362, 7362, 7363, 7364, 7365, 7366, 7366, 7367, 7368, 7369, 7369, 7370, 7371, 7372, 7372, 7373, 7374, 7375, 7376, 7376, 7377, 7378, 7379, 7379, 7380, 7381, 7382, 7382, 7383, 7384, 7385, 7385, 7386, 7387, 7388, 7388, 7389, 7390, 7391, 7391, 7392, 7393, 7394, 7394, 7395, 7396, 7397, 7397, 7398, 7399, 7400, 7400, 7401, 7402, 7403, 7403, 7404, 7405, 7406, 7406, 7407, 7408, 7409, 7409, 7410, 7411, 7411, 7412, 7413, 7414, 7414, 7415, 7416, 7417, 7417, 7418, 7419, 7420, 7420, 7421, 7422, 7422, 7423, 7424, 7425, 7425, 7426, 7427, 7428, 7428, 7429, 7430, 7430, 7431, 7432, 7433, 7433, 7434, 7435, 7435, 7436, 7437, 7438, 7438, 7439, 7440, 7441, 7441, 7442, 7443, 7443, 7444, 7445, 7446, 7446, 7447, 7448, 7448, 7449, 7450, 7450, 7451, 7452, 7453, 7453, 7454, 7455, 7455, 7456, 7457, 7458, 7458, 7459, 7460, 7460, 7461, 7462, 7462, 7463, 7464, 7465, 7465, 7466, 7467, 7467, 7468, 7469, 7469, 7470, 7471, 7472, 7472, 7473, 7474, 7474, 7475, 7476, 7476, 7477, 7478, 7478, 7479, 7480, 7481, 7481, 7482, 7483, 7483, 7484, 7485, 7485, 7486, 7487, 7487, 7488, 7489, 7489, 7490, 7491, 7491, 7492, 7493, 7494, 7494, 7495, 7496, 7496, 7497, 7498, 7498, 7499, 7500, 7500, 7501, 7502, 7502, 7503, 7504, 7504, 7505, 7506, 7506, 7507, 7508, 7508, 7509, 7510, 7510, 7511, 7512, 7512, 7513, 7514, 7514, 7515, 7516, 7516, 7517, 7518, 7518, 7519, 7520, 7520, 7521, 7522, 7522, 7523, 7524, 7524, 7525, 7526, 7526, 7527, 7528, 7528, 7529, 7530, 7530, 7531, 7532, 7532, 7533, 7533, 7534, 7535, 7535, 7536, 7537, 7537, 7538, 7539, 7539, 7540, 7541, 7541, 7542, 7543, 7543, 7544, 7545, 7545, 7546, 7546, 7547, 7548, 7548, 7549, 7550, 7550, 7551, 7552, 7552, 7553, 7554, 7554, 7555, 7555, 7556, 7557, 7557, 7558, 7559, 7559, 7560, 7561, 7561, 7562, 7562, 7563, 7564, 7564, 7565, 7566, 7566, 7567, 7568, 7568, 7569, 7569, 7570, 7571, 7571, 7572, 7573, 7573, 7574, 7574, 7575, 7576, 7576, 7577, 7578, 7578, 7579, 7579, 7580, 7581, 7581, 7582, 7583, 7583, 7584, 7584, 7585, 7586, 7586, 7587, 7588, 7588, 7589, 7589, 7590, 7591, 7591, 7592, 7593, 7593, 7594, 7594, 7595, 7596, 7596, 7597, 7597, 7598, 7599, 7599, 7600, 7601, 7601, 7602, 7602, 7603, 7604, 7604, 7605, 7605, 7606, 7607, 7607, 7608, 7608, 7609, 7610, 7610, 7611, 7611, 7612, 7613, 7613, 7614, 7614, 7615, 7616, 7616, 7617, 7618, 7618, 7619, 7619, 7620, 7621, 7621, 7622, 7622, 7623, 7624, 7624, 7625, 7625, 7626, 7626, 7627, 7628, 7628, 7629, 7629, 7630, 7631, 7631, 7632, 7632, 7633, 7634, 7634, 7635, 7635, 7636, 7637, 7637, 7638, 7638, 7639, 7640, 7640, 7641, 7641, 7642, 7642, 7643, 7644, 7644, 7645, 7645, 7646, 7647, 7647, 7648, 7648, 7649, 7650, 7650, 7651, 7651, 7652, 7652, 7653, 7654, 7654, 7655, 7655, 7656, 7656, 7657, 7658, 7658, 7659, 7659, 7660, 7661, 7661, 7662, 7662, 7663, 7663, 7664, 7665, 7665, 7666, 7666, 7667, 7667, 7668, 7669, 7669, 7670, 7670, 7671, 7671, 7672, 7673, 7673, 7674, 7674, 7675, 7675, 7676, 7677, 7677, 7678, 7678, 7679, 7679, 7680, 7681, 7681, 7682, 7682, 7683, 7683, 7684, 7684, 7685, 7686, 7686, 7687, 7687, 7688, 7688, 7689, 7690, 7690, 7691, 7691, 7692, 7692, 7693, 7693, 7694, 7695, 7695, 7696, 7696, 7697, 7697, 7698, 7698, 7699, 7700, 7700, 7701, 7701, 7702, 7702, 7703, 7703, 7704, 7705, 7705, 7706, 7706, 7707, 7707, 7708, 7708, 7709, 7710, 7710, 7711, 7711, 7712, 7712, 7713, 7713, 7714, 7715, 7715, 7716, 7716, 7717, 7717, 7718, 7718, 7719, 7719, 7720, 7721, 7721, 7722, 7722, 7723, 7723, 7724, 7724, 7725, 7725, 7726, 7726, 7727, 7728, 7728, 7729, 7729, 7730, 7730, 7731, 7731, 7732, 7732, 7733, 7733, 7734, 7735, 7735, 7736, 7736, 7737, 7737, 7738, 7738, 7739, 7739, 7740, 7740, 7741, 7742, 7742, 7743, 7743, 7744, 7744, 7745, 7745, 7746, 7746, 7747, 7747, 7748, 7748, 7749, 7749, 7750, 7751, 7751, 7752, 7752, 7753, 7753, 7754, 7754, 7755, 7755, 7756, 7756, 7757, 7757, 7758, 7758, 7759, 7759, 7760, 7761, 7761, 7762, 7762, 7763, 7763, 7764, 7764, 7765, 7765, 7766, 7766, 7767, 7767, 7768, 7768, 7769, 7769, 7770, 7770, 7771, 7771, 7772, 7773, 7773, 7774, 7774, 7775, 7775, 7776, 7776, 7777, 7777, 7778, 7778, 7779, 7779, 7780, 7780, 7781, 7781, 7782, 7782, 7783, 7783, 7784, 7784, 7785, 7785, 7786, 7786, 7787, 7787, 7788, 7788, 7789, 7789, 7790, 7790, 7791, 7791, 7792, 7792, 7793, 7794, 7794, 7795, 7795, 7796, 7796, 7797, 7797, 7798, 7798, 7799, 7799, 7800, 7800, 7801, 7801, 7802, 7802, 7803, 7803, 7804, 7804, 7805, 7805, 7806, 7806, 7807, 7807, 7808, 7808, 7809, 7809, 7810, 7810, 7811, 7811, 7812, 7812, 7813, 7813, 7814, 7814, 7815, 7815, 7816, 7816, 7817, 7817, 7818, 7818, 7819, 7819, 7820, 7820, 7821, 7821, 7822, 7822, 7823, 7823, 7823, 7824, 7824, 7825, 7825, 7826, 7826, 7827, 7827, 7828, 7828, 7829, 7829, 7830, 7830, 7831, 7831, 7832, 7832, 7833, 7833, 7834, 7834, 7835, 7835, 7836, 7836, 7837, 7837, 7838, 7838, 7839, 7839, 7840, 7840, 7841, 7841, 7842, 7842, 7843, 7843, 7843, 7844, 7844, 7845, 7845, 7846, 7846, 7847, 7847, 7848, 7848, 7849, 7849, 7850, 7850, 7851, 7851, 7852, 7852, 7853, 7853, 7854, 7854, 7855, 7855, 7855, 7856, 7856, 7857, 7857, 7858, 7858, 7859, 7859, 7860, 7860, 7861, 7861, 7862, 7862, 7863, 7863, 7864, 7864, 7864, 7865, 7865, 7866, 7866, 7867, 7867, 7868, 7868, 7869, 7869, 7870, 7870, 7871, 7871, 7872, 7872, 7873, 7873, 7873, 7874, 7874, 7875, 7875, 7876, 7876, 7877, 7877, 7878, 7878, 7879, 7879, 7880, 7880, 7880, 7881, 7881, 7882, 7882, 7883, 7883, 7884, 7884, 7885, 7885, 7886, 7886, 7886, 7887, 7887, 7888, 7888, 7889, 7889, 7890, 7890, 7891, 7891, 7892, 7892, 7892, 7893, 7893, 7894, 7894, 7895, 7895, 7896, 7896, 7897, 7897, 7898, 7898, 7898, 7899, 7899, 7900, 7900, 7901, 7901, 7902, 7902, 7903, 7903, 7903, 7904, 7904, 7905, 7905, 7906, 7906, 7907, 7907, 7908, 7908, 7908, 7909, 7909, 7910, 7910, 7911, 7911, 7912, 7912, 7913, 7913, 7913, 7914, 7914, 7915, 7915, 7916, 7916, 7917, 7917, 7917, 7918, 7918, 7919, 7919, 7920, 7920, 7921, 7921, 7922, 7922, 7922, 7923, 7923, 7924, 7924, 7925, 7925, 7926, 7926, 7926, 7927, 7927, 7928, 7928, 7929, 7929, 7930, 7930, 7930, 7931, 7931, 7932, 7932, 7933, 7933, 7934, 7934, 7934, 7935, 7935, 7936, 7936, 7937, 7937, 7938, 7938, 7938, 7939, 7939, 7940, 7940, 7941, 7941, 7941, 7942, 7942, 7943, 7943, 7944, 7944, 7945, 7945, 7945, 7946, 7946, 7947, 7947, 7948, 7948, 7948, 7949, 7949, 7950, 7950, 7951, 7951, 7952, 7952, 7952, 7953, 7953, 7954, 7954, 7955, 7955, 7955, 7956, 7956, 7957, 7957, 7958, 7958, 7958, 7959, 7959, 7960, 7960, 7961, 7961, 7961, 7962, 7962, 7963, 7963, 7964, 7964, 7964, 7965, 7965, 7966, 7966, 7967, 7967, 7967, 7968, 7968, 7969, 7969, 7970, 7970, 7970, 7971, 7971, 7972, 7972, 7973, 7973, 7973, 7974, 7974, 7975, 7975, 7976, 7976, 7976, 7977, 7977, 7978, 7978, 7979, 7979, 7979, 7980, 7980, 7981, 7981, 7981, 7982, 7982, 7983, 7983, 7984, 7984, 7984, 7985, 7985, 7986, 7986, 7987, 7987, 7987, 7988, 7988, 7989, 7989, 7989, 7990, 7990, 7991, 7991, 7992, 7992, 7992, 7993, 7993, 7994, 7994, 7994, 7995, 7995, 7996, 7996, 7997, 7997, 7997, 7998, 7998, 7999, 7999, 7999, 8000, 8000, 8001, 8001, 8002, 8002, 8002, 8003, 8003, 8004, 8004, 8004, 8005, 8005, 8006, 8006, 8006, 8007, 8007, 8008, 8008, 8009, 8009, 8009, 8010, 8010, 8011, 8011, 8011, 8012, 8012, 8013, 8013, 8013, 8014, 8014, 8015, 8015, 8016, 8016, 8016, 8017, 8017, 8018, 8018, 8018, 8019, 8019, 8020, 8020, 8020, 8021, 8021, 8022, 8022, 8022, 8023, 8023, 8024, 8024, 8024, 8025, 8025, 8026, 8026, 8026, 8027, 8027, 8028, 8028, 8028, 8029, 8029, 8030, 8030, 8030, 8031, 8031, 8032, 8032, 8033, 8033, 8033, 8034, 8034, 8035, 8035, 8035, 8036, 8036, 8037, 8037, 8037, 8038, 8038, 8039, 8039, 8039, 8040, 8040, 8040, 8041, 8041, 8042, 8042, 8042, 8043, 8043, 8044, 8044, 8044, 8045, 8045, 8046, 8046, 8046, 8047, 8047, 8048, 8048, 8048, 8049, 8049, 8050, 8050, 8050, 8051, 8051, 8052, 8052, 8052, 8053, 8053, 8054, 8054, 8054, 8055, 8055, 8056, 8056, 8056, 8057, 8057, 8057, 8058, 8058, 8059, 8059, 8059, 8060, 8060, 8061, 8061, 8061, 8062, 8062, 8063, 8063, 8063, 8064, 8064, 8065, 8065, 8065, 8066, 8066, 8066, 8067, 8067, 8068, 8068, 8068, 8069, 8069, 8070, 8070, 8070, 8071, 8071, 8071, 8072, 8072, 8073, 8073, 8073, 8074, 8074, 8075, 8075, 8075, 8076, 8076, 8077, 8077, 8077, 8078, 8078, 8078, 8079, 8079, 8080, 8080, 8080, 8081, 8081, 8081, 8082, 8082, 8083, 8083, 8083, 8084, 8084, 8085, 8085, 8085, 8086, 8086, 8086, 8087, 8087, 8088, 8088, 8088, 8089, 8089, 8089, 8090, 8090, 8091, 8091, 8091, 8092, 8092, 8093, 8093, 8093, 8094, 8094, 8094, 8095, 8095, 8096, 8096, 8096, 8097, 8097, 8097, 8098, 8098, 8099, 8099, 8099, 8100, 8100, 8100, 8101, 8101, 8102, 8102, 8102, 8103, 8103, 8103, 8104, 8104, 8105, 8105, 8105, 8106, 8106, 8106, 8107, 8107, 8108, 8108, 8108, 8109, 8109, 8109, 8110, 8110, 8111, 8111, 8111, 8112, 8112, 8112, 8113, 8113, 8114, 8114, 8114, 8115, 8115, 8115, 8116, 8116, 8116, 8117, 8117, 8118, 8118, 8118, 8119, 8119, 8119, 8120, 8120, 8121, 8121, 8121, 8122, 8122, 8122, 8123, 8123, 8123, 8124, 8124, 8125, 8125, 8125, 8126, 8126, 8126, 8127, 8127, 8128, 8128, 8128, 8129, 8129, 8129, 8130, 8130, 8130, 8131, 8131, 8132, 8132, 8132, 8133, 8133, 8133, 8134, 8134, 8134, 8135, 8135, 8136, 8136, 8136, 8137, 8137, 8137, 8138, 8138, 8138, 8139, 8139, 8140, 8140, 8140, 8141, 8141, 8141, 8142, 8142, 8142, 8143, 8143, 8143, 8144, 8144, 8145, 8145, 8145, 8146, 8146, 8146, 8147, 8147, 8147, 8148, 8148, 8149, 8149, 8149, 8150, 8150, 8150, 8151, 8151, 8151, 8152, 8152, 8152, 8153, 8153, 8154, 8154, 8154, 8155, 8155, 8155, 8156, 8156, 8156, 8157, 8157, 8157, 8158, 8158, 8158, 8159, 8159, 8160, 8160, 8160, 8161, 8161, 8161, 8162, 8162, 8162, 8163, 8163, 8163, 8164, 8164, 8165, 8165, 8165, 8166, 8166, 8166, 8167, 8167, 8167, 8168, 8168, 8168, 8169, 8169, 8169, 8170, 8170, 8170, 8171, 8171, 8172, 8172, 8172, 8173, 8173, 8173, 8174, 8174, 8174, 8175, 8175, 8175, 8176, 8176, 8176, 8177, 8177, 8177, 8178, 8178, 8179, 8179, 8179, 8180, 8180, 8180, 8181, 8181, 8181, 8182, 8182, 8182, 8183, 8183, 8183, 8184, 8184, 8184, 8185, 8185, 8185, 8186, 8186, 8187, 8187, 8187, 8188, 8188, 8188, 8189, 8189, 8189, 8190, 8190, 8190, 8191, 8191, 8191, 8192, 8192, 8192, 8193, 8193, 8193, 8194, 8194, 8194, 8195, 8195, 8195, 8196, 8196, 8196, 8197, 8197, 8197, 8198, 8198, 8199, 8199, 8199, 8200, 8200, 8200, 8201, 8201, 8201, 8202, 8202, 8202, 8203, 8203, 8203, 8204, 8204, 8204, 8205, 8205, 8205, 8206, 8206, 8206, 8207, 8207, 8207, 8208, 8208, 8208, 8209, 8209, 8209, 8210, 8210, 8210, 8211, 8211, 8211, 8212, 8212, 8212, 8213, 8213, 8213, 8214, 8214, 8214, 8215, 8215, 8215, 8216, 8216, 8216, 8217, 8217, 8217, 8218, 8218, 8218, 8219, 8219, 8219, 8220, 8220, 8220, 8221, 8221, 8221, 8222, 8222, 8222, 8223, 8223, 8223, 8224, 8224, 8224, 8225, 8225, 8225, 8226, 8226, 8226, 8227, 8227, 8227, 8228, 8228, 8228, 8229, 8229, 8229, 8230, 8230, 8230, 8231, 8231, 8231, 8232, 8232, 8232, 8233, 8233, 8233, 8234, 8234, 8234, 8235, 8235, 8235, 8236, 8236, 8236, 8237, 8237, 8237, 8238, 8238, 8238, 8239, 8239, 8239, 8240, 8240, 8240, 8241, 8241, 8241, 8242, 8242, 8242, 8243, 8243, 8243, 8244, 8244, 8244, 8245, 8245, 8245, 8246, 8246, 8246, 8247, 8247, 8247, 8248, 8248, 8248, 8248, 8249, 8249, 8249, 8250, 8250, 8250, 8251, 8251, 8251, 8252, 8252, 8252, 8253, 8253, 8253, 8254, 8254, 8254, 8255, 8255, 8255, 8256, 8256, 8256, 8257, 8257, 8257, 8258, 8258, 8258, 8259, 8259, 8259, 8259, 8260, 8260, 8260, 8261, 8261, 8261, 8262, 8262, 8262, 8263, 8263, 8263, 8264, 8264, 8264, 8265, 8265, 8265, 8266, 8266, 8266, 8267, 8267, 8267, 8267, 8268, 8268, 8268, 8269, 8269, 8269, 8270, 8270, 8270, 8271, 8271, 8271, 8272, 8272, 8272, 8273, 8273, 8273, 8274, 8274, 8274, 8274, 8275, 8275, 8275, 8276, 8276, 8276, 8277, 8277, 8277, 8278, 8278, 8278, 8279, 8279, 8279, 8280, 8280, 8280, 8280, 8281, 8281, 8281, 8282, 8282, 8282, 8283, 8283, 8283, 8284, 8284, 8284, 8285, 8285, 8285, 8286, 8286, 8286, 8286, 8287, 8287, 8287, 8288, 8288, 8288, 8289, 8289, 8289, 8290, 8290, 8290, 8291, 8291, 8291, 8291, 8292, 8292, 8292, 8293, 8293, 8293, 8294, 8294, 8294, 8295, 8295, 8295, 8295, 8296, 8296, 8296, 8297, 8297, 8297, 8298, 8298, 8298, 8299, 8299, 8299, 8300, 8300, 8300, 8300, 8301, 8301, 8301, 8302, 8302, 8302, 8303, 8303, 8303, 8304, 8304, 8304, 8304, 8305, 8305, 8305, 8306, 8306, 8306, 8307, 8307, 8307, 8308, 8308, 8308, 8308, 8309, 8309, 8309, 8310, 8310, 8310, 8311, 8311, 8311, 8312, 8312, 8312, 8312, 8313, 8313, 8313, 8314, 8314, 8314, 8315, 8315, 8315, 8315, 8316, 8316, 8316, 8317, 8317, 8317, 8318, 8318, 8318, 8319, 8319, 8319, 8319, 8320, 8320, 8320, 8321, 8321, 8321, 8322, 8322, 8322, 8322, 8323, 8323, 8323, 8324, 8324, 8324, 8325, 8325, 8325, 8325, 8326, 8326, 8326, 8327, 8327, 8327, 8328, 8328, 8328, 8328, 8329, 8329, 8329, 8330, 8330, 8330, 8331, 8331, 8331, 8331, 8332, 8332, 8332, 8333, 8333, 8333, 8334, 8334, 8334, 8334, 8335, 8335, 8335, 8336, 8336, 8336, 8337, 8337, 8337, 8337, 8338, 8338, 8338, 8339, 8339, 8339, 8340, 8340, 8340, 8340, 8341, 8341, 8341, 8342, 8342, 8342, 8343, 8343, 8343, 8343, 8344, 8344, 8344, 8345, 8345, 8345, 8345, 8346, 8346, 8346, 8347, 8347, 8347, 8348, 8348, 8348, 8348, 8349, 8349, 8349, 8350, 8350, 8350, 8351, 8351, 8351, 8351, 8352, 8352, 8352, 8353, 8353, 8353, 8353, 8354, 8354, 8354, 8355, 8355, 8355, 8355, 8356, 8356, 8356, 8357, 8357, 8357, 8358, 8358, 8358, 8358, 8359, 8359, 8359, 8360, 8360, 8360, 8360, 8361, 8361, 8361, 8362, 8362, 8362, 8362, 8363, 8363, 8363, 8364, 8364, 8364, 8365, 8365, 8365, 8365, 8366, 8366, 8366, 8367, 8367, 8367, 8367, 8368, 8368, 8368, 8369, 8369, 8369, 8369, 8370, 8370, 8370, 8371, 8371, 8371, 8371, 8372, 8372, 8372, 8373, 8373, 8373, 8373, 8374, 8374, 8374, 8375, 8375, 8375, 8376, 8376, 8376, 8376, 8377, 8377, 8377, 8378, 8378, 8378, 8378, 8379, 8379, 8379, 8380, 8380, 8380, 8380, 8381, 8381, 8381, 8382, 8382, 8382, 8382, 8383, 8383, 8383, 8384, 8384, 8384, 8384, 8385, 8385, 8385, 8386, 8386, 8386, 8386, 8387, 8387, 8387, 8387, 8388, 8388, 8388, 8389, 8389, 8389, 8389, 8390, 8390, 8390, 8391, 8391, 8391, 8391, 8392, 8392, 8392, 8393, 8393, 8393, 8393, 8394, 8394, 8394, 8395, 8395, 8395, 8395, 8396, 8396, 8396, 8397, 8397, 8397, 8397, 8398, 8398, 8398, 8399, 8399, 8399, 8399, 8400, 8400, 8400, 8400, 8401, 8401, 8401, 8402, 8402, 8402, 8402, 8403, 8403, 8403, 8404, 8404, 8404, 8404, 8405, 8405, 8405, 8405, 8406, 8406, 8406, 8407, 8407, 8407, 8407, 8408, 8408, 8408, 8409, 8409, 8409, 8409, 8410, 8410, 8410, 8411, 8411, 8411, 8411, 8412, 8412, 8412, 8412, 8413, 8413, 8413, 8414, 8414, 8414, 8414, 8415, 8415, 8415, 8415, 8416, 8416, 8416, 8417, 8417, 8417, 8417, 8418, 8418, 8418, 8419, 8419, 8419, 8419, 8420, 8420, 8420, 8420, 8421, 8421, 8421, 8422, 8422, 8422, 8422, 8423, 8423, 8423, 8423, 8424, 8424, 8424, 8425, 8425, 8425, 8425, 8426, 8426, 8426, 8426, 8427, 8427, 8427, 8428, 8428, 8428, 8428, 8429, 8429, 8429, 8429, 8430, 8430, 8430, 8431, 8431, 8431, 8431, 8432, 8432, 8432, 8432, 8433, 8433, 8433, 8434, 8434, 8434, 8434, 8435, 8435, 8435, 8435, 8436, 8436, 8436, 8437, 8437, 8437, 8437, 8438, 8438, 8438, 8438, 8439, 8439, 8439, 8440, 8440, 8440, 8440, 8441, 8441, 8441, 8441, 8442, 8442, 8442, 8442, 8443, 8443, 8443, 8444, 8444, 8444, 8444, 8445, 8445, 8445, 8445, 8446, 8446, 8446, 8446, 8447, 8447, 8447, 8448, 8448, 8448, 8448, 8449, 8449, 8449, 8449, 8450, 8450, 8450, 8451, 8451, 8451, 8451, 8452, 8452, 8452, 8452, 8453, 8453, 8453, 8453, 8454, 8454, 8454, 8455, 8455, 8455, 8455, 8456, 8456, 8456, 8456, 8457, 8457, 8457, 8457, 8458, 8458, 8458, 8458, 8459, 8459, 8459, 8460, 8460, 8460, 8460, 8461, 8461, 8461, 8461, 8462, 8462, 8462, 8462, 8463, 8463, 8463, 8463, 8464, 8464, 8464, 8465, 8465, 8465, 8465, 8466, 8466, 8466, 8466, 8467, 8467, 8467, 8467, 8468, 8468, 8468, 8468, 8469, 8469, 8469, 8470, 8470, 8470, 8470, 8471, 8471, 8471, 8471, 8472, 8472, 8472, 8472, 8473, 8473, 8473, 8473, 8474, 8474, 8474, 8475, 8475, 8475, 8475, 8476, 8476, 8476, 8476, 8477, 8477, 8477, 8477, 8478, 8478, 8478, 8478, 8479, 8479, 8479, 8479, 8480, 8480, 8480, 8480, 8481, 8481, 8481, 8482, 8482, 8482, 8482, 8483, 8483, 8483, 8483, 8484, 8484, 8484, 8484, 8485, 8485, 8485, 8485, 8486, 8486, 8486, 8486, 8487, 8487, 8487, 8487, 8488, 8488, 8488, 8488, 8489, 8489, 8489, 8490, 8490, 8490, 8490, 8491, 8491, 8491, 8491, 8492, 8492, 8492, 8492, 8493, 8493, 8493, 8493, 8494, 8494, 8494, 8494, 8495, 8495, 8495, 8495, 8496, 8496, 8496, 8496, 8497, 8497, 8497, 8497, 8498, 8498, 8498, 8498, 8499, 8499, 8499, 8499, 8500, 8500, 8500, 8501, 8501, 8501, 8501, 8502, 8502, 8502, 8502, 8503, 8503, 8503, 8503, 8504, 8504, 8504, 8504, 8505, 8505, 8505, 8505, 8506, 8506, 8506, 8506, 8507, 8507, 8507, 8507, 8508, 8508, 8508, 8508, 8509, 8509, 8509, 8509, 8510, 8510, 8510, 8510, 8511, 8511, 8511, 8511, 8512, 8512, 8512, 8512, 8513, 8513, 8513, 8513, 8514, 8514, 8514, 8514, 8515, 8515, 8515, 8515, 8516, 8516, 8516, 8516, 8517, 8517, 8517, 8517 }; /*0*/ + void create_lookup_log(log_table_info *logtab, int num_bits) { int ii; double val; ASSERT(logtab); - + logtab->size = 0x01 << num_bits; logtab->mask = 0x01; for (ii = 0; ii < num_bits; ii++) /* one less than the table size in @@ -60,18 +62,19 @@ void create_lookup_log(log_table_info *logtab, int num_bits) if( DO_USE_LOGTAB__TABLE ) { logtab->table = logtab__table; } else { - logtab->table = (int *) CALLOC(logtab->size + 1, sizeof(int), "cfront.logtable"); + int* table = (int *) CALLOC(logtab->size + 1, sizeof(int), "cfront.logtable"); + logtab->table = table; PRINT_SOME_CODE("#define DO_USE_LOGTAB__TABLE ( (logtab->size == %d) \\\n", logtab->size); PRINT_SOME_CODE(" && LOG_SCALE == %d ) \n", LOG_SCALE); PRINT_SOME_CODE("int logtab__table[%d] = { 0, ", logtab->size); /* filler for pos 0 */ for (ii = 1; ii <= logtab->size; ii++) { val = LOG_SCALE * log((double) ii); - logtab->table[ii] = (int)(val + 0.5); + table[ii] = (int)(val + 0.5); #if DEBUG - log_report("log table: %d %d\n", ii, logtab->table[ii]); + log_report("log table: %d %d\n", ii, table[ii]); #endif - PRINT_SOME_CODE(" %i,", logtab->table[ii]); + PRINT_SOME_CODE(" %i,", table[ii]); } PRINT_SOME_CODE(" }; /*%i*/\n", 0); } diff --git a/srec/clib/log_add.c b/srec/clib/log_add.c index 434f6ca..25d26eb 100644 --- a/srec/clib/log_add.c +++ b/srec/clib/log_add.c @@ -11,7 +11,7 @@ * * * Unless required by applicable law or agreed to in writing, software * * distributed under the License is distributed on an 'AS IS' BASIS, * - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * * See the License for the specific language governing permissions and * * limitations under the License. * * * @@ -34,14 +34,14 @@ static const char logadd[] = "$Id: log_add.c,v 1.3.6.10 2008/01/29 06:36:39 dahan Exp $"; -// #define PRINT_SOME_CODE(fMt,aRg1) printf(fMt,aRg1) -#define PRINT_SOME_CODE(fMt,aRg1) +// #define PRINT_SOME_CODE(fMt,aRg1) printf(fMt,aRg1) +#define PRINT_SOME_CODE(fMt,aRg1) /* values for default case 0 */ #define DO_USE_LOGTAB__TABLE ( logtab->scale == 61 \ && ( (int)(logtab->logscale*10000) == (int)(6.4f*10000)) \ - && ADD_LOG_LIMIT == 8) -static prdata logtab__table[3125] = { 271, 270, 270, 269, 269, 268, 268, 267, 267, 266, 266, 265, 265, 264, 264, 263, 263, 262, 262, 261, 261, 260, 260, 259, 259, 258, 258, 257, 257, 256, 256, 255, 255, 254, 254, 253, 253, 253, 252, 252, 251, 251, 250, 250, 249, 249, 248, 248, 247, 247, 246, 246, 245, 245, 245, 244, 244, 243, 243, 242, 242, 241, 241, 240, 240, 239, 239, 239, 238, 238, 237, 237, 236, 236, 235, 235, 234, 234, 234, 233, 233, 232, 232, 231, 231, 230, 230, 230, 229, 229, 228, 228, 227, 227, 226, 226, 226, 225, 225, 224, 224, 223, 223, 222, 222, 222, 221, 221, 220, 220, 219, 219, 219, 218, 218, 217, 217, 216, 216, 216, 215, 215, 214, 214, 214, 213, 213, 212, 212, 211, 211, 211, 210, 210, 209, 209, 208, 208, 208, 207, 207, 206, 206, 206, 205, 205, 204, 204, 204, 203, 203, 202, 202, 202, 201, 201, 200, 200, 200, 199, 199, 198, 198, 198, 197, 197, 196, 196, 196, 195, 195, 194, 194, 194, 193, 193, 192, 192, 192, 191, 191, 191, 190, 190, 189, 189, 189, 188, 188, 187, 187, 187, 186, 186, 186, 185, 185, 184, 184, 184, 183, 183, 183, 182, 182, 181, 181, 181, 180, 180, 180, 179, 179, 178, 178, 178, 177, 177, 177, 176, 176, 176, 175, 175, 174, 174, 174, 173, 173, 173, 172, 172, 172, 171, 171, 171, 170, 170, 169, 169, 169, 168, 168, 168, 167, 167, 167, 166, 166, 166, 165, 165, 165, 164, 164, 164, 163, 163, 163, 162, 162, 162, 161, 161, 161, 160, 160, 159, 159, 159, 158, 158, 158, 157, 157, 157, 157, 156, 156, 156, 155, 155, 155, 154, 154, 154, 153, 153, 153, 152, 152, 152, 151, 151, 151, 150, 150, 150, 149, 149, 149, 148, 148, 148, 147, 147, 147, 147, 146, 146, 146, 145, 145, 145, 144, 144, 144, 143, 143, 143, 143, 142, 142, 142, 141, 141, 141, 140, 140, 140, 139, 139, 139, 139, 138, 138, 138, 137, 137, 137, 137, 136, 136, 136, 135, 135, 135, 134, 134, 134, 134, 133, 133, 133, 132, 132, 132, 132, 131, 131, 131, 130, 130, 130, 130, 129, 129, 129, 128, 128, 128, 128, 127, 127, 127, 126, 126, 126, 126, 125, 125, 125, 125, 124, 124, 124, 123, 123, 123, 123, 122, 122, 122, 122, 121, 121, 121, 121, 120, 120, 120, 119, 119, 119, 119, 118, 118, 118, 118, 117, 117, 117, 117, 116, 116, 116, 116, 115, 115, 115, 115, 114, 114, 114, 114, 113, 113, 113, 113, 112, 112, 112, 112, 111, 111, 111, 111, 110, 110, 110, 110, 109, 109, 109, 109, 108, 108, 108, 108, 107, 107, 107, 107, 106, 106, 106, 106, 105, 105, 105, 105, 105, 104, 104, 104, 104, 103, 103, 103, 103, 102, 102, 102, 102, 102, 101, 101, 101, 101, 100, 100, 100, 100, 99, 99, 99, 99, 99, 98, 98, 98, 98, 97, 97, 97, 97, 97, 96, 96, 96, 96, 95, 95, 95, 95, 95, 94, 94, 94, 94, 94, 93, 93, 93, 93, 92, 92, 92, 92, 92, 91, 91, 91, 91, 91, 90, 90, 90, 90, 90, 89, 89, 89, 89, 89, 88, 88, 88, 88, 88, 87, 87, 87, 87, 87, 86, 86, 86, 86, 86, 85, 85, 85, 85, 85, 84, 84, 84, 84, 84, 83, 83, 83, 83, 83, 82, 82, 82, 82, 82, 82, 81, 81, 81, 81, 81, 80, 80, 80, 80, 80, 79, 79, 79, 79, 79, 79, 78, 78, 78, 78, 78, 77, 77, 77, 77, 77, 77, 76, 76, 76, 76, 76, 76, 75, 75, 75, 75, 75, 74, 74, 74, 74, 74, 74, 73, 73, 73, 73, 73, 73, 72, 72, 72, 72, 72, 72, 71, 71, 71, 71, 71, 71, 70, 70, 70, 70, 70, 70, 69, 69, 69, 69, 69, 69, 68, 68, 68, 68, 68, 68, 67, 67, 67, 67, 67, 67, 67, 66, 66, 66, 66, 66, 66, 65, 65, 65, 65, 65, 65, 65, 64, 64, 64, 64, 64, 64, 63, 63, 63, 63, 63, 63, 63, 62, 62, 62, 62, 62, 62, 62, 61, 61, 61, 61, 61, 61, 61, 60, 60, 60, 60, 60, 60, 60, 59, 59, 59, 59, 59, 59, 59, 58, 58, 58, 58, 58, 58, 58, 57, 57, 57, 57, 57, 57, 57, 57, 56, 56, 56, 56, 56, 56, 56, 55, 55, 55, 55, 55, 55, 55, 55, 54, 54, 54, 54, 54, 54, 54, 53, 53, 53, 53, 53, 53, 53, 53, 52, 52, 52, 52, 52, 52, 52, 52, 51, 51, 51, 51, 51, 51, 51, 51, 50, 50, 50, 50, 50, 50, 50, 50, 50, 49, 49, 49, 49, 49, 49, 49, 49, 48, 48, 48, 48, 48, 48, 48, 48, 48, 47, 47, 47, 47, 47, 47, 47, 47, 47, 46, 46, 46, 46, 46, 46, 46, 46, 46, 45, 45, 45, 45, 45, 45, 45, 45, 45, 44, 44, 44, 44, 44, 44, 44, 44, 44, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; /*0*/ + && ADD_LOG_LIMIT == 8) +static const prdata logtab__table[3125] = { 271, 270, 270, 269, 269, 268, 268, 267, 267, 266, 266, 265, 265, 264, 264, 263, 263, 262, 262, 261, 261, 260, 260, 259, 259, 258, 258, 257, 257, 256, 256, 255, 255, 254, 254, 253, 253, 253, 252, 252, 251, 251, 250, 250, 249, 249, 248, 248, 247, 247, 246, 246, 245, 245, 245, 244, 244, 243, 243, 242, 242, 241, 241, 240, 240, 239, 239, 239, 238, 238, 237, 237, 236, 236, 235, 235, 234, 234, 234, 233, 233, 232, 232, 231, 231, 230, 230, 230, 229, 229, 228, 228, 227, 227, 226, 226, 226, 225, 225, 224, 224, 223, 223, 222, 222, 222, 221, 221, 220, 220, 219, 219, 219, 218, 218, 217, 217, 216, 216, 216, 215, 215, 214, 214, 214, 213, 213, 212, 212, 211, 211, 211, 210, 210, 209, 209, 208, 208, 208, 207, 207, 206, 206, 206, 205, 205, 204, 204, 204, 203, 203, 202, 202, 202, 201, 201, 200, 200, 200, 199, 199, 198, 198, 198, 197, 197, 196, 196, 196, 195, 195, 194, 194, 194, 193, 193, 192, 192, 192, 191, 191, 191, 190, 190, 189, 189, 189, 188, 188, 187, 187, 187, 186, 186, 186, 185, 185, 184, 184, 184, 183, 183, 183, 182, 182, 181, 181, 181, 180, 180, 180, 179, 179, 178, 178, 178, 177, 177, 177, 176, 176, 176, 175, 175, 174, 174, 174, 173, 173, 173, 172, 172, 172, 171, 171, 171, 170, 170, 169, 169, 169, 168, 168, 168, 167, 167, 167, 166, 166, 166, 165, 165, 165, 164, 164, 164, 163, 163, 163, 162, 162, 162, 161, 161, 161, 160, 160, 159, 159, 159, 158, 158, 158, 157, 157, 157, 157, 156, 156, 156, 155, 155, 155, 154, 154, 154, 153, 153, 153, 152, 152, 152, 151, 151, 151, 150, 150, 150, 149, 149, 149, 148, 148, 148, 147, 147, 147, 147, 146, 146, 146, 145, 145, 145, 144, 144, 144, 143, 143, 143, 143, 142, 142, 142, 141, 141, 141, 140, 140, 140, 139, 139, 139, 139, 138, 138, 138, 137, 137, 137, 137, 136, 136, 136, 135, 135, 135, 134, 134, 134, 134, 133, 133, 133, 132, 132, 132, 132, 131, 131, 131, 130, 130, 130, 130, 129, 129, 129, 128, 128, 128, 128, 127, 127, 127, 126, 126, 126, 126, 125, 125, 125, 125, 124, 124, 124, 123, 123, 123, 123, 122, 122, 122, 122, 121, 121, 121, 121, 120, 120, 120, 119, 119, 119, 119, 118, 118, 118, 118, 117, 117, 117, 117, 116, 116, 116, 116, 115, 115, 115, 115, 114, 114, 114, 114, 113, 113, 113, 113, 112, 112, 112, 112, 111, 111, 111, 111, 110, 110, 110, 110, 109, 109, 109, 109, 108, 108, 108, 108, 107, 107, 107, 107, 106, 106, 106, 106, 105, 105, 105, 105, 105, 104, 104, 104, 104, 103, 103, 103, 103, 102, 102, 102, 102, 102, 101, 101, 101, 101, 100, 100, 100, 100, 99, 99, 99, 99, 99, 98, 98, 98, 98, 97, 97, 97, 97, 97, 96, 96, 96, 96, 95, 95, 95, 95, 95, 94, 94, 94, 94, 94, 93, 93, 93, 93, 92, 92, 92, 92, 92, 91, 91, 91, 91, 91, 90, 90, 90, 90, 90, 89, 89, 89, 89, 89, 88, 88, 88, 88, 88, 87, 87, 87, 87, 87, 86, 86, 86, 86, 86, 85, 85, 85, 85, 85, 84, 84, 84, 84, 84, 83, 83, 83, 83, 83, 82, 82, 82, 82, 82, 82, 81, 81, 81, 81, 81, 80, 80, 80, 80, 80, 79, 79, 79, 79, 79, 79, 78, 78, 78, 78, 78, 77, 77, 77, 77, 77, 77, 76, 76, 76, 76, 76, 76, 75, 75, 75, 75, 75, 74, 74, 74, 74, 74, 74, 73, 73, 73, 73, 73, 73, 72, 72, 72, 72, 72, 72, 71, 71, 71, 71, 71, 71, 70, 70, 70, 70, 70, 70, 69, 69, 69, 69, 69, 69, 68, 68, 68, 68, 68, 68, 67, 67, 67, 67, 67, 67, 67, 66, 66, 66, 66, 66, 66, 65, 65, 65, 65, 65, 65, 65, 64, 64, 64, 64, 64, 64, 63, 63, 63, 63, 63, 63, 63, 62, 62, 62, 62, 62, 62, 62, 61, 61, 61, 61, 61, 61, 61, 60, 60, 60, 60, 60, 60, 60, 59, 59, 59, 59, 59, 59, 59, 58, 58, 58, 58, 58, 58, 58, 57, 57, 57, 57, 57, 57, 57, 57, 56, 56, 56, 56, 56, 56, 56, 55, 55, 55, 55, 55, 55, 55, 55, 54, 54, 54, 54, 54, 54, 54, 53, 53, 53, 53, 53, 53, 53, 53, 52, 52, 52, 52, 52, 52, 52, 52, 51, 51, 51, 51, 51, 51, 51, 51, 50, 50, 50, 50, 50, 50, 50, 50, 50, 49, 49, 49, 49, 49, 49, 49, 49, 48, 48, 48, 48, 48, 48, 48, 48, 48, 47, 47, 47, 47, 47, 47, 47, 47, 47, 46, 46, 46, 46, 46, 46, 46, 46, 46, 45, 45, 45, 45, 45, 45, 45, 45, 45, 44, 44, 44, 44, 44, 44, 44, 44, 44, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; /*0*/ void create_lookup_logadd(logadd_table_info *logtab, float mul_scale) { @@ -55,18 +55,18 @@ void create_lookup_logadd(logadd_table_info *logtab, float mul_scale) if( DO_USE_LOGTAB__TABLE) { logtab->table = logtab__table; } else { - logtab->table = (prdata *) CALLOC(logtab->add_log_limit + 2, - sizeof(prdata), "clib.logadd"); + prdata* table = (prdata *) CALLOC(logtab->add_log_limit + 2, sizeof(prdata), "clib.logadd"); + logtab->table = table; PRINT_SOME_CODE( "/* values for default case %d */\n", 0); PRINT_SOME_CODE( "#define DO_USE_LOGTAB__TABLE (logtab->scale == %d \\\n", logtab->scale); PRINT_SOME_CODE( " && ( (int)(logtab->logscale*10000) == (int)(%ff*10000) \\\n", logtab->logscale); PRINT_SOME_CODE( " && ADD_LOG_LIMIT == %d) \n", ADD_LOG_LIMIT); PRINT_SOME_CODE( "static prdata logtab__table[%d] = {", logtab->add_log_limit + 2); for (ii = 0; ii <= logtab->add_log_limit; ii++) { - logtab->table[ii] = (prdata)(logtab->scale * mul_scale * log(1 + table[ii] = (prdata)(logtab->scale * mul_scale * log(1 + exp(-(float)ii / ((float)logtab->scale * mul_scale))) + 0.5) ; - PRINT_SOME_CODE(" %d,", logtab->table[ii]); + PRINT_SOME_CODE(" %d,", table[ii]); } PRINT_SOME_CODE( ", 0 }; /*%i*/\n", 0); /*not sure why the +2 above, just append 0 for now*/ } diff --git a/srec/clib/srec_arb.c b/srec/clib/srec_arb.c index 246d722..5badcd9 100644 --- a/srec/clib/srec_arb.c +++ b/srec/clib/srec_arb.c @@ -1,7 +1,7 @@ /*---------------------------------------------------------------------------* - * srec_arb.c * + * srec_arb.c * * * - * Copyright 2007, 2008 Nuance Communciations, Inc. * + * Copyright 2007, 2008 Nuance Communciations, Inc. * * * * Licensed under the Apache License, Version 2.0 (the 'License'); * * you may not use this file except in compliance with the License. * @@ -11,7 +11,7 @@ * * * Unless required by applicable law or agreed to in writing, software * * distributed under the License is distributed on an 'AS IS' BASIS, * - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * * See the License for the specific language governing permissions and * * limitations under the License. * * * @@ -123,7 +123,7 @@ int get_modelids_for_pron(srec_arbdata* allotree, modelID modelid; phonemeID lphon, cphon, rphon; - if( allotree == NULL) + if( allotree == NULL) return 1; if (num_phonemes == 0) @@ -142,11 +142,11 @@ int get_modelids_for_pron(srec_arbdata* allotree, return 1; /* bad phoneme */ for(i=0; i<num_phonemes; i++) { #if !USE_WWTRIPHONE - rphon = (i==num_phonemes-1 ? + rphon = (i==num_phonemes-1 ? (phonemeID)allotree->phoneme_index[ SILENCE_CODE] : (phonemeID)allotree->phoneme_index[ (unsigned)phonemes[i+1] ] ) ; #else - rphon = (i==num_phonemes-1 ? + rphon = (i==num_phonemes-1 ? WBPHONEME_CODE /*(phonemeID)allotree->phoneme_index[ WBPHONEME_CODE] */ : (phonemeID)allotree->phoneme_index[ (unsigned)phonemes[i+1] ] ) ; #endif @@ -436,35 +436,23 @@ static unsigned int version_arbdata_add(unsigned int ics, int data) unsigned int version_arbdata_models(srec_arbdata* a) { - static unsigned int last_arbdata_modelid = 0; - static srec_arbdata* last_arbdata; int i, num_hmms_in_phoneme; tree_head topo; unsigned int checksum = 0; - - if (a == last_arbdata) - { - checksum = last_arbdata_modelid; - } - else + /* if(debug)printf("num_hmms %d\n", a->num_hmms); */ + /* if(debug)printf("num_phonemes %d\n", a->num_phonemes); */ + for (i = 0; i < a->num_phonemes; i++) { - /* if(debug)printf("num_hmms %d\n", a->num_hmms); */ - /* if(debug)printf("num_phonemes %d\n", a->num_phonemes); */ - for (i = 0; i < a->num_phonemes; i++) - { - num_hmms_in_phoneme = 0; - topo.low_pel_no = 32567; - topo.high_pel_no = 0; - topo.nnodes = 0; - traverse_tree(a->pdata[i].model_nodes, &topo, &num_hmms_in_phoneme); - /* if(debug)printf("phoneme %d num_hmms %d (%d-%d)\n", i, num_hmms_in_phoneme, - topo.low_pel_no, topo.high_pel_no); */ - if (topo.nnodes == 256) return(checksum = 0); - checksum = version_arbdata_add(checksum, topo.low_pel_no); - } - last_arbdata_modelid = checksum; - last_arbdata = a; + num_hmms_in_phoneme = 0; + topo.low_pel_no = 32567; + topo.high_pel_no = 0; + topo.nnodes = 0; + traverse_tree(a->pdata[i].model_nodes, &topo, &num_hmms_in_phoneme); + /* if(debug)printf("phoneme %d num_hmms %d (%d-%d)\n", i, num_hmms_in_phoneme, + topo.low_pel_no, topo.high_pel_no); */ + if (topo.nnodes == 256) return 0; + checksum = version_arbdata_add(checksum, topo.low_pel_no); } return checksum; } diff --git a/srec/clib/swicms.c b/srec/clib/swicms.c index b1adc0b..4b3381b 100644 --- a/srec/clib/swicms.c +++ b/srec/clib/swicms.c @@ -1,7 +1,7 @@ /*---------------------------------------------------------------------------* - * swicms.c * + * swicms.c * * * - * Copyright 2007, 2008 Nuance Communciations, Inc. * + * Copyright 2007, 2008 Nuance Communciations, Inc. * * * * Licensed under the Apache License, Version 2.0 (the 'License'); * * you may not use this file except in compliance with the License. * @@ -11,7 +11,7 @@ * * * Unless required by applicable law or agreed to in writing, software * * distributed under the License is distributed on an 'AS IS' BASIS, * - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * * See the License for the specific language governing permissions and * * limitations under the License. * * * @@ -34,16 +34,16 @@ We try to normalize the speech frames before they get to the recognizer. The speech frames are LDA-processed mfcc-with-dynamic feature vectors. We collect these speech frames during recognition. At the end of - recognition we exclude the silence frames from the collected data, and + recognition we exclude the silence frames from the collected data, and generate a new channel average based on the previous average and the new - data, using an exponential decay formula. + data, using an exponential decay formula. In-utterance CMN calculation: A new short-term average mechanism was introduced, with faster update, to improve recognition on the very first recognition after init or reset. - We wait for a minimum number of new data frames to apply this. We also - disable the fast updater after some frames, because we assume the - cross-utterance estimator to be more reliable, particularly in its + We wait for a minimum number of new data frames to apply this. We also + disable the fast updater after some frames, because we assume the + cross-utterance estimator to be more reliable, particularly in its ability to exclude silence frames from the calculation. */ @@ -57,9 +57,9 @@ #define SWICMS_INUTT_FORGET_FACTOR2_DISABLE 65535 /* any large number */ #define SWICMS_INUTT_FORGET_FACTOR2_DEFAULT SWICMS_INUTT_FORGET_FACTOR2_DISABLE /* disable this when cross-utt become more reliable */ -#define SWICMS_INUTT_DISABLE_AFTER_FRAMES 200 +#define SWICMS_INUTT_DISABLE_AFTER_FRAMES 200 /* wait while the estimate is poor */ -#define SWICMS_INUTT_ENABLE_AFTER_FRAMES 10 +#define SWICMS_INUTT_ENABLE_AFTER_FRAMES 10 /** * Logging Stuff @@ -72,35 +72,30 @@ static const char *rcsid = 0 ? (const char *) &rcsid : "$Id: swicms.c,v 1.21.6.16 2008/06/05 19:00:55 stever Exp $"; static ESR_BOOL SWICMS_DEBUG = ESR_FALSE; -#define INT_STRING_MAX 11 /* 10 digits plus - sign */ -/* Delim per int string */ -#define CHAN_NORM_PARAMS_STRING_MAX ( MAX_CHAN_DIM * ( INT_STRING_MAX+1) ) - -static char chan_norm_params [CHAN_NORM_PARAMS_STRING_MAX]; /* these are good values from cmn/tmn files */ -static imeldata gswicms_cmn1_8 [MAX_CHAN_DIM] = +static const imeldata gswicms_cmn1_8 [MAX_CHAN_DIM] = { 158, 141, 99, 125, 101, 162, 113, 138, 128, 143, 123, 141, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127 }; -static imeldata gswicms_cmn1_11 [MAX_CHAN_DIM] = +static const imeldata gswicms_cmn1_11 [MAX_CHAN_DIM] = { 163, 121, 120, 114, 124, 139, 144, 108, 150, 119, 146, 124, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127 }; -static imeldata gswicms_tmn1_8 [MAX_CHAN_DIM] = +static const imeldata gswicms_tmn1_8 [MAX_CHAN_DIM] = { 108, 138, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127 }; -static imeldata gswicms_tmn1_11 [MAX_CHAN_DIM] = +static const imeldata gswicms_tmn1_11 [MAX_CHAN_DIM] = { 108, 138, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, @@ -113,7 +108,7 @@ static ESR_ReturnCode GetSomeIntsIfAny( const LCHAR* parname, imeldata* parvalue ESR_ReturnCode rc; ESR_BOOL exists; IntArrayList* intList = 0; - + CHKLOG(rc, ESR_SessionContains(parname, &exists)); if (exists) { rc = ESR_SessionGetProperty(parname, (void**)&intList, TYPES_INTARRAYLIST); @@ -127,7 +122,7 @@ static ESR_ReturnCode GetSomeIntsIfAny( const LCHAR* parname, imeldata* parvalue if(size != reqSize) { PLogError(L("Error reading %s from session, expected len %d: %s"), parname, reqSize, ESR_rc2str(rc)); return ESR_FATAL_ERROR; - } + } if(reqSize == 1) CHKLOG(rc, IntArrayListGet(intList, 0, parvalue)); else { @@ -157,7 +152,7 @@ int swicms_init(swicms_norm_info* swicms) CHKLOG(rc, ESR_SessionExists(&sessionExists)); - if (sessionExists) + if (sessionExists) { /* We'll assume this rate is valid or someone else will be complaining. SteveR */ rc = ESR_SessionGetSize_t ( L ( "CREC.Frontend.samplerate" ), &sample_rate ); @@ -192,7 +187,7 @@ int swicms_init(swicms_norm_info* swicms) } CHKLOG(rc, ESR_SessionExists(&sessionExists)); - if (sessionExists) + if (sessionExists) { const LCHAR* parname = L("CREC.Frontend.swicms.debug"); CHKLOG(rc, ESR_SessionContains(parname, &exists)); @@ -203,19 +198,19 @@ int swicms_init(swicms_norm_info* swicms) return rc; } } - - rc = GetSomeIntsIfAny( L("CREC.Frontend.swicms.forget_factor"), + + rc = GetSomeIntsIfAny( L("CREC.Frontend.swicms.forget_factor"), &swicms->forget_factor, 1); if(rc != ESR_SUCCESS) return rc; - - rc = GetSomeIntsIfAny( L("CREC.Frontend.swicms.sbindex"), + + rc = GetSomeIntsIfAny( L("CREC.Frontend.swicms.sbindex"), &swicms->sbindex, 1); if(rc != ESR_SUCCESS) return rc; - - rc = GetSomeIntsIfAny( L("CREC.Frontend.swicms.cmn"), + + rc = GetSomeIntsIfAny( L("CREC.Frontend.swicms.cmn"), &swicms->cmn[0], MAX_CHAN_DIM); if(rc != ESR_SUCCESS) return rc; - + if ( sample_rate == 8000 ) { rc = GetSomeIntsIfAny( L("CREC.Frontend.swicms.cmn8"), &swicms->cmn[0], MAX_CHAN_DIM); @@ -231,43 +226,43 @@ int swicms_init(swicms_norm_info* swicms) return rc; } - rc = GetSomeIntsIfAny( L("CREC.Frontend.swicms.tmn"), + rc = GetSomeIntsIfAny( L("CREC.Frontend.swicms.tmn"), &swicms->tmn[0], MAX_CHAN_DIM); if(rc != ESR_SUCCESS) return rc; } - + swicms->is_valid = 0; for (i = 0; i < MAX_CHAN_DIM; i++) swicms->adjust[i] = 255; - + #ifdef SREC_ENGINE_VERBOSE_LOGGING PLogMessage("swicms->forget_factor = %d\n", swicms->forget_factor); PLogMessage("swicms->cache_resolution = %d\n", swicms->cache_resolution); PLogMessage("swicms->sbindex = %d\n", swicms->sbindex); #endif - + /* in-utt cms parameters */ - swicms->inutt.forget_factor2 = SWICMS_INUTT_FORGET_FACTOR2_DEFAULT; - swicms->inutt.disable_after = 200; + swicms->inutt.forget_factor2 = SWICMS_INUTT_FORGET_FACTOR2_DEFAULT; + swicms->inutt.disable_after = 200; swicms->inutt.enable_after = 10; /* in-utt is less reliable */ swicms->inutt.num_bou_frames_to_skip = 20; /* silence frames! see windback */ - swicms->inutt.num_frames_since_bou = 0; + swicms->inutt.num_frames_since_bou = 0; swicms->inutt.num_frames_in_accum = 0; for(i=0; i<MAX_CHAN_DIM; i++) swicms->inutt.accum[i] = 0; if (sessionExists) { - rc = GetSomeIntsIfAny(L("CREC.Frontend.swicms.inutt.forget_factor2"), + rc = GetSomeIntsIfAny(L("CREC.Frontend.swicms.inutt.forget_factor2"), &swicms->inutt.forget_factor2, 1); if(rc != ESR_SUCCESS) return rc; - - rc = GetSomeIntsIfAny(L("CREC.Frontend.swicms.inutt.disable_after"), + + rc = GetSomeIntsIfAny(L("CREC.Frontend.swicms.inutt.disable_after"), &swicms->inutt.disable_after, 1); if(rc != ESR_SUCCESS) return rc; - - rc = GetSomeIntsIfAny(L("CREC.Frontend.swicms.inutt.enable_after"), + + rc = GetSomeIntsIfAny(L("CREC.Frontend.swicms.inutt.enable_after"), &swicms->inutt.enable_after, 1); if(rc != ESR_SUCCESS) return rc; - + /* we need to estimate the in-utt cmn from speech frames only! so let's make sure to skip some frames before collecting data, */ ESR_SessionContains(L("CREC.Frontend.start_windback"), &exists); @@ -275,7 +270,7 @@ int swicms_init(swicms_norm_info* swicms) ESR_BOOL do_skip_even_frames = ESR_TRUE; ESR_SessionGetBool(L("CREC.Frontend.do_skip_even_frames"), &do_skip_even_frames); ESR_SessionGetInt(L("CREC.Frontend.start_windback"), &swicms->inutt.num_bou_frames_to_skip); - if( do_skip_even_frames) + if( do_skip_even_frames) swicms->inutt.num_bou_frames_to_skip /= 2; swicms->inutt.num_bou_frames_to_skip -= 5; /* ensure spch frames only */ } @@ -287,15 +282,12 @@ int swicms_init(swicms_norm_info* swicms) } -ESR_ReturnCode swicms_get_cmn ( swicms_norm_info* swicms, const char **cmn_params ) +ESR_ReturnCode swicms_get_cmn ( swicms_norm_info* swicms, LCHAR *cmn_params, size_t* len ) { - ESR_ReturnCode get_status; - int dim_count; - int current_params_position; - int bytes_printed; - imeldata temp[MAX_CHAN_DIM]; - - get_status = ESR_SUCCESS; + int dim_count; + int i; + imeldata temp[MAX_CHAN_DIM]; + const size_t INT_LENGTH = 12; if ( swicms->_prep != NULL ) /* lda exists give them transformed lda. */ { @@ -308,19 +300,17 @@ ESR_ReturnCode swicms_get_cmn ( swicms_norm_info* swicms, const char **cmn_param for ( dim_count = 0; dim_count < MAX_CHAN_DIM; dim_count++ ) temp [dim_count] = swicms->cmn [dim_count]; } - current_params_position = 0; - - for ( dim_count = 0; dim_count < MAX_CHAN_DIM; dim_count++ ) + + for ( dim_count = 0, i = 0; dim_count < MAX_CHAN_DIM; dim_count++ ) { - if ( dim_count < ( MAX_CHAN_DIM - 1 ) ) - bytes_printed = sprintf ( chan_norm_params + current_params_position, "%d,", temp [dim_count] ); - else - bytes_printed = sprintf ( chan_norm_params + current_params_position, "%d", temp [dim_count] ); - current_params_position += bytes_printed; + i += sprintf( cmn_params + i, dim_count==0 ? "%d" : ",%d", temp [dim_count] ); + if (i + INT_LENGTH >= *len) { + *len = MAX_CHAN_DIM * (INT_LENGTH + 2) * sizeof(LCHAR); + return ESR_BUFFER_OVERFLOW; + } } - *cmn_params = chan_norm_params; - return ( get_status ); + return ESR_SUCCESS; } @@ -368,7 +358,7 @@ ESR_ReturnCode swicms_set_cmn ( swicms_norm_info* swicms, const char *cmn_params set_status = ESR_INVALID_ARGUMENT; } break; - + case ',': if ( got_word == 1 ) { @@ -385,7 +375,7 @@ ESR_ReturnCode swicms_set_cmn ( swicms_norm_info* swicms, const char *cmn_params } parsed_strings [dim_count] = copy_of_params + current_position; got_word = 0; - } + } else { PLogError ( "Channel Normalization : Too Many Params Must Contain %d Params\n", MAX_CHAN_DIM ); @@ -487,7 +477,7 @@ int apply_channel_normalization_in_swicms(swicms_norm_info *swicms, { int ii; ASSERT(dimen == MAX_CHAN_DIM); - + /* IF inutt is activated at all */ if(swicms->inutt.forget_factor2 != SWICMS_INUTT_FORGET_FACTOR2_DISABLE) { /* AND IF we have not disabled it (due to x-utt more reliable) */ @@ -497,7 +487,7 @@ int apply_channel_normalization_in_swicms(swicms_norm_info *swicms, swicms->inutt.num_frames_in_accum++; for(ii=0;ii<dimen;ii++) swicms->inutt.accum[ii] += iframe[ii]; /* AND IF we've already seen at least 10 frames (presumably) of speech */ - if(swicms->inutt.num_frames_in_accum>swicms->inutt.enable_after) { + if(swicms->inutt.num_frames_in_accum>swicms->inutt.enable_after) { /* THEN we update the adjustment in-line with the current utterance! */ for(ii=0;ii<dimen;ii++) { imeldata denom = ( swicms->inutt.forget_factor2 @@ -513,7 +503,7 @@ int apply_channel_normalization_in_swicms(swicms_norm_info *swicms, } swicms->inutt.num_frames_since_bou++; } - + for (ii = 0; ii < dimen; ii++) oframe[ii] = MAKEBYTE(iframe[ii] + swicms->adjust[ii]); return 0; @@ -628,12 +618,12 @@ int swicms_update(swicms_norm_info* swicms, int speech_start, int speech_end) { imeldata temp[MAX_CHAN_DIM]; PLogMessage("swicms_update() used %d frames (%d-%d)", nn, speech_start, speech_end); - + for(i=0;i<MAX_CHAN_DIM;i++) temp[i]=swicms->lda_cmn[i]; inverse_transform_frame( swicms->_prep, temp, 1 /*do_shift*/); /* use this dump, to put back into CREC.Frontend.swicms.cmn */ printf_vector("swicms.cmn(r) ", " %d", temp, MAX_CHAN_DIM); - + //printf_vector("swicms.lda_cmn ", " %d", &swicms.lda_cmn [0], MAX_CHAN_DIM); //printf_vector("swicms.lda_tmn ", " %d", &swicms.lda_tmn [0], MAX_CHAN_DIM); //printf_vector("swicms->adjust", " %d", swicms->adjust, MAX_CHAN_DIM); @@ -668,19 +658,19 @@ int swicms_lda_process(swicms_norm_info* swicms, preprocessed* prep) #endif swicms->is_valid = 1; swicms->_prep = prep; - - if(SWICMS_DEBUG) { + + if(SWICMS_DEBUG) { imeldata temp[MAX_CHAN_DIM]; printf_vector("swicms->cmn ", " %d", swicms->cmn, MAX_CHAN_DIM); printf_vector("swicms->lda_cmn ", " %d", swicms->lda_cmn, MAX_CHAN_DIM); //printf_vector("swicms->tmn ", " %d", swicms->tmn, MAX_CHAN_DIM); //printf_vector("swicms->lda_tmn ", " %d", swicms->lda_tmn, MAX_CHAN_DIM); //printf_vector("swicms->adjust ", " %d", swicms->adjust, MAX_CHAN_DIM); - + //for(i=0;i<MAX_CHAN_DIM;i++) temp[i]=swicms->lda_tmn[i]; //inverse_transform_frame( swicms->_prep, temp, 1 /*do_shift*/); //printf_vector("swicms->tmn(r) ", " %d", temp, MAX_CHAN_DIM); - + for(i=0;i<MAX_CHAN_DIM;i++) temp[i]=swicms->lda_cmn[i]; inverse_transform_frame( swicms->_prep, temp, 1 /*do_shift*/); printf_vector("swicms->cmn(r) ", " %d", temp, MAX_CHAN_DIM); diff --git a/srec/crec/srec_context.c b/srec/crec/srec_context.c index b00ec86..1de8f35 100644 --- a/srec/crec/srec_context.c +++ b/srec/crec/srec_context.c @@ -1,7 +1,7 @@ /*---------------------------------------------------------------------------* - * srec_context.c * + * srec_context.c * * * - * Copyright 2007, 2008 Nuance Communciations, Inc. * + * Copyright 2007, 2008 Nuance Communciations, Inc. * * * * Licensed under the Apache License, Version 2.0 (the 'License'); * * you may not use this file except in compliance with the License. * @@ -86,7 +86,7 @@ EXAMPLE: We need to cast a memory address to a (wordmap*) #define DATA_ALIGN(x, y, z) #endif -int do_minimize = 1; +static const int do_minimize = 1; #define PTR_TO_IDX(ptr, base) ((asr_uint32_t) (ptr == NULL ? 0xFFFFFFFFu : (asr_uint32_t)(ptr - base))) #define IDX_TO_PTR(idx, base) (idx == 0xFFFFFFFFu ? NULL : base + idx) @@ -298,8 +298,6 @@ modelID hmm_number(const char* hmm_Name, modelID hmm_ilabel_offset) char* hmm_name(modelID ilabel, modelID hmm_ilabel_offset, char* buf) { - static char mybuf[32]; - if (!buf) buf = mybuf; if (ilabel == EPSILON_LABEL) sprintf(buf, "eps"); else if (ilabel == WORD_BOUNDARY) @@ -1156,10 +1154,11 @@ int FST_DumpGraph(srec_context* fst, PFile* fp) { for (atok = ntoken->un_ptr.first_next_arc; atok != FSMARC_NULL; atok = atoken->linkl_next_arc) { + char buf[32]; atoken = ARC_XtoP(atok); into_node = NODE_XtoI(atoken->to_node); ilabel = fst->ilabels->num_words == 0 ? - hmm_name(atoken->ilabel, fst->hmm_ilabel_offset, NULL) : + hmm_name(atoken->ilabel, fst->hmm_ilabel_offset, buf) : fst->ilabels->words[atoken->ilabel] ; olabel = fst->olabels->words[atoken->olabel]; diff --git a/srec/crec/srec_debug.c b/srec/crec/srec_debug.c index 55eac65..1a9f087 100644 --- a/srec/crec/srec_debug.c +++ b/srec/crec/srec_debug.c @@ -23,9 +23,8 @@ #include "srec_tokens.h" -char* sprint_altwords(srec* rec, altword_token* awtoken) +static char* sprint_altwords(srec* rec, altword_token* awtoken, char* buf) { - static char buf[64]; char *bufp = &buf[0]; if (awtoken == AWTNULL) buf[0] = 0; @@ -46,15 +45,15 @@ void print_fsmnode_token(srec* rec, ftokenID token_index, char* msg) fsmnode_token *ftoken; char word_backtrace_trans[512]; char *p; + char buf[64]; if (token_index == MAXftokenID) { printf("%sftoken %d\n", msg, token_index); return; } ftoken = &rec->fsmnode_token_array[token_index]; -#define SPRINT_ALTWORDS(rEc,aWt) sprint_altwords(rEc,aWt) printf("%sftoken %d rec %d@%d fsmnode %d cost %d word %d(%s) word_backtrace %d next_token_index %d ", msg, token_index, rec->id, rec->current_search_frame, ftoken->FSMnode_index, ftoken->cost, ftoken->word, - SPRINT_ALTWORDS(rec, ftoken->aword_backtrace), + sprint_altwords(rec, ftoken->aword_backtrace, buf), ftoken->word_backtrace, ftoken->next_token_index); p = "null"; @@ -107,11 +106,12 @@ void print_fsmarc_token(srec* rec, stokenID token_index, char* msg) stoken->FSMarc_index, arc->ilabel, arc->to_node); for (i = 0; i < stoken->num_hmm_states; i++) { + char buf[64]; char *p = "null"; if (wordids[i] < context->olabels->num_words) p = context->olabels->words[wordids[i]]; sprint_bword_token_backtrace(word_backtrace_trans, 256, rec, word_backtrace[i]); printf(" w%d(%s)/%s/c%d/C%d/B%d/%d(%s)", wordids[i], - SPRINT_ALTWORDS(rec, stoken->aword_backtrace[i]), + sprint_altwords(rec, stoken->aword_backtrace[i], buf), p, costs[i], costs[i] + cost_offset, word_backtrace[i], duration[i], word_backtrace_trans); } printf("\n"); diff --git a/srec/crec/text_parser.c b/srec/crec/text_parser.c index 4b3dc15..b367b38 100644 --- a/srec/crec/text_parser.c +++ b/srec/crec/text_parser.c @@ -29,7 +29,7 @@ #define PARSE_PASS 0 #define PARSE_FAIL 1 -static char copy_of_word[MAX_LOCAL_LEN]; /* save heap on recursive function */ + static int check_word_path(srec_context* context, arc_token* atok, const char* transcription, int tlen) { @@ -37,59 +37,59 @@ static int check_word_path(srec_context* context, arc_token* atok, char *q; arc_token* next_atok; wordID wdID; - size_t copy_of_word_size; int q_position; - if ( strlen ( transcription ) >= MAX_LOCAL_LEN ) + if ( strlen ( transcription ) >= MAX_LOCAL_LEN - 1) + { + PLogError("Transcription too long [%s]\n", transcription); + return PARSE_FAIL; + } + + while (1) { + char copy_of_word[MAX_LOCAL_LEN]; /* save heap on recursive function */ + + /* wd points to the first char of last word */ + wd = transcription; + if (tlen > 0) { - PLogError("Transcription too long [%s]\n", transcription); - return PARSE_FAIL; + for (wd = transcription + tlen - 1; wd > transcription; wd--) + { + if (*wd == ' ') + { + wd++; + break; + } + } } - copy_of_word_size = sizeof(copy_of_word) / sizeof(char); - - /* wd points to the first char of last word */ - wd = transcription; - if (tlen > 0) - { - for (wd = transcription + tlen - 1; wd > transcription; wd--) + for (p = wd, q = copy_of_word; ; p++, q++) { - if (*wd == ' ') + q_position = q - copy_of_word; + if (q_position < 0 || (size_t)q_position >= MAX_LOCAL_LEN) + { + PLogError("Word too long in transcription [%s]\n", transcription); + return PARSE_FAIL; + } + *q = *p; + if (*p == ' ' || *p == '\0') { - wd++; + *q = 0; break; } } - } - for (p = wd, q = copy_of_word; ; p++, q++) - { - q_position = q - copy_of_word; - if ( ( q_position < 0 ) || ( (size_t)( q_position ) >= copy_of_word_size ) ) + wdID = wordmap_find_index(context->olabels, copy_of_word); + + if (wdID < MAXwordID) { - PLogError("Word too long in transcription [%s]\n", transcription); - return PARSE_FAIL; + next_atok = get_arc_for_word(atok, wdID, context, context->beg_silence_word); } - *q = *p; - if (*p == ' ' || *p == '\0') + else { - *q = 0; - break; + next_atok = get_arc_for_word_without_slot_annotation(atok, wd, context, context->beg_silence_word); + if (!next_atok) return PARSE_FAIL; } - } - wdID = wordmap_find_index(context->olabels, copy_of_word); - - if (wdID < MAXwordID) - { - next_atok = get_arc_for_word(atok, wdID, context, context->beg_silence_word); - } - else - { - next_atok = get_arc_for_word_without_slot_annotation(atok, wd, context, context->beg_silence_word); - if (!next_atok) - return PARSE_FAIL; - } + + if (!next_atok) return PARSE_FAIL; - if (next_atok) - { int whether_final_atok = 0; arc_token* tmp; for (tmp = ARC_TOKEN_PTR(context->arc_token_list, next_atok->first_next_arc); tmp != NULL; @@ -98,20 +98,12 @@ static int check_word_path(srec_context* context, arc_token* atok, if (tmp->ilabel == MAXwordID) whether_final_atok = 1; } - if (wd == transcription && whether_final_atok) - return PARSE_PASS; - else if (wd == transcription) - return PARSE_FAIL; - else - { - tlen--; - while (transcription[tlen] != ' ' && tlen > 0) tlen--; - return check_word_path(context, next_atok, transcription, tlen); - } - } - else - { - return PARSE_FAIL; + if (wd == transcription && whether_final_atok) return PARSE_PASS; + if (wd == transcription) return PARSE_FAIL; + tlen--; + while (transcription[tlen] != ' ' && tlen > 0) tlen--; + + atok = next_atok; } } diff --git a/srec/include/frontapi.h b/srec/include/frontapi.h index a8ddcae..b25b3de 100644 --- a/srec/include/frontapi.h +++ b/srec/include/frontapi.h @@ -1,7 +1,7 @@ /*---------------------------------------------------------------------------* - * frontapi.h * + * frontapi.h * * * - * Copyright 2007, 2008 Nuance Communciations, Inc. * + * Copyright 2007, 2008 Nuance Communciations, Inc. * * * * Licensed under the Apache License, Version 2.0 (the 'License'); * * you may not use this file except in compliance with the License. * @@ -11,7 +11,7 @@ * * * Unless required by applicable law or agreed to in writing, software * * distributed under the License is distributed on an 'AS IS' BASIS, * - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * * See the License for the specific language governing permissions and * * limitations under the License. * * * @@ -48,9 +48,9 @@ extern "C" ************************************************************************ */ #include "mutualob.h" - + #ifndef SWIGBUILD - + typedef struct { int ca_rtti; @@ -62,7 +62,7 @@ extern "C" voicing_info voice; } CA_Wave; - + typedef struct { int ca_rtti; @@ -76,19 +76,19 @@ extern "C" front_config *config; } CA_Frontend; - + #endif - + /** ************************************************************************ * SwigImageEnd <- DO NOT MOVE THIS LINE ! ************************************************************************ */ - + /* ** Frontend */ - + CA_Frontend* CA_AllocateFrontend(float srcscale, int offset, float sinkscale); @@ -106,8 +106,8 @@ extern "C" * Allocates a front-end object ************************************************************************ */ - - + + void CA_FreeFrontend(CA_Frontend* hFrontend); /** * @@ -121,8 +121,8 @@ extern "C" * Deletes a front-end object ************************************************************************ */ - - + + void CA_ConfigureFrontend(CA_Frontend *hFrontend, CA_FrontendInputParams *hFrontArgs); /** @@ -140,8 +140,8 @@ extern "C" * create and setup functions. ************************************************************************ */ - - + + void CA_SetWarpScale(CA_Frontend *hFrontend, float wscale); /** * @@ -155,7 +155,7 @@ extern "C" ************************************************************************ ************************************************************************ */ - + void CA_UnconfigureFrontend(CA_Frontend *hFrontend); /** * @@ -169,8 +169,8 @@ extern "C" * Undo all of the front end configurations ************************************************************************ */ - - + + int CA_MakeFrame(CA_Frontend* hFrontend, CA_Utterance* hUtt, CA_Wave* hWave); @@ -191,8 +191,8 @@ extern "C" * this method returns zero to the caller. ************************************************************************ */ - - + + int CA_GetFrontendFramesPerValidFrame(CA_Frontend *hFrontend); int CA_GetFrontendSampleRate(CA_Frontend *hFrontend); /** @@ -207,8 +207,8 @@ extern "C" * Gets the sample rate from the front end object ************************************************************************ */ - - + + int CA_GetFrontendUtteranceDimension(CA_Frontend *hFrontend); /** * @@ -224,8 +224,8 @@ extern "C" * Returns the number of items in an utterance. ************************************************************************ */ - - + + int CA_GetRecognitionHoldoff(CA_FrontendInputParams *hFrontPar); /** * @@ -239,20 +239,20 @@ extern "C" * a par file is unnecessary if this function is used. ************************************************************************ */ - - + + /* ** Channel normalization */ -ESR_ReturnCode CA_GetCMSParameters ( CA_Wave *hWave, const LCHAR **param_string ); +ESR_ReturnCode CA_GetCMSParameters ( CA_Wave *hWave, LCHAR *param_string, size_t* len ); ESR_ReturnCode CA_SetCMSParameters ( CA_Wave *hWave, const LCHAR *param_string ); void CA_ReLoadCMSParameters(CA_Wave *hWave, const char *basename); - + void CA_LoadCMSParameters(CA_Wave *hWave, - char *basename, + const char *basename, CA_FrontendInputParams *hFrontArgs); /** @@ -272,8 +272,8 @@ ESR_ReturnCode CA_SetCMSParameters ( CA_Wave *hWave, const LCHAR *param_string ) * The .cmn and .tmn files must obviously have the same basename. ************************************************************************ */ - - + + void CA_SaveCMSParameters(CA_Wave *hWave, const char *basename); /** @@ -296,8 +296,8 @@ ESR_ReturnCode CA_SetCMSParameters ( CA_Wave *hWave, const LCHAR *param_string ) * The .cmn and .tmn files will obviously have the same basename. ************************************************************************ */ - - + + void CA_ClearCMSParameters(CA_Wave *hWave); /** * @@ -315,7 +315,7 @@ ESR_ReturnCode CA_SetCMSParameters ( CA_Wave *hWave, const LCHAR *param_string ) * has been called. ************************************************************************ */ - + void CA_AttachCMStoUtterance(CA_Wave *hWave, CA_Utterance *hUtt); /** @@ -335,7 +335,7 @@ ESR_ReturnCode CA_SetCMSParameters ( CA_Wave *hWave, const LCHAR *param_string ) * CA_Wave object. ************************************************************************ */ - + /** * Returns true if CMS is attached to utterance. * @@ -343,7 +343,7 @@ ESR_ReturnCode CA_SetCMSParameters ( CA_Wave *hWave, const LCHAR *param_string ) * @param isAttached [out] True if attached */ ESR_ReturnCode CA_IsCMSAttachedtoUtterance(CA_Wave* hWave, ESR_BOOL* isAttached); - + /** * Returns true if CA_Wave is configured for Agc. * @@ -351,7 +351,7 @@ ESR_ReturnCode CA_SetCMSParameters ( CA_Wave *hWave, const LCHAR *param_string ) * @param isAttached [out] True if attached */ ESR_ReturnCode CA_IsConfiguredForAgc(CA_Wave* hWave, ESR_BOOL* isConfigured); - + void CA_DetachCMSfromUtterance(CA_Wave *hWave, CA_Utterance *hUtt); /** @@ -372,8 +372,8 @@ ESR_ReturnCode CA_SetCMSParameters ( CA_Wave *hWave, const LCHAR *param_string ) * CA_Wave object. ************************************************************************ */ - - + + void CA_CalculateCMSParameters(CA_Wave *hWave); /** * @@ -392,8 +392,8 @@ ESR_ReturnCode CA_SetCMSParameters ( CA_Wave *hWave, const LCHAR *param_string ) * subsequently to a CA_AttachCMStoUtterance. ************************************************************************ */ - - + + void CA_DiscardCMSAccumulates(CA_Wave *hWave); /** * @@ -411,9 +411,9 @@ ESR_ReturnCode CA_SetCMSParameters ( CA_Wave *hWave, const LCHAR *param_string ) * CMS parameters must have been loaded and attached to the wave. ************************************************************************ */ - - - + + + /* ** Wave */ @@ -429,7 +429,7 @@ ESR_ReturnCode CA_SetCMSParameters ( CA_Wave *hWave, const LCHAR *param_string ) * a physical device is external to CREC-API. ************************************************************************ */ - + CA_Wave* CA_AllocateWave(char typ); /** * @@ -453,8 +453,8 @@ ESR_ReturnCode CA_SetCMSParameters ( CA_Wave *hWave, const LCHAR *param_string ) * to CA_ConfigureWave(). ************************************************************************ */ - - + + void CA_ConfigureWave(CA_Wave *hWave, CA_Frontend *hFrontend); /** @@ -472,8 +472,8 @@ ESR_ReturnCode CA_SetCMSParameters ( CA_Wave *hWave, const LCHAR *param_string ) * This should be called before any other Wave methods. ************************************************************************ */ - - + + void CA_ConfigureVoicingAnalysis(CA_Wave *hWave, CA_FrontendInputParams *hFrontPar); /** @@ -487,8 +487,8 @@ ESR_ReturnCode CA_SetCMSParameters ( CA_Wave *hWave, const LCHAR *param_string ) * Initializes a Wave's voicin analysis module. ************************************************************************ */ - - + + void CA_ResetWave(CA_Wave *hWave); /** * @@ -503,8 +503,8 @@ ESR_ReturnCode CA_SetCMSParameters ( CA_Wave *hWave, const LCHAR *param_string ) * ************************************************************************ */ - - + + void CA_UnconfigureWave(CA_Wave *hWave); /** * @@ -518,8 +518,8 @@ ESR_ReturnCode CA_SetCMSParameters ( CA_Wave *hWave, const LCHAR *param_string ) * Uninitializes a Wave structure. ************************************************************************ */ - - + + void CA_FreeWave(CA_Wave *hWave); /** * @@ -533,8 +533,8 @@ ESR_ReturnCode CA_SetCMSParameters ( CA_Wave *hWave, const LCHAR *param_string ) * Removes a previously allocated Wave structure ************************************************************************ */ - - + + int CA_OpenWaveFromFile(CA_Wave *hWave, char* filename, char typ, @@ -566,8 +566,8 @@ ESR_ReturnCode CA_SetCMSParameters ( CA_Wave *hWave, const LCHAR *param_string ) * It is an error to call this function without first configuring hWave ************************************************************************ */ - - + + void CA_CloseFile(CA_Wave *hWave); /** * @@ -581,8 +581,8 @@ ESR_ReturnCode CA_SetCMSParameters ( CA_Wave *hWave, const LCHAR *param_string ) * It is an error to call this function without first configuring hWave ************************************************************************ */ - - + + int CA_OpenWaveFromDevice(CA_Wave *hWave, int wave_type, int samplerate, @@ -614,8 +614,8 @@ ESR_ReturnCode CA_SetCMSParameters ( CA_Wave *hWave, const LCHAR *param_string ) * or WAVE_DEVICE_RAW (if using the raw interface - CA_LoadSamples) ************************************************************************ */ - - + + void CA_CloseDevice(CA_Wave *hWave); /** * @@ -629,8 +629,8 @@ ESR_ReturnCode CA_SetCMSParameters ( CA_Wave *hWave, const LCHAR *param_string ) * It is an error to call this function without first configuring hWave ************************************************************************ */ - - + + void CA_SetWaveBoostValue(CA_Wave *hWave, int waveBoost); /** @@ -648,8 +648,8 @@ ESR_ReturnCode CA_SetCMSParameters ( CA_Wave *hWave, const LCHAR *param_string ) * It is an error to call this function without first configuring hWave ************************************************************************ */ - - + + int CA_GetWaveBoostValue(CA_Wave *hWave); /** * @@ -661,8 +661,8 @@ ESR_ReturnCode CA_SetCMSParameters ( CA_Wave *hWave, const LCHAR *param_string ) * It is an error to call this function without first configuring hWave ************************************************************************ */ - - + + int CA_GetSampleRate(CA_Wave *hWave); /** * @@ -677,8 +677,8 @@ ESR_ReturnCode CA_SetCMSParameters ( CA_Wave *hWave, const LCHAR *param_string ) * It is an error to call this function without first configuring hWave ************************************************************************ */ - - + + void CA_CopyWaveSegment(CA_Wave *source, CA_Wave *sink, unsigned long offset, @@ -702,8 +702,8 @@ ESR_ReturnCode CA_SetCMSParameters ( CA_Wave *hWave, const LCHAR *param_string ) * the 'source' and 'sink' wave objects. ************************************************************************ */ - - + + int CA_GetBufferSize(CA_Wave *hWave); /** * @@ -724,8 +724,8 @@ ESR_ReturnCode CA_SetCMSParameters ( CA_Wave *hWave, const LCHAR *param_string ) * It is an error to call this function without first configuring hWave ************************************************************************ */ - - + + #ifndef SWIGBUILD int CA_LoadSamples(CA_Wave *hWave, samdata *pPCMData, @@ -759,8 +759,8 @@ ESR_ReturnCode CA_SetCMSParameters ( CA_Wave *hWave, const LCHAR *param_string ) * It is an error to call this function without first configuring hWave ************************************************************************ */ - - + + int CA_ReadSamplesForFrame(CA_Wave *hWave); /** * @@ -774,8 +774,8 @@ ESR_ReturnCode CA_SetCMSParameters ( CA_Wave *hWave, const LCHAR *param_string ) * It is an error to call this function without first configuring hWave ************************************************************************ */ - - + + int CA_SaveSamplesForFrame(CA_Wave *hWave); /** * @@ -789,8 +789,8 @@ ESR_ReturnCode CA_SetCMSParameters ( CA_Wave *hWave, const LCHAR *param_string ) * It is an error to call this function without first configuring hWave ************************************************************************ */ - - + + void CA_ConditionSamples(CA_Wave *hWave); /** * @@ -806,8 +806,8 @@ ESR_ReturnCode CA_SetCMSParameters ( CA_Wave *hWave, const LCHAR *param_string ) * It is an error to call this function without first configuring hWave ************************************************************************ */ - - + + void CA_CopyWaveSamples(CA_Wave *hWaveIn, CA_Wave *hWaveOut); /** @@ -829,8 +829,8 @@ ESR_ReturnCode CA_SetCMSParameters ( CA_Wave *hWave, const LCHAR *param_string ) * the 'hWaveIn' and 'hWaveOut' wave objects. ************************************************************************ */ - - + + int CA_WaveIsOutput(CA_Wave *hWave); /** * @@ -845,8 +845,8 @@ ESR_ReturnCode CA_SetCMSParameters ( CA_Wave *hWave, const LCHAR *param_string ) * and setting it up as a device or a file ************************************************************************ */ - - + + int CA_WaveIsInput(CA_Wave *hWave); /** * @@ -861,8 +861,8 @@ ESR_ReturnCode CA_SetCMSParameters ( CA_Wave *hWave, const LCHAR *param_string ) * and setting it up as a device or a file ************************************************************************ */ - - + + int CA_WaveIsADevice(CA_Wave *hWave); /** * @@ -877,8 +877,8 @@ ESR_ReturnCode CA_SetCMSParameters ( CA_Wave *hWave, const LCHAR *param_string ) * and setting it up as a device or a file ************************************************************************ */ - - + + int CA_WaveIsAFile(CA_Wave *hWave); /** * @@ -893,7 +893,7 @@ ESR_ReturnCode CA_SetCMSParameters ( CA_Wave *hWave, const LCHAR *param_string ) * and setting it up as a device or a file ************************************************************************ */ - + void CA_StartSigCheck(CA_Wave *hWave); void CA_StopSigCheck(CA_Wave *hWave); void CA_ResetSigCheck(CA_Wave *hWave); @@ -903,9 +903,9 @@ ESR_ReturnCode CA_SetCMSParameters ( CA_Wave *hWave, const LCHAR *param_string ) ESR_BOOL CA_DoSignalCheck(CA_Wave *hWave, ESR_BOOL *clipping, ESR_BOOL *dcoffset, ESR_BOOL *highnoise, ESR_BOOL *quietspeech, ESR_BOOL *too_few_samples, ESR_BOOL *too_many_samples); - - - + + + /* Frontend parameter API */ /** @@ -921,9 +921,9 @@ ESR_ReturnCode CA_SetCMSParameters ( CA_Wave *hWave, const LCHAR *param_string ) * used to read a given parameter file. ************************************************************************ */ - - - + + + CA_FrontendInputParams* CA_AllocateFrontendParameters(void); /** * @@ -938,8 +938,8 @@ ESR_ReturnCode CA_SetCMSParameters ( CA_Wave *hWave, const LCHAR *param_string ) * Creates a new front-end input paramater onject ************************************************************************ */ - - + + void CA_LoadFrontendParameters(CA_FrontendInputParams* hFrontpar, const char* parfile); /** @@ -957,8 +957,8 @@ ESR_ReturnCode CA_SetCMSParameters ( CA_Wave *hWave, const LCHAR *param_string ) * The file is a .par file ************************************************************************ */ - - + + void CA_FreeFrontendParameters(CA_FrontendInputParams* hFrontpar); /** * @@ -972,8 +972,8 @@ ESR_ReturnCode CA_SetCMSParameters ( CA_Wave *hWave, const LCHAR *param_string ) * Removes a previously allocated parameter object ************************************************************************ */ - - + + void CA_SaveFrontendParameters(CA_FrontendInputParams* hFrontpar, const char* parfile); /** @@ -993,8 +993,8 @@ ESR_ReturnCode CA_SetCMSParameters ( CA_Wave *hWave, const LCHAR *param_string ) * front-end input parameters. ************************************************************************ */ - - + + int CA_SetFrontendParameter(CA_FrontendInputParams *hFrontpar, char *key, char *value); @@ -1018,8 +1018,8 @@ ESR_ReturnCode CA_SetCMSParameters ( CA_Wave *hWave, const LCHAR *param_string ) * front-end input parameters. ************************************************************************ */ - - + + int CA_GetFrontendParameter(CA_FrontendInputParams *hFrontpar, char *key, void *value); @@ -1042,7 +1042,7 @@ ESR_ReturnCode CA_SetCMSParameters ( CA_Wave *hWave, const LCHAR *param_string ) * front-end input parameters. ************************************************************************ */ - + int CA_GetFrontendStringParameter(CA_FrontendInputParams *hFrontpar, char *key, char *value, @@ -1068,7 +1068,7 @@ ESR_ReturnCode CA_SetCMSParameters ( CA_Wave *hWave, const LCHAR *param_string ) * front-end input parameters. ************************************************************************ */ - + int CA_LoadSpectrumFilter(CA_Frontend *hFrontend, char *basename); /** * @@ -1088,7 +1088,7 @@ ESR_ReturnCode CA_SetCMSParameters ( CA_Wave *hWave, const LCHAR *param_string ) * front-end input parameters. ************************************************************************ */ - + void CA_ClearSpectrumFilter(CA_Frontend *hFrontend); /** * @@ -1105,7 +1105,7 @@ ESR_ReturnCode CA_SetCMSParameters ( CA_Wave *hWave, const LCHAR *param_string ) * front-end input parameters. ************************************************************************ */ - + int CA_IsSpectrumFilterLoaded(CA_Frontend *hFrontend); /** * @@ -1119,12 +1119,12 @@ ESR_ReturnCode CA_SetCMSParameters ( CA_Wave *hWave, const LCHAR *param_string ) * ************************************************************************ */ - + void CA_EnableNonlinearFilter(CA_Frontend *hFrontend); void CA_DisableNonlinearFilter(CA_Frontend *hFrontend); void CA_EnableSpectrumFilter(CA_Frontend *hFrontend); void CA_DisableSpectrumFilter(CA_Frontend *hFrontend); - + #ifdef __cplusplus } #endif diff --git a/srec/include/log_tabl.h b/srec/include/log_tabl.h index bd0eaae..eac247b 100644 --- a/srec/include/log_tabl.h +++ b/srec/include/log_tabl.h @@ -32,7 +32,7 @@ typedef struct int shift; int scale; unsigned long mask; - int *table; + const int *table; } log_table_info; diff --git a/srec/include/pre_desc.h b/srec/include/pre_desc.h index 4b7eef6..bdfb7f8 100644 --- a/srec/include/pre_desc.h +++ b/srec/include/pre_desc.h @@ -77,7 +77,7 @@ mul_table_info; */ typedef struct { - prdata *table; + const prdata *table; prdata add_log_limit; prdata scale; /* X - scale to log function */ prdata inv_scale; diff --git a/srec/include/swicms.h b/srec/include/swicms.h index 12504b3..650fbc3 100644 --- a/srec/include/swicms.h +++ b/srec/include/swicms.h @@ -1,7 +1,7 @@ /*---------------------------------------------------------------------------* - * swicms.h * + * swicms.h * * * - * Copyright 2007, 2008 Nuance Communciations, Inc. * + * Copyright 2007, 2008 Nuance Communciations, Inc. * * * * Licensed under the Apache License, Version 2.0 (the 'License'); * * you may not use this file except in compliance with the License. * @@ -11,7 +11,7 @@ * * * Unless required by applicable law or agreed to in writing, software * * distributed under the License is distributed on an 'AS IS' BASIS, * - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * * See the License for the specific language governing permissions and * * limitations under the License. * * * @@ -40,7 +40,7 @@ typedef struct imelvec; /** - * Does channel normalization without using fine recognition segmenation. It remembers the + * Does channel normalization without using fine recognition segmenation. It remembers the * frames of speech and uses that as a channel mean for the next utterance. A forget_factor * is used to weigh the new speech mean estimate with an older one. */ @@ -48,12 +48,12 @@ typedef struct { imeldata tmn [MAX_CHAN_DIM]; /* target mean */ imeldata cmn [MAX_CHAN_DIM]; /* channel mean */ - + imeldata lda_tmn [MAX_CHAN_DIM]; /* target mean */ imeldata lda_cmn [MAX_CHAN_DIM]; /* channel mean */ - + imeldata adjust[MAX_CHAN_DIM]; /* target less channel */ - + int is_valid; int forget_factor; /* in frames, mass of cmn average */ int sbindex; /* speech to background index @@ -78,7 +78,7 @@ typedef struct int cached_num_frames; /* we cache frames, until recognition is done and can calculate speech mean from these */ int cache_resolution; /* we'll avg this many frames per section */ - imeldata cached_sections[SWICMS_CACHE_SIZE_DEFAULT][MAX_CHAN_DIM]; + imeldata cached_sections[SWICMS_CACHE_SIZE_DEFAULT][MAX_CHAN_DIM]; /*const*/ preprocessed* _prep; } swicms_norm_info; @@ -93,7 +93,7 @@ int swicms_lda_process(swicms_norm_info* swicms, preprocessed* prep); int swicms_update(swicms_norm_info* swicms, int speech_start_frame, int speech_end_frame); ESR_ReturnCode swicms_set_cmn(swicms_norm_info *swicms, const LCHAR *new_cmn_params ); -ESR_ReturnCode swicms_get_cmn(swicms_norm_info *swicms, const LCHAR **cmn_params ); +ESR_ReturnCode swicms_get_cmn(swicms_norm_info *swicms, LCHAR *cmn_params, size_t* len ); #if DEBUG_SWICMS int swicms_compare(swicms_norm_info* swicms, imeldata* imelda_adjust); diff --git a/srec/test/SRecTest/src/SRecTest.c b/srec/test/SRecTest/src/SRecTest.c index bc8d81b..072a650 100644 --- a/srec/test/SRecTest/src/SRecTest.c +++ b/srec/test/SRecTest/src/SRecTest.c @@ -1687,10 +1687,12 @@ int srec_test_get_acousticstate ( ApplicationData *data ) { int get_status; ESR_ReturnCode esr_status; - const LCHAR *state_string; + LCHAR state_string[1000]; + size_t len; get_status = 0; - esr_status = SR_AcousticStateGet ( data->recognizer, &state_string ); + len = sizeof(state_string); + esr_status = SR_AcousticStateGet ( data->recognizer, state_string, &len ); if ( esr_status == ESR_SUCCESS ) { diff --git a/srec_jni/android_speech_srec_Recognizer.cpp b/srec_jni/android_speech_srec_Recognizer.cpp index 5a0fc44..c71159b 100644 --- a/srec_jni/android_speech_srec_Recognizer.cpp +++ b/srec_jni/android_speech_srec_Recognizer.cpp @@ -328,13 +328,15 @@ static JNIEXPORT void JNICALL Java_android_speech_srec_Recognizer_SR_1AcousticSt static JNIEXPORT jstring JNICALL Java_android_speech_srec_Recognizer_SR_1AcousticStateGet (JNIEnv *env, jclass clazz, jint recognizer) { - const LCHAR* st = NULL; - ESR_ReturnCode esr_status = SR_AcousticStateGet((SR_Recognizer*)recognizer, &st); - if (esr_status || st == NULL) { + char rtn[1000]; + size_t rtnLength = sizeof(rtn) - 1; + ESR_ReturnCode esr_status = SR_AcousticStateGet((SR_Recognizer*)recognizer, rtn, &rtnLength); + if (esr_status) { checkEsrError(env, esr_status); return NULL; } - return env->NewStringUTF(st); + rtn[rtnLength] = 0; + return env->NewStringUTF(rtn); } |