~ppsspp/ppsspp/ffmpeg

« back to all changes in this revision

Viewing changes to libavformat/ape.c

  • Committer: Henrik Rydgård
  • Date: 2014-01-03 10:44:32 UTC
  • Revision ID: git-v1:87c6c126784b1718bfa448ecf2e6a9fef781eb4e
Update our ffmpeg snapshot to a clone of the official repository.

This is because Maxim's at3plus support has been officially merged!

Show diffs side-by-side

added added

removed removed

Lines of Context:
86
86
 
87
87
static int ape_probe(AVProbeData * p)
88
88
{
89
 
    if (p->buf[0] == 'M' && p->buf[1] == 'A' && p->buf[2] == 'C' && p->buf[3] == ' ')
90
 
        return AVPROBE_SCORE_MAX;
91
 
 
92
 
    return 0;
 
89
    int version = AV_RL16(p->buf+4);
 
90
    if (AV_RL32(p->buf) != MKTAG('M', 'A', 'C', ' '))
 
91
        return 0;
 
92
 
 
93
    if (version < APE_MIN_VERSION || version > APE_MAX_VERSION)
 
94
        return AVPROBE_SCORE_MAX/4;
 
95
 
 
96
    return AVPROBE_SCORE_MAX;
93
97
}
94
98
 
95
99
static void ape_dumpinfo(AVFormatContext * s, APEContext * ape_ctx)
278
282
        ape->totalsamples += ape->blocksperframe * (ape->totalframes - 1);
279
283
 
280
284
    if (ape->seektablelength > 0) {
281
 
        ape->seektable = av_malloc(ape->seektablelength);
 
285
        ape->seektable = av_mallocz(ape->seektablelength);
282
286
        if (!ape->seektable)
283
287
            return AVERROR(ENOMEM);
284
288
        for (i = 0; i < ape->seektablelength / sizeof(uint32_t) && !pb->eof_reached; i++)
285
289
            ape->seektable[i] = avio_rl32(pb);
286
290
        if (ape->fileversion < 3810) {
287
 
            ape->bittable = av_malloc(ape->totalframes);
 
291
            ape->bittable = av_mallocz(ape->totalframes);
288
292
            if (!ape->bittable)
289
293
                return AVERROR(ENOMEM);
290
294
            for (i = 0; i < ape->totalframes && !pb->eof_reached; i++)
291
295
                ape->bittable[i] = avio_r8(pb);
292
296
        }
 
297
        if (pb->eof_reached)
 
298
            av_log(s, AV_LOG_WARNING, "File truncated\n");
293
299
    }
294
300
 
295
301
    ape->frames[0].pos     = ape->firstframe;
411
417
    AV_WL32(pkt->data    , nblocks);
412
418
    AV_WL32(pkt->data + 4, ape->frames[ape->currentframe].skip);
413
419
    ret = avio_read(s->pb, pkt->data + extra_size, ape->frames[ape->currentframe].size);
414
 
    if (ret < 0)
 
420
    if (ret < 0) {
 
421
        av_free_packet(pkt);
415
422
        return ret;
 
423
    }
416
424
 
417
425
    pkt->pts = ape->frames[ape->currentframe].pts;
418
426
    pkt->stream_index = 0;