aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2007-08-09 23:24:02 +0000
committerMichael Niedermayer <michaelni@gmx.at>2007-08-09 23:24:02 +0000
commit4a3b5fe16afdce332eb0a78375da3591c4d5acb3 (patch)
tree18f2341b7cc959b890787c1e45e7552c9b9755c3
parent073811cdd29e365498b3455ee4e0eda4b957a957 (diff)
downloadffmpeg-4a3b5fe16afdce332eb0a78375da3591c4d5acb3.tar.gz
move syncpoint cache related stuff to common file
Originally committed as revision 10038 to svn://svn.ffmpeg.org/ffmpeg/trunk
-rw-r--r--libavformat/nut.c18
-rw-r--r--libavformat/nut.h3
-rw-r--r--libavformat/nutdec.c27
3 files changed, 25 insertions, 23 deletions
diff --git a/libavformat/nut.c b/libavformat/nut.c
index 91509afbd8..4b41a05f33 100644
--- a/libavformat/nut.c
+++ b/libavformat/nut.c
@@ -42,3 +42,21 @@ int64_t ff_lsb2full(StreamContext *stream, int64_t lsb){
return ((lsb - delta)&mask) + delta;
}
+int ff_nut_sp_pos_cmp(syncpoint_t *a, syncpoint_t *b){
+ return (a->pos - b->pos>>32) - (b->pos - a->pos>>32);
+}
+
+int ff_nut_sp_pts_cmp(syncpoint_t *a, syncpoint_t *b){
+ return (a->ts - b->ts>>32) - (b->ts - a->ts>>32);
+}
+
+void ff_nut_add_sp(NUTContext *nut, int64_t pos, int64_t back_ptr, int64_t ts){
+ syncpoint_t *sp2, *sp= av_mallocz(sizeof(syncpoint_t));
+
+ sp->pos= pos;
+ sp->back_ptr= back_ptr;
+ sp->ts= ts;
+ sp2= av_tree_insert(&nut->syncpoints, sp, ff_nut_sp_pos_cmp);
+ if(sp2 && sp2 != sp)
+ av_free(sp);
+}
diff --git a/libavformat/nut.h b/libavformat/nut.h
index 3c518acd4e..0816d4640d 100644
--- a/libavformat/nut.h
+++ b/libavformat/nut.h
@@ -95,5 +95,8 @@ typedef struct {
unsigned long av_crc04C11DB7_update(unsigned long checksum, const uint8_t *buf, unsigned int len);
void ff_nut_reset_ts(NUTContext *nut, AVRational time_base, int64_t val);
int64_t ff_lsb2full(StreamContext *stream, int64_t lsb);
+int ff_nut_sp_pos_cmp(syncpoint_t *a, syncpoint_t *b);
+int ff_nut_sp_pts_cmp(syncpoint_t *a, syncpoint_t *b);
+void ff_nut_add_sp(NUTContext *nut, int64_t pos, int64_t back_ptr, int64_t ts);
#endif /* AVFORMAT_NUT_H */
diff --git a/libavformat/nutdec.c b/libavformat/nutdec.c
index e6d9ced2fd..fa20503ef2 100644
--- a/libavformat/nutdec.c
+++ b/libavformat/nutdec.c
@@ -421,25 +421,6 @@ static int decode_info_header(NUTContext *nut){
return 0;
}
-static int sp_pos_cmp(syncpoint_t *a, syncpoint_t *b){
- return (a->pos - b->pos>>32) - (b->pos - a->pos>>32);
-}
-
-static int sp_pts_cmp(syncpoint_t *a, syncpoint_t *b){
- return (a->ts - b->ts>>32) - (b->ts - a->ts>>32);
-}
-
-static void add_sp(NUTContext *nut, int64_t pos, int64_t back_ptr, int64_t ts){
- syncpoint_t *sp2, *sp= av_mallocz(sizeof(syncpoint_t));
-
- sp->pos= pos;
- sp->back_ptr= back_ptr;
- sp->ts= ts;
- sp2= av_tree_insert(&nut->syncpoints, sp, sp_pos_cmp);
- if(sp2 && sp2 != sp)
- av_free(sp);
-}
-
static int decode_syncpoint(NUTContext *nut, int64_t *ts, int64_t *back_ptr){
AVFormatContext *s= nut->avf;
ByteIOContext *bc = &s->pb;
@@ -464,7 +445,7 @@ static int decode_syncpoint(NUTContext *nut, int64_t *ts, int64_t *back_ptr){
}
*ts= tmp / s->nb_streams * av_q2d(nut->time_base[tmp % s->nb_streams])*AV_TIME_BASE;
- add_sp(nut, nut->last_syncpoint_pos, *back_ptr, *ts);
+ ff_nut_add_sp(nut, nut->last_syncpoint_pos, *back_ptr, *ts);
return 0;
}
@@ -812,7 +793,7 @@ static int read_seek(AVFormatContext *s, int stream_index, int64_t pts, int flag
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_tree_find(nut->syncpoints, &dummy, ff_nut_sp_pts_cmp, 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,
@@ -821,7 +802,7 @@ static int read_seek(AVFormatContext *s, int stream_index, int64_t pts, int flag
if(!(flags & AVSEEK_FLAG_BACKWARD)){
dummy.pos= pos+16;
next_node[1]= &nopts_sp;
- av_tree_find(nut->syncpoints, &dummy, sp_pos_cmp, next_node);
+ av_tree_find(nut->syncpoints, &dummy, ff_nut_sp_pos_cmp, 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);
if(pos2>=0)
@@ -829,7 +810,7 @@ static int read_seek(AVFormatContext *s, int stream_index, int64_t pts, int flag
//FIXME dir but i think it does not matter
}
dummy.pos= pos;
- sp= av_tree_find(nut->syncpoints, &dummy, sp_pos_cmp, NULL);
+ sp= av_tree_find(nut->syncpoints, &dummy, ff_nut_sp_pos_cmp, NULL);
assert(sp);
pos2= sp->back_ptr - 15;