00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include "libavutil/mathematics.h"
00023 #include "libavutil/tree.h"
00024 #include "nut.h"
00025 #include "internal.h"
00026
00027 const AVCodecTag ff_nut_subtitle_tags[] = {
00028 { CODEC_ID_TEXT , MKTAG('U', 'T', 'F', '8') },
00029 { CODEC_ID_SSA , MKTAG('S', 'S', 'A', 0 ) },
00030 { CODEC_ID_DVD_SUBTITLE, MKTAG('D', 'V', 'D', 'S') },
00031 { CODEC_ID_DVB_SUBTITLE, MKTAG('D', 'V', 'B', 'S') },
00032 { CODEC_ID_NONE , 0 }
00033 };
00034
00035 const AVCodecTag ff_nut_video_tags[] = {
00036 { CODEC_ID_RAWVIDEO, MKTAG('R', 'G', 'B', 15 ) },
00037 { CODEC_ID_RAWVIDEO, MKTAG('B', 'G', 'R', 15 ) },
00038 { CODEC_ID_RAWVIDEO, MKTAG('R', 'G', 'B', 16 ) },
00039 { CODEC_ID_RAWVIDEO, MKTAG('B', 'G', 'R', 16 ) },
00040 { CODEC_ID_RAWVIDEO, MKTAG(15 , 'B', 'G', 'R') },
00041 { CODEC_ID_RAWVIDEO, MKTAG(15 , 'R', 'G', 'B') },
00042 { CODEC_ID_RAWVIDEO, MKTAG(16 , 'B', 'G', 'R') },
00043 { CODEC_ID_RAWVIDEO, MKTAG(16 , 'R', 'G', 'B') },
00044 { CODEC_ID_RAWVIDEO, MKTAG('R', 'G', 'B', 12 ) },
00045 { CODEC_ID_RAWVIDEO, MKTAG('B', 'G', 'R', 12 ) },
00046 { CODEC_ID_RAWVIDEO, MKTAG(12 , 'B', 'G', 'R') },
00047 { CODEC_ID_RAWVIDEO, MKTAG(12 , 'R', 'G', 'B') },
00048 { CODEC_ID_RAWVIDEO, MKTAG('R', 'G', 'B', 'A') },
00049 { CODEC_ID_RAWVIDEO, MKTAG('R', 'G', 'B', 0 ) },
00050 { CODEC_ID_RAWVIDEO, MKTAG('B', 'G', 'R', 'A') },
00051 { CODEC_ID_RAWVIDEO, MKTAG('B', 'G', 'R', 0 ) },
00052 { CODEC_ID_RAWVIDEO, MKTAG('A', 'B', 'G', 'R') },
00053 { CODEC_ID_RAWVIDEO, MKTAG( 0 , 'B', 'G', 'R') },
00054 { CODEC_ID_RAWVIDEO, MKTAG('A', 'R', 'G', 'B') },
00055 { CODEC_ID_RAWVIDEO, MKTAG( 0 , 'R', 'G', 'B') },
00056 { CODEC_ID_RAWVIDEO, MKTAG('R', 'G', 'B', 24 ) },
00057 { CODEC_ID_RAWVIDEO, MKTAG('B', 'G', 'R', 24 ) },
00058 { CODEC_ID_RAWVIDEO, MKTAG('4', '1', '1', 'P') },
00059 { CODEC_ID_RAWVIDEO, MKTAG('4', '2', '2', 'P') },
00060 { CODEC_ID_RAWVIDEO, MKTAG('4', '2', '2', 'P') },
00061 { CODEC_ID_RAWVIDEO, MKTAG('4', '4', '0', 'P') },
00062 { CODEC_ID_RAWVIDEO, MKTAG('4', '4', '0', 'P') },
00063 { CODEC_ID_RAWVIDEO, MKTAG('4', '4', '4', 'P') },
00064 { CODEC_ID_RAWVIDEO, MKTAG('4', '4', '4', 'P') },
00065 { CODEC_ID_RAWVIDEO, MKTAG('B', '1', 'W', '0') },
00066 { CODEC_ID_RAWVIDEO, MKTAG('B', '0', 'W', '1') },
00067 { CODEC_ID_RAWVIDEO, MKTAG('B', 'G', 'R', 8 ) },
00068 { CODEC_ID_RAWVIDEO, MKTAG('R', 'G', 'B', 8 ) },
00069 { CODEC_ID_RAWVIDEO, MKTAG('B', 'G', 'R', 4 ) },
00070 { CODEC_ID_RAWVIDEO, MKTAG('R', 'G', 'B', 4 ) },
00071 { CODEC_ID_RAWVIDEO, MKTAG('B', '4', 'B', 'Y') },
00072 { CODEC_ID_RAWVIDEO, MKTAG('R', '4', 'B', 'Y') },
00073 { CODEC_ID_RAWVIDEO, MKTAG('B', 'G', 'R', 48 ) },
00074 { CODEC_ID_RAWVIDEO, MKTAG('R', 'G', 'B', 48 ) },
00075 { CODEC_ID_RAWVIDEO, MKTAG(48 , 'B', 'G', 'R') },
00076 { CODEC_ID_RAWVIDEO, MKTAG(48 , 'R', 'G', 'B') },
00077 { CODEC_ID_RAWVIDEO, MKTAG('B', 'R', 'A', 64 ) },
00078 { CODEC_ID_RAWVIDEO, MKTAG('R', 'B', 'A', 64 ) },
00079 { CODEC_ID_RAWVIDEO, MKTAG(64 , 'B', 'R', 'A') },
00080 { CODEC_ID_RAWVIDEO, MKTAG(64 , 'R', 'B', 'A') },
00081 { CODEC_ID_RAWVIDEO, MKTAG('Y', '3', 11 , 10 ) },
00082 { CODEC_ID_RAWVIDEO, MKTAG(10 , 11 , '3', 'Y') },
00083 { CODEC_ID_RAWVIDEO, MKTAG('Y', '3', 10 , 10 ) },
00084 { CODEC_ID_RAWVIDEO, MKTAG(10 , 10 , '3', 'Y') },
00085 { CODEC_ID_RAWVIDEO, MKTAG('Y', '3', 0 , 10 ) },
00086 { CODEC_ID_RAWVIDEO, MKTAG(10 , 0 , '3', 'Y') },
00087 { CODEC_ID_RAWVIDEO, MKTAG('Y', '1', 0 , 16 ) },
00088 { CODEC_ID_RAWVIDEO, MKTAG(16 , 0 , '1', 'Y') },
00089 { CODEC_ID_RAWVIDEO, MKTAG('Y', '3', 11 , 16 ) },
00090 { CODEC_ID_RAWVIDEO, MKTAG(16 , 11 , '3', 'Y') },
00091 { CODEC_ID_RAWVIDEO, MKTAG('Y', '3', 10 , 16 ) },
00092 { CODEC_ID_RAWVIDEO, MKTAG(16 , 10 , '3', 'Y') },
00093 { CODEC_ID_RAWVIDEO, MKTAG('Y', '3', 0 , 16 ) },
00094 { CODEC_ID_RAWVIDEO, MKTAG(16 , 0 , '3', 'Y') },
00095 { CODEC_ID_RAWVIDEO, MKTAG('Y', '4', 11 , 8 ) },
00096 { CODEC_ID_RAWVIDEO, MKTAG('Y', '4', 10 , 8 ) },
00097 { CODEC_ID_RAWVIDEO, MKTAG('Y', '4', 0 , 8 ) },
00098 { CODEC_ID_RAWVIDEO, MKTAG('Y', '2', 0 , 8 ) },
00099 { CODEC_ID_NONE , 0 }
00100 };
00101
00102 void ff_nut_reset_ts(NUTContext *nut, AVRational time_base, int64_t val){
00103 int i;
00104 for(i=0; i<nut->avf->nb_streams; i++){
00105 nut->stream[i].last_pts= av_rescale_rnd(
00106 val,
00107 time_base.num * (int64_t)nut->stream[i].time_base->den,
00108 time_base.den * (int64_t)nut->stream[i].time_base->num,
00109 AV_ROUND_DOWN);
00110 }
00111 }
00112
00113 int64_t ff_lsb2full(StreamContext *stream, int64_t lsb){
00114 int64_t mask = (1<<stream->msb_pts_shift)-1;
00115 int64_t delta= stream->last_pts - mask/2;
00116 return ((lsb - delta)&mask) + delta;
00117 }
00118
00119 int ff_nut_sp_pos_cmp(const Syncpoint *a, const Syncpoint *b){
00120 return ((a->pos - b->pos) >> 32) - ((b->pos - a->pos) >> 32);
00121 }
00122
00123 int ff_nut_sp_pts_cmp(const Syncpoint *a, const Syncpoint *b){
00124 return ((a->ts - b->ts) >> 32) - ((b->ts - a->ts) >> 32);
00125 }
00126
00127 void ff_nut_add_sp(NUTContext *nut, int64_t pos, int64_t back_ptr, int64_t ts){
00128 Syncpoint *sp= av_mallocz(sizeof(Syncpoint));
00129 struct AVTreeNode *node= av_mallocz(av_tree_node_size);
00130
00131 sp->pos= pos;
00132 sp->back_ptr= back_ptr;
00133 sp->ts= ts;
00134 av_tree_insert(&nut->syncpoints, sp, (void *) ff_nut_sp_pos_cmp, &node);
00135 if(node){
00136 av_free(sp);
00137 av_free(node);
00138 }
00139 }
00140
00141 static int enu_free(void *opaque, void *elem)
00142 {
00143 av_free(elem);
00144 return 0;
00145 }
00146
00147 void ff_nut_free_sp(NUTContext *nut)
00148 {
00149 av_tree_enumerate(nut->syncpoints, NULL, NULL, enu_free);
00150 av_tree_destroy(nut->syncpoints);
00151 }
00152
00153 const Dispositions ff_nut_dispositions[] = {
00154 {"default" , AV_DISPOSITION_DEFAULT},
00155 {"dub" , AV_DISPOSITION_DUB},
00156 {"original" , AV_DISPOSITION_ORIGINAL},
00157 {"comment" , AV_DISPOSITION_COMMENT},
00158 {"lyrics" , AV_DISPOSITION_LYRICS},
00159 {"karaoke" , AV_DISPOSITION_KARAOKE},
00160 {"" , 0}
00161 };
00162
00163 const AVMetadataConv ff_nut_metadata_conv[] = {
00164 { "Author", "artist" },
00165 { "X-CreationTime", "date" },
00166 { "CreationTime", "date" },
00167 { "SourceFilename", "filename" },
00168 { "X-Language", "language" },
00169 { "X-Disposition", "disposition" },
00170 { "X-Replaces", "replaces" },
00171 { "X-Depends", "depends" },
00172 { "X-Uses", "uses" },
00173 { "X-UsesFont", "usesfont" },
00174 { 0 },
00175 };