From: Michael Niedermayer Date: Fri, 25 Aug 2006 20:50:18 +0000 (+0000) Subject: support some totally broken ODML variant X-Git-Tag: v0.5~12020 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=965a63af2bdc300dfca35df6b7777f0ce08afadb;p=platform%2Fupstream%2Flibav.git support some totally broken ODML variant Originally committed as revision 6091 to svn://svn.ffmpeg.org/ffmpeg/trunk --- diff --git a/libavformat/avidec.c b/libavformat/avidec.c index fd50c86..21d5019 100644 --- a/libavformat/avidec.c +++ b/libavformat/avidec.c @@ -100,9 +100,12 @@ static int read_braindead_odml_indx(AVFormatContext *s, int frame_num){ 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 @@ static int read_braindead_odml_indx(AVFormatContext *s, int frame_num){ 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 @@ static int read_braindead_odml_indx(AVFormatContext *s, int frame_num){ 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 @@ static int avi_read_header(AVFormatContext *s, AVFormatParameters *ap) 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 @@ static int avi_read_idx1(AVFormatContext *s, int size) 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;