aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2006-08-25 20:50:18 +0000
committerMichael Niedermayer <michaelni@gmx.at>2006-08-25 20:50:18 +0000
commit965a63af2bdc300dfca35df6b7777f0ce08afadb (patch)
tree7d3bcf75152151d75faddba46873396f3235b85b
parentb89c8f589af0fcb350614d9f49cf6ff2a5e92c43 (diff)
downloadffmpeg-965a63af2bdc300dfca35df6b7777f0ce08afadb.tar.gz
support some totally broken ODML variant
Originally committed as revision 6091 to svn://svn.ffmpeg.org/ffmpeg/trunk
-rw-r--r--libavformat/avidec.c26
1 files changed, 20 insertions, 6 deletions
diff --git a/libavformat/avidec.c b/libavformat/avidec.c
index fd50c86508..21d5019029 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<entries_in_use; i++){
if(index_type){
int64_t pos= get_le32(pb) + base - 8;
@@ -126,7 +137,9 @@ static int read_braindead_odml_indx(AVFormatContext *s, int frame_num){
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 @@ 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; i<s->nb_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;