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