Commit 0cdd1208 authored by Kostya Shishkov's avatar Kostya Shishkov Committed by Anton Khirnov

Musepack SV7: try to read files without number of frames provided

Signed-off-by: 's avatarAnton Khirnov <anton@khirnov.net>
parent 2cb6dec6
...@@ -70,7 +70,15 @@ static int mpc_read_header(AVFormatContext *s, AVFormatParameters *ap) ...@@ -70,7 +70,15 @@ static int mpc_read_header(AVFormatContext *s, AVFormatParameters *ap)
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 -1;
} }
if(c->fcount){
c->frames = av_malloc(c->fcount * sizeof(MPCFrame)); c->frames = av_malloc(c->fcount * sizeof(MPCFrame));
if(!c->frames){
av_log(s, AV_LOG_ERROR, "Cannot allocate seektable\n");
return AVERROR(ENOMEM);
}
}else{
av_log(s, AV_LOG_WARNING, "Container reports no frames\n");
}
c->curframe = 0; c->curframe = 0;
c->lastframe = -1; c->lastframe = -1;
c->curbits = 8; c->curbits = 8;
...@@ -111,7 +119,7 @@ static int mpc_read_packet(AVFormatContext *s, AVPacket *pkt) ...@@ -111,7 +119,7 @@ static int mpc_read_packet(AVFormatContext *s, AVPacket *pkt)
int ret, size, size2, curbits, cur = c->curframe; int ret, size, size2, curbits, cur = c->curframe;
int64_t tmp, pos; int64_t tmp, pos;
if (c->curframe >= c->fcount) if (c->curframe >= c->fcount && c->fcount)
return -1; return -1;
if(c->curframe != c->lastframe + 1){ if(c->curframe != c->lastframe + 1){
...@@ -133,7 +141,7 @@ static int mpc_read_packet(AVFormatContext *s, AVPacket *pkt) ...@@ -133,7 +141,7 @@ static int mpc_read_packet(AVFormatContext *s, AVPacket *pkt)
avio_seek(s->pb, pos, SEEK_SET); avio_seek(s->pb, pos, SEEK_SET);
size = ((size2 + curbits + 31) & ~31) >> 3; size = ((size2 + curbits + 31) & ~31) >> 3;
if(cur == c->frames_noted){ if(cur == c->frames_noted && c->fcount){
c->frames[cur].pos = pos; c->frames[cur].pos = pos;
c->frames[cur].size = size; c->frames[cur].size = size;
c->frames[cur].skip = curbits - 20; c->frames[cur].skip = curbits - 20;
...@@ -146,7 +154,7 @@ static int mpc_read_packet(AVFormatContext *s, AVPacket *pkt) ...@@ -146,7 +154,7 @@ static int mpc_read_packet(AVFormatContext *s, AVPacket *pkt)
return AVERROR(EIO); return AVERROR(EIO);
pkt->data[0] = curbits; pkt->data[0] = curbits;
pkt->data[1] = (c->curframe > c->fcount); pkt->data[1] = (c->curframe > c->fcount) && c->fcount;
pkt->data[2] = 0; pkt->data[2] = 0;
pkt->data[3] = 0; pkt->data[3] = 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment