You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

680 lines
18KB

  1. /*
  2. * MP3 muxer and demuxer
  3. * Copyright (c) 2003 Fabrice Bellard.
  4. *
  5. * This file is part of FFmpeg.
  6. *
  7. * FFmpeg is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU Lesser General Public
  9. * License as published by the Free Software Foundation; either
  10. * version 2.1 of the License, or (at your option) any later version.
  11. *
  12. * FFmpeg is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * Lesser General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Lesser General Public
  18. * License along with FFmpeg; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  20. */
  21. #include <strings.h>
  22. #include "libavutil/avstring.h"
  23. #include "libavcodec/mpegaudio.h"
  24. #include "libavcodec/mpegaudiodecheader.h"
  25. #include "avformat.h"
  26. #include "id3v2.h"
  27. #define ID3v1_TAG_SIZE 128
  28. #define ID3v1_GENRE_MAX 125
  29. static const char * const id3v1_genre_str[ID3v1_GENRE_MAX + 1] = {
  30. [0] = "Blues",
  31. [1] = "Classic Rock",
  32. [2] = "Country",
  33. [3] = "Dance",
  34. [4] = "Disco",
  35. [5] = "Funk",
  36. [6] = "Grunge",
  37. [7] = "Hip-Hop",
  38. [8] = "Jazz",
  39. [9] = "Metal",
  40. [10] = "New Age",
  41. [11] = "Oldies",
  42. [12] = "Other",
  43. [13] = "Pop",
  44. [14] = "R&B",
  45. [15] = "Rap",
  46. [16] = "Reggae",
  47. [17] = "Rock",
  48. [18] = "Techno",
  49. [19] = "Industrial",
  50. [20] = "Alternative",
  51. [21] = "Ska",
  52. [22] = "Death Metal",
  53. [23] = "Pranks",
  54. [24] = "Soundtrack",
  55. [25] = "Euro-Techno",
  56. [26] = "Ambient",
  57. [27] = "Trip-Hop",
  58. [28] = "Vocal",
  59. [29] = "Jazz+Funk",
  60. [30] = "Fusion",
  61. [31] = "Trance",
  62. [32] = "Classical",
  63. [33] = "Instrumental",
  64. [34] = "Acid",
  65. [35] = "House",
  66. [36] = "Game",
  67. [37] = "Sound Clip",
  68. [38] = "Gospel",
  69. [39] = "Noise",
  70. [40] = "AlternRock",
  71. [41] = "Bass",
  72. [42] = "Soul",
  73. [43] = "Punk",
  74. [44] = "Space",
  75. [45] = "Meditative",
  76. [46] = "Instrumental Pop",
  77. [47] = "Instrumental Rock",
  78. [48] = "Ethnic",
  79. [49] = "Gothic",
  80. [50] = "Darkwave",
  81. [51] = "Techno-Industrial",
  82. [52] = "Electronic",
  83. [53] = "Pop-Folk",
  84. [54] = "Eurodance",
  85. [55] = "Dream",
  86. [56] = "Southern Rock",
  87. [57] = "Comedy",
  88. [58] = "Cult",
  89. [59] = "Gangsta",
  90. [60] = "Top 40",
  91. [61] = "Christian Rap",
  92. [62] = "Pop/Funk",
  93. [63] = "Jungle",
  94. [64] = "Native American",
  95. [65] = "Cabaret",
  96. [66] = "New Wave",
  97. [67] = "Psychadelic",
  98. [68] = "Rave",
  99. [69] = "Showtunes",
  100. [70] = "Trailer",
  101. [71] = "Lo-Fi",
  102. [72] = "Tribal",
  103. [73] = "Acid Punk",
  104. [74] = "Acid Jazz",
  105. [75] = "Polka",
  106. [76] = "Retro",
  107. [77] = "Musical",
  108. [78] = "Rock & Roll",
  109. [79] = "Hard Rock",
  110. [80] = "Folk",
  111. [81] = "Folk-Rock",
  112. [82] = "National Folk",
  113. [83] = "Swing",
  114. [84] = "Fast Fusion",
  115. [85] = "Bebob",
  116. [86] = "Latin",
  117. [87] = "Revival",
  118. [88] = "Celtic",
  119. [89] = "Bluegrass",
  120. [90] = "Avantgarde",
  121. [91] = "Gothic Rock",
  122. [92] = "Progressive Rock",
  123. [93] = "Psychedelic Rock",
  124. [94] = "Symphonic Rock",
  125. [95] = "Slow Rock",
  126. [96] = "Big Band",
  127. [97] = "Chorus",
  128. [98] = "Easy Listening",
  129. [99] = "Acoustic",
  130. [100] = "Humour",
  131. [101] = "Speech",
  132. [102] = "Chanson",
  133. [103] = "Opera",
  134. [104] = "Chamber Music",
  135. [105] = "Sonata",
  136. [106] = "Symphony",
  137. [107] = "Booty Bass",
  138. [108] = "Primus",
  139. [109] = "Porn Groove",
  140. [110] = "Satire",
  141. [111] = "Slow Jam",
  142. [112] = "Club",
  143. [113] = "Tango",
  144. [114] = "Samba",
  145. [115] = "Folklore",
  146. [116] = "Ballad",
  147. [117] = "Power Ballad",
  148. [118] = "Rhythmic Soul",
  149. [119] = "Freestyle",
  150. [120] = "Duet",
  151. [121] = "Punk Rock",
  152. [122] = "Drum Solo",
  153. [123] = "A capella",
  154. [124] = "Euro-House",
  155. [125] = "Dance Hall",
  156. };
  157. static unsigned int id3v2_get_size(ByteIOContext *s, int len)
  158. {
  159. int v=0;
  160. while(len--)
  161. v= (v<<7) + (get_byte(s)&0x7F);
  162. return v;
  163. }
  164. static void id3v2_read_ttag(AVFormatContext *s, int taglen, char *dst, int dstlen)
  165. {
  166. char *q;
  167. int len;
  168. if(dstlen > 0)
  169. dst[0]= 0;
  170. if(taglen < 1)
  171. return;
  172. taglen--; /* account for encoding type byte */
  173. dstlen--; /* Leave space for zero terminator */
  174. switch(get_byte(s->pb)) { /* encoding type */
  175. case 0: /* ISO-8859-1 (0 - 255 maps directly into unicode) */
  176. q = dst;
  177. while(taglen--) {
  178. uint8_t tmp;
  179. PUT_UTF8(get_byte(s->pb), tmp, if (q - dst < dstlen - 1) *q++ = tmp;)
  180. }
  181. *q = '\0';
  182. break;
  183. case 3: /* UTF-8 */
  184. len = FFMIN(taglen, dstlen-1);
  185. get_buffer(s->pb, dst, len);
  186. dst[len] = 0;
  187. break;
  188. }
  189. }
  190. /**
  191. * ID3v2 parser
  192. *
  193. * Handles ID3v2.2, 2.3 and 2.4.
  194. *
  195. */
  196. static void id3v2_parse(AVFormatContext *s, int len, uint8_t version, uint8_t flags)
  197. {
  198. int isv34, tlen;
  199. uint32_t tag;
  200. int64_t next;
  201. char tmp[16];
  202. int taghdrlen;
  203. const char *reason;
  204. switch(version) {
  205. case 2:
  206. if(flags & 0x40) {
  207. reason = "compression";
  208. goto error;
  209. }
  210. isv34 = 0;
  211. taghdrlen = 6;
  212. break;
  213. case 3:
  214. case 4:
  215. isv34 = 1;
  216. taghdrlen = 10;
  217. break;
  218. default:
  219. reason = "version";
  220. goto error;
  221. }
  222. if(flags & 0x80) {
  223. reason = "unsynchronization";
  224. goto error;
  225. }
  226. if(isv34 && flags & 0x40) /* Extended header present, just skip over it */
  227. url_fskip(s->pb, id3v2_get_size(s->pb, 4));
  228. while(len >= taghdrlen) {
  229. if(isv34) {
  230. tag = get_be32(s->pb);
  231. tlen = id3v2_get_size(s->pb, 4);
  232. get_be16(s->pb); /* flags */
  233. } else {
  234. tag = get_be24(s->pb);
  235. tlen = id3v2_get_size(s->pb, 3);
  236. }
  237. len -= taghdrlen + tlen;
  238. if(len < 0)
  239. break;
  240. next = url_ftell(s->pb) + tlen;
  241. switch(tag) {
  242. case MKBETAG('T', 'I', 'T', '2'):
  243. case MKBETAG(0, 'T', 'T', '2'):
  244. id3v2_read_ttag(s, tlen, s->title, sizeof(s->title));
  245. break;
  246. case MKBETAG('T', 'P', 'E', '1'):
  247. case MKBETAG(0, 'T', 'P', '1'):
  248. id3v2_read_ttag(s, tlen, s->author, sizeof(s->author));
  249. break;
  250. case MKBETAG('T', 'A', 'L', 'B'):
  251. case MKBETAG(0, 'T', 'A', 'L'):
  252. id3v2_read_ttag(s, tlen, s->album, sizeof(s->album));
  253. break;
  254. case MKBETAG('T', 'C', 'O', 'N'):
  255. case MKBETAG(0, 'T', 'C', 'O'):
  256. id3v2_read_ttag(s, tlen, s->genre, sizeof(s->genre));
  257. break;
  258. case MKBETAG('T', 'C', 'O', 'P'):
  259. case MKBETAG(0, 'T', 'C', 'R'):
  260. id3v2_read_ttag(s, tlen, s->copyright, sizeof(s->copyright));
  261. break;
  262. case MKBETAG('T', 'R', 'C', 'K'):
  263. case MKBETAG(0, 'T', 'R', 'K'):
  264. id3v2_read_ttag(s, tlen, tmp, sizeof(tmp));
  265. s->track = atoi(tmp);
  266. break;
  267. case 0:
  268. /* padding, skip to end */
  269. url_fskip(s->pb, len);
  270. len = 0;
  271. continue;
  272. }
  273. /* Skip to end of tag */
  274. url_fseek(s->pb, next, SEEK_SET);
  275. }
  276. if(version == 4 && flags & 0x10) /* Footer preset, always 10 bytes, skip over it */
  277. url_fskip(s->pb, 10);
  278. return;
  279. error:
  280. av_log(s, AV_LOG_INFO, "ID3v2.%d tag skipped, cannot handle %s\n", version, reason);
  281. url_fskip(s->pb, len);
  282. }
  283. static void id3v1_get_string(char *str, int str_size,
  284. const uint8_t *buf, int buf_size)
  285. {
  286. int i, c;
  287. char *q;
  288. q = str;
  289. for(i = 0; i < buf_size; i++) {
  290. c = buf[i];
  291. if (c == '\0')
  292. break;
  293. if ((q - str) >= str_size - 1)
  294. break;
  295. *q++ = c;
  296. }
  297. *q = '\0';
  298. }
  299. /* 'buf' must be ID3v1_TAG_SIZE byte long */
  300. static int id3v1_parse_tag(AVFormatContext *s, const uint8_t *buf)
  301. {
  302. char str[5];
  303. int genre;
  304. if (!(buf[0] == 'T' &&
  305. buf[1] == 'A' &&
  306. buf[2] == 'G'))
  307. return -1;
  308. id3v1_get_string(s->title, sizeof(s->title), buf + 3, 30);
  309. id3v1_get_string(s->author, sizeof(s->author), buf + 33, 30);
  310. id3v1_get_string(s->album, sizeof(s->album), buf + 63, 30);
  311. id3v1_get_string(str, sizeof(str), buf + 93, 4);
  312. s->year = atoi(str);
  313. id3v1_get_string(s->comment, sizeof(s->comment), buf + 97, 30);
  314. if (buf[125] == 0 && buf[126] != 0)
  315. s->track = buf[126];
  316. genre = buf[127];
  317. if (genre <= ID3v1_GENRE_MAX)
  318. av_strlcpy(s->genre, id3v1_genre_str[genre], sizeof(s->genre));
  319. return 0;
  320. }
  321. /* mp3 read */
  322. static int mp3_read_probe(AVProbeData *p)
  323. {
  324. int max_frames, first_frames = 0;
  325. int fsize, frames, sample_rate;
  326. uint32_t header;
  327. uint8_t *buf, *buf2, *end;
  328. AVCodecContext avctx;
  329. if(ff_id3v2_match(p->buf))
  330. return AVPROBE_SCORE_MAX/2+1; // this must be less than mpeg-ps because some retards put id3v2 tags before mpeg-ps files
  331. max_frames = 0;
  332. buf = p->buf;
  333. end = buf + p->buf_size - sizeof(uint32_t);
  334. for(; buf < end; buf= buf2+1) {
  335. buf2 = buf;
  336. for(frames = 0; buf2 < end; frames++) {
  337. header = AV_RB32(buf2);
  338. fsize = ff_mpa_decode_header(&avctx, header, &sample_rate, &sample_rate, &sample_rate, &sample_rate);
  339. if(fsize < 0)
  340. break;
  341. buf2 += fsize;
  342. }
  343. max_frames = FFMAX(max_frames, frames);
  344. if(buf == p->buf)
  345. first_frames= frames;
  346. }
  347. if (first_frames>=3) return AVPROBE_SCORE_MAX/2+1;
  348. else if(max_frames>500)return AVPROBE_SCORE_MAX/2;
  349. else if(max_frames>=3) return AVPROBE_SCORE_MAX/4;
  350. else if(max_frames>=1) return 1;
  351. else return 0;
  352. }
  353. /**
  354. * Try to find Xing/Info/VBRI tags and compute duration from info therein
  355. */
  356. static int mp3_parse_vbr_tags(AVFormatContext *s, AVStream *st, int64_t base)
  357. {
  358. uint32_t v, spf;
  359. int frames = -1; /* Total number of frames in file */
  360. const int64_t xing_offtbl[2][2] = {{32, 17}, {17,9}};
  361. MPADecodeContext c;
  362. int vbrtag_size = 0;
  363. v = get_be32(s->pb);
  364. if(ff_mpa_check_header(v) < 0)
  365. return -1;
  366. if (ff_mpegaudio_decode_header(&c, v) == 0)
  367. vbrtag_size = c.frame_size;
  368. if(c.layer != 3)
  369. return -1;
  370. /* Check for Xing / Info tag */
  371. url_fseek(s->pb, xing_offtbl[c.lsf == 1][c.nb_channels == 1], SEEK_CUR);
  372. v = get_be32(s->pb);
  373. if(v == MKBETAG('X', 'i', 'n', 'g') || v == MKBETAG('I', 'n', 'f', 'o')) {
  374. v = get_be32(s->pb);
  375. if(v & 0x1)
  376. frames = get_be32(s->pb);
  377. }
  378. /* Check for VBRI tag (always 32 bytes after end of mpegaudio header) */
  379. url_fseek(s->pb, base + 4 + 32, SEEK_SET);
  380. v = get_be32(s->pb);
  381. if(v == MKBETAG('V', 'B', 'R', 'I')) {
  382. /* Check tag version */
  383. if(get_be16(s->pb) == 1) {
  384. /* skip delay, quality and total bytes */
  385. url_fseek(s->pb, 8, SEEK_CUR);
  386. frames = get_be32(s->pb);
  387. }
  388. }
  389. if(frames < 0)
  390. return -1;
  391. /* Skip the vbr tag frame */
  392. url_fseek(s->pb, base + vbrtag_size, SEEK_SET);
  393. spf = c.lsf ? 576 : 1152; /* Samples per frame, layer 3 */
  394. st->duration = av_rescale_q(frames, (AVRational){spf, c.sample_rate},
  395. st->time_base);
  396. return 0;
  397. }
  398. static int mp3_read_header(AVFormatContext *s,
  399. AVFormatParameters *ap)
  400. {
  401. AVStream *st;
  402. uint8_t buf[ID3v1_TAG_SIZE];
  403. int len, ret, filesize;
  404. int64_t off;
  405. st = av_new_stream(s, 0);
  406. if (!st)
  407. return AVERROR(ENOMEM);
  408. st->codec->codec_type = CODEC_TYPE_AUDIO;
  409. st->codec->codec_id = CODEC_ID_MP3;
  410. st->need_parsing = AVSTREAM_PARSE_FULL;
  411. st->start_time = 0;
  412. /* try to get the TAG */
  413. if (!url_is_streamed(s->pb)) {
  414. /* XXX: change that */
  415. filesize = url_fsize(s->pb);
  416. if (filesize > 128) {
  417. url_fseek(s->pb, filesize - 128, SEEK_SET);
  418. ret = get_buffer(s->pb, buf, ID3v1_TAG_SIZE);
  419. if (ret == ID3v1_TAG_SIZE) {
  420. id3v1_parse_tag(s, buf);
  421. }
  422. url_fseek(s->pb, 0, SEEK_SET);
  423. }
  424. }
  425. /* if ID3v2 header found, skip it */
  426. ret = get_buffer(s->pb, buf, ID3v2_HEADER_SIZE);
  427. if (ret != ID3v2_HEADER_SIZE)
  428. return -1;
  429. if (ff_id3v2_match(buf)) {
  430. /* parse ID3v2 header */
  431. len = ((buf[6] & 0x7f) << 21) |
  432. ((buf[7] & 0x7f) << 14) |
  433. ((buf[8] & 0x7f) << 7) |
  434. (buf[9] & 0x7f);
  435. id3v2_parse(s, len, buf[3], buf[5]);
  436. } else {
  437. url_fseek(s->pb, 0, SEEK_SET);
  438. }
  439. off = url_ftell(s->pb);
  440. if (mp3_parse_vbr_tags(s, st, off) < 0)
  441. url_fseek(s->pb, off, SEEK_SET);
  442. /* the parameters will be extracted from the compressed bitstream */
  443. return 0;
  444. }
  445. #define MP3_PACKET_SIZE 1024
  446. static int mp3_read_packet(AVFormatContext *s, AVPacket *pkt)
  447. {
  448. int ret, size;
  449. // AVStream *st = s->streams[0];
  450. size= MP3_PACKET_SIZE;
  451. ret= av_get_packet(s->pb, pkt, size);
  452. pkt->stream_index = 0;
  453. if (ret <= 0) {
  454. return AVERROR(EIO);
  455. }
  456. /* note: we need to modify the packet size here to handle the last
  457. packet */
  458. pkt->size = ret;
  459. return ret;
  460. }
  461. #if CONFIG_MP2_MUXER || CONFIG_MP3_MUXER
  462. static void id3v1_create_tag(AVFormatContext *s, uint8_t *buf)
  463. {
  464. int v, i;
  465. memset(buf, 0, ID3v1_TAG_SIZE); /* fail safe */
  466. buf[0] = 'T';
  467. buf[1] = 'A';
  468. buf[2] = 'G';
  469. strncpy(buf + 3, s->title, 30);
  470. strncpy(buf + 33, s->author, 30);
  471. strncpy(buf + 63, s->album, 30);
  472. v = s->year;
  473. if (v > 0) {
  474. for(i = 0;i < 4; i++) {
  475. buf[96 - i] = '0' + (v % 10);
  476. v = v / 10;
  477. }
  478. }
  479. strncpy(buf + 97, s->comment, 30);
  480. if (s->track != 0) {
  481. buf[125] = 0;
  482. buf[126] = s->track;
  483. }
  484. for(i = 0; i <= ID3v1_GENRE_MAX; i++) {
  485. if (!strcasecmp(s->genre, id3v1_genre_str[i])) {
  486. buf[127] = i;
  487. break;
  488. }
  489. }
  490. }
  491. /* simple formats */
  492. static void id3v2_put_size(AVFormatContext *s, int size)
  493. {
  494. put_byte(s->pb, size >> 21 & 0x7f);
  495. put_byte(s->pb, size >> 14 & 0x7f);
  496. put_byte(s->pb, size >> 7 & 0x7f);
  497. put_byte(s->pb, size & 0x7f);
  498. }
  499. static void id3v2_put_ttag(AVFormatContext *s, const char *string, uint32_t tag)
  500. {
  501. int len = strlen(string);
  502. put_be32(s->pb, tag);
  503. id3v2_put_size(s, len + 1);
  504. put_be16(s->pb, 0);
  505. put_byte(s->pb, 3); /* UTF-8 */
  506. put_buffer(s->pb, string, len);
  507. }
  508. /**
  509. * Write an ID3v2.4 header at beginning of stream
  510. */
  511. static int mp3_write_header(struct AVFormatContext *s)
  512. {
  513. int totlen = 0;
  514. char tracktxt[10];
  515. char yeartxt[10];
  516. if(s->track)
  517. snprintf(tracktxt, sizeof(tracktxt), "%d", s->track);
  518. if(s->year)
  519. snprintf( yeartxt, sizeof(yeartxt) , "%d", s->year );
  520. if(s->title[0]) totlen += 11 + strlen(s->title);
  521. if(s->author[0]) totlen += 11 + strlen(s->author);
  522. if(s->album[0]) totlen += 11 + strlen(s->album);
  523. if(s->genre[0]) totlen += 11 + strlen(s->genre);
  524. if(s->copyright[0]) totlen += 11 + strlen(s->copyright);
  525. if(s->track) totlen += 11 + strlen(tracktxt);
  526. if(s->year) totlen += 11 + strlen(yeartxt);
  527. if(!(s->streams[0]->codec->flags & CODEC_FLAG_BITEXACT))
  528. totlen += strlen(LIBAVFORMAT_IDENT) + 11;
  529. if(totlen == 0)
  530. return 0;
  531. put_be32(s->pb, MKBETAG('I', 'D', '3', 0x04)); /* ID3v2.4 */
  532. put_byte(s->pb, 0);
  533. put_byte(s->pb, 0); /* flags */
  534. id3v2_put_size(s, totlen);
  535. if(s->title[0]) id3v2_put_ttag(s, s->title, MKBETAG('T', 'I', 'T', '2'));
  536. if(s->author[0]) id3v2_put_ttag(s, s->author, MKBETAG('T', 'P', 'E', '1'));
  537. if(s->album[0]) id3v2_put_ttag(s, s->album, MKBETAG('T', 'A', 'L', 'B'));
  538. if(s->genre[0]) id3v2_put_ttag(s, s->genre, MKBETAG('T', 'C', 'O', 'N'));
  539. if(s->copyright[0]) id3v2_put_ttag(s, s->copyright, MKBETAG('T', 'C', 'O', 'P'));
  540. if(s->track) id3v2_put_ttag(s, tracktxt, MKBETAG('T', 'R', 'C', 'K'));
  541. if(s->year) id3v2_put_ttag(s, yeartxt, MKBETAG('T', 'Y', 'E', 'R'));
  542. if(!(s->streams[0]->codec->flags & CODEC_FLAG_BITEXACT))
  543. id3v2_put_ttag(s, LIBAVFORMAT_IDENT, MKBETAG('T', 'E', 'N', 'C'));
  544. return 0;
  545. }
  546. static int mp3_write_packet(struct AVFormatContext *s, AVPacket *pkt)
  547. {
  548. put_buffer(s->pb, pkt->data, pkt->size);
  549. put_flush_packet(s->pb);
  550. return 0;
  551. }
  552. static int mp3_write_trailer(struct AVFormatContext *s)
  553. {
  554. uint8_t buf[ID3v1_TAG_SIZE];
  555. /* write the id3v1 tag */
  556. if (s->title[0] != '\0') {
  557. id3v1_create_tag(s, buf);
  558. put_buffer(s->pb, buf, ID3v1_TAG_SIZE);
  559. put_flush_packet(s->pb);
  560. }
  561. return 0;
  562. }
  563. #endif /* CONFIG_MP2_MUXER || CONFIG_MP3_MUXER */
  564. #if CONFIG_MP3_DEMUXER
  565. AVInputFormat mp3_demuxer = {
  566. "mp3",
  567. NULL_IF_CONFIG_SMALL("MPEG audio"),
  568. 0,
  569. mp3_read_probe,
  570. mp3_read_header,
  571. mp3_read_packet,
  572. .flags= AVFMT_GENERIC_INDEX,
  573. .extensions = "mp2,mp3,m2a", /* XXX: use probe */
  574. };
  575. #endif
  576. #if CONFIG_MP2_MUXER
  577. AVOutputFormat mp2_muxer = {
  578. "mp2",
  579. NULL_IF_CONFIG_SMALL("MPEG audio layer 2"),
  580. "audio/x-mpeg",
  581. #if CONFIG_LIBMP3LAME
  582. "mp2,m2a",
  583. #else
  584. "mp2,mp3,m2a",
  585. #endif
  586. 0,
  587. CODEC_ID_MP2,
  588. CODEC_ID_NONE,
  589. NULL,
  590. mp3_write_packet,
  591. mp3_write_trailer,
  592. };
  593. #endif
  594. #if CONFIG_MP3_MUXER
  595. AVOutputFormat mp3_muxer = {
  596. "mp3",
  597. NULL_IF_CONFIG_SMALL("MPEG audio layer 3"),
  598. "audio/x-mpeg",
  599. "mp3",
  600. 0,
  601. CODEC_ID_MP3,
  602. CODEC_ID_NONE,
  603. mp3_write_header,
  604. mp3_write_packet,
  605. mp3_write_trailer,
  606. };
  607. #endif