Logo Search packages:      
Sourcecode: blender version File versions  Download package

int av_index_search_timestamp ( AVStream *  st,
int64_t  wanted_timestamp,
int  flags 
)

Gets the index for a specific timestamp.

Parameters:
flags if AVSEEK_FLAG_BACKWARD then the returned index will correspond to the timestamp which is <= the requested one, if backward is 0 then it will be >= if AVSEEK_FLAG_ANY seek to any frame, only keyframes otherwise
Returns:
< 0 if no such timestamp could be found

Definition at line 1234 of file utils.c.

Referenced by av_add_index_entry(), and av_seek_frame_binary().

{
    AVIndexEntry *entries= st->index_entries;
    int nb_entries= st->nb_index_entries;
    int a, b, m;
    int64_t timestamp;

    a = - 1;
    b = nb_entries;

    while (b - a > 1) {
        m = (a + b) >> 1;
        timestamp = entries[m].timestamp;
        if(timestamp >= wanted_timestamp)
            b = m;
        if(timestamp <= wanted_timestamp)
            a = m;
    }
    m= (flags & AVSEEK_FLAG_BACKWARD) ? a : b;

    if(!(flags & AVSEEK_FLAG_ANY)){
        while(m>=0 && m<nb_entries && !(entries[m].flags & AVINDEX_KEYFRAME)){
            m += (flags & AVSEEK_FLAG_BACKWARD) ? -1 : 1;
        }
    }

    if(m == nb_entries)
        return -1;
    return  m;
}


Generated by  Doxygen 1.6.0   Back to index