61 buf[126] = atoi(tag->
value);
77 #define XING_NUM_BAGS 400
78 #define XING_TOC_SIZE 100
80 #define XING_MAX_SIZE (32 + 4 + 4 + 4 + 4 + XING_TOC_SIZE)
119 int srate_idx, i, channels;
121 int best_bitrate_idx;
122 int best_bitrate_error = INT_MAX;
125 int lsf, bytes_needed;
134 else if (codec->
sample_rate == base_freq / 2) ver = 0x2;
135 else if (codec->
sample_rate == base_freq / 4) ver = 0x0;
151 "not writing Xing header.\n");
157 header |= (0x7 << 5 | ver << 3 | 0x1 << 1 | 0x1) << 16;
158 header |= (srate_idx << 2) << 8;
159 header |= channels << 6;
161 lsf = !((header & (1 << 20) && header & (1 << 19)));
163 xing_offset =
xing_offtbl[ver != 3][channels == 1];
172 for (bitrate_idx = 1; bitrate_idx < 15; bitrate_idx++) {
176 if (error < best_bitrate_error){
177 best_bitrate_error = error;
178 best_bitrate_idx = bitrate_idx;
182 for (bitrate_idx = best_bitrate_idx; bitrate_idx < 15; bitrate_idx++) {
188 if (bytes_needed <= mpah.frame_size)
205 mp3->
size = mpah.frame_size;
215 ffio_fill(s->
pb, 0, mpah.frame_size - bytes_needed);
236 mp3->
bag[i / 2] = mp3->
bag[i];
241 mp3->
pos = XING_NUM_BAGS / 2;
275 int ret = 0, write = 1;
280 while ((pktl = mp3->
queue)) {
310 int seek_point = 256LL * mp3->
bag[j] / mp3->
size;
324 "attached pictures.\n");
343 .mime_type =
"audio/x-mpeg",
344 .extensions =
"mp2,m2a",
355 {
"id3v2_version",
"Select ID3v2 version to write. Currently 3 and 4 are supported.",
357 {
"write_id3v1",
"Enable ID3v1 writing. ID3v1 tags are written in UTF-8 which may not be supported by most software.",
362 static const AVClass mp3_muxer_class = {
395 av_log(s, AV_LOG_WARNING,
"Got more than one picture in stream %d,"
430 av_log(s, AV_LOG_ERROR,
"Invalid audio stream. Exactly one MP3 "
431 "audio stream is required.\n");
436 av_log(s, AV_LOG_ERROR,
"Only audio streams and pictures are allowed in MP3.\n");
441 av_log(s, AV_LOG_ERROR,
"No audio stream present.\n");
462 .mime_type =
"audio/x-mpeg",
470 .
flags = AVFMT_NOTIMESTAMPS,
471 .priv_class = &mp3_muxer_class,