00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include "nut.h"
00023 #include "tree.h"
00024
00025 void ff_nut_reset_ts(NUTContext *nut, AVRational time_base, int64_t val){
00026 int i;
00027 for(i=0; i<nut->avf->nb_streams; i++){
00028 nut->stream[i].last_pts= av_rescale_rnd(
00029 val,
00030 time_base.num * (int64_t)nut->stream[i].time_base->den,
00031 time_base.den * (int64_t)nut->stream[i].time_base->num,
00032 AV_ROUND_DOWN);
00033 }
00034 }
00035
00036 int64_t ff_lsb2full(StreamContext *stream, int64_t lsb){
00037 int64_t mask = (1<<stream->msb_pts_shift)-1;
00038 int64_t delta= stream->last_pts - mask/2;
00039 return ((lsb - delta)&mask) + delta;
00040 }
00041
00042 int ff_nut_sp_pos_cmp(syncpoint_t *a, syncpoint_t *b){
00043 return ((a->pos - b->pos) >> 32) - ((b->pos - a->pos) >> 32);
00044 }
00045
00046 int ff_nut_sp_pts_cmp(syncpoint_t *a, syncpoint_t *b){
00047 return ((a->ts - b->ts) >> 32) - ((b->ts - a->ts) >> 32);
00048 }
00049
00050 void ff_nut_add_sp(NUTContext *nut, int64_t pos, int64_t back_ptr, int64_t ts){
00051 syncpoint_t *sp= av_mallocz(sizeof(syncpoint_t));
00052 struct AVTreeNode *node= av_mallocz(av_tree_node_size);
00053
00054 sp->pos= pos;
00055 sp->back_ptr= back_ptr;
00056 sp->ts= ts;
00057 av_tree_insert(&nut->syncpoints, sp, ff_nut_sp_pos_cmp, &node);
00058 if(node){
00059 av_free(sp);
00060 av_free(node);
00061 }
00062 }