comparison audioDB.cpp @ 57:67de6f2c5f7d

Fix a couple of off-by-one errors, including one which was preventing a sequence match of the length of the track from matching, and one which was causing the threshold computation to yield NaN for one-frame tracks. Mark a couple more off-by-one errors as needing to be fixed.
author mas01cr
date Thu, 20 Sep 2007 11:30:24 +0000
parents 32f8b7845b30
children 7e18b5adce8c
comparison
equal deleted inserted replaced
56:c02b5a6104a9 57:67de6f2c5f7d
1518 *pn++=0.0; 1518 *pn++=0.0;
1519 ps=sNorm; 1519 ps=sNorm;
1520 unsigned processedTracks=0; 1520 unsigned processedTracks=0;
1521 for(i=0; i<dbH->numFiles; i++){ 1521 for(i=0; i<dbH->numFiles; i++){
1522 if(trackTable[i]>sequenceLength-1){ 1522 if(trackTable[i]>sequenceLength-1){
1523 w = trackTable[i]-sequenceLength; 1523 w = trackTable[i]-sequenceLength+1;
1524 pn = sMeanL2+i; 1524 pn = sMeanL2+i;
1525 *pn=0; 1525 *pn=0;
1526 while(w--) 1526 while(w--)
1527 if(*ps>0) 1527 if(*ps>0)
1528 *pn+=*ps++; 1528 *pn+=*ps++;
1529 *pn/=trackTable[i]-sequenceLength; 1529 *pn/=trackTable[i]-sequenceLength+1;
1530 SILENCE_THRESH+=*pn; 1530 SILENCE_THRESH+=*pn;
1531 processedTracks++; 1531 processedTracks++;
1532 } 1532 }
1533 ps = sNorm + trackTable[i]; 1533 ps = sNorm + trackTable[i];
1534 } 1534 }
1697 } 1697 }
1698 1698
1699 trackOffset=trackOffsetTable[track]; // numDoubles offset 1699 trackOffset=trackOffsetTable[track]; // numDoubles offset
1700 trackIndexOffset=trackOffset/dbH->dim; // numVectors offset 1700 trackIndexOffset=trackOffset/dbH->dim; // numVectors offset
1701 1701
1702 if(sequenceLength<trackTable[track]){ // test for short sequences 1702 if(sequenceLength<=trackTable[track]){ // test for short sequences
1703 1703
1704 if(verbosity>7) 1704 if(verbosity>7)
1705 cerr << track << "." << trackIndexOffset << "." << trackTable[track] << " | ";cerr.flush(); 1705 cerr << track << "." << trackIndexOffset << "." << trackTable[track] << " | ";cerr.flush();
1706 1706
1707 // Sum products matrix 1707 // Sum products matrix
1799 thisDist=thisDist; // Computed above 1799 thisDist=thisDist; // Computed above
1800 else 1800 else
1801 thisDist=1000000.0; 1801 thisDist=1000000.0;
1802 1802
1803 // k-NN match algorithm 1803 // k-NN match algorithm
1804 m=pointNN; 1804 m=pointNN; /* FIXME: -1? distances[pointNN] */
1805 while(m--){ 1805 while(m--){
1806 if(thisDist<=distances[m]) 1806 if(thisDist<=distances[m])
1807 if(m==0 || thisDist>=distances[m-1]){ 1807 if(m==0 || thisDist>=distances[m-1]){
1808 // Shuffle distances up the list 1808 // Shuffle distances up the list
1809 for(l=pointNN-1; l>m; l--){ 1809 for(l=pointNN-1; l>m; l--){
1833 if(verbosity>3) 1833 if(verbosity>3)
1834 cerr << fileTable+track*O2_FILETABLESIZE << " " << thisDist << endl; 1834 cerr << fileTable+track*O2_FILETABLESIZE << " " << thisDist << endl;
1835 1835
1836 1836
1837 // All the track stuff goes here 1837 // All the track stuff goes here
1838 n=trackNN; 1838 n=trackNN; /* FIXME: trackNN-1 */
1839 while(n--){ 1839 while(n--){
1840 if(thisDist<=trackDistances[n]){ 1840 if(thisDist<=trackDistances[n]){
1841 if((n==0 || thisDist>=trackDistances[n-1])){ 1841 if((n==0 || thisDist>=trackDistances[n-1])){
1842 // Copy all values above up the queue 1842 // Copy all values above up the queue
1843 for( l=trackNN-1 ; l > n ; l--){ 1843 for( l=trackNN-1 ; l > n ; l--){