/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // Source: http://svn.mplayerhq.hu/nut/docs/nut.txt?view=markup // //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //--------------------------------------------------------------------------- // Pre-compilation #include "MediaInfo/PreComp.h" #ifdef __BORLANDC__ #pragma hdrstop #endif //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/Setup.h" //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #if defined(MEDIAINFO_NUT_YES) //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/Multiple/File_Nut.h" //--------------------------------------------------------------------------- namespace MediaInfoLib { //*************************************************************************** // Const //*************************************************************************** //--------------------------------------------------------------------------- namespace Elements { const int64u main =0x4E4D7A561F5F04ADLL; const int64u stream =0x4E5311405BF2F9DBLL; const int64u syncpoint =0x4E4BE4ADEECA4569LL; const int64u index =0x4E58DD672F23E64ELL; const int64u info =0x4E49AB68B596BA78LL; } //*************************************************************************** // Buffer //*************************************************************************** //--------------------------------------------------------------------------- void File_Nut::FileHeader_Parse() { //Parsing Element_Begin1("Nut header"); std::string file_id_string; int8u file_id_string_zero; Get_String(24, file_id_string, "file_id_string"); Get_B1 (file_id_string_zero, "file_id_string zero"); Element_End0(); FILLING_BEGIN(); //Integrity if (file_id_string!="nut/multimedia container" || file_id_string_zero) { Reject("Nut"); return; } //Filling Accept("Nut"); Fill(Stream_General, 0, General_Format, "Nut"); FILLING_END(); } //*************************************************************************** // Elements //*************************************************************************** //--------------------------------------------------------------------------- void File_Nut::Header_Parse() { //Parsing int8u N; Peek_B1(N); if (N==0x4E) //'N' { //Header int64u startcode, forward_ptr; Get_B8(startcode, "startcode"); Get_VS(forward_ptr, "forward_ptr"); if (forward_ptr>4096) Skip_B4( "header_checksum"); Header_Fill_Code(startcode, Ztring().From_Number(startcode, 16)); //Quick filling for CC8 with text Header_Fill_Size(Element_Offset+forward_ptr); //4 for cheksum } else { //Frame Header_Fill_Code(0, "Frame"); Header_Fill_Size(File_Size-(File_Offset+Buffer_Offset+Element_Offset)); } } //--------------------------------------------------------------------------- void File_Nut::Data_Parse() { #define ELEMENT_CASE(_NAME) \ case Elements::_NAME : _NAME(); break; //Parsing if (Element_Size < 4) { Skip_XX(Element_Size, "Unknown"); return; } Element_Size-=4; #ifndef __BORLANDC__ switch (Element_Code) #else //__BORLANDC__ switch (Element_Code&0xFFFFFFFF) //Borland does not like int64u for const? #endif //__BORLANDC__ { ELEMENT_CASE(main); ELEMENT_CASE(stream); ELEMENT_CASE(syncpoint); ELEMENT_CASE(index); ELEMENT_CASE(info); default : Skip_XX(Element_Size, "Data"); } Element_Size+=4; if (Element_Offset+4!=Element_Size) Skip_XX(Element_Size - 4 - Element_Offset, "Unknown"); Skip_B4( "cheksum"); } //*************************************************************************** // Elements //*************************************************************************** //--------------------------------------------------------------------------- void File_Nut::main() { Element_Name("main"); //Parsing int64u time_base_count; Skip_VS( "version"); Skip_VS( "stream_count"); Skip_VS( "max_distance"); Get_VS (time_base_count, "time_base_count"); for(int64u i=0; i0) Skip_VS( "tmp_pts"); //TODO: signed if(tmp_fields>1) Skip_VS( "tmp_mul"); if(tmp_fields>2) Skip_VS( "tmp_stream"); if(tmp_fields>3) Get_VS (tmp_size, "tmp_size"); else tmp_size=0; if(tmp_fields>4) Get_VS (tmp_res, "tmp_res"); else tmp_res=0; if(tmp_fields>5) Get_VS(count, "count"); else count=tmp_mul-tmp_size; for(int64u j=6; j