Mercurial > hg > audiodb
diff audioDB.h @ 108:bc141fd1dc41
New on-disk format!
* new magic number: "o2db" rather than "O2DB". Check for the old one
and give a helpful error message. (We could in principle handle the
old databases transparently, but since only MC has actually used them
and he has indicated that this is not desperately necessary...)
* add fields to header: a file format version (currently 0; we have
2^32-1 revisions to make before we have to worry...) and fields for
the offsets of the various tables. This is hopefully a little bit
more futureproof: we can move the default locations of the tables
around, and even adding new optional tables can be done easily in a
fairly transparent manner (if the relevant header field is 0, don't
use that feature).
* align regions to the appropriate 32-word boundary. This gives us some
space to breathe for in the header (admittedly only 15 words on 64-bit
architectures...)
author | mas01cr |
---|---|
date | Fri, 05 Oct 2007 14:21:43 +0000 |
parents | 10feb98abebf |
children | 43722a0ba717 |
line wrap: on
line diff
--- a/audioDB.h Fri Oct 05 11:37:56 2007 +0000 +++ b/audioDB.h Fri Oct 05 14:21:43 2007 +0000 @@ -44,7 +44,9 @@ #define COM_KEYLIST "--keyList" #define COM_TIMES "--times" -#define O2_MAGIC 1111765583 // 'B'<<24|'D'<<16|'2'<<8|'O' reads O2DB in little endian order +#define O2_OLD_MAGIC ('O'|'2'<<8|'D'<<16|'B'<<24) +#define O2_MAGIC ('o'|'2'<<8|'d'<<16|'b'<<24) +#define O2_FORMAT_VERSION (0U) #define O2_DEFAULT_POINTNN (10U) #define O2_DEFAULT_TRACKNN (10U) @@ -78,15 +80,24 @@ // Macros #define O2_ACTION(a) (strcmp(command,a)==0) +#define ALIGN_UP(x,w) ((x) + ((1<<w)-1) & ~((1<<w)-1)) +#define ALIGN_DOWN(x,w) ((x) & ~((1<<w)-1)) + using namespace std; // 64 byte header typedef struct dbTableHeader{ unsigned magic; + unsigned version; unsigned numFiles; unsigned dim; - unsigned length; unsigned flags; + size_t length; + size_t fileTableOffset; + size_t trackTableOffset; + size_t dataOffset; + size_t l2normTableOffset; + size_t timesTableOffset; } dbTableHeaderT, *dbTableHeaderPtr; @@ -111,11 +122,6 @@ char* indata; struct stat statbuf; dbTableHeaderPtr dbH; - size_t fileTableOffset; - size_t trackTableOffset; - size_t dataoffset; - size_t l2normTableOffset; - size_t timesTableOffset; char *fileTable; unsigned* trackTable;