mirror of
https://github.com/xenia-project/FFmpeg.git
synced 2024-11-25 04:30:02 +00:00
mpc: return more meaningful error codes.
This commit is contained in:
parent
782e64fbe1
commit
263dbe9d95
@ -59,17 +59,17 @@ static int mpc_read_header(AVFormatContext *s)
|
||||
|
||||
if(avio_rl24(s->pb) != MKTAG('M', 'P', '+', 0)){
|
||||
av_log(s, AV_LOG_ERROR, "Not a Musepack file\n");
|
||||
return -1;
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
c->ver = avio_r8(s->pb);
|
||||
if(c->ver != 0x07 && c->ver != 0x17){
|
||||
av_log(s, AV_LOG_ERROR, "Can demux Musepack SV7, got version %02X\n", c->ver);
|
||||
return -1;
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
c->fcount = avio_rl32(s->pb);
|
||||
if((int64_t)c->fcount * sizeof(MPCFrame) >= UINT_MAX){
|
||||
av_log(s, AV_LOG_ERROR, "Too many frames, seeking is not possible\n");
|
||||
return -1;
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
if(c->fcount){
|
||||
c->frames = av_malloc(c->fcount * sizeof(MPCFrame));
|
||||
@ -122,7 +122,7 @@ static int mpc_read_packet(AVFormatContext *s, AVPacket *pkt)
|
||||
int64_t pos;
|
||||
|
||||
if (c->curframe >= c->fcount && c->fcount)
|
||||
return -1;
|
||||
return AVERROR_EOF;
|
||||
|
||||
if(c->curframe != c->lastframe + 1){
|
||||
avio_seek(s->pb, c->frames[c->curframe].pos, SEEK_SET);
|
||||
@ -151,8 +151,8 @@ static int mpc_read_packet(AVFormatContext *s, AVPacket *pkt)
|
||||
}
|
||||
c->curbits = (curbits + size2) & 0x1F;
|
||||
|
||||
if (av_new_packet(pkt, size) < 0)
|
||||
return AVERROR(EIO);
|
||||
if ((ret = av_new_packet(pkt, size)) < 0)
|
||||
return ret;
|
||||
|
||||
pkt->data[0] = curbits;
|
||||
pkt->data[1] = (c->curframe > c->fcount) && c->fcount;
|
||||
@ -166,7 +166,7 @@ static int mpc_read_packet(AVFormatContext *s, AVPacket *pkt)
|
||||
avio_seek(s->pb, -4, SEEK_CUR);
|
||||
if(ret < size){
|
||||
av_free_packet(pkt);
|
||||
return AVERROR(EIO);
|
||||
return ret < 0 ? ret : AVERROR(EIO);
|
||||
}
|
||||
pkt->size = ret + 4;
|
||||
|
||||
@ -214,7 +214,7 @@ static int mpc_read_seek(AVFormatContext *s, int stream_index, int64_t timestamp
|
||||
ret = av_read_frame(s, pkt);
|
||||
if (ret < 0){
|
||||
c->curframe = lastframe;
|
||||
return -1;
|
||||
return ret;
|
||||
}
|
||||
av_free_packet(pkt);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user