assert(ie->timestamp > timestamp);
if(ie->timestamp <= timestamp) return -1;
int av_add_index_entry(AVStream *st,                            int64_t pos, int64_t timestamp, int distance, int flags){    AVIndexEntry *entries, *ie;    int index;        entries = av_fast_realloc(st->index_entries,                              &st->index_entries_allocated_size,                              (st->nb_index_entries + 1) *                               sizeof(AVIndexEntry));    st->index_entries= entries;    index= av_index_search_timestamp(st, timestamp, 0);    if(index<0){        index= st->nb_index_entries++;        ie= &entries[index];        assert(index==0 || ie[-1].timestamp < timestamp);    }else{        ie= &entries[index];        if(ie->timestamp != timestamp){            assert(ie->timestamp > timestamp);            memmove(entries + index + 1, entries + index, sizeof(AVIndexEntry)*(st->nb_index_entries - index));            st->nb_index_entries++;        }else if(ie->pos == pos && distance < ie->min_distance) //dont reduce the distance            distance= ie->min_distance;    }    ie->pos = pos;    ie->timestamp = timestamp;    ie->min_distance= distance;    ie->flags = flags;        return index;}