1
0
Fork 0
forked from len0rd/rockbox

Unify fourcc macro and some style changes

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23664 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Nils Wallménius 2009-11-18 17:30:42 +00:00
parent 556daaf34a
commit 2e28c1853b
8 changed files with 79 additions and 75 deletions

View file

@ -59,7 +59,8 @@ bool read_ape_tags(int fd, struct mp3entry* id3)
struct apetag_header header;
if ((lseek(fd, -APETAG_HEADER_LENGTH, SEEK_END) < 0)
|| (ecread(fd, &header, 1, APETAG_HEADER_FORMAT, IS_BIG_ENDIAN) != APETAG_HEADER_LENGTH)
|| (ecread(fd, &header, 1, APETAG_HEADER_FORMAT, IS_BIG_ENDIAN)
!= APETAG_HEADER_LENGTH)
|| (memcmp(header.id, "APETAGEX", sizeof(header.id))))
{
return false;
@ -91,7 +92,8 @@ bool read_ape_tags(int fd, struct mp3entry* id3)
break;
}
if (ecread(fd, &item, 1, APETAG_ITEM_HEADER_FORMAT, IS_BIG_ENDIAN) < (long) sizeof(item))
if (ecread(fd, &item, 1, APETAG_ITEM_HEADER_FORMAT, IS_BIG_ENDIAN)
< (long) sizeof(item))
{
return false;
}

View file

@ -104,9 +104,10 @@ static int ASAP_ParseDuration(const char *s)
return r;
}
static bool read_asap_string(char* source,char** buf,char** buffer_end,char** dest)
static bool read_asap_string(char* source, char** buf, char** buffer_end, char** dest)
{
if(parse_text(*buf,source) == false) return false;
if(parse_text(*buf,source) == false)
return false;
/* set dest pointer */
*dest = *buf;
@ -123,7 +124,7 @@ static bool read_asap_string(char* source,char** buf,char** buffer_end,char** de
return true;
}
static bool parse_sap_header(int fd,struct mp3entry* id3,int file_len)
static bool parse_sap_header(int fd, struct mp3entry* id3, int file_len)
{
int module_index = 0;
int sap_signature = -1;
@ -132,9 +133,9 @@ static bool parse_sap_header(int fd,struct mp3entry* id3,int file_len)
int i;
/* set defaults */
int numSongs=1;
int defSong=0;
int numChannels=1;
int numSongs = 1;
int defSong = 0;
int numChannels = 1;
int durations[MAX_SONGS];
int loops[MAX_SONGS];
for (i = 0; i < MAX_SONGS; i++) {
@ -190,36 +191,36 @@ static bool parse_sap_header(int fd,struct mp3entry* id3,int file_len)
sap_signature = 1;
if (sap_signature == -1)
return false;
if (strcmp(line,"AUTHOR") == 0)
if (strcmp(line, "AUTHOR") == 0)
{
if(read_asap_string(p,&buffer,&buffer_end,&id3->artist) == false)
if(read_asap_string(p, &buffer, &buffer_end, &id3->artist) == false)
return false;
}
else if(strcmp(line,"NAME")==0)
else if(strcmp(line, "NAME") == 0)
{
if(read_asap_string(p,&buffer,&buffer_end,&id3->title) == false)
if(read_asap_string(p, &buffer, &buffer_end, &id3->title) == false)
return false;
}
else if(strcmp(line,"DATE")==0)
else if(strcmp(line, "DATE") == 0)
{
if(read_asap_string(p,&buffer,&buffer_end,&id3->year_string) == false)
if(read_asap_string(p, &buffer, &buffer_end, &id3->year_string) == false)
return false;
}
else if (strcmp(line,"SONGS")==0)
else if (strcmp(line, "SONGS") == 0)
{
if (parse_dec(&numSongs, p,1,MAX_SONGS) == false )
if (parse_dec(&numSongs, p, 1, MAX_SONGS) == false )
return false;
}
else if (strcmp(line,"DEFSONG")==0)
else if (strcmp(line, "DEFSONG") == 0)
{
if (parse_dec(&defSong, p,0,MAX_SONGS) == false)
if (parse_dec(&defSong, p, 0, MAX_SONGS) == false)
return false;
}
else if (strcmp(line,"STEREO")==0)
else if (strcmp(line, "STEREO") == 0)
{
numChannels = 2;
}
else if (strcmp(line,"TIME") == 0)
else if (strcmp(line, "TIME") == 0)
{
int durationTemp = ASAP_ParseDuration(p);
if (durationTemp < 0 || duration_index >= MAX_SONGS)
@ -237,7 +238,7 @@ static bool parse_sap_header(int fd,struct mp3entry* id3,int file_len)
length = 180 * 1000;
id3->length = length;
lseek(fd,0,SEEK_SET);
lseek(fd, 0, SEEK_SET);
return true;
}
@ -247,7 +248,7 @@ bool get_asap_metadata(int fd, struct mp3entry* id3)
int filelength = filesize(fd);
if(parse_sap_header(fd,id3,filelength) == false)
if(parse_sap_header(fd, id3, filelength) == false)
{
DEBUGF("parse sap header failed.\n");
return false;

View file

@ -140,11 +140,11 @@ static int asf_intdecode(int fd, int type, int length)
uint32_t tmp32;
uint64_t tmp64;
if (type==3) {
if (type == 3) {
read_uint32le(fd, &tmp32);
lseek(fd,length - 4,SEEK_CUR);
return (int)tmp32;
} else if (type==4) {
} else if (type == 4) {
read_uint64le(fd, &tmp64);
lseek(fd,length - 8,SEEK_CUR);
return (int)tmp64;
@ -430,19 +430,19 @@ static int asf_parse_header(int fd, struct mp3entry* id3,
} else {
lseek(fd, length, SEEK_CUR);
}
} else if ((!strcmp("WM/Genre",utf8buf)) && (type == 0)) {
} else if ((!strcmp("WM/Genre", utf8buf)) && (type == 0)) {
id3->genre_string = id3buf;
asf_utf16LEdecode(fd, length, &id3buf, &id3buf_remaining);
} else if ((!strcmp("WM/AlbumTitle",utf8buf)) && (type == 0)) {
} else if ((!strcmp("WM/AlbumTitle", utf8buf)) && (type == 0)) {
id3->album = id3buf;
asf_utf16LEdecode(fd, length, &id3buf, &id3buf_remaining);
} else if ((!strcmp("WM/AlbumArtist",utf8buf)) && (type == 0)) {
} else if ((!strcmp("WM/AlbumArtist", utf8buf)) && (type == 0)) {
id3->albumartist = id3buf;
asf_utf16LEdecode(fd, length, &id3buf, &id3buf_remaining);
} else if ((!strcmp("WM/Composer",utf8buf)) && (type == 0)) {
} else if ((!strcmp("WM/Composer", utf8buf)) && (type == 0)) {
id3->composer = id3buf;
asf_utf16LEdecode(fd, length, &id3buf, &id3buf_remaining);
} else if (!strcmp("WM/Year",utf8buf)) {
} else if (!strcmp("WM/Year", utf8buf)) {
if (type == 0) {
id3->year_string = id3buf;
asf_utf16LEdecode(fd, length, &id3buf, &id3buf_remaining);

View file

@ -29,6 +29,8 @@
#define TAG_NAME_LENGTH 32
#define TAG_VALUE_LENGTH 128
#define FOURCC(a,b,c,d) (((a)<<24) | ((b) << 16) | ((c) << 8) | (d))
enum tagtype { TAGTYPE_APE = 1, TAGTYPE_VORBIS };
bool read_ape_tags(int fd, struct mp3entry* id3);

View file

@ -33,45 +33,43 @@
#include "debug.h"
#include "replaygain.h"
#define MP4_ID(a, b, c, d) (((a) << 24) | ((b) << 16) | ((c) << 8) | (d))
#define MP4_3gp6 MP4_ID('3', 'g', 'p', '6')
#define MP4_aART MP4_ID('a', 'A', 'R', 'T')
#define MP4_alac MP4_ID('a', 'l', 'a', 'c')
#define MP4_calb MP4_ID(0xa9, 'a', 'l', 'b')
#define MP4_cART MP4_ID(0xa9, 'A', 'R', 'T')
#define MP4_cgrp MP4_ID(0xa9, 'g', 'r', 'p')
#define MP4_cgen MP4_ID(0xa9, 'g', 'e', 'n')
#define MP4_chpl MP4_ID('c', 'h', 'p', 'l')
#define MP4_cnam MP4_ID(0xa9, 'n', 'a', 'm')
#define MP4_cwrt MP4_ID(0xa9, 'w', 'r', 't')
#define MP4_ccmt MP4_ID(0xa9, 'c', 'm', 't')
#define MP4_cday MP4_ID(0xa9, 'd', 'a', 'y')
#define MP4_disk MP4_ID('d', 'i', 's', 'k')
#define MP4_esds MP4_ID('e', 's', 'd', 's')
#define MP4_ftyp MP4_ID('f', 't', 'y', 'p')
#define MP4_gnre MP4_ID('g', 'n', 'r', 'e')
#define MP4_hdlr MP4_ID('h', 'd', 'l', 'r')
#define MP4_ilst MP4_ID('i', 'l', 's', 't')
#define MP4_M4A MP4_ID('M', '4', 'A', ' ')
#define MP4_M4B MP4_ID('M', '4', 'B', ' ')
#define MP4_mdat MP4_ID('m', 'd', 'a', 't')
#define MP4_mdia MP4_ID('m', 'd', 'i', 'a')
#define MP4_mdir MP4_ID('m', 'd', 'i', 'r')
#define MP4_meta MP4_ID('m', 'e', 't', 'a')
#define MP4_minf MP4_ID('m', 'i', 'n', 'f')
#define MP4_moov MP4_ID('m', 'o', 'o', 'v')
#define MP4_mp4a MP4_ID('m', 'p', '4', 'a')
#define MP4_mp42 MP4_ID('m', 'p', '4', '2')
#define MP4_qt MP4_ID('q', 't', ' ', ' ')
#define MP4_soun MP4_ID('s', 'o', 'u', 'n')
#define MP4_stbl MP4_ID('s', 't', 'b', 'l')
#define MP4_stsd MP4_ID('s', 't', 's', 'd')
#define MP4_stts MP4_ID('s', 't', 't', 's')
#define MP4_trak MP4_ID('t', 'r', 'a', 'k')
#define MP4_trkn MP4_ID('t', 'r', 'k', 'n')
#define MP4_udta MP4_ID('u', 'd', 't', 'a')
#define MP4_extra MP4_ID('-', '-', '-', '-')
#define MP4_3gp6 FOURCC('3', 'g', 'p', '6')
#define MP4_aART FOURCC('a', 'A', 'R', 'T')
#define MP4_alac FOURCC('a', 'l', 'a', 'c')
#define MP4_calb FOURCC(0xa9, 'a', 'l', 'b')
#define MP4_cART FOURCC(0xa9, 'A', 'R', 'T')
#define MP4_cgrp FOURCC(0xa9, 'g', 'r', 'p')
#define MP4_cgen FOURCC(0xa9, 'g', 'e', 'n')
#define MP4_chpl FOURCC('c', 'h', 'p', 'l')
#define MP4_cnam FOURCC(0xa9, 'n', 'a', 'm')
#define MP4_cwrt FOURCC(0xa9, 'w', 'r', 't')
#define MP4_ccmt FOURCC(0xa9, 'c', 'm', 't')
#define MP4_cday FOURCC(0xa9, 'd', 'a', 'y')
#define MP4_disk FOURCC('d', 'i', 's', 'k')
#define MP4_esds FOURCC('e', 's', 'd', 's')
#define MP4_ftyp FOURCC('f', 't', 'y', 'p')
#define MP4_gnre FOURCC('g', 'n', 'r', 'e')
#define MP4_hdlr FOURCC('h', 'd', 'l', 'r')
#define MP4_ilst FOURCC('i', 'l', 's', 't')
#define MP4_M4A FOURCC('M', '4', 'A', ' ')
#define MP4_M4B FOURCC('M', '4', 'B', ' ')
#define MP4_mdat FOURCC('m', 'd', 'a', 't')
#define MP4_mdia FOURCC('m', 'd', 'i', 'a')
#define MP4_mdir FOURCC('m', 'd', 'i', 'r')
#define MP4_meta FOURCC('m', 'e', 't', 'a')
#define MP4_minf FOURCC('m', 'i', 'n', 'f')
#define MP4_moov FOURCC('m', 'o', 'o', 'v')
#define MP4_mp4a FOURCC('m', 'p', '4', 'a')
#define MP4_mp42 FOURCC('m', 'p', '4', '2')
#define MP4_qt FOURCC('q', 't', ' ', ' ')
#define MP4_soun FOURCC('s', 'o', 'u', 'n')
#define MP4_stbl FOURCC('s', 't', 'b', 'l')
#define MP4_stsd FOURCC('s', 't', 's', 'd')
#define MP4_stts FOURCC('s', 't', 't', 's')
#define MP4_trak FOURCC('t', 'r', 'a', 'k')
#define MP4_trkn FOURCC('t', 'r', 'k', 'n')
#define MP4_udta FOURCC('u', 'd', 't', 'a')
#define MP4_extra FOURCC('-', '-', '-', '-')
/* Read the tag data from an MP4 file, storing up to buffer_size bytes in
* buffer.

View file

@ -50,7 +50,7 @@ static int set_replaygain(struct mp3entry* id3, bool album, long value,
bool get_musepack_metadata(int fd, struct mp3entry *id3)
{
const int32_t sfreqs_sv7[4] = { 44100, 48000, 37800, 32000 };
static const int32_t sfreqs_sv7[4] = { 44100, 48000, 37800, 32000 };
uint32_t header[8];
uint64_t samples = 0;
int i;

View file

@ -60,15 +60,16 @@ struct real_object_t
uint16_t version;
};
#define FOURCC(a,b,c,d) (((a)<<24) | ((b) << 16) | ((c) << 8) | (d))
static int real_read_object_header(int fd, struct real_object_t* obj)
{
int n;
if ((n = read_uint32be(fd, &obj->fourcc)) <= 0) return n;
if ((n = read_uint32be(fd, &obj->size)) <= 0) return n;
if ((n = read_uint16be(fd, &obj->version)) <= 0) return n;
if ((n = read_uint32be(fd, &obj->fourcc)) <= 0)
return n;
if ((n = read_uint32be(fd, &obj->size)) <= 0)
return n;
if ((n = read_uint16be(fd, &obj->version)) <= 0)
return n;
return 1;
}

View file

@ -46,7 +46,7 @@ bool get_sid_metadata(int fd, struct mp3entry* id3)
return false;
}
if ((memcmp(buf, "PSID",4) != 0))
if ((memcmp(buf, "PSID", 4) != 0))
{
return false;
}