mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-11-21 10:55:51 +02:00
lavf: make some seeking functions private
Specifically av_update_cur_dts(), av_seek_frame_binary() and av_gen_search(). They are not supposed to be called outside lavf.
This commit is contained in:
parent
ec6d743118
commit
a2faa95151
@ -1282,7 +1282,7 @@ static int asf_read_seek(AVFormatContext *s, int stream_index, int64_t pts, int
|
||||
}
|
||||
}
|
||||
/* no index or seeking by index failed */
|
||||
if(av_seek_frame_binary(s, stream_index, pts, flags)<0)
|
||||
if (ff_seek_frame_binary(s, stream_index, pts, flags) < 0)
|
||||
return -1;
|
||||
asf_reset_header(s);
|
||||
return 0;
|
||||
|
@ -1388,40 +1388,20 @@ int av_index_search_timestamp(AVStream *st, int64_t timestamp, int flags);
|
||||
int av_add_index_entry(AVStream *st, int64_t pos, int64_t timestamp,
|
||||
int size, int distance, int flags);
|
||||
|
||||
/**
|
||||
* Perform a binary search using av_index_search_timestamp() and
|
||||
* AVInputFormat.read_timestamp().
|
||||
* This is not supposed to be called directly by a user application,
|
||||
* but by demuxers.
|
||||
* @param target_ts target timestamp in the time base of the given stream
|
||||
* @param stream_index stream number
|
||||
*/
|
||||
#if FF_API_SEEK_PUBLIC
|
||||
attribute_deprecated
|
||||
int av_seek_frame_binary(AVFormatContext *s, int stream_index,
|
||||
int64_t target_ts, int flags);
|
||||
|
||||
/**
|
||||
* Update cur_dts of all streams based on the given timestamp and AVStream.
|
||||
*
|
||||
* Stream ref_st unchanged, others set cur_dts in their native time base.
|
||||
* Only needed for timestamp wrapping or if (dts not set and pts!=dts).
|
||||
* @param timestamp new dts expressed in time_base of param ref_st
|
||||
* @param ref_st reference stream giving time_base of param timestamp
|
||||
*/
|
||||
attribute_deprecated
|
||||
void av_update_cur_dts(AVFormatContext *s, AVStream *ref_st, int64_t timestamp);
|
||||
|
||||
/**
|
||||
* Perform a binary search using read_timestamp().
|
||||
* This is not supposed to be called directly by a user application,
|
||||
* but by demuxers.
|
||||
* @param target_ts target timestamp in the time base of the given stream
|
||||
* @param stream_index stream number
|
||||
*/
|
||||
attribute_deprecated
|
||||
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 ));
|
||||
#endif
|
||||
|
||||
/**
|
||||
* media file output
|
||||
|
@ -253,4 +253,37 @@ enum CodecID ff_guess_image2_codec(const char *filename);
|
||||
*/
|
||||
int64_t ff_iso8601_to_unix_time(const char *datestr);
|
||||
|
||||
/**
|
||||
* Perform a binary search using av_index_search_timestamp() and
|
||||
* AVInputFormat.read_timestamp().
|
||||
*
|
||||
* @param target_ts target timestamp in the time base of the given stream
|
||||
* @param stream_index stream number
|
||||
*/
|
||||
int ff_seek_frame_binary(AVFormatContext *s, int stream_index,
|
||||
int64_t target_ts, int flags);
|
||||
|
||||
/**
|
||||
* Update cur_dts of all streams based on the given timestamp and AVStream.
|
||||
*
|
||||
* Stream ref_st unchanged, others set cur_dts in their native time base.
|
||||
* Only needed for timestamp wrapping or if (dts not set and pts!=dts).
|
||||
* @param timestamp new dts expressed in time_base of param ref_st
|
||||
* @param ref_st reference stream giving time_base of param timestamp
|
||||
*/
|
||||
void ff_update_cur_dts(AVFormatContext *s, AVStream *ref_st, int64_t timestamp);
|
||||
|
||||
/**
|
||||
* Perform a binary search using read_timestamp().
|
||||
*
|
||||
* @param target_ts target timestamp in the time base of the given stream
|
||||
* @param stream_index stream number
|
||||
*/
|
||||
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 ));
|
||||
|
||||
#endif /* AVFORMAT_INTERNAL_H */
|
||||
|
@ -2002,7 +2002,7 @@ static int matroska_read_seek(AVFormatContext *s, int stream_index,
|
||||
matroska->skip_to_keyframe = !(flags & AVSEEK_FLAG_ANY);
|
||||
matroska->skip_to_timecode = st->index_entries[index].timestamp;
|
||||
matroska->done = 0;
|
||||
av_update_cur_dts(s, st, st->index_entries[index].timestamp);
|
||||
ff_update_cur_dts(s, st, st->index_entries[index].timestamp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1768,7 +1768,7 @@ static int read_seek2(AVFormatContext *s,
|
||||
ts_adj = target_ts;
|
||||
stream_index_gen_search = stream_index;
|
||||
}
|
||||
pos = av_gen_search(s, stream_index_gen_search, ts_adj,
|
||||
pos = ff_gen_search(s, stream_index_gen_search, ts_adj,
|
||||
0, INT64_MAX, -1,
|
||||
AV_NOPTS_VALUE,
|
||||
AV_NOPTS_VALUE,
|
||||
@ -1816,7 +1816,7 @@ static int read_seek(AVFormatContext *s, int stream_index, int64_t target_ts, in
|
||||
uint8_t buf[TS_PACKET_SIZE];
|
||||
int64_t pos;
|
||||
|
||||
if(av_seek_frame_binary(s, stream_index, target_ts, flags) < 0)
|
||||
if (ff_seek_frame_binary(s, stream_index, target_ts, flags) < 0)
|
||||
return -1;
|
||||
|
||||
pos= avio_tell(s->pb);
|
||||
|
@ -49,6 +49,7 @@
|
||||
#include "libavutil/mathematics.h"
|
||||
#include "libavcodec/bytestream.h"
|
||||
#include "avformat.h"
|
||||
#include "internal.h"
|
||||
#include "mxf.h"
|
||||
|
||||
typedef struct {
|
||||
@ -1020,7 +1021,7 @@ static int mxf_read_seek(AVFormatContext *s, int stream_index, int64_t sample_ti
|
||||
sample_time = 0;
|
||||
seconds = av_rescale(sample_time, st->time_base.num, st->time_base.den);
|
||||
avio_seek(s->pb, (s->bit_rate * seconds) >> 3, SEEK_SET);
|
||||
av_update_cur_dts(s, st, sample_time);
|
||||
ff_update_cur_dts(s, st, sample_time);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -874,16 +874,16 @@ static int read_seek(AVFormatContext *s, int stream_index, int64_t pts, int flag
|
||||
(void **) next_node);
|
||||
av_log(s, AV_LOG_DEBUG, "%"PRIu64"-%"PRIu64" %"PRId64"-%"PRId64"\n", next_node[0]->pos, next_node[1]->pos,
|
||||
next_node[0]->ts , next_node[1]->ts);
|
||||
pos= av_gen_search(s, -1, dummy.ts, next_node[0]->pos, next_node[1]->pos, next_node[1]->pos,
|
||||
next_node[0]->ts , next_node[1]->ts, AVSEEK_FLAG_BACKWARD, &ts, nut_read_timestamp);
|
||||
pos = ff_gen_search(s, -1, dummy.ts, next_node[0]->pos, next_node[1]->pos, next_node[1]->pos,
|
||||
next_node[0]->ts , next_node[1]->ts, AVSEEK_FLAG_BACKWARD, &ts, nut_read_timestamp);
|
||||
|
||||
if(!(flags & AVSEEK_FLAG_BACKWARD)){
|
||||
dummy.pos= pos+16;
|
||||
next_node[1]= &nopts_sp;
|
||||
av_tree_find(nut->syncpoints, &dummy, (void *) ff_nut_sp_pos_cmp,
|
||||
(void **) next_node);
|
||||
pos2= av_gen_search(s, -2, dummy.pos, next_node[0]->pos , next_node[1]->pos, next_node[1]->pos,
|
||||
next_node[0]->back_ptr, next_node[1]->back_ptr, flags, &ts, nut_read_timestamp);
|
||||
pos2 = ff_gen_search(s, -2, dummy.pos, next_node[0]->pos , next_node[1]->pos, next_node[1]->pos,
|
||||
next_node[0]->back_ptr, next_node[1]->back_ptr, flags, &ts, nut_read_timestamp);
|
||||
if(pos2>=0)
|
||||
pos= pos2;
|
||||
//FIXME dir but I think it does not matter
|
||||
|
@ -33,6 +33,7 @@
|
||||
#include <stdio.h>
|
||||
#include "oggdec.h"
|
||||
#include "avformat.h"
|
||||
#include "internal.h"
|
||||
#include "vorbiscomment.h"
|
||||
|
||||
#define MAX_PAGE_SIZE 65307
|
||||
@ -637,7 +638,7 @@ static int ogg_read_seek(AVFormatContext *s, int stream_index,
|
||||
&& !(flags & AVSEEK_FLAG_ANY))
|
||||
os->keyframe_seek = 1;
|
||||
|
||||
ret = av_seek_frame_binary(s, stream_index, timestamp, flags);
|
||||
ret = ff_seek_frame_binary(s, stream_index, timestamp, flags);
|
||||
os = ogg->streams + stream_index;
|
||||
if (ret < 0)
|
||||
os->keyframe_seek = 0;
|
||||
|
@ -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);
|
||||
|
@ -104,5 +104,8 @@
|
||||
#ifndef FF_API_STREAM_COPY
|
||||
#define FF_API_STREAM_COPY (LIBAVFORMAT_VERSION_MAJOR < 54)
|
||||
#endif
|
||||
#ifndef FF_API_SEEK_PUBLIC
|
||||
#define FF_API_SEEK_PUBLIC (LIBAVFORMAT_VERSION_MAJOR < 54)
|
||||
#endif
|
||||
|
||||
#endif /* AVFORMAT_VERSION_H */
|
||||
|
Loading…
Reference in New Issue
Block a user