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