Mercurial > libavformat.hg
changeset 1501:1d17ea4b6e94 libavformat
seeking with index
author | michael |
---|---|
date | Tue, 14 Nov 2006 13:32:14 +0000 |
parents | 2ac9e4f39a67 |
children | eae8cc31215e |
files | nutdec.c |
diffstat | 1 files changed, 14 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- a/nutdec.c Tue Nov 14 13:19:51 2006 +0000 +++ b/nutdec.c Tue Nov 14 13:32:14 2006 +0000 @@ -633,7 +633,7 @@ s->data_offset= pos-8; - if(0 &&!url_is_streamed(bc)){ + if(!url_is_streamed(bc)){ int64_t orig_pos= url_ftell(bc); find_and_decode_index(nut); url_fseek(bc, orig_pos, SEEK_SET); @@ -694,16 +694,6 @@ stc->last_pts= *pts; stc->last_key_frame= flags&FLAG_KEY; //FIXME change to last flags - if(flags&FLAG_KEY){ - av_add_index_entry( - s->streams[*stream_id], - nut->last_syncpoint_pos, - *pts, - 0, - 0, - AVINDEX_KEYFRAME); - } - return size; } @@ -846,6 +836,14 @@ syncpoint_t *sp, *next_node[2]= {&nopts_sp, &nopts_sp}; int64_t pos, pos2, ts; + if(st->index_entries){ + int index= av_index_search_timestamp(st, pts, flags); + if(index<0) + return -1; + + pos2= st->index_entries[index].pos; + ts = st->index_entries[index].timestamp; + }else{ av_tree_find(nut->syncpoints, &dummy, sp_pts_cmp, next_node); av_log(s, AV_LOG_DEBUG, "%Ld-%Ld %Ld-%Ld\n", next_node[0]->pos, next_node[1]->pos, next_node[0]->ts , next_node[1]->ts); @@ -866,12 +864,13 @@ sp= av_tree_find(nut->syncpoints, &dummy, sp_pos_cmp, NULL); assert(sp); - - av_log(NULL, AV_LOG_DEBUG, "SEEKTO: %"PRId64"\n", sp->back_ptr); - pos= find_startcode(&s->pb, SYNCPOINT_STARTCODE, sp->back_ptr - 15); + pos2= sp->back_ptr - 15; + } + av_log(NULL, AV_LOG_DEBUG, "SEEKTO: %"PRId64"\n", pos2); + pos= find_startcode(&s->pb, SYNCPOINT_STARTCODE, pos2); url_fseek(&s->pb, pos, SEEK_SET); av_log(NULL, AV_LOG_DEBUG, "SP: %"PRId64"\n", pos); - if(sp->back_ptr - 15 > pos || sp->back_ptr < pos){ + if(pos2 > pos || pos2 + 15 < pos){ av_log(NULL, AV_LOG_ERROR, "no syncpoint at backptr pos\n"); } return 0;