66 buf[126] = atoi(tag->
value);
82 #define XING_NUM_BAGS 400
83 #define XING_TOC_SIZE 100
85 #define XING_MAX_SIZE (32 + 4 + 4 + 4 + 4 + XING_TOC_SIZE)
123 int best_bitrate_idx = -1;
124 int best_bitrate_error= INT_MAX;
128 int srate_idx, ver = 0, i, channels;
139 else if (codec->
sample_rate == base_freq / 2) ver = 0x2;
140 else if (codec->
sample_rate == base_freq / 4) ver = 0x0;
155 "not writing Xing header.\n");
160 header = 0xff
U << 24;
161 header |= (0x7 << 5 | ver << 3 | 0x1 << 1 | 0x1) << 16;
162 header |= (srate_idx << 2) << 8;
163 header |= channels << 6;
165 for (bitrate_idx=1; bitrate_idx<15; bitrate_idx++) {
169 if(error < best_bitrate_error){
170 best_bitrate_error= error;
171 best_bitrate_idx = bitrate_idx;
176 for (bitrate_idx= best_bitrate_idx;; bitrate_idx++) {
177 if (15 == bitrate_idx)
179 mask = bitrate_idx << (4+8);
182 xing_offset=
xing_offtbl[c.lsf == 1][c.nb_channels == 1];
193 if (needed <= c.frame_size)
205 mp3->
size = c.frame_size;
217 for (i = 0; i < strlen(vendor); ++i)
246 mp3->
bag[i >> 1] = mp3->
bag[i];
251 mp3->
pos = XING_NUM_BAGS / 2;
269 "is invalid, writing it anyway.\n", pkt->
size, head);
279 #ifdef FILTER_VBR_HEADERS
281 base = 4 +
xing_offtbl[c.lsf == 1][c.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/x-mpeg",
388 .extensions =
"mp2,m2a",
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.",
406 static const AVClass mp3_muxer_class = {
475 "audio stream is required.\n");
506 .mime_type =
"audio/x-mpeg",
516 .priv_class = &mp3_muxer_class,