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)
120 int best_bitrate_idx = -1;
121 int best_bitrate_error= INT_MAX;
125 int srate_idx, ver = 0, i, channels;
136 else if (codec->
sample_rate == base_freq / 2) ver = 0x2;
137 else if (codec->
sample_rate == base_freq / 4) ver = 0x0;
152 "not writing Xing header.\n");
157 header = 0xff
U << 24;
158 header |= (0x7 << 5 | ver << 3 | 0x1 << 1 | 0x1) << 16;
159 header |= (srate_idx << 2) << 8;
160 header |= channels << 6;
162 for (bitrate_idx=1; bitrate_idx<15; bitrate_idx++) {
166 if(error < best_bitrate_error){
167 best_bitrate_error= error;
168 best_bitrate_idx = bitrate_idx;
173 for (bitrate_idx= best_bitrate_idx;; bitrate_idx++) {
174 if (15 == bitrate_idx)
176 mask = bitrate_idx << (4+8);
179 xing_offset=
xing_offtbl[c.lsf == 1][c.nb_channels == 1];
190 if (needed <= c.frame_size)
202 mp3->
size = c.frame_size;
214 for (i = 0; i < strlen(vendor); ++i)
243 mp3->
bag[i >> 1] = mp3->
bag[i];
248 mp3->
pos = XING_NUM_BAGS / 2;
266 "is invalid, writing it anyway.\n", pkt->
size, head);
276 #ifdef FILTER_VBR_HEADERS
278 base = 4 +
xing_offtbl[c.lsf == 1][c.nb_channels == 1];
280 if (base + 4 <= pkt->
size) {
283 if (
MKBETAG(
'X',
'i',
'n',
'g') == v ||
MKBETAG(
'I',
'n',
'f',
'o') == v)
305 int ret = 0, write = 1;
310 while ((pktl = mp3->
queue)) {
340 int seek_point = 256LL * mp3->
bag[j] / mp3->
size;
354 "attached pictures.\n");
374 return MKTAG(
'A',
'P',
'I',
'C');
384 .mime_type =
"audio/x-mpeg",
385 .extensions =
"mp2,m2a,mpa",
396 {
"id3v2_version",
"Select ID3v2 version to write. Currently 3 and 4 are supported.",
398 {
"write_id3v1",
"Enable ID3v1 writing. ID3v1 tags are written in UTF-8 which may not be supported by most software.",
400 {
"write_xing",
"Write the Xing header containing file duration.",
405 static const AVClass mp3_muxer_class = {
486 "audio stream is required.\n");
503 "ID3v2 header is disabled.\n");
526 .mime_type =
"audio/x-mpeg",
536 .priv_class = &mp3_muxer_class,