|
|
|
@ -1374,7 +1374,15 @@ void ff_read_frame_flush(AVFormatContext *s) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void av_update_cur_dts(AVFormatContext *s, AVStream *ref_st, int64_t timestamp){ |
|
|
|
|
#if FF_API_SEEK_PUBLIC |
|
|
|
|
void av_update_cur_dts(AVFormatContext *s, AVStream *ref_st, int64_t timestamp) |
|
|
|
|
{ |
|
|
|
|
return ff_update_cur_dts(s, ref_st, timestamp); |
|
|
|
|
} |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
void ff_update_cur_dts(AVFormatContext *s, AVStream *ref_st, int64_t timestamp) |
|
|
|
|
{ |
|
|
|
|
int i; |
|
|
|
|
|
|
|
|
|
for(i = 0; i < s->nb_streams; i++) { |
|
|
|
@ -1494,7 +1502,14 @@ int av_index_search_timestamp(AVStream *st, int64_t wanted_timestamp, |
|
|
|
|
wanted_timestamp, flags); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#if FF_API_SEEK_PUBLIC |
|
|
|
|
int av_seek_frame_binary(AVFormatContext *s, int stream_index, int64_t target_ts, int flags){ |
|
|
|
|
return ff_seek_frame_binary(s, stream_index, target_ts, flags); |
|
|
|
|
} |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
int ff_seek_frame_binary(AVFormatContext *s, int stream_index, int64_t target_ts, int flags) |
|
|
|
|
{ |
|
|
|
|
AVInputFormat *avif= s->iformat; |
|
|
|
|
int64_t av_uninit(pos_min), av_uninit(pos_max), pos, pos_limit; |
|
|
|
|
int64_t ts_min, ts_max, ts; |
|
|
|
@ -1541,7 +1556,7 @@ int av_seek_frame_binary(AVFormatContext *s, int stream_index, int64_t target_ts |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
pos= av_gen_search(s, stream_index, target_ts, pos_min, pos_max, pos_limit, ts_min, ts_max, flags, &ts, avif->read_timestamp); |
|
|
|
|
pos= ff_gen_search(s, stream_index, target_ts, pos_min, pos_max, pos_limit, ts_min, ts_max, flags, &ts, avif->read_timestamp); |
|
|
|
|
if(pos<0) |
|
|
|
|
return -1; |
|
|
|
|
|
|
|
|
@ -1549,12 +1564,28 @@ int av_seek_frame_binary(AVFormatContext *s, int stream_index, int64_t target_ts |
|
|
|
|
if ((ret = avio_seek(s->pb, pos, SEEK_SET)) < 0) |
|
|
|
|
return ret; |
|
|
|
|
|
|
|
|
|
av_update_cur_dts(s, st, ts); |
|
|
|
|
ff_update_cur_dts(s, st, ts); |
|
|
|
|
|
|
|
|
|
return 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int64_t av_gen_search(AVFormatContext *s, int stream_index, int64_t target_ts, int64_t pos_min, int64_t pos_max, int64_t pos_limit, int64_t ts_min, int64_t ts_max, int flags, int64_t *ts_ret, int64_t (*read_timestamp)(struct AVFormatContext *, int , int64_t *, int64_t )){ |
|
|
|
|
#if FF_API_SEEK_PUBLIC |
|
|
|
|
int64_t av_gen_search(AVFormatContext *s, int stream_index, int64_t target_ts, |
|
|
|
|
int64_t pos_min, int64_t pos_max, int64_t pos_limit, |
|
|
|
|
int64_t ts_min, int64_t ts_max, int flags, int64_t *ts_ret, |
|
|
|
|
int64_t (*read_timestamp)(struct AVFormatContext *, int , int64_t *, int64_t )) |
|
|
|
|
{ |
|
|
|
|
return ff_gen_search(s, stream_index, target_ts, pos_min, pos_max, |
|
|
|
|
pos_limit, ts_min, ts_max, flags, ts_ret, |
|
|
|
|
read_timestamp); |
|
|
|
|
} |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
int64_t ff_gen_search(AVFormatContext *s, int stream_index, int64_t target_ts, |
|
|
|
|
int64_t pos_min, int64_t pos_max, int64_t pos_limit, |
|
|
|
|
int64_t ts_min, int64_t ts_max, int flags, int64_t *ts_ret, |
|
|
|
|
int64_t (*read_timestamp)(struct AVFormatContext *, int , int64_t *, int64_t )) |
|
|
|
|
{ |
|
|
|
|
int64_t pos, ts; |
|
|
|
|
int64_t start_pos, filesize; |
|
|
|
|
int no_change; |
|
|
|
@ -1708,7 +1739,7 @@ static int seek_frame_generic(AVFormatContext *s, |
|
|
|
|
ie= &st->index_entries[st->nb_index_entries-1]; |
|
|
|
|
if ((ret = avio_seek(s->pb, ie->pos, SEEK_SET)) < 0) |
|
|
|
|
return ret; |
|
|
|
|
av_update_cur_dts(s, st, ie->timestamp); |
|
|
|
|
ff_update_cur_dts(s, st, ie->timestamp); |
|
|
|
|
}else{ |
|
|
|
|
if ((ret = avio_seek(s->pb, s->data_offset, SEEK_SET)) < 0) |
|
|
|
|
return ret; |
|
|
|
@ -1739,7 +1770,7 @@ static int seek_frame_generic(AVFormatContext *s, |
|
|
|
|
ie = &st->index_entries[index]; |
|
|
|
|
if ((ret = avio_seek(s->pb, ie->pos, SEEK_SET)) < 0) |
|
|
|
|
return ret; |
|
|
|
|
av_update_cur_dts(s, st, ie->timestamp); |
|
|
|
|
ff_update_cur_dts(s, st, ie->timestamp); |
|
|
|
|
|
|
|
|
|
return 0; |
|
|
|
|
} |
|
|
|
@ -1778,7 +1809,7 @@ int av_seek_frame(AVFormatContext *s, int stream_index, int64_t timestamp, int f |
|
|
|
|
|
|
|
|
|
if (s->iformat->read_timestamp && !(s->iformat->flags & AVFMT_NOBINSEARCH)) { |
|
|
|
|
ff_read_frame_flush(s); |
|
|
|
|
return av_seek_frame_binary(s, stream_index, timestamp, flags); |
|
|
|
|
return ff_seek_frame_binary(s, stream_index, timestamp, flags); |
|
|
|
|
} else if (!(s->iformat->flags & AVFMT_NOGENSEARCH)) { |
|
|
|
|
ff_read_frame_flush(s); |
|
|
|
|
return seek_frame_generic(s, stream_index, timestamp, flags); |
|
|
|
|