Revision 6612d8cf libavformat/mpc.c

View differences:

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){

Also available in: Unified diff