X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavformat%2Fape.c;h=ed6752a41506f2057397a4ba2a0e68ef62e62483;hb=6a7b5226e1c868fe6406b114e7303c70d886900b;hp=c06db7848083192a1af3d4d047586d326013ba73;hpb=d0c43e32427ec1efac364be0987a6aafa695527f;p=ffmpeg diff --git a/libavformat/ape.c b/libavformat/ape.c index c06db784808..ed6752a4150 100644 --- a/libavformat/ape.c +++ b/libavformat/ape.c @@ -83,7 +83,7 @@ typedef struct APEContext { uint8_t *bittable; } APEContext; -static int ape_probe(AVProbeData * p) +static int ape_probe(const AVProbeData * p) { int version = AV_RL16(p->buf+4); if (AV_RL32(p->buf) != MKTAG('M', 'A', 'C', ' ')) @@ -163,7 +163,7 @@ static int ape_read_header(AVFormatContext * s) APEContext *ape = s->priv_data; AVStream *st; uint32_t tag; - int i; + int i, ret; int total_blocks, final_size = 0; int64_t pts, file_size; @@ -358,8 +358,8 @@ static int ape_read_header(AVFormatContext * s) st->duration = total_blocks; avpriv_set_pts_info(st, 64, 1, ape->samplerate); - if (ff_alloc_extradata(st->codecpar, APE_EXTRADATA_SIZE)) - return AVERROR(ENOMEM); + if ((ret = ff_alloc_extradata(st->codecpar, APE_EXTRADATA_SIZE)) < 0) + return ret; AV_WL16(st->codecpar->extradata + 0, ape->fileversion); AV_WL16(st->codecpar->extradata + 2, ape->compressiontype); AV_WL16(st->codecpar->extradata + 4, ape->formatflags); @@ -386,14 +386,16 @@ static int ape_read_packet(AVFormatContext * s, AVPacket * pkt) int nblocks; APEContext *ape = s->priv_data; uint32_t extra_size = 8; + int64_t ret64; if (avio_feof(s->pb)) return AVERROR_EOF; if (ape->currentframe >= ape->totalframes) return AVERROR_EOF; - if (avio_seek(s->pb, ape->frames[ape->currentframe].pos, SEEK_SET) < 0) - return AVERROR(EIO); + ret64 = avio_seek(s->pb, ape->frames[ape->currentframe].pos, SEEK_SET); + if (ret64 < 0) + return ret64; /* Calculate how many blocks there are in this frame */ if (ape->currentframe == (ape->totalframes - 1)) @@ -409,14 +411,14 @@ static int ape_read_packet(AVFormatContext * s, AVPacket * pkt) return AVERROR(EIO); } - if (av_new_packet(pkt, ape->frames[ape->currentframe].size + extra_size) < 0) - return AVERROR(ENOMEM); + ret = av_new_packet(pkt, ape->frames[ape->currentframe].size + extra_size); + if (ret < 0) + return ret; AV_WL32(pkt->data , nblocks); AV_WL32(pkt->data + 4, ape->frames[ape->currentframe].skip); ret = avio_read(s->pb, pkt->data + extra_size, ape->frames[ape->currentframe].size); if (ret < 0) { - av_packet_unref(pkt); return ret; } @@ -447,12 +449,13 @@ static int ape_read_seek(AVFormatContext *s, int stream_index, int64_t timestamp AVStream *st = s->streams[stream_index]; APEContext *ape = s->priv_data; int index = av_index_search_timestamp(st, timestamp, flags); + int64_t ret; if (index < 0) return -1; - if (avio_seek(s->pb, st->index_entries[index].pos, SEEK_SET) < 0) - return -1; + if ((ret = avio_seek(s->pb, st->index_entries[index].pos, SEEK_SET)) < 0) + return ret; ape->currentframe = index; return 0; }