Revision 965a63af

View differences:

libavformat/avidec.c
100 100
    AVIStream *ast;
101 101
    int i;
102 102
    int64_t last_pos= -1;
103
    int64_t filesize= url_fsize(&s->pb);
103 104

  
104
//    av_log(s, AV_LOG_ERROR, "longs_pre_entry:%d index_type:%d entries_in_use:%d chunk_id:%X base:%Ld\n",
105
//        longs_pre_entry,index_type, entries_in_use, chunk_id, base);
105
#ifdef DEBUG_SEEK
106
    av_log(s, AV_LOG_ERROR, "longs_pre_entry:%d index_type:%d entries_in_use:%d chunk_id:%X base:%16LX\n",
107
        longs_pre_entry,index_type, entries_in_use, chunk_id, base);
108
#endif
106 109

  
107 110
    if(stream_id > s->nb_streams || stream_id < 0)
108 111
        return -1;
......
119 122
    if(index_type>1)
120 123
        return -1;
121 124

  
125
    if(filesize > 0 && base >= filesize){
126
        av_log(s, AV_LOG_ERROR, "ODML index invalid\n");
127
        if(base>>32 == (base & 0xFFFFFFFF) && (base & 0xFFFFFFFF) < filesize && filesize <= 0xFFFFFFFF)
128
            base &= 0xFFFFFFFF;
129
        else
130
            return -1;
131
    }
132

  
122 133
    for(i=0; i<entries_in_use; i++){
123 134
        if(index_type){
124 135
            int64_t pos= get_le32(pb) + base - 8;
......
126 137
            int key= len >= 0;
127 138
            len &= 0x7FFFFFFF;
128 139

  
129
//av_log(s, AV_LOG_ERROR, "pos:%Ld, len:%X\n", pos, len);
140
#ifdef DEBUG_SEEK
141
            av_log(s, AV_LOG_ERROR, "pos:%Ld, len:%X\n", pos, len);
142
#endif
130 143
            if(last_pos == pos || pos == base - 8)
131 144
                avi->non_interleaved= 1;
132 145
            else
......
152 165
            url_fseek(pb, pos, SEEK_SET);
153 166
        }
154 167
    }
168
    avi->index_loaded=1;
155 169
    return 0;
156 170
}
157 171

  
158 172
static void clean_index(AVFormatContext *s){
159
    int i, j;
173
    int i;
174
    int64_t j;
160 175

  
161 176
    for(i=0; i<s->nb_streams; i++){
162 177
        AVStream *st = s->streams[i];
......
443 458
            i= url_ftell(pb);
444 459
            if(!url_is_streamed(pb)){
445 460
                read_braindead_odml_indx(s, 0);
446
                avi->index_loaded=1;
447 461
            }
448 462
            url_fseek(pb, i+size, SEEK_SET);
449 463
            break;
......
771 785
        ast = st->priv_data;
772 786

  
773 787
#if defined(DEBUG_SEEK)
774
        av_log(NULL, AV_LOG_DEBUG, "%d cum_len=%d\n", len, ast->cum_len);
788
        av_log(NULL, AV_LOG_DEBUG, "%d cum_len=%Ld\n", len, ast->cum_len);
775 789
#endif
776 790
        if(last_pos == pos)
777 791
            avi->non_interleaved= 1;

Also available in: Unified diff