| @@ -59,17 +59,17 @@ static int mpc_read_header(AVFormatContext *s) | |||||
| if(avio_rl24(s->pb) != MKTAG('M', 'P', '+', 0)){ | if(avio_rl24(s->pb) != MKTAG('M', 'P', '+', 0)){ | ||||
| av_log(s, AV_LOG_ERROR, "Not a Musepack file\n"); | av_log(s, AV_LOG_ERROR, "Not a Musepack file\n"); | ||||
| return -1; | |||||
| return AVERROR_INVALIDDATA; | |||||
| } | } | ||||
| c->ver = avio_r8(s->pb); | c->ver = avio_r8(s->pb); | ||||
| if(c->ver != 0x07 && c->ver != 0x17){ | if(c->ver != 0x07 && c->ver != 0x17){ | ||||
| av_log(s, AV_LOG_ERROR, "Can demux Musepack SV7, got version %02X\n", c->ver); | 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); | c->fcount = avio_rl32(s->pb); | ||||
| if((int64_t)c->fcount * sizeof(MPCFrame) >= UINT_MAX){ | if((int64_t)c->fcount * sizeof(MPCFrame) >= UINT_MAX){ | ||||
| av_log(s, AV_LOG_ERROR, "Too many frames, seeking is not possible\n"); | av_log(s, AV_LOG_ERROR, "Too many frames, seeking is not possible\n"); | ||||
| return -1; | |||||
| return AVERROR_INVALIDDATA; | |||||
| } | } | ||||
| if(c->fcount){ | if(c->fcount){ | ||||
| c->frames = av_malloc(c->fcount * sizeof(MPCFrame)); | c->frames = av_malloc(c->fcount * sizeof(MPCFrame)); | ||||
| @@ -122,7 +122,7 @@ static int mpc_read_packet(AVFormatContext *s, AVPacket *pkt) | |||||
| int64_t pos; | int64_t pos; | ||||
| if (c->curframe >= c->fcount && c->fcount) | if (c->curframe >= c->fcount && c->fcount) | ||||
| return -1; | |||||
| return AVERROR_EOF; | |||||
| if(c->curframe != c->lastframe + 1){ | if(c->curframe != c->lastframe + 1){ | ||||
| avio_seek(s->pb, c->frames[c->curframe].pos, SEEK_SET); | 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; | 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[0] = curbits; | ||||
| pkt->data[1] = (c->curframe > c->fcount) && c->fcount; | 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); | avio_seek(s->pb, -4, SEEK_CUR); | ||||
| if(ret < size){ | if(ret < size){ | ||||
| av_free_packet(pkt); | av_free_packet(pkt); | ||||
| return AVERROR(EIO); | |||||
| return ret < 0 ? ret : AVERROR(EIO); | |||||
| } | } | ||||
| pkt->size = ret + 4; | 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); | ret = av_read_frame(s, pkt); | ||||
| if (ret < 0){ | if (ret < 0){ | ||||
| c->curframe = lastframe; | c->curframe = lastframe; | ||||
| return -1; | |||||
| return ret; | |||||
| } | } | ||||
| av_free_packet(pkt); | av_free_packet(pkt); | ||||
| } | } | ||||