if (st->codec.codec_type == CODEC_TYPE_VIDEO)
if (ast->sample_size==0)
static int avi_read_seek(AVFormatContext *s, int stream_index, int64_t timestamp){    AVIContext *avi = s->priv_data;    AVStream *st;    AVIStream *ast;    int frame_number, i;    int64_t pos;    if (!avi->index_loaded) {        /* we only load the index on demand */        avi_load_index(s);        avi->index_loaded = 1;    }    if (stream_index < 0) {        for(i = 0; i < s->nb_streams; i++) {            st = s->streams[i];            if (st->codec.codec_type == CODEC_TYPE_VIDEO)                goto found;        }        return -1;    found:        stream_index = i;    }    st = s->streams[stream_index];    if (st->codec.codec_type != CODEC_TYPE_VIDEO)        return -1;    ast = st->priv_data;    /* compute the frame number */    frame_number = (timestamp * ast->rate) /        (ast->scale * (int64_t)AV_TIME_BASE);#ifdef DEBUG_SEEK    printf("timestamp=%0.3f nb_indexes=%d frame_number=%d\n",            (double)timestamp / AV_TIME_BASE,           ast->nb_index_entries, frame_number);#endif    /* find a closest key frame before */    if (frame_number >= ast->nb_index_entries)        return -1;    while (frame_number >= 0 &&           !(ast->index_entries[frame_number].flags & AVIIF_INDEX))        frame_number--;    if (frame_number < 0)        return -1;    ast->new_frame_offset = frame_number;    /* find the position */    pos = ast->index_entries[frame_number].pos;#ifdef DEBUG_SEEK    printf("key_frame_number=%d pos=0x%llx\n",            frame_number, pos);#endif        /* update the frame counters for all the other stream by looking       at the positions just after the one found */    for(i = 0; i < s->nb_streams; i++) {        int j;        if (i != stream_index) {            st = s->streams[i];            ast = st->priv_data;            if (ast->nb_index_entries <= 0)                return -1;            j = locate_frame_in_index(ast->index_entries,                                      ast->nb_index_entries,                                      pos);            /* get next frame */            if ((j  + 1) < ast->nb_index_entries)                j++;            /* extract the current frame number */            if (st->codec.codec_type == CODEC_TYPE_VIDEO)                           ast->new_frame_offset = j;            else                ast->new_frame_offset = ast->index_entries[j].cum_len;        }    }        /* everything is OK now. We can update the frame offsets */    for(i = 0; i < s->nb_streams; i++) {        st = s->streams[i];        ast = st->priv_data;        ast->frame_offset = ast->new_frame_offset;#ifdef DEBUG_SEEK        printf("%d: frame_offset=%d\n", i,                ast->frame_offset);#endif    }    /* do the seek */    pos += avi->movi_list;    url_fseek(&s->pb, pos, SEEK_SET);    return 0;}