* License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+#include "libavutil/avstring.h"
+#include "libavcodec/mpegaudio.h"
+#include "libavcodec/mpegaudiodecheader.h"
#include "avformat.h"
-#include "mpegaudio.h"
-#include "avstring.h"
-#include "mpegaudiodecheader.h"
#define ID3v2_HEADER_SIZE 10
#define ID3v1_TAG_SIZE 128
/* buf must be ID3v2_HEADER_SIZE byte long */
static int id3v2_match(const uint8_t *buf)
{
- return (buf[0] == 'I' &&
+ return buf[0] == 'I' &&
buf[1] == 'D' &&
buf[2] == '3' &&
buf[3] != 0xff &&
(buf[6] & 0x80) == 0 &&
(buf[7] & 0x80) == 0 &&
(buf[8] & 0x80) == 0 &&
- (buf[9] & 0x80) == 0);
+ (buf[9] & 0x80) == 0;
}
static unsigned int id3v2_get_size(ByteIOContext *s, int len)
char *q;
int len;
+ if(dstlen > 0)
+ dst[0]= 0;
if(taglen < 1)
return;
break;
case 3: /* UTF-8 */
- len = FFMIN(taglen, dstlen);
+ len = FFMIN(taglen, dstlen-1);
get_buffer(s->pb, dst, len);
dst[len] = 0;
break;
return 0;
}
-static void id3v1_create_tag(AVFormatContext *s, uint8_t *buf)
-{
- int v, i;
-
- memset(buf, 0, ID3v1_TAG_SIZE); /* fail safe */
- buf[0] = 'T';
- buf[1] = 'A';
- buf[2] = 'G';
- strncpy(buf + 3, s->title, 30);
- strncpy(buf + 33, s->author, 30);
- strncpy(buf + 63, s->album, 30);
- v = s->year;
- if (v > 0) {
- for(i = 0;i < 4; i++) {
- buf[96 - i] = '0' + (v % 10);
- v = v / 10;
- }
- }
- strncpy(buf + 97, s->comment, 30);
- if (s->track != 0) {
- buf[125] = 0;
- buf[126] = s->track;
- }
- for(i = 0; i <= ID3v1_GENRE_MAX; i++) {
- if (!strcasecmp(s->genre, id3v1_genre_str[i])) {
- buf[127] = i;
- break;
- }
- }
-}
-
/* mp3 read */
static int mp3_read_probe(AVProbeData *p)
max_frames = 0;
buf = p->buf;
- end = buf + FFMIN(4096, p->buf_size - sizeof(uint32_t));
+ end = buf + p->buf_size - sizeof(uint32_t);
- for(; buf < end; buf++) {
+ for(; buf < end; buf= buf2+1) {
buf2 = buf;
for(frames = 0; buf2 < end; frames++) {
max_frames = FFMAX(max_frames, frames);
if(buf == p->buf)
first_frames= frames;
- if(buf2 > end)
- break;
}
if (first_frames>=3) return AVPROBE_SCORE_MAX/2+1;
+ else if(max_frames>500)return AVPROBE_SCORE_MAX/2;
else if(max_frames>=3) return AVPROBE_SCORE_MAX/4;
else if(max_frames>=1) return 1;
else return 0;
return ret;
}
-static int mp3_read_close(AVFormatContext *s)
+#ifdef CONFIG_MUXERS
+static void id3v1_create_tag(AVFormatContext *s, uint8_t *buf)
{
- return 0;
+ int v, i;
+
+ memset(buf, 0, ID3v1_TAG_SIZE); /* fail safe */
+ buf[0] = 'T';
+ buf[1] = 'A';
+ buf[2] = 'G';
+ strncpy(buf + 3, s->title, 30);
+ strncpy(buf + 33, s->author, 30);
+ strncpy(buf + 63, s->album, 30);
+ v = s->year;
+ if (v > 0) {
+ for(i = 0;i < 4; i++) {
+ buf[96 - i] = '0' + (v % 10);
+ v = v / 10;
+ }
+ }
+ strncpy(buf + 97, s->comment, 30);
+ if (s->track != 0) {
+ buf[125] = 0;
+ buf[126] = s->track;
+ }
+ for(i = 0; i <= ID3v1_GENRE_MAX; i++) {
+ if (!strcasecmp(s->genre, id3v1_genre_str[i])) {
+ buf[127] = i;
+ break;
+ }
+ }
}
-#ifdef CONFIG_MUXERS
/* simple formats */
static void id3v2_put_size(AVFormatContext *s, int size)
put_byte(s->pb, size & 0x7f);
}
-static void id3v2_put_ttag(AVFormatContext *s, char *string, uint32_t tag)
+static void id3v2_put_ttag(AVFormatContext *s, const char *string, uint32_t tag)
{
int len = strlen(string);
put_be32(s->pb, tag);
#ifdef CONFIG_MP3_DEMUXER
AVInputFormat mp3_demuxer = {
"mp3",
- "MPEG audio",
+ NULL_IF_CONFIG_SMALL("MPEG audio"),
0,
mp3_read_probe,
mp3_read_header,
mp3_read_packet,
- mp3_read_close,
.flags= AVFMT_GENERIC_INDEX,
.extensions = "mp2,mp3,m2a", /* XXX: use probe */
};
#ifdef CONFIG_MP2_MUXER
AVOutputFormat mp2_muxer = {
"mp2",
- "MPEG audio layer 2",
+ NULL_IF_CONFIG_SMALL("MPEG audio layer 2"),
"audio/x-mpeg",
#ifdef CONFIG_LIBMP3LAME
"mp2,m2a",
#endif
0,
CODEC_ID_MP2,
- 0,
+ CODEC_ID_NONE,
NULL,
mp3_write_packet,
mp3_write_trailer,
#ifdef CONFIG_MP3_MUXER
AVOutputFormat mp3_muxer = {
"mp3",
- "MPEG audio layer 3",
+ NULL_IF_CONFIG_SMALL("MPEG audio layer 3"),
"audio/x-mpeg",
"mp3",
0,
CODEC_ID_MP3,
- 0,
+ CODEC_ID_NONE,
mp3_write_header,
mp3_write_packet,
mp3_write_trailer,