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