41signed long id3_parse_int(id3_byte_t
const **ptr,
unsigned int bytes)
43 signed long value = 0;
45 assert(bytes >= 1 && bytes <= 4);
51 case 4: value = (value << 8) | *(*ptr)++;
52 case 3: value = (value << 8) | *(*ptr)++;
53 case 2: value = (value << 8) | *(*ptr)++;
54 case 1: value = (value << 8) | *(*ptr)++;
60unsigned long id3_parse_uint(id3_byte_t
const **ptr,
unsigned int bytes)
62 unsigned long value = 0;
64 assert(bytes >= 1 && bytes <= 4);
67 case 4: value = (value << 8) | *(*ptr)++;
68 case 3: value = (value << 8) | *(*ptr)++;
69 case 2: value = (value << 8) | *(*ptr)++;
70 case 1: value = (value << 8) | *(*ptr)++;
76unsigned long id3_parse_syncsafe(id3_byte_t
const **ptr,
unsigned int bytes)
78 unsigned long value = 0;
80 assert(bytes == 4 || bytes == 5);
83 case 5: value = (value << 4) | (*(*ptr)++ & 0x0f);
84 case 4: value = (value << 7) | (*(*ptr)++ & 0x7f);
85 value = (value << 7) | (*(*ptr)++ & 0x7f);
86 value = (value << 7) | (*(*ptr)++ & 0x7f);
87 value = (value << 7) | (*(*ptr)++ & 0x7f);
93void id3_parse_immediate(id3_byte_t
const **ptr,
unsigned int bytes,
97 assert(bytes == 8 || bytes == 4 || bytes == 3);
100 case 8: *value++ = *(*ptr)++;
101 *value++ = *(*ptr)++;
102 *value++ = *(*ptr)++;
103 *value++ = *(*ptr)++;
104 case 4: *value++ = *(*ptr)++;
105 case 3: *value++ = *(*ptr)++;
106 *value++ = *(*ptr)++;
107 *value++ = *(*ptr)++;
113id3_latin1_t *id3_parse_latin1(id3_byte_t
const **ptr, id3_length_t length,
116 id3_byte_t
const *end;
118 id3_latin1_t *latin1;
120 end = memchr(*ptr, 0, length);
128 latin1 = malloc(length + 1);
130 memcpy(latin1, *ptr, length);
136 for (check = latin1; *check; ++check) {
143 *ptr += length + terminated;
148id3_ucs4_t *id3_parse_string(id3_byte_t
const **ptr, id3_length_t length,
149 enum id3_field_textencoding encoding,
int full)
151 id3_ucs4_t *ucs4 = 0;
152 enum id3_utf16_byteorder byteorder = ID3_UTF16_BYTEORDER_ANY;
155 case ID3_FIELD_TEXTENCODING_ISO_8859_1:
156 ucs4 = id3_latin1_deserialize(ptr, length);
159 case ID3_FIELD_TEXTENCODING_UTF_16BE:
160 byteorder = ID3_UTF16_BYTEORDER_BE;
161 case ID3_FIELD_TEXTENCODING_UTF_16:
162 ucs4 = id3_utf16_deserialize(ptr, length, byteorder);
165 case ID3_FIELD_TEXTENCODING_UTF_8:
166 ucs4 = id3_utf8_deserialize(ptr, length);
173 for (check = ucs4; *check; ++check) {
182id3_byte_t *id3_parse_binary(id3_byte_t
const **ptr, id3_length_t length)
189 data = malloc(length);
191 memcpy(data, *ptr, length);