/*
* MP3 muxer and demuxer
- * Copyright (c) 2003 Fabrice Bellard.
+ * Copyright (c) 2003 Fabrice Bellard
*
* This file is part of FFmpeg.
*
#include "libavcodec/mpegaudio.h"
#include "libavcodec/mpegaudiodecheader.h"
#include "avformat.h"
+#include "id3v2.h"
-#define ID3v2_HEADER_SIZE 10
#define ID3v1_TAG_SIZE 128
#define ID3v1_GENRE_MAX 125
[125] = "Dance Hall",
};
-/* buf must be ID3v2_HEADER_SIZE byte long */
-static int id3v2_match(const uint8_t *buf)
-{
- return buf[0] == 'I' &&
- buf[1] == 'D' &&
- buf[2] == '3' &&
- buf[3] != 0xff &&
- buf[4] != 0xff &&
- (buf[6] & 0x80) == 0 &&
- (buf[7] & 0x80) == 0 &&
- (buf[8] & 0x80) == 0 &&
- (buf[9] & 0x80) == 0;
-}
-
static unsigned int id3v2_get_size(ByteIOContext *s, int len)
{
int v=0;
int max_frames, first_frames = 0;
int fsize, frames, sample_rate;
uint32_t header;
- uint8_t *buf, *buf2, *end;
+ uint8_t *buf, *buf0, *buf2, *end;
AVCodecContext avctx;
- if(id3v2_match(p->buf))
- return AVPROBE_SCORE_MAX/2+1; // this must be less than mpeg-ps because some retards put id3v2 tags before mpeg-ps files
+ buf0 = p->buf;
+ if(ff_id3v2_match(buf0)) {
+ buf0 += ff_id3v2_tag_len(buf0);
+ }
max_frames = 0;
- buf = p->buf;
- end = buf + p->buf_size - sizeof(uint32_t);
+ buf = buf0;
+ end = p->buf + p->buf_size - sizeof(uint32_t);
for(; buf < end; buf= buf2+1) {
buf2 = buf;
buf2 += fsize;
}
max_frames = FFMAX(max_frames, frames);
- if(buf == p->buf)
+ if(buf == buf0)
first_frames= frames;
}
if (first_frames>=3) return AVPROBE_SCORE_MAX/2+1;
uint32_t v, spf;
int frames = -1; /* Total number of frames in file */
const int64_t xing_offtbl[2][2] = {{32, 17}, {17,9}};
- MPADecodeContext c;
+ MPADecodeHeader c;
int vbrtag_size = 0;
v = get_be32(s->pb);
ret = get_buffer(s->pb, buf, ID3v2_HEADER_SIZE);
if (ret != ID3v2_HEADER_SIZE)
return -1;
- if (id3v2_match(buf)) {
+ if (ff_id3v2_match(buf)) {
/* parse ID3v2 header */
len = ((buf[6] & 0x7f) << 21) |
((buf[7] & 0x7f) << 14) |
"mp2",
NULL_IF_CONFIG_SMALL("MPEG audio layer 2"),
"audio/x-mpeg",
-#if CONFIG_LIBMP3LAME
"mp2,m2a",
-#else
- "mp2,mp3,m2a",
-#endif
0,
CODEC_ID_MP2,
CODEC_ID_NONE,