Revision 6612d8cf

View differences:

libavformat/aacdec.c
23 23
#include "libavutil/intreadwrite.h"
24 24
#include "avformat.h"
25 25
#include "rawdec.h"
26
#include "id3v2.h"
27 26
#include "id3v1.h"
28 27

  
29 28

  
......
36 35
    uint8_t *buf;
37 36
    uint8_t *end = buf0 + p->buf_size - 7;
38 37

  
39
    if (ff_id3v2_match(buf0, ID3v2_DEFAULT_MAGIC)) {
40
        buf0 += ff_id3v2_tag_len(buf0);
41
    }
42 38
    buf = buf0;
43 39

  
44 40
    for(; buf < end; buf= buf2+1) {
......
78 74
    st->need_parsing = AVSTREAM_PARSE_FULL;
79 75

  
80 76
    ff_id3v1_read(s);
81
    ff_id3v2_read(s, ID3v2_DEFAULT_MAGIC);
82 77

  
83 78
    //LCM of all possible ADTS sample rates
84 79
    av_set_pts_info(st, 64, 1, 28224000);
libavformat/flacdec.c
22 22
#include "libavcodec/flac.h"
23 23
#include "avformat.h"
24 24
#include "rawdec.h"
25
#include "id3v2.h"
26 25
#include "oggdec.h"
27 26
#include "vorbiscomment.h"
28 27

  
29 28
static int flac_read_header(AVFormatContext *s,
30 29
                             AVFormatParameters *ap)
31 30
{
32
    uint8_t buf[ID3v2_HEADER_SIZE];
33 31
    int ret, metadata_last=0, metadata_type, metadata_size, found_streaminfo=0;
34 32
    uint8_t header[4];
35 33
    uint8_t *buffer=NULL;
......
41 39
    st->need_parsing = AVSTREAM_PARSE_FULL;
42 40
    /* the parameters will be extracted from the compressed bitstream */
43 41

  
44
    /* skip ID3v2 header if found */
45
    ret = get_buffer(s->pb, buf, ID3v2_HEADER_SIZE);
46
    if (ret == ID3v2_HEADER_SIZE && ff_id3v2_match(buf, ID3v2_DEFAULT_MAGIC)) {
47
        int len = ff_id3v2_tag_len(buf);
48
        url_fseek(s->pb, len - ID3v2_HEADER_SIZE, SEEK_CUR);
49
    } else {
50
        url_fseek(s->pb, 0, SEEK_SET);
51
    }
52

  
53 42
    /* if fLaC marker is not found, assume there is no header */
54 43
    if (get_le32(s->pb) != MKTAG('f','L','a','C')) {
55 44
        url_fseek(s->pb, -4, SEEK_CUR);
......
130 119
    uint8_t *bufptr = p->buf;
131 120
    uint8_t *end    = p->buf + p->buf_size;
132 121

  
133
    if(ff_id3v2_match(bufptr, ID3v2_DEFAULT_MAGIC))
134
        bufptr += ff_id3v2_tag_len(bufptr);
135

  
136 122
    if(bufptr > end-4 || memcmp(bufptr, "fLaC", 4)) return 0;
137 123
    else                                            return AVPROBE_SCORE_MAX/2;
138 124
}
libavformat/mp3.c
42 42
    AVCodecContext avctx;
43 43

  
44 44
    buf0 = p->buf;
45
    if(ff_id3v2_match(buf0, ID3v2_DEFAULT_MAGIC)) {
46
        buf0 += ff_id3v2_tag_len(buf0);
47
    }
48 45
    end = p->buf + p->buf_size - sizeof(uint32_t);
49 46
    while(buf0 < end && !*buf0)
50 47
        buf0++;
......
156 153
    // lcm of all mp3 sample rates
157 154
    av_set_pts_info(st, 64, 1, 14112000);
158 155

  
159
    ff_id3v2_read(s, ID3v2_DEFAULT_MAGIC);
160 156
    off = url_ftell(s->pb);
161 157

  
162 158
    if (!av_metadata_get(s->metadata, "", NULL, AV_METADATA_IGNORE_SUFFIX))
libavformat/mpc.c
21 21

  
22 22
#include "libavcodec/get_bits.h"
23 23
#include "avformat.h"
24
#include "id3v2.h"
25 24
#include "apetag.h"
26 25

  
27 26
#define MPC_FRAMESIZE  1152
......
45 44
static int mpc_probe(AVProbeData *p)
46 45
{
47 46
    const uint8_t *d = p->buf;
48
    if (ff_id3v2_match(d, ID3v2_DEFAULT_MAGIC)) {
49
        d += ff_id3v2_tag_len(d);
50
    }
51
    if (d+3 < p->buf+p->buf_size)
52 47
    if (d[0] == 'M' && d[1] == 'P' && d[2] == '+' && (d[3] == 0x17 || d[3] == 0x7))
53 48
        return AVPROBE_SCORE_MAX;
54 49
    return 0;
......
58 53
{
59 54
    MPCContext *c = s->priv_data;
60 55
    AVStream *st;
61
    int t, ret;
62
    int64_t pos = url_ftell(s->pb);
63 56

  
64
    t = get_le24(s->pb);
65
    if(t != MKTAG('M', 'P', '+', 0)){
66
        uint8_t buf[ID3v2_HEADER_SIZE];
67
        if (url_fseek(s->pb, pos, SEEK_SET) < 0)
68
            return -1;
69
        ret = get_buffer(s->pb, buf, ID3v2_HEADER_SIZE);
70
        if (ret != ID3v2_HEADER_SIZE || !ff_id3v2_match(buf, ID3v2_DEFAULT_MAGIC)) {
71
            av_log(s, AV_LOG_ERROR, "Not a Musepack file\n");
72
            return -1;
73
        }
74
        /* skip ID3 tags and try again */
75
        t = ff_id3v2_tag_len(buf) - ID3v2_HEADER_SIZE;
76
        av_log(s, AV_LOG_DEBUG, "Skipping %d(%X) bytes of ID3 data\n", t, t);
77
        url_fskip(s->pb, t);
78
        if(get_le24(s->pb) != MKTAG('M', 'P', '+', 0)){
79
            av_log(s, AV_LOG_ERROR, "Not a Musepack file\n");
80
            return -1;
81
        }
82
        /* read ID3 tags */
83
        if (url_fseek(s->pb, pos, SEEK_SET) < 0)
84
            return -1;
85
        ff_id3v2_read(s, ID3v2_DEFAULT_MAGIC);
86
        get_le24(s->pb);
57
    if(get_le24(s->pb) != MKTAG('M', 'P', '+', 0)){
58
        av_log(s, AV_LOG_ERROR, "Not a Musepack file\n");
59
        return -1;
87 60
    }
88 61
    c->ver = get_byte(s->pb);
89 62
    if(c->ver != 0x07 && c->ver != 0x17){
libavformat/tta.c
21 21

  
22 22
#include "libavcodec/get_bits.h"
23 23
#include "avformat.h"
24
#include "id3v2.h"
25 24
#include "id3v1.h"
26 25

  
27 26
typedef struct {
......
32 31
{
33 32
    const uint8_t *d = p->buf;
34 33

  
35
    if (ff_id3v2_match(d, ID3v2_DEFAULT_MAGIC))
36
        d += ff_id3v2_tag_len(d);
37

  
38
    if (d - p->buf >= p->buf_size)
39
        return 0;
40

  
41 34
    if (d[0] == 'T' && d[1] == 'T' && d[2] == 'A' && d[3] == '1')
42 35
        return 80;
43 36
    return 0;
......
50 43
    int i, channels, bps, samplerate, datalen, framelen;
51 44
    uint64_t framepos, start_offset;
52 45

  
53
    ff_id3v2_read(s, ID3v2_DEFAULT_MAGIC);
54 46
    if (!av_metadata_get(s->metadata, "", NULL, AV_METADATA_IGNORE_SUFFIX))
55 47
        ff_id3v1_read(s);
56 48

  
libavformat/utils.c
23 23
#include "libavcodec/internal.h"
24 24
#include "libavutil/opt.h"
25 25
#include "metadata.h"
26
#include "id3v2.h"
26 27
#include "libavutil/avstring.h"
27 28
#include "riff.h"
28 29
#include "audiointerleave.h"
......
343 344

  
344 345
AVInputFormat *av_probe_input_format2(AVProbeData *pd, int is_opened, int *score_max)
345 346
{
347
    AVProbeData lpd = *pd;
346 348
    AVInputFormat *fmt1, *fmt;
347 349
    int score;
348 350

  
351
    if (lpd.buf_size > 10 && ff_id3v2_match(lpd.buf, ID3v2_DEFAULT_MAGIC)) {
352
        int id3len = ff_id3v2_tag_len(lpd.buf);
353
        if (lpd.buf_size > id3len + 16) {
354
            lpd.buf += id3len;
355
            lpd.buf_size -= id3len;
356
        }
357
    }
358

  
349 359
    fmt = NULL;
350 360
    for(fmt1 = first_iformat; fmt1 != NULL; fmt1 = fmt1->next) {
351 361
        if (!is_opened == !(fmt1->flags & AVFMT_NOFILE))
352 362
            continue;
353 363
        score = 0;
354 364
        if (fmt1->read_probe) {
355
            score = fmt1->read_probe(pd);
365
            score = fmt1->read_probe(&lpd);
356 366
        } else if (fmt1->extensions) {
357
            if (av_match_ext(pd->filename, fmt1->extensions)) {
367
            if (av_match_ext(lpd.filename, fmt1->extensions)) {
358 368
                score = 50;
359 369
            }
360 370
        }
......
448 458
        ic->priv_data = NULL;
449 459
    }
450 460

  
461
    // e.g. AVFMT_NOFILE formats will not have a ByteIOContext
462
    if (ic->pb)
463
        ff_id3v2_read(ic, ID3v2_DEFAULT_MAGIC);
464

  
451 465
    if (ic->iformat->read_header) {
452 466
        err = ic->iformat->read_header(ic, ap);
453 467
        if (err < 0)

Also available in: Unified diff