//--------------------------------------------------------------------------- bool File_ScreamTracker3::FileHeader_Begin() { //Element_Size if (Buffer_Size<44) return false; //Must wait for more data if (CC1(Buffer+28)!=0x1A || CC4(Buffer+44)!=0x5343524D) //"SCRM" { Reject("Scream Tracker 3"); return false; } //All should be OK... return true; }
//--------------------------------------------------------------------------- bool File_Dirac::Synchronize() { //Synchronizing while (Buffer_Offset+5<=Buffer_Size && CC4(Buffer+Buffer_Offset)!=0x42424344) //"BBCD" Buffer_Offset++; if (Buffer_Offset+5>Buffer_Size) { //Parsing last bytes if (Buffer_Offset+4==Buffer_Size) { if (CC4(Buffer+Buffer_Offset)!=0x42424344) { Buffer_Offset++; if (CC3(Buffer+Buffer_Offset)!=0x424243) { Buffer_Offset++; if (CC2(Buffer+Buffer_Offset)!=0x4242) { Buffer_Offset++; if (CC1(Buffer+Buffer_Offset)!=0x42) Buffer_Offset++; } } } } return false; } //Synched is OK Synched=true; if (Streams.empty()) { //Count of a Packets Frame_Count=0; //Temp Dirac_base_video_format((int32u)-1, frame_width, frame_height, chroma_format, source_sampling, clean_width, clean_height, clean_left_offset, clean_top_offset, frame_rate, pixel_aspect_ratio); //Default stream values Streams.resize(0x100); Streams[0x00].Searching_Payload=true; //Sequence header } return true; }
//--------------------------------------------------------------------------- bool File_Mpc::FileHeader_Begin() { //Tags if (!File__Tags_Helper::FileHeader_Begin()) return false; if (Buffer_Offset+4>Buffer_Size) return false; //Test if (CC3(Buffer)!=0x4D502B || (CC1(Buffer+3)&0x0F)!=7) //"MP+" version 7 { File__Tags_Helper::Reject("Musepack SV7"); return false; } return true; }
//--------------------------------------------------------------------------- bool File_Dirac::Header_Parser_QuickSearch() { while ( Buffer_Offset+13<=Buffer_Size && CC4(Buffer+Buffer_Offset)==0x42424344) //"BBCD" { //Getting start_code int8u start_code=CC1(Buffer+Buffer_Offset+4); //Searching start if (Streams[start_code].Searching_Payload) return true; //Getting size Buffer_Offset+=BigEndian2int32u(Buffer+Buffer_Offset+5); } if (Buffer_Offset+13<=Buffer_Size) Trusted_IsNot("Dirac, Synchronisation lost"); Synched=false; return Synchronize(); }
//--------------------------------------------------------------------------- bool File_Dirac::Synchronize() { //Synchronizing while (Buffer_Offset+5<=Buffer_Size && CC4(Buffer+Buffer_Offset)!=0x42424344) //"BBCD" Buffer_Offset++; //Parsing last bytes if needed if (Buffer_Offset+5>Buffer_Size) { if (Buffer_Offset+4==Buffer_Size && CC4(Buffer+Buffer_Offset)!=0x42424344) //"BBCD" Buffer_Offset++; if (Buffer_Offset+3==Buffer_Size && CC3(Buffer+Buffer_Offset)!=0x424243) //"BBC" Buffer_Offset++; if (Buffer_Offset+2==Buffer_Size && CC2(Buffer+Buffer_Offset)!=0x4242) //"BB" Buffer_Offset++; if (Buffer_Offset+1==Buffer_Size && CC1(Buffer+Buffer_Offset)!=0x42) //"B" Buffer_Offset++; return false; } //Synched is OK return true; }
//--------------------------------------------------------------------------- bool File_Wvpk::Synchronize() { //Specific case if (FromMKV) return true; //Tags bool Tag_Found; if (!File__Tags_Helper::Synchronize(Tag_Found)) return false; if (Tag_Found) return true; //Synchronizing while (Buffer_Offset+8<=Buffer_Size) { while (Buffer_Offset+8<=Buffer_Size && CC4(Buffer+Buffer_Offset)!=CC4("wvpk")) { Buffer_Offset++; } if (Buffer_Offset+8<=Buffer_Size)//Testing if size is coherant { //Testing next start, to be sure size_t Size=LittleEndian2int32u(Buffer+Buffer_Offset+4)+8; if (1)//File_Offset+Buffer_Offset+Size!=File_Size-File_EndTagSize) { if (Buffer_Offset+Size+8>Buffer_Size) return false; //Need more data //Testing if (CC4(Buffer+Buffer_Offset+Size)!=CC4("wvpk")) Buffer_Offset++; else break; //while() } else Buffer_Offset++; } } //Parsing last bytes if needed if (Buffer_Offset+8>Buffer_Size) { if (Buffer_Offset+7==Buffer_Size && CC4(Buffer+Buffer_Offset)!=0x7776706B) //"wvpk" Buffer_Offset++; if (Buffer_Offset+6==Buffer_Size && CC4(Buffer+Buffer_Offset)!=0x7776706B) //"wvpk" Buffer_Offset++; if (Buffer_Offset+5==Buffer_Size && CC4(Buffer+Buffer_Offset)!=0x7776706B) //"wvpk" Buffer_Offset++; if (Buffer_Offset+4==Buffer_Size && CC4(Buffer+Buffer_Offset)!=0x7776706B) //"wvpk" Buffer_Offset++; if (Buffer_Offset+3==Buffer_Size && CC3(Buffer+Buffer_Offset)!=0x777670) //"wv" Buffer_Offset++; if (Buffer_Offset+2==Buffer_Size && CC2(Buffer+Buffer_Offset)!=0x7776) //"wv" Buffer_Offset++; if (Buffer_Offset+1==Buffer_Size && CC1(Buffer+Buffer_Offset)!=0x77) //"w" Buffer_Offset++; return false; } //Synched is OK return true; }
//--------------------------------------------------------------------------- bool File_Dts::Synchronize() { //Synchronizing while (Buffer_Offset+6<=Buffer_Size && !(BigEndian2int16u (Buffer+Buffer_Offset+0)==0x7FFE && BigEndian2int16u (Buffer+Buffer_Offset+2)==0x8001) //16 bits and big endian bitstream && !(LittleEndian2int16u(Buffer+Buffer_Offset+0)==0x7FFE && LittleEndian2int16u(Buffer+Buffer_Offset+2)==0x8001) //16 bits and little endian bitstream && !(BigEndian2int16u (Buffer+Buffer_Offset+0)==0x1FFF && BigEndian2int16u (Buffer+Buffer_Offset+2)==0xE800 && (BigEndian2int16u (Buffer+Buffer_Offset+4)&0xFFF0)==0x07F0) //14 bits and big endian bitstream && !(LittleEndian2int16u(Buffer+Buffer_Offset+0)==0x1FFF && LittleEndian2int16u(Buffer+Buffer_Offset+2)==0xE800 && (LittleEndian2int16u(Buffer+Buffer_Offset+4)&0xFFF0)==0x07F0) //14 bits and little endian bitstream ) Buffer_Offset++; if (Buffer_Offset+6>Buffer_Size) { //Parsing last bytes if (Buffer_Offset+6==Buffer_Size) { if (CC4(Buffer+Buffer_Offset)!=0x7FFE8001) //For 6 bytes instead of 4 (14 bits) { Buffer_Offset++; if (CC4(Buffer+Buffer_Offset)!=0x7FFE8001) //For 6 bytes instead of 4 (14 bits) { Buffer_Offset++; if (CC4(Buffer+Buffer_Offset)!=0x7FFE8001) { Buffer_Offset++; if (CC3(Buffer+Buffer_Offset)!=0x7FFE80) { Buffer_Offset++; if (CC2(Buffer+Buffer_Offset)!=0x7FFE) { Buffer_Offset++; if (CC1(Buffer+Buffer_Offset)!=0x7F) Buffer_Offset++; } } } } } } //Delay if (Frame_Count==0) Delay+=Buffer_Offset; return false; } //Configuring and Delay if (Frame_Count==0) { if (0) ; else if (BigEndian2int16u (Buffer+Buffer_Offset)==0x7FFE) //16 bits and big endian bitstream { } else if (LittleEndian2int16u(Buffer+Buffer_Offset)==0x7FFE) //16 bits and little endian bitstream { BigEndian=false; } else if (BigEndian2int16u (Buffer+Buffer_Offset)==0x1FFF) //14 bits and big endian bitstream { Word=false; } else if (LittleEndian2int16u(Buffer+Buffer_Offset)==0x1FFF) //14 bits and little endian bitstream { Word=false; BigEndian=false; } SyncCode=CC4(Buffer+Buffer_Offset); //14-bits and Little endian are not yet supported if (!Word || !BigEndian) { Finnished(); return false; } //Delay Delay+=Buffer_Offset; } //Synched is OK Synched=true; return true; }