62 buf[126] = atoi(tag->
value);
78 #define XING_NUM_BAGS 400
79 #define XING_TOC_SIZE 100
81 #define XING_MAX_SIZE (32 + 4 + 4 + 4 + 4 + XING_TOC_SIZE)
119 int best_bitrate_idx = -1;
120 int best_bitrate_error= INT_MAX;
124 int srate_idx, ver = 0, i, channels;
135 else if (codec->
sample_rate == base_freq / 2) ver = 0x2;
136 else if (codec->
sample_rate == base_freq / 4) ver = 0x0;
151 "not writing Xing header.\n");
156 header = 0xff
U << 24;
157 header |= (0x7 << 5 | ver << 3 | 0x1 << 1 | 0x1) << 16;
158 header |= (srate_idx << 2) << 8;
159 header |= channels << 6;
161 for (bitrate_idx=1; bitrate_idx<15; bitrate_idx++) {
165 if(error < best_bitrate_error){
166 best_bitrate_error= error;
167 best_bitrate_idx = bitrate_idx;
172 for (bitrate_idx= best_bitrate_idx;; bitrate_idx++) {
173 if (15 == bitrate_idx)
175 mask = bitrate_idx << (4+8);
178 xing_offset=
xing_offtbl[c.lsf == 1][c.nb_channels == 1];
189 if (needed <= c.frame_size)
201 mp3->
size = c.frame_size;
213 for (i = 0; i < strlen(vendor); ++i)
242 mp3->
bag[i >> 1] = mp3->
bag[i];
247 mp3->
pos = XING_NUM_BAGS / 2;
265 "is invalid, writing it anyway.\n", pkt->
size, head);
275 #ifdef FILTER_VBR_HEADERS
277 base = 4 +
xing_offtbl[c.lsf == 1][c.nb_channels == 1];
279 if (base + 4 <= pkt->
size) {
282 if (
MKBETAG(
'X',
'i',
'n',
'g') == v ||
MKBETAG(
'I',
'n',
'f',
'o') == v)
304 int ret = 0, write = 1;
309 while ((pktl = mp3->
queue)) {
339 int seek_point = 256LL * mp3->
bag[j] / mp3->
size;
353 "attached pictures.\n");
373 return MKTAG(
'A',
'P',
'I',
'C');
383 .mime_type =
"audio/x-mpeg",
384 .extensions =
"mp2,m2a,mpa",
395 {
"id3v2_version",
"Select ID3v2 version to write. Currently 3 and 4 are supported.",
397 {
"write_id3v1",
"Enable ID3v1 writing. ID3v1 tags are written in UTF-8 which may not be supported by most software.",
402 static const AVClass mp3_muxer_class = {
475 "audio stream is required.\n");
506 .mime_type =
"audio/x-mpeg",
516 .priv_class = &mp3_muxer_class,