From a3d00fc64ece84cd7946fc898adf1ef0305a4058 Mon Sep 17 00:00:00 2001 From: Yusuke Nakamura Date: Sun, 15 May 2016 16:10:10 +0900 Subject: [PATCH] mp4sys: Handle extra bytes within descriptors. --- codecs/mp4sys.c | 18 ++++++++++++++++++ lsmash.h | 2 +- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/codecs/mp4sys.c b/codecs/mp4sys.c index b07a7b4..e87101d 100644 --- a/codecs/mp4sys.c +++ b/codecs/mp4sys.c @@ -1269,6 +1269,7 @@ mp4sys_descriptor_t *mp4sys_get_descriptor( lsmash_bs_t *bs, void *parent ) { mp4sys_descriptor_head_t header; mp4sys_get_descriptor_header( bs, &header ); + uint64_t end_pos = header.size + lsmash_bs_count( bs ); mp4sys_descriptor_t *desc; switch( header.tag ) { @@ -1302,6 +1303,23 @@ mp4sys_descriptor_t *mp4sys_get_descriptor( lsmash_bs_t *bs, void *parent ) } break; } + /* Skip extra bytes if present. */ + uint64_t skip_bytes = end_pos - lsmash_bs_count( bs ); + if( skip_bytes ) + { + printf( "[MPEG-4 Systems Descriptor Tag = 0x%02"PRIx8"] has more bytes than expected: %"PRId64"\n", header.tag, skip_bytes ); + if( !bs->unseekable ) + { + /* The stream is seekable. So, skip by seeking the stream. */ + uint64_t start = lsmash_bs_get_stream_pos( bs ); + lsmash_bs_read_seek( bs, skip_bytes, SEEK_CUR ); + uint64_t end = lsmash_bs_get_stream_pos( bs ); + bs->buffer.count += end - start; + } + else + /* The stream is unseekable. So, skip by reading the stream. */ + lsmash_bs_skip_bytes_64( bs, skip_bytes ); + } return desc; } diff --git a/lsmash.h b/lsmash.h index 0b0d0fc..920b0a7 100644 --- a/lsmash.h +++ b/lsmash.h @@ -48,7 +48,7 @@ extern "C" { ****************************************************************************/ #define LSMASH_VERSION_MAJOR 2 #define LSMASH_VERSION_MINOR 11 -#define LSMASH_VERSION_MICRO 3 +#define LSMASH_VERSION_MICRO 4 #define LSMASH_VERSION_INT( a, b, c ) (((a) << 16) | ((b) << 8) | (c)) -- 2.11.4.GIT