summaryrefslogtreecommitdiff
path: root/libavformat/nutdec.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2006-11-14 13:32:14 +0000
committerMichael Niedermayer <michaelni@gmx.at>2006-11-14 13:32:14 +0000
commit071790c876b436ca0cb6bd504ae665769a2c33ef (patch)
tree7cc6fac4736b9dd80cf95853624f7fcafda9bf15 /libavformat/nutdec.c
parent4d5be986f0f84d38b4859e04eba2ca0381c6f8c4 (diff)
seeking with index
Originally committed as revision 7057 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavformat/nutdec.c')
-rw-r--r--libavformat/nutdec.c29
1 files changed, 14 insertions, 15 deletions
diff --git a/libavformat/nutdec.c b/libavformat/nutdec.c
index 7c3e88ac95..b44f8042c7 100644
--- a/libavformat/nutdec.c
+++ b/libavformat/nutdec.c
@@ -633,7 +633,7 @@ static int nut_read_header(AVFormatContext *s, AVFormatParameters *ap)
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 @@ static int decode_frame_header(NUTContext *nut, int *flags_ret, int64_t *pts, in
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 @@ static int read_seek(AVFormatContext *s, int stream_index, int64_t pts, int flag
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 @@ static int read_seek(AVFormatContext *s, int stream_index, int64_t pts, int flag
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;