Libav
|
00001 /* 00002 * nut 00003 * Copyright (c) 2004-2007 Michael Niedermayer 00004 * 00005 * This file is part of FFmpeg. 00006 * 00007 * FFmpeg is free software; you can redistribute it and/or 00008 * modify it under the terms of the GNU Lesser General Public 00009 * License as published by the Free Software Foundation; either 00010 * version 2.1 of the License, or (at your option) any later version. 00011 * 00012 * FFmpeg is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00015 * Lesser General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU Lesser General Public 00018 * License along with FFmpeg; if not, write to the Free Software 00019 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 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(const Syncpoint *a, const Syncpoint *b){ 00051 return ((a->pos - b->pos) >> 32) - ((b->pos - a->pos) >> 32); 00052 } 00053 00054 int ff_nut_sp_pts_cmp(const Syncpoint *a, const 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, (void *) ff_nut_sp_pos_cmp, &node); 00066 if(node){ 00067 av_free(sp); 00068 av_free(node); 00069 } 00070 } 00071 00072 static int enu_free(void *opaque, void *elem) 00073 { 00074 av_free(elem); 00075 return 0; 00076 } 00077 00078 void ff_nut_free_sp(NUTContext *nut) 00079 { 00080 av_tree_enumerate(nut->syncpoints, NULL, NULL, enu_free); 00081 av_tree_destroy(nut->syncpoints); 00082 } 00083 00084 const Dispositions ff_nut_dispositions[] = { 00085 {"default" , AV_DISPOSITION_DEFAULT}, 00086 {"dub" , AV_DISPOSITION_DUB}, 00087 {"original" , AV_DISPOSITION_ORIGINAL}, 00088 {"comment" , AV_DISPOSITION_COMMENT}, 00089 {"lyrics" , AV_DISPOSITION_LYRICS}, 00090 {"karaoke" , AV_DISPOSITION_KARAOKE}, 00091 {"" , 0} 00092 }; 00093 00094 const AVMetadataConv ff_nut_metadata_conv[] = { 00095 { "Author", "artist" }, 00096 { "X-CreationTime", "date" }, 00097 { "CreationTime", "date" }, 00098 { "SourceFilename", "filename" }, 00099 { "X-Language", "language" }, 00100 { "X-Disposition", "disposition" }, 00101 { "X-Replaces", "replaces" }, 00102 { "X-Depends", "depends" }, 00103 { "X-Uses", "uses" }, 00104 { "X-UsesFont", "usesfont" }, 00105 { 0 }, 00106 };