aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2011-10-16 15:03:30 +0200
committerAnton Khirnov <anton@khirnov.net>2011-10-28 09:23:24 +0200
commita2faa9515167bf1537abdc4fa9caa88934171cdd (patch)
treeeabdcd055e89cc202b82bf594ce9081638b1a7da
parentec6d743118282bbbc652372a7af44c6ec6f8048e (diff)
downloadffmpeg-a2faa9515167bf1537abdc4fa9caa88934171cdd.tar.gz
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.
-rw-r--r--libavformat/asfdec.c2
-rw-r--r--libavformat/avformat.h30
-rw-r--r--libavformat/internal.h33
-rw-r--r--libavformat/matroskadec.c2
-rw-r--r--libavformat/mpegts.c4
-rw-r--r--libavformat/mxfdec.c3
-rw-r--r--libavformat/nutdec.c8
-rw-r--r--libavformat/oggdec.c3
-rw-r--r--libavformat/utils.c45
-rw-r--r--libavformat/version.h3
10 files changed, 91 insertions, 42 deletions
diff --git a/libavformat/asfdec.c b/libavformat/asfdec.c
index 88091a5c9e..ed06e8a897 100644
--- a/libavformat/asfdec.c
+++ b/libavformat/asfdec.c
@@ -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;
diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index 1b67ee6bc2..d9d45a52d6 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -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
diff --git a/libavformat/internal.h b/libavformat/internal.h
index 9ef9d64051..0d8bbe7d96 100644
--- a/libavformat/internal.h
+++ b/libavformat/internal.h
@@ -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 */
diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
index 8ee3698ac4..3f48a72c8e 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -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;
}
diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
index b7814e59c9..5668f546f6 100644
--- a/libavformat/mpegts.c
+++ b/libavformat/mpegts.c
@@ -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);
diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c
index 76a8329766..c0386583bd 100644
--- a/libavformat/mxfdec.c
+++ b/libavformat/mxfdec.c
@@ -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;
}
diff --git a/libavformat/nutdec.c b/libavformat/nutdec.c
index fb5ccf7fa9..8903424b09 100644
--- a/libavformat/nutdec.c
+++ b/libavformat/nutdec.c
@@ -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
diff --git a/libavformat/oggdec.c b/libavformat/oggdec.c
index 7fd50a5590..f7513cffd2 100644
--- a/libavformat/oggdec.c
+++ b/libavformat/oggdec.c
@@ -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;
diff --git a/libavformat/utils.c b/libavformat/utils.c
index 640fa70c3d..637d615d90 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -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);
diff --git a/libavformat/version.h b/libavformat/version.h
index 6041daebd6..99a2017d7a 100644
--- a/libavformat/version.h
+++ b/libavformat/version.h
@@ -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 */