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.

694 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. #define ID3v2_HEADER_SIZE 10
  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. /* buf must be ID3v2_HEADER_SIZE byte long */
  158. static int id3v2_match(const uint8_t *buf)
  159. {
  160. return buf[0] == 'I' &&
  161. buf[1] == 'D' &&
  162. buf[2] == '3' &&
  163. buf[3] != 0xff &&
  164. buf[4] != 0xff &&
  165. (buf[6] & 0x80) == 0 &&
  166. (buf[7] & 0x80) == 0 &&
  167. (buf[8] & 0x80) == 0 &&
  168. (buf[9] & 0x80) == 0;
  169. }
  170. static unsigned int id3v2_get_size(ByteIOContext *s, int len)
  171. {
  172. int v=0;
  173. while(len--)
  174. v= (v<<7) + (get_byte(s)&0x7F);
  175. return v;
  176. }
  177. static void id3v2_read_ttag(AVFormatContext *s, int taglen, char *dst, int dstlen)
  178. {
  179. char *q;
  180. int len;
  181. if(dstlen > 0)
  182. dst[0]= 0;
  183. if(taglen < 1)
  184. return;
  185. taglen--; /* account for encoding type byte */
  186. dstlen--; /* Leave space for zero terminator */
  187. switch(get_byte(s->pb)) { /* encoding type */
  188. case 0: /* ISO-8859-1 (0 - 255 maps directly into unicode) */
  189. q = dst;
  190. while(taglen--) {
  191. uint8_t tmp;
  192. PUT_UTF8(get_byte(s->pb), tmp, if (q - dst < dstlen - 1) *q++ = tmp;)
  193. }
  194. *q = '\0';
  195. break;
  196. case 3: /* UTF-8 */
  197. len = FFMIN(taglen, dstlen-1);
  198. get_buffer(s->pb, dst, len);
  199. dst[len] = 0;
  200. break;
  201. }
  202. }
  203. /**
  204. * ID3v2 parser
  205. *
  206. * Handles ID3v2.2, 2.3 and 2.4.
  207. *
  208. */
  209. static void id3v2_parse(AVFormatContext *s, int len, uint8_t version, uint8_t flags)
  210. {
  211. int isv34, tlen;
  212. uint32_t tag;
  213. int64_t next;
  214. char tmp[16];
  215. int taghdrlen;
  216. const char *reason;
  217. switch(version) {
  218. case 2:
  219. if(flags & 0x40) {
  220. reason = "compression";
  221. goto error;
  222. }
  223. isv34 = 0;
  224. taghdrlen = 6;
  225. break;
  226. case 3:
  227. case 4:
  228. isv34 = 1;
  229. taghdrlen = 10;
  230. break;
  231. default:
  232. reason = "version";
  233. goto error;
  234. }
  235. if(flags & 0x80) {
  236. reason = "unsynchronization";
  237. goto error;
  238. }
  239. if(isv34 && flags & 0x40) /* Extended header present, just skip over it */
  240. url_fskip(s->pb, id3v2_get_size(s->pb, 4));
  241. while(len >= taghdrlen) {
  242. if(isv34) {
  243. tag = get_be32(s->pb);
  244. tlen = id3v2_get_size(s->pb, 4);
  245. get_be16(s->pb); /* flags */
  246. } else {
  247. tag = get_be24(s->pb);
  248. tlen = id3v2_get_size(s->pb, 3);
  249. }
  250. len -= taghdrlen + tlen;
  251. if(len < 0)
  252. break;
  253. next = url_ftell(s->pb) + tlen;
  254. switch(tag) {
  255. case MKBETAG('T', 'I', 'T', '2'):
  256. case MKBETAG(0, 'T', 'T', '2'):
  257. id3v2_read_ttag(s, tlen, s->title, sizeof(s->title));
  258. break;
  259. case MKBETAG('T', 'P', 'E', '1'):
  260. case MKBETAG(0, 'T', 'P', '1'):
  261. id3v2_read_ttag(s, tlen, s->author, sizeof(s->author));
  262. break;
  263. case MKBETAG('T', 'A', 'L', 'B'):
  264. case MKBETAG(0, 'T', 'A', 'L'):
  265. id3v2_read_ttag(s, tlen, s->album, sizeof(s->album));
  266. break;
  267. case MKBETAG('T', 'C', 'O', 'N'):
  268. case MKBETAG(0, 'T', 'C', 'O'):
  269. id3v2_read_ttag(s, tlen, s->genre, sizeof(s->genre));
  270. break;
  271. case MKBETAG('T', 'C', 'O', 'P'):
  272. case MKBETAG(0, 'T', 'C', 'R'):
  273. id3v2_read_ttag(s, tlen, s->copyright, sizeof(s->copyright));
  274. break;
  275. case MKBETAG('T', 'R', 'C', 'K'):
  276. case MKBETAG(0, 'T', 'R', 'K'):
  277. id3v2_read_ttag(s, tlen, tmp, sizeof(tmp));
  278. s->track = atoi(tmp);
  279. break;
  280. case 0:
  281. /* padding, skip to end */
  282. url_fskip(s->pb, len);
  283. len = 0;
  284. continue;
  285. }
  286. /* Skip to end of tag */
  287. url_fseek(s->pb, next, SEEK_SET);
  288. }
  289. if(version == 4 && flags & 0x10) /* Footer preset, always 10 bytes, skip over it */
  290. url_fskip(s->pb, 10);
  291. return;
  292. error:
  293. av_log(s, AV_LOG_INFO, "ID3v2.%d tag skipped, cannot handle %s\n", version, reason);
  294. url_fskip(s->pb, len);
  295. }
  296. static void id3v1_get_string(char *str, int str_size,
  297. const uint8_t *buf, int buf_size)
  298. {
  299. int i, c;
  300. char *q;
  301. q = str;
  302. for(i = 0; i < buf_size; i++) {
  303. c = buf[i];
  304. if (c == '\0')
  305. break;
  306. if ((q - str) >= str_size - 1)
  307. break;
  308. *q++ = c;
  309. }
  310. *q = '\0';
  311. }
  312. /* 'buf' must be ID3v1_TAG_SIZE byte long */
  313. static int id3v1_parse_tag(AVFormatContext *s, const uint8_t *buf)
  314. {
  315. char str[5];
  316. int genre;
  317. if (!(buf[0] == 'T' &&
  318. buf[1] == 'A' &&
  319. buf[2] == 'G'))
  320. return -1;
  321. id3v1_get_string(s->title, sizeof(s->title), buf + 3, 30);
  322. id3v1_get_string(s->author, sizeof(s->author), buf + 33, 30);
  323. id3v1_get_string(s->album, sizeof(s->album), buf + 63, 30);
  324. id3v1_get_string(str, sizeof(str), buf + 93, 4);
  325. s->year = atoi(str);
  326. id3v1_get_string(s->comment, sizeof(s->comment), buf + 97, 30);
  327. if (buf[125] == 0 && buf[126] != 0)
  328. s->track = buf[126];
  329. genre = buf[127];
  330. if (genre <= ID3v1_GENRE_MAX)
  331. av_strlcpy(s->genre, id3v1_genre_str[genre], sizeof(s->genre));
  332. return 0;
  333. }
  334. /* mp3 read */
  335. static int mp3_read_probe(AVProbeData *p)
  336. {
  337. int max_frames, first_frames = 0;
  338. int fsize, frames, sample_rate;
  339. uint32_t header;
  340. uint8_t *buf, *buf2, *end;
  341. AVCodecContext avctx;
  342. if(id3v2_match(p->buf))
  343. return AVPROBE_SCORE_MAX/2+1; // this must be less than mpeg-ps because some retards put id3v2 tags before mpeg-ps files
  344. max_frames = 0;
  345. buf = p->buf;
  346. end = buf + p->buf_size - sizeof(uint32_t);
  347. for(; buf < end; buf= buf2+1) {
  348. buf2 = buf;
  349. for(frames = 0; buf2 < end; frames++) {
  350. header = AV_RB32(buf2);
  351. fsize = ff_mpa_decode_header(&avctx, header, &sample_rate, &sample_rate, &sample_rate, &sample_rate);
  352. if(fsize < 0)
  353. break;
  354. buf2 += fsize;
  355. }
  356. max_frames = FFMAX(max_frames, frames);
  357. if(buf == p->buf)
  358. first_frames= frames;
  359. }
  360. if (first_frames>=3) return AVPROBE_SCORE_MAX/2+1;
  361. else if(max_frames>500)return AVPROBE_SCORE_MAX/2;
  362. else if(max_frames>=3) return AVPROBE_SCORE_MAX/4;
  363. else if(max_frames>=1) return 1;
  364. else return 0;
  365. }
  366. /**
  367. * Try to find Xing/Info/VBRI tags and compute duration from info therein
  368. */
  369. static int mp3_parse_vbr_tags(AVFormatContext *s, AVStream *st, int64_t base)
  370. {
  371. uint32_t v, spf;
  372. int frames = -1; /* Total number of frames in file */
  373. const int64_t xing_offtbl[2][2] = {{32, 17}, {17,9}};
  374. MPADecodeContext c;
  375. int vbrtag_size = 0;
  376. v = get_be32(s->pb);
  377. if(ff_mpa_check_header(v) < 0)
  378. return -1;
  379. if (ff_mpegaudio_decode_header(&c, v) == 0)
  380. vbrtag_size = c.frame_size;
  381. if(c.layer != 3)
  382. return -1;
  383. /* Check for Xing / Info tag */
  384. url_fseek(s->pb, xing_offtbl[c.lsf == 1][c.nb_channels == 1], SEEK_CUR);
  385. v = get_be32(s->pb);
  386. if(v == MKBETAG('X', 'i', 'n', 'g') || v == MKBETAG('I', 'n', 'f', 'o')) {
  387. v = get_be32(s->pb);
  388. if(v & 0x1)
  389. frames = get_be32(s->pb);
  390. }
  391. /* Check for VBRI tag (always 32 bytes after end of mpegaudio header) */
  392. url_fseek(s->pb, base + 4 + 32, SEEK_SET);
  393. v = get_be32(s->pb);
  394. if(v == MKBETAG('V', 'B', 'R', 'I')) {
  395. /* Check tag version */
  396. if(get_be16(s->pb) == 1) {
  397. /* skip delay, quality and total bytes */
  398. url_fseek(s->pb, 8, SEEK_CUR);
  399. frames = get_be32(s->pb);
  400. }
  401. }
  402. if(frames < 0)
  403. return -1;
  404. /* Skip the vbr tag frame */
  405. url_fseek(s->pb, base + vbrtag_size, SEEK_SET);
  406. spf = c.lsf ? 576 : 1152; /* Samples per frame, layer 3 */
  407. st->duration = av_rescale_q(frames, (AVRational){spf, c.sample_rate},
  408. st->time_base);
  409. return 0;
  410. }
  411. static int mp3_read_header(AVFormatContext *s,
  412. AVFormatParameters *ap)
  413. {
  414. AVStream *st;
  415. uint8_t buf[ID3v1_TAG_SIZE];
  416. int len, ret, filesize;
  417. int64_t off;
  418. st = av_new_stream(s, 0);
  419. if (!st)
  420. return AVERROR(ENOMEM);
  421. st->codec->codec_type = CODEC_TYPE_AUDIO;
  422. st->codec->codec_id = CODEC_ID_MP3;
  423. st->need_parsing = AVSTREAM_PARSE_FULL;
  424. st->start_time = 0;
  425. /* try to get the TAG */
  426. if (!url_is_streamed(s->pb)) {
  427. /* XXX: change that */
  428. filesize = url_fsize(s->pb);
  429. if (filesize > 128) {
  430. url_fseek(s->pb, filesize - 128, SEEK_SET);
  431. ret = get_buffer(s->pb, buf, ID3v1_TAG_SIZE);
  432. if (ret == ID3v1_TAG_SIZE) {
  433. id3v1_parse_tag(s, buf);
  434. }
  435. url_fseek(s->pb, 0, SEEK_SET);
  436. }
  437. }
  438. /* if ID3v2 header found, skip it */
  439. ret = get_buffer(s->pb, buf, ID3v2_HEADER_SIZE);
  440. if (ret != ID3v2_HEADER_SIZE)
  441. return -1;
  442. if (id3v2_match(buf)) {
  443. /* parse ID3v2 header */
  444. len = ((buf[6] & 0x7f) << 21) |
  445. ((buf[7] & 0x7f) << 14) |
  446. ((buf[8] & 0x7f) << 7) |
  447. (buf[9] & 0x7f);
  448. id3v2_parse(s, len, buf[3], buf[5]);
  449. } else {
  450. url_fseek(s->pb, 0, SEEK_SET);
  451. }
  452. off = url_ftell(s->pb);
  453. if (mp3_parse_vbr_tags(s, st, off) < 0)
  454. url_fseek(s->pb, off, SEEK_SET);
  455. /* the parameters will be extracted from the compressed bitstream */
  456. return 0;
  457. }
  458. #define MP3_PACKET_SIZE 1024
  459. static int mp3_read_packet(AVFormatContext *s, AVPacket *pkt)
  460. {
  461. int ret, size;
  462. // AVStream *st = s->streams[0];
  463. size= MP3_PACKET_SIZE;
  464. ret= av_get_packet(s->pb, pkt, size);
  465. pkt->stream_index = 0;
  466. if (ret <= 0) {
  467. return AVERROR(EIO);
  468. }
  469. /* note: we need to modify the packet size here to handle the last
  470. packet */
  471. pkt->size = ret;
  472. return ret;
  473. }
  474. #if defined(CONFIG_MP2_MUXER) || defined(CONFIG_MP3_MUXER)
  475. static void id3v1_create_tag(AVFormatContext *s, uint8_t *buf)
  476. {
  477. int v, i;
  478. memset(buf, 0, ID3v1_TAG_SIZE); /* fail safe */
  479. buf[0] = 'T';
  480. buf[1] = 'A';
  481. buf[2] = 'G';
  482. strncpy(buf + 3, s->title, 30);
  483. strncpy(buf + 33, s->author, 30);
  484. strncpy(buf + 63, s->album, 30);
  485. v = s->year;
  486. if (v > 0) {
  487. for(i = 0;i < 4; i++) {
  488. buf[96 - i] = '0' + (v % 10);
  489. v = v / 10;
  490. }
  491. }
  492. strncpy(buf + 97, s->comment, 30);
  493. if (s->track != 0) {
  494. buf[125] = 0;
  495. buf[126] = s->track;
  496. }
  497. for(i = 0; i <= ID3v1_GENRE_MAX; i++) {
  498. if (!strcasecmp(s->genre, id3v1_genre_str[i])) {
  499. buf[127] = i;
  500. break;
  501. }
  502. }
  503. }
  504. /* simple formats */
  505. static void id3v2_put_size(AVFormatContext *s, int size)
  506. {
  507. put_byte(s->pb, size >> 21 & 0x7f);
  508. put_byte(s->pb, size >> 14 & 0x7f);
  509. put_byte(s->pb, size >> 7 & 0x7f);
  510. put_byte(s->pb, size & 0x7f);
  511. }
  512. static void id3v2_put_ttag(AVFormatContext *s, const char *string, uint32_t tag)
  513. {
  514. int len = strlen(string);
  515. put_be32(s->pb, tag);
  516. id3v2_put_size(s, len + 1);
  517. put_be16(s->pb, 0);
  518. put_byte(s->pb, 3); /* UTF-8 */
  519. put_buffer(s->pb, string, len);
  520. }
  521. /**
  522. * Write an ID3v2.4 header at beginning of stream
  523. */
  524. static int mp3_write_header(struct AVFormatContext *s)
  525. {
  526. int totlen = 0;
  527. char tracktxt[10];
  528. char yeartxt[10];
  529. if(s->track)
  530. snprintf(tracktxt, sizeof(tracktxt), "%d", s->track);
  531. if(s->year)
  532. snprintf( yeartxt, sizeof(yeartxt) , "%d", s->year );
  533. if(s->title[0]) totlen += 11 + strlen(s->title);
  534. if(s->author[0]) totlen += 11 + strlen(s->author);
  535. if(s->album[0]) totlen += 11 + strlen(s->album);
  536. if(s->genre[0]) totlen += 11 + strlen(s->genre);
  537. if(s->copyright[0]) totlen += 11 + strlen(s->copyright);
  538. if(s->track) totlen += 11 + strlen(tracktxt);
  539. if(s->year) totlen += 11 + strlen(yeartxt);
  540. if(!(s->streams[0]->codec->flags & CODEC_FLAG_BITEXACT))
  541. totlen += strlen(LIBAVFORMAT_IDENT) + 11;
  542. if(totlen == 0)
  543. return 0;
  544. put_be32(s->pb, MKBETAG('I', 'D', '3', 0x04)); /* ID3v2.4 */
  545. put_byte(s->pb, 0);
  546. put_byte(s->pb, 0); /* flags */
  547. id3v2_put_size(s, totlen);
  548. if(s->title[0]) id3v2_put_ttag(s, s->title, MKBETAG('T', 'I', 'T', '2'));
  549. if(s->author[0]) id3v2_put_ttag(s, s->author, MKBETAG('T', 'P', 'E', '1'));
  550. if(s->album[0]) id3v2_put_ttag(s, s->album, MKBETAG('T', 'A', 'L', 'B'));
  551. if(s->genre[0]) id3v2_put_ttag(s, s->genre, MKBETAG('T', 'C', 'O', 'N'));
  552. if(s->copyright[0]) id3v2_put_ttag(s, s->copyright, MKBETAG('T', 'C', 'O', 'P'));
  553. if(s->track) id3v2_put_ttag(s, tracktxt, MKBETAG('T', 'R', 'C', 'K'));
  554. if(s->year) id3v2_put_ttag(s, yeartxt, MKBETAG('T', 'Y', 'E', 'R'));
  555. if(!(s->streams[0]->codec->flags & CODEC_FLAG_BITEXACT))
  556. id3v2_put_ttag(s, LIBAVFORMAT_IDENT, MKBETAG('T', 'E', 'N', 'C'));
  557. return 0;
  558. }
  559. static int mp3_write_packet(struct AVFormatContext *s, AVPacket *pkt)
  560. {
  561. put_buffer(s->pb, pkt->data, pkt->size);
  562. put_flush_packet(s->pb);
  563. return 0;
  564. }
  565. static int mp3_write_trailer(struct AVFormatContext *s)
  566. {
  567. uint8_t buf[ID3v1_TAG_SIZE];
  568. /* write the id3v1 tag */
  569. if (s->title[0] != '\0') {
  570. id3v1_create_tag(s, buf);
  571. put_buffer(s->pb, buf, ID3v1_TAG_SIZE);
  572. put_flush_packet(s->pb);
  573. }
  574. return 0;
  575. }
  576. #endif /* defined(CONFIG_MP2_MUXER) || defined(CONFIG_MP3_MUXER) */
  577. #ifdef CONFIG_MP3_DEMUXER
  578. AVInputFormat mp3_demuxer = {
  579. "mp3",
  580. NULL_IF_CONFIG_SMALL("MPEG audio"),
  581. 0,
  582. mp3_read_probe,
  583. mp3_read_header,
  584. mp3_read_packet,
  585. .flags= AVFMT_GENERIC_INDEX,
  586. .extensions = "mp2,mp3,m2a", /* XXX: use probe */
  587. };
  588. #endif
  589. #ifdef CONFIG_MP2_MUXER
  590. AVOutputFormat mp2_muxer = {
  591. "mp2",
  592. NULL_IF_CONFIG_SMALL("MPEG audio layer 2"),
  593. "audio/x-mpeg",
  594. #ifdef CONFIG_LIBMP3LAME
  595. "mp2,m2a",
  596. #else
  597. "mp2,mp3,m2a",
  598. #endif
  599. 0,
  600. CODEC_ID_MP2,
  601. CODEC_ID_NONE,
  602. NULL,
  603. mp3_write_packet,
  604. mp3_write_trailer,
  605. };
  606. #endif
  607. #ifdef CONFIG_MP3_MUXER
  608. AVOutputFormat mp3_muxer = {
  609. "mp3",
  610. NULL_IF_CONFIG_SMALL("MPEG audio layer 3"),
  611. "audio/x-mpeg",
  612. "mp3",
  613. 0,
  614. CODEC_ID_MP3,
  615. CODEC_ID_NONE,
  616. mp3_write_header,
  617. mp3_write_packet,
  618. mp3_write_trailer,
  619. };
  620. #endif