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)
121 int srate_idx, i, channels;
123 int best_bitrate_idx = -1;
124 int best_bitrate_error = INT_MAX;
137 else if (codec->
sample_rate == base_freq / 2) ver = 0x2;
138 else if (codec->
sample_rate == base_freq / 4) ver = 0x0;
153 "not writing Xing header.\n");
158 header = 0xff
U << 24;
159 header |= (0x7 << 5 | ver << 3 | 0x1 << 1 | 0x1) << 16;
160 header |= (srate_idx << 2) << 8;
161 header |= channels << 6;
163 for (bitrate_idx = 1; bitrate_idx < 15; bitrate_idx++) {
167 if (error < best_bitrate_error) {
168 best_bitrate_error = error;
169 best_bitrate_idx = bitrate_idx;
174 for (bitrate_idx = best_bitrate_idx; ; bitrate_idx++) {
176 if (15 == bitrate_idx)
181 xing_offset=
xing_offtbl[mpah.lsf == 1][mpah.nb_channels == 1];
192 if (bytes_needed <= mpah.frame_size)
205 mp3->
size = mpah.frame_size;
217 for (i = 0; i < strlen(vendor); ++i)
223 ffio_fill(s->
pb, 0, mpah.frame_size - bytes_needed);
246 mp3->
bag[i >> 1] = mp3->
bag[i];
251 mp3->
pos = XING_NUM_BAGS / 2;
276 "is invalid, writing it anyway.\n", pkt->
size, h);
279 #ifdef FILTER_VBR_HEADERS
281 base = 4 +
xing_offtbl[mpah.lsf == 1][mpah.nb_channels == 1];
283 if (base + 4 <= pkt->
size) {
286 if (
MKBETAG(
'X',
'i',
'n',
'g') == v ||
MKBETAG(
'I',
'n',
'f',
'o') == v)
308 int ret = 0, write = 1;
313 while ((pktl = mp3->
queue)) {
343 int seek_point = 256LL * mp3->
bag[j] / mp3->
size;
357 "attached pictures.\n");
377 return MKTAG(
'A',
'P',
'I',
'C');
387 .mime_type =
"audio/mpeg",
388 .extensions =
"mp2,m2a,mpa",
399 {
"id3v2_version",
"Select ID3v2 version to write. Currently 3 and 4 are supported.",
401 {
"write_id3v1",
"Enable ID3v1 writing. ID3v1 tags are written in UTF-8 which may not be supported by most software.",
403 {
"write_xing",
"Write the Xing header containing file duration.",
408 static const AVClass mp3_muxer_class = {
489 "audio stream is required.\n");
506 "ID3v2 header is disabled.\n");
529 .mime_type =
"audio/mpeg",
539 .priv_class = &mp3_muxer_class,