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.

690 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= buf2+1) {
  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. }
  386. if (first_frames>=3) return AVPROBE_SCORE_MAX/2+1;
  387. else if(max_frames>500)return AVPROBE_SCORE_MAX/2;
  388. else if(max_frames>=3) return AVPROBE_SCORE_MAX/4;
  389. else if(max_frames>=1) return 1;
  390. else return 0;
  391. }
  392. /**
  393. * Try to find Xing/Info/VBRI tags and compute duration from info therein
  394. */
  395. static void mp3_parse_vbr_tags(AVFormatContext *s, AVStream *st, offset_t base)
  396. {
  397. uint32_t v, spf;
  398. int frames = -1; /* Total number of frames in file */
  399. const offset_t xing_offtbl[2][2] = {{32, 17}, {17,9}};
  400. MPADecodeContext c;
  401. v = get_be32(s->pb);
  402. if(ff_mpa_check_header(v) < 0)
  403. return;
  404. ff_mpegaudio_decode_header(&c, v);
  405. if(c.layer != 3)
  406. return;
  407. /* Check for Xing / Info tag */
  408. url_fseek(s->pb, xing_offtbl[c.lsf == 1][c.nb_channels == 1], SEEK_CUR);
  409. v = get_be32(s->pb);
  410. if(v == MKBETAG('X', 'i', 'n', 'g') || v == MKBETAG('I', 'n', 'f', 'o')) {
  411. v = get_be32(s->pb);
  412. if(v & 0x1)
  413. frames = get_be32(s->pb);
  414. }
  415. /* Check for VBRI tag (always 32 bytes after end of mpegaudio header) */
  416. url_fseek(s->pb, base + 4 + 32, SEEK_SET);
  417. v = get_be32(s->pb);
  418. if(v == MKBETAG('V', 'B', 'R', 'I')) {
  419. /* Check tag version */
  420. if(get_be16(s->pb) == 1) {
  421. /* skip delay, quality and total bytes */
  422. url_fseek(s->pb, 8, SEEK_CUR);
  423. frames = get_be32(s->pb);
  424. }
  425. }
  426. if(frames < 0)
  427. return;
  428. spf = c.lsf ? 576 : 1152; /* Samples per frame, layer 3 */
  429. st->duration = av_rescale_q(frames, (AVRational){spf, c.sample_rate},
  430. st->time_base);
  431. }
  432. static int mp3_read_header(AVFormatContext *s,
  433. AVFormatParameters *ap)
  434. {
  435. AVStream *st;
  436. uint8_t buf[ID3v1_TAG_SIZE];
  437. int len, ret, filesize;
  438. offset_t off;
  439. st = av_new_stream(s, 0);
  440. if (!st)
  441. return AVERROR(ENOMEM);
  442. st->codec->codec_type = CODEC_TYPE_AUDIO;
  443. st->codec->codec_id = CODEC_ID_MP3;
  444. st->need_parsing = AVSTREAM_PARSE_FULL;
  445. st->start_time = 0;
  446. /* try to get the TAG */
  447. if (!url_is_streamed(s->pb)) {
  448. /* XXX: change that */
  449. filesize = url_fsize(s->pb);
  450. if (filesize > 128) {
  451. url_fseek(s->pb, filesize - 128, SEEK_SET);
  452. ret = get_buffer(s->pb, buf, ID3v1_TAG_SIZE);
  453. if (ret == ID3v1_TAG_SIZE) {
  454. id3v1_parse_tag(s, buf);
  455. }
  456. url_fseek(s->pb, 0, SEEK_SET);
  457. }
  458. }
  459. /* if ID3v2 header found, skip it */
  460. ret = get_buffer(s->pb, buf, ID3v2_HEADER_SIZE);
  461. if (ret != ID3v2_HEADER_SIZE)
  462. return -1;
  463. if (id3v2_match(buf)) {
  464. /* parse ID3v2 header */
  465. len = ((buf[6] & 0x7f) << 21) |
  466. ((buf[7] & 0x7f) << 14) |
  467. ((buf[8] & 0x7f) << 7) |
  468. (buf[9] & 0x7f);
  469. id3v2_parse(s, len, buf[3], buf[5]);
  470. } else {
  471. url_fseek(s->pb, 0, SEEK_SET);
  472. }
  473. off = url_ftell(s->pb);
  474. mp3_parse_vbr_tags(s, st, off);
  475. url_fseek(s->pb, off, SEEK_SET);
  476. /* the parameters will be extracted from the compressed bitstream */
  477. return 0;
  478. }
  479. #define MP3_PACKET_SIZE 1024
  480. static int mp3_read_packet(AVFormatContext *s, AVPacket *pkt)
  481. {
  482. int ret, size;
  483. // AVStream *st = s->streams[0];
  484. size= MP3_PACKET_SIZE;
  485. ret= av_get_packet(s->pb, pkt, size);
  486. pkt->stream_index = 0;
  487. if (ret <= 0) {
  488. return AVERROR(EIO);
  489. }
  490. /* note: we need to modify the packet size here to handle the last
  491. packet */
  492. pkt->size = ret;
  493. return ret;
  494. }
  495. static int mp3_read_close(AVFormatContext *s)
  496. {
  497. return 0;
  498. }
  499. #ifdef CONFIG_MUXERS
  500. /* simple formats */
  501. static void id3v2_put_size(AVFormatContext *s, int size)
  502. {
  503. put_byte(s->pb, size >> 21 & 0x7f);
  504. put_byte(s->pb, size >> 14 & 0x7f);
  505. put_byte(s->pb, size >> 7 & 0x7f);
  506. put_byte(s->pb, size & 0x7f);
  507. }
  508. static void id3v2_put_ttag(AVFormatContext *s, const char *string, uint32_t tag)
  509. {
  510. int len = strlen(string);
  511. put_be32(s->pb, tag);
  512. id3v2_put_size(s, len + 1);
  513. put_be16(s->pb, 0);
  514. put_byte(s->pb, 3); /* UTF-8 */
  515. put_buffer(s->pb, string, len);
  516. }
  517. /**
  518. * Write an ID3v2.4 header at beginning of stream
  519. */
  520. static int mp3_write_header(struct AVFormatContext *s)
  521. {
  522. int totlen = 0;
  523. char tracktxt[10];
  524. char yeartxt[10];
  525. if(s->track)
  526. snprintf(tracktxt, sizeof(tracktxt), "%d", s->track);
  527. if(s->year)
  528. snprintf( yeartxt, sizeof(yeartxt) , "%d", s->year );
  529. if(s->title[0]) totlen += 11 + strlen(s->title);
  530. if(s->author[0]) totlen += 11 + strlen(s->author);
  531. if(s->album[0]) totlen += 11 + strlen(s->album);
  532. if(s->genre[0]) totlen += 11 + strlen(s->genre);
  533. if(s->copyright[0]) totlen += 11 + strlen(s->copyright);
  534. if(s->track) totlen += 11 + strlen(tracktxt);
  535. if(s->year) totlen += 11 + strlen(yeartxt);
  536. if(!(s->streams[0]->codec->flags & CODEC_FLAG_BITEXACT))
  537. totlen += strlen(LIBAVFORMAT_IDENT) + 11;
  538. if(totlen == 0)
  539. return 0;
  540. put_be32(s->pb, MKBETAG('I', 'D', '3', 0x04)); /* ID3v2.4 */
  541. put_byte(s->pb, 0);
  542. put_byte(s->pb, 0); /* flags */
  543. id3v2_put_size(s, totlen);
  544. if(s->title[0]) id3v2_put_ttag(s, s->title, MKBETAG('T', 'I', 'T', '2'));
  545. if(s->author[0]) id3v2_put_ttag(s, s->author, MKBETAG('T', 'P', 'E', '1'));
  546. if(s->album[0]) id3v2_put_ttag(s, s->album, MKBETAG('T', 'A', 'L', 'B'));
  547. if(s->genre[0]) id3v2_put_ttag(s, s->genre, MKBETAG('T', 'C', 'O', 'N'));
  548. if(s->copyright[0]) id3v2_put_ttag(s, s->copyright, MKBETAG('T', 'C', 'O', 'P'));
  549. if(s->track) id3v2_put_ttag(s, tracktxt, MKBETAG('T', 'R', 'C', 'K'));
  550. if(s->year) id3v2_put_ttag(s, yeartxt, MKBETAG('T', 'Y', 'E', 'R'));
  551. if(!(s->streams[0]->codec->flags & CODEC_FLAG_BITEXACT))
  552. id3v2_put_ttag(s, LIBAVFORMAT_IDENT, MKBETAG('T', 'E', 'N', 'C'));
  553. return 0;
  554. }
  555. static int mp3_write_packet(struct AVFormatContext *s, AVPacket *pkt)
  556. {
  557. put_buffer(s->pb, pkt->data, pkt->size);
  558. put_flush_packet(s->pb);
  559. return 0;
  560. }
  561. static int mp3_write_trailer(struct AVFormatContext *s)
  562. {
  563. uint8_t buf[ID3v1_TAG_SIZE];
  564. /* write the id3v1 tag */
  565. if (s->title[0] != '\0') {
  566. id3v1_create_tag(s, buf);
  567. put_buffer(s->pb, buf, ID3v1_TAG_SIZE);
  568. put_flush_packet(s->pb);
  569. }
  570. return 0;
  571. }
  572. #endif //CONFIG_MUXERS
  573. #ifdef CONFIG_MP3_DEMUXER
  574. AVInputFormat mp3_demuxer = {
  575. "mp3",
  576. "MPEG audio",
  577. 0,
  578. mp3_read_probe,
  579. mp3_read_header,
  580. mp3_read_packet,
  581. mp3_read_close,
  582. .flags= AVFMT_GENERIC_INDEX,
  583. .extensions = "mp2,mp3,m2a", /* XXX: use probe */
  584. };
  585. #endif
  586. #ifdef CONFIG_MP2_MUXER
  587. AVOutputFormat mp2_muxer = {
  588. "mp2",
  589. "MPEG audio layer 2",
  590. "audio/x-mpeg",
  591. #ifdef CONFIG_LIBMP3LAME
  592. "mp2,m2a",
  593. #else
  594. "mp2,mp3,m2a",
  595. #endif
  596. 0,
  597. CODEC_ID_MP2,
  598. 0,
  599. NULL,
  600. mp3_write_packet,
  601. mp3_write_trailer,
  602. };
  603. #endif
  604. #ifdef CONFIG_MP3_MUXER
  605. AVOutputFormat mp3_muxer = {
  606. "mp3",
  607. "MPEG audio layer 3",
  608. "audio/x-mpeg",
  609. "mp3",
  610. 0,
  611. CODEC_ID_MP3,
  612. 0,
  613. mp3_write_header,
  614. mp3_write_packet,
  615. mp3_write_trailer,
  616. };
  617. #endif