42id3_length_t id3_render_immediate(id3_byte_t **ptr,
43 char const *value,
unsigned int bytes)
46 assert(bytes == 8 || bytes == 4 || bytes == 3);
50 case 8: *(*ptr)++ = *value++;
54 case 4: *(*ptr)++ = *value++;
55 case 3: *(*ptr)++ = *value++;
64id3_length_t id3_render_syncsafe(id3_byte_t **ptr,
65 unsigned long num,
unsigned int bytes)
67 assert(bytes == 4 || bytes == 5);
71 case 5: *(*ptr)++ = (num >> 28) & 0x0f;
72 case 4: *(*ptr)++ = (num >> 21) & 0x7f;
73 *(*ptr)++ = (num >> 14) & 0x7f;
74 *(*ptr)++ = (num >> 7) & 0x7f;
75 *(*ptr)++ = (num >> 0) & 0x7f;
82id3_length_t id3_render_int(id3_byte_t **ptr,
83 signed long num,
unsigned int bytes)
85 assert(bytes >= 1 && bytes <= 4);
89 case 4: *(*ptr)++ = num >> 24;
90 case 3: *(*ptr)++ = num >> 16;
91 case 2: *(*ptr)++ = num >> 8;
92 case 1: *(*ptr)++ = num >> 0;
99id3_length_t id3_render_binary(id3_byte_t **ptr,
100 id3_byte_t
const *data, id3_length_t length)
106 memcpy(*ptr, data, length);
113id3_length_t id3_render_latin1(id3_byte_t **ptr,
114 id3_latin1_t
const *latin1,
int terminate)
121 size = id3_latin1_size(latin1);
126 memcpy(*ptr, latin1, size);
133id3_length_t id3_render_string(id3_byte_t **ptr, id3_ucs4_t
const *ucs4,
134 enum id3_field_textencoding encoding,
137 enum id3_utf16_byteorder byteorder = ID3_UTF16_BYTEORDER_ANY;
140 ucs4 = id3_ucs4_empty;
143 case ID3_FIELD_TEXTENCODING_ISO_8859_1:
144 return id3_latin1_serialize(ptr, ucs4, terminate);
146 case ID3_FIELD_TEXTENCODING_UTF_16BE:
147 byteorder = ID3_UTF16_BYTEORDER_BE;
148 case ID3_FIELD_TEXTENCODING_UTF_16:
149 return id3_utf16_serialize(ptr, ucs4, byteorder, terminate);
151 case ID3_FIELD_TEXTENCODING_UTF_8:
152 return id3_utf8_serialize(ptr, ucs4, terminate);
158id3_length_t id3_render_padding(id3_byte_t **ptr, id3_byte_t value,
162 memset(*ptr, value, length);
173id3_length_t id3_render_paddedstring(id3_byte_t **ptr, id3_ucs4_t
const *ucs4,
176 id3_ucs4_t padded[31], *data, *end;
180 assert(length <= 30);
186 while (*ucs4 && end - data > 0) {
189 if (data[-1] ==
'\n')
194 while (end - data > 0)
199 return id3_latin1_serialize(ptr, padded, 0);