# HG changeset patch # User michael # Date 1156539018 0 # Node ID e27e94ac0c4bc488d6b1ebd9d6c47afeb506c61c # Parent bc0b7f4637f06f111e82e3bf46a1c5270c721d46 support some totally broken ODML variant diff -r bc0b7f4637f0 -r e27e94ac0c4b avidec.c --- 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= 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; inb_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;