Revision 811e0fc2

View differences:

Changelog
40 40
- Core Audio Format demuxer
41 41
- Atrac1 decoder
42 42
- MD STUDIO audio demuxer
43
- RF64 support in WAV demuxer
43 44

  
44 45

  
45 46

  
libavformat/wav.c
3 3
 * Copyright (c) 2001, 2002 Fabrice Bellard
4 4
 *
5 5
 * Sony Wave64 demuxer
6
 * RF64 demuxer
6 7
 * Copyright (c) 2009 Daniel Verkamp
7 8
 *
8 9
 * This file is part of FFmpeg.
......
160 161
    /* check file header */
161 162
    if (p->buf_size <= 32)
162 163
        return 0;
163
    if (p->buf[ 0] == 'R' && p->buf[ 1] == 'I' &&
164
        p->buf[ 2] == 'F' && p->buf[ 3] == 'F' &&
165
        p->buf[ 8] == 'W' && p->buf[ 9] == 'A' &&
166
        p->buf[10] == 'V' && p->buf[11] == 'E')
164
    if (!memcmp(p->buf + 8, "WAVE", 4)) {
165
        if (!memcmp(p->buf, "RIFF", 4))
167 166
        /*
168 167
          Since ACT demuxer has standard WAV header at top of it's own,
169 168
          returning score is decreased to avoid probe conflict
170 169
          between ACT and WAV.
171 170
        */
172 171
        return AVPROBE_SCORE_MAX - 1;
173
    else
172
        else if (!memcmp(p->buf,      "RF64", 4) &&
173
                 !memcmp(p->buf + 12, "ds64", 4))
174
            return AVPROBE_SCORE_MAX;
175
    }
174 176
        return 0;
175 177
}
176 178

  
......
178 180
static int wav_read_header(AVFormatContext *s,
179 181
                           AVFormatParameters *ap)
180 182
{
181
    int64_t size;
183
    int64_t size, av_uninit(data_size);
184
    int rf64;
182 185
    unsigned int tag;
183 186
    ByteIOContext *pb = s->pb;
184 187
    AVStream *st;
......
187 190
    /* check RIFF header */
188 191
    tag = get_le32(pb);
189 192

  
190
    if (tag != MKTAG('R', 'I', 'F', 'F'))
193
    rf64 = tag == MKTAG('R', 'F', '6', '4');
194
    if (!rf64 && tag != MKTAG('R', 'I', 'F', 'F'))
191 195
        return -1;
192 196
    get_le32(pb); /* file size */
193 197
    tag = get_le32(pb);
194 198
    if (tag != MKTAG('W', 'A', 'V', 'E'))
195 199
        return -1;
196 200

  
201
    if (rf64) {
202
        if (get_le32(pb) != MKTAG('d', 's', '6', '4'))
203
            return -1;
204
        size = get_le32(pb);
205
        if (size < 16)
206
            return -1;
207
        get_le64(pb); /* RIFF size */
208
        data_size = get_le64(pb);
209
        url_fskip(pb, size - 16); /* skip rest of ds64 chunk */
210
    }
211

  
197 212
    /* parse fmt header */
198 213
    size = find_tag(pb, MKTAG('f', 'm', 't', ' '));
199 214
    if (size < 0)
......
208 223
    av_set_pts_info(st, 64, 1, st->codec->sample_rate);
209 224

  
210 225
    size = find_tag(pb, MKTAG('d', 'a', 't', 'a'));
226
    if (rf64)
227
        size = data_size;
211 228
    if (size < 0)
212 229
        return -1;
213 230
    wav->data_end= url_ftell(pb) + size;

Also available in: Unified diff