Commit 8c83062a authored by Sophia Wang's avatar Sophia Wang Committed by Michael Niedermayer

avformat/matroskadec: retain error codes in matroska_resync() and matroska_read_packet()

Signed-off-by: 's avatarSophia Wang <skw@google.com>
Signed-off-by: 's avatarMichael Niedermayer <michael@niedermayer.cc>
parent a54c3ff6
...@@ -738,13 +738,16 @@ static int matroska_read_close(AVFormatContext *s); ...@@ -738,13 +738,16 @@ static int matroska_read_close(AVFormatContext *s);
static int matroska_resync(MatroskaDemuxContext *matroska, int64_t last_pos) static int matroska_resync(MatroskaDemuxContext *matroska, int64_t last_pos)
{ {
AVIOContext *pb = matroska->ctx->pb; AVIOContext *pb = matroska->ctx->pb;
int64_t ret;
uint32_t id; uint32_t id;
matroska->current_id = 0; matroska->current_id = 0;
matroska->num_levels = 0; matroska->num_levels = 0;
/* seek to next position to resync from */ /* seek to next position to resync from */
if (avio_seek(pb, last_pos + 1, SEEK_SET) < 0) if ((ret = avio_seek(pb, last_pos + 1, SEEK_SET)) < 0) {
goto eof; matroska->done = 1;
return ret;
}
id = avio_rb32(pb); id = avio_rb32(pb);
...@@ -760,7 +763,6 @@ static int matroska_resync(MatroskaDemuxContext *matroska, int64_t last_pos) ...@@ -760,7 +763,6 @@ static int matroska_resync(MatroskaDemuxContext *matroska, int64_t last_pos)
id = (id << 8) | avio_r8(pb); id = (id << 8) | avio_r8(pb);
} }
eof:
matroska->done = 1; matroska->done = 1;
return AVERROR_EOF; return AVERROR_EOF;
} }
...@@ -3317,16 +3319,17 @@ static int matroska_parse_cluster(MatroskaDemuxContext *matroska) ...@@ -3317,16 +3319,17 @@ static int matroska_parse_cluster(MatroskaDemuxContext *matroska)
static int matroska_read_packet(AVFormatContext *s, AVPacket *pkt) static int matroska_read_packet(AVFormatContext *s, AVPacket *pkt)
{ {
MatroskaDemuxContext *matroska = s->priv_data; MatroskaDemuxContext *matroska = s->priv_data;
int ret = 0;
while (matroska_deliver_packet(matroska, pkt)) { while (matroska_deliver_packet(matroska, pkt)) {
int64_t pos = avio_tell(matroska->ctx->pb); int64_t pos = avio_tell(matroska->ctx->pb);
if (matroska->done) if (matroska->done)
return AVERROR_EOF; return (ret < 0) ? ret : AVERROR_EOF;
if (matroska_parse_cluster(matroska) < 0) if (matroska_parse_cluster(matroska) < 0)
matroska_resync(matroska, pos); ret = matroska_resync(matroska, pos);
} }
return 0; return ret;
} }
static int matroska_read_seek(AVFormatContext *s, int stream_index, static int matroska_read_seek(AVFormatContext *s, int stream_index,
......
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