From 782e64fbe1daa84c38594db037d0edfac7193c37 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Mon, 30 Jul 2012 07:28:35 +0200 Subject: wv,mpc8: don't return apetag data in packets. --- libavformat/mpc8.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'libavformat/mpc8.c') diff --git a/libavformat/mpc8.c b/libavformat/mpc8.c index 93848f4ebf..6b9f77e6ab 100644 --- a/libavformat/mpc8.c +++ b/libavformat/mpc8.c @@ -52,6 +52,8 @@ typedef struct { int frame; int64_t header_pos; int64_t samples; + + int64_t apetag_start; } MPCContext; static inline int64_t bs_get_v(uint8_t **bs) @@ -243,7 +245,7 @@ static int mpc8_read_header(AVFormatContext *s) if (pb->seekable) { int64_t pos = avio_tell(s->pb); - ff_ape_parse_tag(s); + c->apetag_start = ff_ape_parse_tag(s); avio_seek(s->pb, pos, SEEK_SET); } @@ -258,6 +260,11 @@ static int mpc8_read_packet(AVFormatContext *s, AVPacket *pkt) while(!s->pb->eof_reached){ pos = avio_tell(s->pb); + + /* don't return bogus packets with the ape tag data */ + if (c->apetag_start && pos >= c->apetag_start) + return AVERROR_EOF; + mpc8_get_chunk_header(s->pb, &tag, &size); if (size < 0) return -1; -- cgit v1.2.3 From f2ed006c90ccb65cd143d8b0fcfc28ffb98c4289 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Mon, 30 Jul 2012 07:29:34 +0200 Subject: mpc8: return more meaningful error codes. --- libavformat/mpc8.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'libavformat/mpc8.c') diff --git a/libavformat/mpc8.c b/libavformat/mpc8.c index 6b9f77e6ab..b6837c52f7 100644 --- a/libavformat/mpc8.c +++ b/libavformat/mpc8.c @@ -202,7 +202,7 @@ static int mpc8_read_header(AVFormatContext *s) c->header_pos = avio_tell(pb); if(avio_rl32(pb) != TAG_MPCK){ av_log(s, AV_LOG_ERROR, "Not a Musepack8 file\n"); - return -1; + return AVERROR_INVALIDDATA; } while(!pb->eof_reached){ @@ -214,14 +214,14 @@ static int mpc8_read_header(AVFormatContext *s) } if(tag != TAG_STREAMHDR){ av_log(s, AV_LOG_ERROR, "Stream header not found\n"); - return -1; + return AVERROR_INVALIDDATA; } pos = avio_tell(pb); avio_skip(pb, 4); //CRC c->ver = avio_r8(pb); if(c->ver != 8){ av_log(s, AV_LOG_ERROR, "Unknown stream version %d\n", c->ver); - return -1; + return AVERROR_PATCHWELCOME; } c->samples = ffio_read_varlen(pb); ffio_read_varlen(pb); //silence samples at the beginning -- cgit v1.2.3