rjw | 6c1fd8f | 2022-11-30 14:33:01 +0800 | [diff] [blame] | 1 | /*============================================================================*/ |
| 2 | /* eCall ANSI C fixed-point reference source code */ |
| 3 | /* */ |
| 4 | /* File: ecall_sync.h */ |
| 5 | /* Version: 12.0.0 (Rel12) */ |
| 6 | /* Date: 2014-09-11 */ |
| 7 | /* Description: synchronization functions (header file) */ |
| 8 | /*----------------------------------------------------------------------------*/ |
| 9 | |
| 10 | #ifndef ECALL_SYNC_H_ |
| 11 | #define ECALL_SYNC_H_ |
| 12 | |
| 13 | #include "ecall_defines.h" |
| 14 | |
| 15 | |
| 16 | typedef struct { |
| 17 | Int32 amplitude[2]; /* amplitudes (average, maximum) */ |
| 18 | Int32 shape[2*NRS_CP+1]; /* shape of peak causing a sync event */ |
| 19 | Int32 sign; /* sync sign marker */ |
| 20 | |
| 21 | Bool flag; /* indicates sync success */ |
| 22 | Int16 delay; /* synchronization delay */ |
| 23 | Int16 npeaks; /* number of sync peaks detected */ |
| 24 | Int16 npeaksChk; /* number of sync peaks detected by sync check */ |
| 25 | } SyncSub; |
| 26 | |
| 27 | typedef struct { |
| 28 | Int32 *mem; /* memory for sync */ |
| 29 | Int32 *memWakeup; /* memory for wakeup tone detector */ |
| 30 | |
| 31 | SyncSub syncPos; /* regular sync (non-inverted) */ |
| 32 | SyncSub syncNeg; /* inverted sync */ |
| 33 | |
| 34 | Int32 amplitude[3]; /* amplitudes (average, maximum, memory) */ |
| 35 | Int32 shape[2*NRS_CP+1]; /* shape of peak causing a sync event */ |
| 36 | Int32 sign; /* sync sign marker */ |
| 37 | |
| 38 | Bool flag; /* indicates sync success */ |
| 39 | Bool invert; /* indicates sync inversion */ |
| 40 | Bool resync; /* indicates resynchronization event */ |
| 41 | |
| 42 | Int16 delay; /* synchronization delay */ |
| 43 | Int16 delayMem; /* synchronization delay (memory) */ |
| 44 | Int16 npeaks; /* number of sync peaks detected */ |
| 45 | Int16 npeaksMem; /* number of sync peaks detected (memory) */ |
| 46 | Int16 events; /* number of subsequent equal sync events */ |
| 47 | |
| 48 | Tern check; /* indicates sync check result (ternary variable) */ |
| 49 | Int16 checkCnt; /* counter for subsequent sync check failures */ |
| 50 | Int16 index; /* frame reference for sync evaluation */ |
| 51 | } SyncState; |
| 52 | |
| 53 | |
| 54 | /*============================================================================*/ |
| 55 | /* Sync functions */ |
| 56 | /*----------------------------------------------------------------------------*/ |
| 57 | |
| 58 | void SyncReset(SyncState*, Int32*, Int32*); |
| 59 | void SyncSubReset(SyncSub*); |
| 60 | |
| 61 | void Sync(SyncState*, const Int16*, const char*, Bool); |
| 62 | void SyncCheck(SyncState*, const Int16*, const char*); |
| 63 | void SyncTrack(SyncState*, Bool); |
| 64 | |
| 65 | void SyncFilter(SyncState*, const Int16*, Bool); |
| 66 | |
| 67 | void SyncSubPut(const SyncState*, SyncSub*); |
| 68 | void SyncSubGet(SyncState*, const SyncSub*); |
| 69 | void SyncSubCpy(const SyncSub*, SyncSub*); |
| 70 | |
| 71 | void SyncSubRun(SyncSub*, const char*, |
| 72 | const Int32*, const Int32*, const Int32*, const Int32*); |
| 73 | void SyncSubChk(SyncSub*, const char*, |
| 74 | const Int32*, const Int32*, const Int32*, const Int32*, Int16); |
| 75 | |
| 76 | Int16 PeakUpdate(const Int32*, const Int32*, Int16); |
| 77 | void PeakCheck(SyncSub*, const char*, const Bool*, const Int16*, |
| 78 | const Int32*, const Int32*, const Int32*, |
| 79 | Int16, Int16, Int16, Int16); |
| 80 | |
| 81 | void ToneDetect(SyncState*, const Int16*); |
| 82 | |
| 83 | #endif |