00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef AVFORMAT_NUT_H
00023 #define AVFORMAT_NUT_H
00024
00025
00026
00027
00028 #include "avformat.h"
00029 #include "riff.h"
00030 #include "metadata.h"
00031
00032 #define MAIN_STARTCODE (0x7A561F5F04ADULL + (((uint64_t)('N'<<8) + 'M')<<48))
00033 #define STREAM_STARTCODE (0x11405BF2F9DBULL + (((uint64_t)('N'<<8) + 'S')<<48))
00034 #define SYNCPOINT_STARTCODE (0xE4ADEECA4569ULL + (((uint64_t)('N'<<8) + 'K')<<48))
00035 #define INDEX_STARTCODE (0xDD672F23E64EULL + (((uint64_t)('N'<<8) + 'X')<<48))
00036 #define INFO_STARTCODE (0xAB68B596BA78ULL + (((uint64_t)('N'<<8) + 'I')<<48))
00037
00038 #define ID_STRING "nut/multimedia container\0"
00039
00040 #define MAX_DISTANCE (1024*32-1)
00041
00042 typedef enum{
00043 FLAG_KEY = 1,
00044 FLAG_EOR = 2,
00045 FLAG_CODED_PTS = 8,
00046 FLAG_STREAM_ID = 16,
00047 FLAG_SIZE_MSB = 32,
00048 FLAG_CHECKSUM = 64,
00049 FLAG_RESERVED = 128,
00050 FLAG_HEADER_IDX =1024,
00051 FLAG_MATCH_TIME =2048,
00052 FLAG_CODED =4096,
00053 FLAG_INVALID =8192,
00054 } Flag;
00055
00056 typedef struct {
00057 uint64_t pos;
00058 uint64_t back_ptr;
00059
00060 int64_t ts;
00061 } Syncpoint;
00062
00063 typedef struct {
00064 uint16_t flags;
00065 uint8_t stream_id;
00066 uint16_t size_mul;
00067 uint16_t size_lsb;
00068 int16_t pts_delta;
00069 uint8_t reserved_count;
00070 uint8_t header_idx;
00071 } FrameCode;
00072
00073 typedef struct {
00074 int last_flags;
00075 int skip_until_key_frame;
00076 int64_t last_pts;
00077 int time_base_id;
00078 AVRational *time_base;
00079 int msb_pts_shift;
00080 int max_pts_distance;
00081 int decode_delay;
00082 } StreamContext;
00083
00084 typedef struct {
00085 AVRational *time_base;
00086 } ChapterContext;
00087
00088 typedef struct {
00089 AVFormatContext *avf;
00090
00091
00092 FrameCode frame_code[256];
00093 uint8_t header_len[128];
00094 const uint8_t *header[128];
00095 uint64_t next_startcode;
00096 StreamContext *stream;
00097 ChapterContext *chapter;
00098 unsigned int max_distance;
00099 unsigned int time_base_count;
00100 int64_t last_syncpoint_pos;
00101 int header_count;
00102 AVRational *time_base;
00103 struct AVTreeNode *syncpoints;
00104 } NUTContext;
00105
00106 extern const AVCodecTag ff_nut_subtitle_tags[];
00107 extern const AVCodecTag ff_nut_video_tags[];
00108
00109 typedef struct {
00110 char str[9];
00111 int flag;
00112 } Dispositions;
00113
00114 void ff_nut_reset_ts(NUTContext *nut, AVRational time_base, int64_t val);
00115 int64_t ff_lsb2full(StreamContext *stream, int64_t lsb);
00116 int ff_nut_sp_pos_cmp(const Syncpoint *a, const Syncpoint *b);
00117 int ff_nut_sp_pts_cmp(const Syncpoint *a, const Syncpoint *b);
00118 void ff_nut_add_sp(NUTContext *nut, int64_t pos, int64_t back_ptr, int64_t ts);
00119 void ff_nut_free_sp(NUTContext *nut);
00120
00121 extern const Dispositions ff_nut_dispositions[];
00122
00123 extern const AVMetadataConv ff_nut_metadata_conv[];
00124
00125 #endif