-/*
+/*
* MP3 encoder and decoder
* Copyright (c) 2003 Fabrice Bellard.
*
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "avformat.h"
(buf[9] & 0x80) == 0);
}
-static void id3_get_string(char *str, int str_size,
+static void id3_get_string(char *str, int str_size,
const uint8_t *buf, int buf_size)
{
int i, c;
{
char str[5];
int genre;
-
+
if (!(buf[0] == 'T' &&
buf[1] == 'A' &&
buf[2] == 'G'))
}
/* mp3 read */
+
+static int mp3_read_probe(AVProbeData *p)
+{
+ int d;
+
+ if(p->buf_size < 4)
+ return 0;
+
+ if(p->buf[0] == 'I' && p->buf[1] == 'D' && p->buf[2] == '3' &&
+ p->buf[3] < 5)
+ return AVPROBE_SCORE_MAX;
+
+ if(p->buf[0] != 0xff)
+ return 0;
+
+ d = p->buf[1];
+ if((d & 0xe0) != 0xe0 || ((d & 0x18) == 0x08 || (d & 0x06) == 0))
+ return 0;
+
+ d = p->buf[2];
+ if((d & 0xf0) == 0xf0 || (d & 0x0c) == 0x0c)
+ return 0;
+
+ return AVPROBE_SCORE_MAX;
+}
+
static int mp3_read_header(AVFormatContext *s,
AVFormatParameters *ap)
{
if (!st)
return AVERROR_NOMEM;
- st->codec.codec_type = CODEC_TYPE_AUDIO;
- st->codec.codec_id = CODEC_ID_MP3;
+ st->codec->codec_type = CODEC_TYPE_AUDIO;
+ st->codec->codec_id = CODEC_ID_MP3;
st->need_parsing = 1;
-
+
/* try to get the TAG */
if (!url_is_streamed(&s->pb)) {
/* XXX: change that */
{
int ret, size;
// AVStream *st = s->streams[0];
-
+
size= MP3_PACKET_SIZE;
ret= av_get_packet(&s->pb, pkt, size);
return 0;
}
-#ifdef CONFIG_ENCODERS
+#ifdef CONFIG_MUXERS
/* simple formats */
static int mp3_write_header(struct AVFormatContext *s)
{
}
return 0;
}
-#endif //CONFIG_ENCODERS
+#endif //CONFIG_MUXERS
-AVInputFormat mp3_iformat = {
+#ifdef CONFIG_MP3_DEMUXER
+AVInputFormat mp3_demuxer = {
"mp3",
"MPEG audio",
0,
- NULL,
+ mp3_read_probe,
mp3_read_header,
mp3_read_packet,
mp3_read_close,
.extensions = "mp2,mp3,m2a", /* XXX: use probe */
};
-
-#ifdef CONFIG_ENCODERS
-AVOutputFormat mp2_oformat = {
+#endif
+#ifdef CONFIG_MP2_MUXER
+AVOutputFormat mp2_muxer = {
"mp2",
"MPEG audio layer 2",
"audio/x-mpeg",
mp3_write_packet,
mp3_write_trailer,
};
-
-#ifdef CONFIG_MP3LAME
-AVOutputFormat mp3_oformat = {
+#endif
+#ifdef CONFIG_MP3_MUXER
+AVOutputFormat mp3_muxer = {
"mp3",
"MPEG audio layer 3",
"audio/x-mpeg",
mp3_write_trailer,
};
#endif
-#endif //CONFIG_ENCODERS
-
-int mp3_init(void)
-{
- av_register_input_format(&mp3_iformat);
-#ifdef CONFIG_ENCODERS
- av_register_output_format(&mp2_oformat);
-#ifdef CONFIG_MP3LAME
- av_register_output_format(&mp3_oformat);
-#endif
-#endif //CONFIG_ENCODERS
- return 0;
-}