Mercurial > libavformat.hg
changeset 1277:e27e94ac0c4b libavformat
support some totally broken ODML variant
author | michael |
---|---|
date | Fri, 25 Aug 2006 20:50:18 +0000 |
parents | bc0b7f4637f0 |
children | f40d75601106 |
files | avidec.c |
diffstat | 1 files changed, 20 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/avidec.c Thu Aug 24 18:39:57 2006 +0000 +++ b/avidec.c Fri Aug 25 20:50:18 2006 +0000 @@ -100,9 +100,12 @@ AVIStream *ast; int i; int64_t last_pos= -1; + int64_t filesize= url_fsize(&s->pb); -// av_log(s, AV_LOG_ERROR, "longs_pre_entry:%d index_type:%d entries_in_use:%d chunk_id:%X base:%Ld\n", -// longs_pre_entry,index_type, entries_in_use, chunk_id, base); +#ifdef DEBUG_SEEK + av_log(s, AV_LOG_ERROR, "longs_pre_entry:%d index_type:%d entries_in_use:%d chunk_id:%X base:%16LX\n", + longs_pre_entry,index_type, entries_in_use, chunk_id, base); +#endif if(stream_id > s->nb_streams || stream_id < 0) return -1; @@ -119,6 +122,14 @@ if(index_type>1) return -1; + if(filesize > 0 && base >= filesize){ + av_log(s, AV_LOG_ERROR, "ODML index invalid\n"); + if(base>>32 == (base & 0xFFFFFFFF) && (base & 0xFFFFFFFF) < filesize && filesize <= 0xFFFFFFFF) + base &= 0xFFFFFFFF; + else + return -1; + } + for(i=0; i<entries_in_use; i++){ if(index_type){ int64_t pos= get_le32(pb) + base - 8; @@ -126,7 +137,9 @@ int key= len >= 0; len &= 0x7FFFFFFF; -//av_log(s, AV_LOG_ERROR, "pos:%Ld, len:%X\n", pos, len); +#ifdef DEBUG_SEEK + av_log(s, AV_LOG_ERROR, "pos:%Ld, len:%X\n", pos, len); +#endif if(last_pos == pos || pos == base - 8) avi->non_interleaved= 1; else @@ -152,11 +165,13 @@ url_fseek(pb, pos, SEEK_SET); } } + avi->index_loaded=1; return 0; } static void clean_index(AVFormatContext *s){ - int i, j; + int i; + int64_t j; for(i=0; i<s->nb_streams; i++){ AVStream *st = s->streams[i]; @@ -443,7 +458,6 @@ i= url_ftell(pb); if(!url_is_streamed(pb)){ read_braindead_odml_indx(s, 0); - avi->index_loaded=1; } url_fseek(pb, i+size, SEEK_SET); break; @@ -771,7 +785,7 @@ ast = st->priv_data; #if defined(DEBUG_SEEK) - av_log(NULL, AV_LOG_DEBUG, "%d cum_len=%d\n", len, ast->cum_len); + av_log(NULL, AV_LOG_DEBUG, "%d cum_len=%Ld\n", len, ast->cum_len); #endif if(last_pos == pos) avi->non_interleaved= 1;