Mercurial > hg > audiodb
diff dump.cpp @ 432:62a0515f59be api-inversion
Include track_lengths data structure in struct adb.
Remove mapping of trackTable where I can...
author | mas01cr |
---|---|
date | Wed, 24 Dec 2008 10:55:44 +0000 |
parents | d7e590d58c85 |
children |
line wrap: on
line diff
--- a/dump.cpp Wed Dec 24 10:55:40 2008 +0000 +++ b/dump.cpp Wed Dec 24 10:55:44 2008 +0000 @@ -6,12 +6,10 @@ int audiodb_dump(adb_t *adb, const char *output) { char *fileTable = 0; /* key_table */ - unsigned *trackTable = 0; /* track_size_table */ double *timesTable = 0; /* timestamps_table */ double *powerTable = 0; /* power_table */ size_t fileTableLength = 0; - size_t trackTableLength = 0; size_t timesTableLength = 0; size_t powerTableLength = 0; @@ -39,7 +37,6 @@ if(adb->header->length > 0) { fileTableLength = ALIGN_PAGE_UP(nfiles * O2_FILETABLE_ENTRY_SIZE); - trackTableLength = ALIGN_PAGE_UP(nfiles * O2_TRACKTABLE_ENTRY_SIZE); if(!(adb->header->flags & O2_FLAG_LARGE_ADB)) { off_t length = adb->header->length; unsigned dim = adb->header->dim; @@ -48,7 +45,6 @@ } mmap_or_goto_error(char *, fileTable, adb->header->fileTableOffset, fileTableLength); - mmap_or_goto_error(unsigned *, trackTable, adb->header->trackTableOffset, trackTableLength); if (adb->header->flags & O2_FLAG_LARGE_ADB) { mmap_or_goto_error(char *, featureFileNameTable, adb->header->dataOffset, fileTableLength); mmap_or_goto_error(char *, powerFileNameTable, adb->header->powerTableOffset, fileTableLength); @@ -139,7 +135,7 @@ /* FIXME: this repeated malloc()/free() of data buffers is inefficient. */ - data_buffer_size = trackTable[k] * adb->header->dim * sizeof(double); + data_buffer_size = (*adb->track_lengths)[k] * adb->header->dim * sizeof(double); { void *tmp = malloc(data_buffer_size); @@ -164,7 +160,7 @@ if (times) { snprintf(fName, 256, "%05d.times", k); tFile = fopen(fName, "w"); - for(unsigned i = 0; i < trackTable[k]; i++) { + for(unsigned i = 0; i < (*adb->track_lengths)[k]; i++) { // KLUDGE: specifying 16 digits of precision after the decimal // point is (but check this!) sufficient to uniquely identify // doubles; however, that will cause ugliness, as that's @@ -173,7 +169,7 @@ // -- CSR, 2007-10-19 fprintf(tFile, "%.16e\n", *(timesTable + 2*pos + 2*i)); } - fprintf(tFile, "%.16e\n", *(timesTable + 2*pos + 2*trackTable[k]-1)); + fprintf(tFile, "%.16e\n", *(timesTable + 2*pos + 2*(*adb->track_lengths)[k]-1)); fclose(tFile); fprintf(tLFile, "%s\n", fName); @@ -186,14 +182,14 @@ goto error; } write_or_goto_error(pfd, &one, sizeof(uint32_t)); - write_or_goto_error(pfd, powerTable + pos, trackTable[k] * sizeof(double)); + write_or_goto_error(pfd, powerTable + pos, (*adb->track_lengths)[k] * sizeof(double)); fprintf(pLFile, "%s\n", fName); close(pfd); pfd = 0; } - pos += trackTable[k]; - std::cout << fileTable+k*O2_FILETABLE_ENTRY_SIZE << " " << trackTable[k] << std::endl; + pos += (*adb->track_lengths)[k]; + std::cout << fileTable+k*O2_FILETABLE_ENTRY_SIZE << " " << (*adb->track_lengths)[k] << std::endl; } } @@ -237,7 +233,6 @@ fclose(kLFile); maybe_munmap(fileTable, fileTableLength); - maybe_munmap(trackTable, trackTableLength); maybe_munmap(timesTable, timesTableLength); maybe_munmap(powerTable, powerTableLength); maybe_munmap(featureFileNameTable, fileTableLength); @@ -278,7 +273,6 @@ } maybe_munmap(fileTable, fileTableLength); - maybe_munmap(trackTable, trackTableLength); maybe_munmap(timesTable, timesTableLength); maybe_munmap(powerTable, powerTableLength); maybe_munmap(featureFileNameTable, fileTableLength);