-void identify_art_type( hb_metadata_t *metadata )
-{
- typedef struct header_s {
- enum arttype type;
- char* name; // short string describing name of type
- char* data; // header-bytes to match
- } header;
-
- // types which may be detected by first-bytes only
- static header headers[] = {
- { BMP, "bmp", "\x4d\x42" },
- { GIF87A, "GIF (87a)", "GIF87a" },
- { GIF89A, "GIF (89a)", "GIF89a" },
- { JPG, "JPEG", "\xff\xd8\xff\xe0" },
- { PNG, "PNG", "\x89\x50\x4e\x47\x0d\x0a\x1a\x0a" },
- { TIFFL, "TIFF (little-endian)", "II42" },
- { TIFFB, "TIFF (big-endian)", "MM42" },
- { UNKNOWN } // must be last
- };
- header* p;
- header* found = NULL;
- for( p = headers; p->type != UNKNOWN; p++ ) {
- header *h = p;
-
- if( metadata->coverart_size < strlen(h->data) )
- continue;
-
- if( memcmp(h->data, metadata->coverart, strlen(h->data)) == 0 ) {
- metadata->coverart_type = h->type;
- break;
- }
- }
-}
-