00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include "libavutil/tree.h"
00023 #include "nut.h"
00024
00025 const AVCodecTag ff_nut_subtitle_tags[] = {
00026 { CODEC_ID_TEXT , MKTAG('U', 'T', 'F', '8') },
00027 { CODEC_ID_SSA , MKTAG('S', 'S', 'A', 0 ) },
00028 { CODEC_ID_DVD_SUBTITLE, MKTAG('D', 'V', 'D', 'S') },
00029 { CODEC_ID_DVB_SUBTITLE, MKTAG('D', 'V', 'B', 'S') },
00030 { CODEC_ID_NONE , 0 }
00031 };
00032
00033 void ff_nut_reset_ts(NUTContext *nut, AVRational time_base, int64_t val){
00034 int i;
00035 for(i=0; i<nut->avf->nb_streams; i++){
00036 nut->stream[i].last_pts= av_rescale_rnd(
00037 val,
00038 time_base.num * (int64_t)nut->stream[i].time_base->den,
00039 time_base.den * (int64_t)nut->stream[i].time_base->num,
00040 AV_ROUND_DOWN);
00041 }
00042 }
00043
00044 int64_t ff_lsb2full(StreamContext *stream, int64_t lsb){
00045 int64_t mask = (1<<stream->msb_pts_shift)-1;
00046 int64_t delta= stream->last_pts - mask/2;
00047 return ((lsb - delta)&mask) + delta;
00048 }
00049
00050 int ff_nut_sp_pos_cmp(Syncpoint *a, Syncpoint *b){
00051 return ((a->pos - b->pos) >> 32) - ((b->pos - a->pos) >> 32);
00052 }
00053
00054 int ff_nut_sp_pts_cmp(Syncpoint *a, Syncpoint *b){
00055 return ((a->ts - b->ts) >> 32) - ((b->ts - a->ts) >> 32);
00056 }
00057
00058 void ff_nut_add_sp(NUTContext *nut, int64_t pos, int64_t back_ptr, int64_t ts){
00059 Syncpoint *sp= av_mallocz(sizeof(Syncpoint));
00060 struct AVTreeNode *node= av_mallocz(av_tree_node_size);
00061
00062 sp->pos= pos;
00063 sp->back_ptr= back_ptr;
00064 sp->ts= ts;
00065 av_tree_insert(&nut->syncpoints, sp, ff_nut_sp_pos_cmp, &node);
00066 if(node){
00067 av_free(sp);
00068 av_free(node);
00069 }
00070 }
00071
00072 const Dispositions ff_nut_dispositions[] = {
00073 {"default" , AV_DISPOSITION_DEFAULT},
00074 {"dub" , AV_DISPOSITION_DUB},
00075 {"original" , AV_DISPOSITION_ORIGINAL},
00076 {"comment" , AV_DISPOSITION_COMMENT},
00077 {"lyrics" , AV_DISPOSITION_LYRICS},
00078 {"karaoke" , AV_DISPOSITION_KARAOKE},
00079 {"" , 0}
00080 };
00081