00001 #pragma once 00002 00003 #include "..\BaseSplitter\BaseSplitter.h" 00004 00005 class CNutFile : public CBaseSplitterFile 00006 { 00007 HRESULT Init(); 00008 00009 public: 00010 00011 #pragma pack(push, 1) 00012 00013 typedef UINT64 vint; 00014 typedef INT64 svint; 00015 typedef CArray<BYTE> binary; 00016 typedef CArray<BYTE> string; 00017 00018 struct packet_header 00019 { 00020 __int64 pos; 00021 vint fptr, bptr; 00022 UINT32 checksum; 00023 }; 00024 00025 struct main_header 00026 { 00027 vint version; 00028 vint stream_count; 00029 }; 00030 00031 struct codec_specific 00032 { 00033 vint type; 00034 binary data; 00035 }; 00036 00037 struct video_stream_header 00038 { 00039 vint width, height; 00040 vint sample_width, sample_height; 00041 vint colorspace_type; 00042 }; 00043 00044 struct audio_stream_header 00045 { 00046 vint samplerate_mul; 00047 vint channel_count; 00048 }; 00049 00050 struct stream_header 00051 { 00052 vint stream_id; 00053 vint stream_class; 00054 string fourcc; 00055 vint average_bitrate; 00056 string language_code; 00057 vint time_base_nom; 00058 vint time_base_denom; 00059 vint msb_timestamp_shift; 00060 vint shuffle_type; 00061 int fixed_fps:1; 00062 int index_flag:1; 00063 int reserved:6; 00064 CAutoPtrList<codec_specific> cs; 00065 union {video_stream_header vsh; audio_stream_header ash;}; 00066 vint msb_timestamp; 00067 }; 00068 00069 struct frame_header 00070 { 00071 BYTE zero_bit:1; 00072 BYTE priority:2; 00073 BYTE checksum_flag:1; 00074 BYTE msb_timestamp_flag:2; 00075 BYTE subpacket_type:2; 00076 BYTE reserved:1; 00077 }; 00078 00079 struct index_entry 00080 { 00081 vint timestamp; 00082 vint position; 00083 }; 00084 00085 struct index_header 00086 { 00087 vint stream_id; 00088 CArray<index_entry> ie; 00089 }; 00090 00091 struct info_header 00092 { 00093 // TODO 00094 vint dummy; 00095 }; 00096 00097 #pragma pack(pop) 00098 00099 #define NUTM 0xF9526A624E55544Dui64 00100 #define NUTS 0xD667773F4E555453ui64 00101 #define NUTK 0xCB8630874E55544Bui64 00102 #define NUTX 0xEBFCDE0E4E555458ui64 00103 #define NUTI 0xA37B64354E555449ui64 00104 00105 enum {SC_VIDEO = 0, SC_AUDIO = 32, SC_SUBTITLE = 64}; 00106 00107 void Read(vint& v); 00108 void Read(svint& sv); 00109 void Read(binary& b); 00110 void Read(packet_header& ph); 00111 void Read(main_header& mh); 00112 void Read(stream_header& sh); 00113 void Read(video_stream_header& vsh); 00114 void Read(audio_stream_header& ash); 00115 void Read(index_header& ih); 00116 void Read(info_header& ih); 00117 00118 public: 00119 00120 CNutFile(IAsyncReader* pAsyncReader, HRESULT& hr); 00121 00122 main_header m_mh; 00123 CAutoPtrList<stream_header> m_streams; 00124 };