comparison index.cpp @ 305:8cec6eb40526

Guard against too-short tracks. Fixes a segfault on attempting to index the AWAL.frames1.mfcc20.adb with default parameters.
author mas01cr
date Tue, 05 Aug 2008 15:34:10 +0000
parents f922c234462f
children 896679d8cc39
comparison
equal deleted inserted replaced
304:2d6efbe56bb8 305:8cec6eb40526
224 std::cout << "finished inserting." << endl; 224 std::cout << "finished inserting." << endl;
225 } 225 }
226 226
227 int audioDB::index_insert_track(Uns32T trackID, double** fvpp, double** snpp, double** sppp){ 227 int audioDB::index_insert_track(Uns32T trackID, double** fvpp, double** snpp, double** sppp){
228 // Loop over the current input track's vectors 228 // Loop over the current input track's vectors
229 Uns32T numVecs = (trackTable[trackID]>O2_MAXTRACKLEN?O2_MAXTRACKLEN:trackTable[trackID]) - sequenceLength + 1 ; 229 Uns32T numVecs = 0;
230 if (trackTable[trackID] > O2_MAXTRACKLEN) {
231 if (O2_MAXTRACKLEN < sequenceLength - 1) {
232 numVecs = 0;
233 } else {
234 numVecs = O2_MAXTRACKLEN - sequenceLength + 1;
235 }
236 } else {
237 if (trackTable[trackID] < sequenceLength - 1) {
238 numVecs = 0;
239 } else {
240 numVecs = trackTable[trackID] - sequenceLength + 1;
241 }
242 }
230 vv = index_initialize_shingles(numVecs); 243 vv = index_initialize_shingles(numVecs);
231 244
232 for( Uns32T pointID = 0 ; pointID < numVecs; pointID++ ) 245 for( Uns32T pointID = 0 ; pointID < numVecs; pointID++ )
233 index_make_shingle(vv, pointID, *fvpp, dbH->dim, sequenceLength); 246 index_make_shingle(vv, pointID, *fvpp, dbH->dim, sequenceLength);
234 247