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.

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