//--------------------------------------------------------------------------- bool File_Dirac::Header_Parser_QuickSearch() { while ( Buffer_Offset+5<=Buffer_Size && Buffer[Buffer_Offset ]==0x42 && Buffer[Buffer_Offset+1]==0x42 && Buffer[Buffer_Offset+2]==0x43 && Buffer[Buffer_Offset+3]==0x44) //"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+4==Buffer_Size) return false; //Sync is OK, but start_code is not available if (Buffer_Offset+5<=Buffer_Size) Trusted_IsNot("Dirac, Synchronisation lost"); Synched=false; return Synchronize(); }
//--------------------------------------------------------------------------- void File_Vc3::Header_Parse() { int32u CompressionID=BigEndian2int32u(Buffer+Buffer_Offset+0x28); Header_Fill_Code(0, "Frame"); Header_Fill_Size(Vc3_CompressedFrameSize(CompressionID)); }
//--------------------------------------------------------------------------- void File_Dpx::Header_Parse() { //Filling Header_Fill_Code(Sizes_Pos); //We use Sizes_Pos as the unique key if (Sizes.empty()) { if (Element_Size<28) { Element_WaitForMoreData(); return; } int32u Size=LittleEndian?LittleEndian2int32u(Buffer+Buffer_Offset+24):BigEndian2int32u(Buffer+Buffer_Offset+24); if (Size==(int32u)-1) Size=LittleEndian?LittleEndian2int32u(Buffer+Buffer_Offset+4):BigEndian2int32u(Buffer+Buffer_Offset+4); Header_Fill_Size(Size); } else Header_Fill_Size(Sizes[Sizes_Pos]); }
//--------------------------------------------------------------------------- void Riff_AVI__idx1::Read_Internal () { if (Global->AVI__idx1_Pointer) throw exception_read_chunk("2 idx1 chunks, not supported"); Global->AVI__idx1_Pointer=this; //Reading Read_Internal_ReadAllInBuffer(); if (Chunk.Content.Size<16) return; if (Global->AVI__movi_FirstDataChunkSize==(int64u)-1) throw exception_read_chunk("idx1 is before movi chunk, or movi chunk has no frame, not supported"); //Parsing for (Chunk.Content.Buffer_Offset=0; Chunk.Content.Buffer_Offset+16<=Chunk.Content.Size; Chunk.Content.Buffer_Offset+=16) { int32u ChunkId=BigEndian2int32u(Chunk.Content.Buffer+Chunk.Content.Buffer_Offset); bool IsOk; switch (ChunkId&0x0000FFFF) { case Elements::AVI__movi___db : case Elements::AVI__movi___dc : case Elements::AVI__movi___pc : case Elements::AVI__movi___wb : IsOk=true; break; default : IsOk=false; } if (IsOk) break; } if (Chunk.Content.Buffer_Offset+16>Chunk.Content.Size) throw exception_read_chunk("index data has no frame reference?"); int32u Offset=LittleEndian2int32u(Chunk.Content.Buffer+Chunk.Content.Buffer_Offset+8); int32u Size=LittleEndian2int32u(Chunk.Content.Buffer+Chunk.Content.Buffer_Offset+12); if (Size!=Global->AVI__movi_FirstDataChunkSize) throw exception_read_chunk("index data (size) not coherent"); int64u movi_Position=(int64u)-1; for (std::set<void*>::iterator movi=Global->AVI__movi_Pointers.begin(); movi!=Global->AVI__movi_Pointers.end(); movi++) { if (((Riff_AVI__movi*)(*movi))->Chunk.File_In_Position<movi_Position) movi_Position=((Riff_AVI__movi*)(*movi))->Chunk.File_In_Position; } if (Offset==4+Global->AVI__movi_FirstDataChunkMoviOffset) Global->AVI__idx1_IsAbsolute=false; else if (Offset==Global->AVI__movi_FirstDataChunkPosition) Global->AVI__idx1_IsAbsolute=true; else throw exception_read_chunk("index data (position) is not coherent"); }
bool File_Vc3::Demux_UnpacketizeContainer_Test() { if (Buffer_Offset+0x2C>Buffer_Size) return false; int32u CompressionID=BigEndian2int32u(Buffer+Buffer_Offset+0x28); int32u Size=Vc3_CompressedFrameSize(CompressionID); Demux_Offset=Buffer_Offset+Size; if (Demux_Offset>Buffer_Size && File_Offset+Buffer_Size!=File_Size) return false; //No complete frame Demux_UnpacketizeContainer_Demux(); 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(); }
//--------------------------------------------------------------------------- // Big Endian - float 32 bits float32 BigEndian2float32(const char* Liste) { //sign 1 bit //exponent 8 bit //significand 23 bit //Retrieving data int32u Integer=BigEndian2int32u(Liste); //Retrieving elements bool Sign =(Integer&0x80000000)?true:false; int32u Exponent=(Integer>>23)&0xFF; int32u Mantissa= Integer&0x007FFFFF; //Some computing if (Exponent==0 || Exponent==0xFF) return 0; //These are denormalised numbers, NANs, and other horrible things Exponent-=0x7F; //Bias float64 Answer=(((float64)Mantissa)/8388608+1.0)*std::pow((float64)2, (int)Exponent); //(1+Mantissa) * 2^Exponent if (Sign) Answer=-Answer; return (float32)Answer; }
//--------------------------------------------------------------------------- void File_Tiff::GetValueOffsetu(ifditem &IfdItem) { ZtringList &Info=Infos[IfdItem.Tag]; Info.clear(); Info.Separator_Set(0, __T(" / ")); const char* Name=Tiff_Tag_Name(IfdItem.Tag); if (IfdItem.Count>=10) { //Too many data, we don't currently need it and we skip it Skip_XX(Element_Size-(Element_Offset+4), Name); Info.clear(); return; } switch (IfdItem.Type) { case 1: /* 8-bit unsigned integer. */ for (int16u Pos=0; Pos<IfdItem.Count; Pos++) { int8u Ret8; #if MEDIAINFO_TRACE if (LittleEndian) Get_L1 (Ret8, Name); else Get_B1 (Ret8, Name); Element_Info1(Ztring::ToZtring(Ret8)); #else //MEDIAINFO_TRACE if (Element_Offset+1>Element_Size) { Trusted_IsNot(); break; } if (LittleEndian) Ret8=LittleEndian2int8u(Buffer+Buffer_Offset+(size_t)Element_Offset); else Ret8=BigEndian2int8u(Buffer+Buffer_Offset+(size_t)Element_Offset); Element_Offset++; #endif //MEDIAINFO_TRACE Info.push_back(Ztring::ToZtring(Ret8)); } break; case 3: /* 16-bit (2-byte) unsigned integer. */ for (int16u Pos=0; Pos<IfdItem.Count; Pos++) { int16u Ret16; #if MEDIAINFO_TRACE if (LittleEndian) Get_L2 (Ret16, Name); else Get_B2 (Ret16, Name); switch (IfdItem.Tag) { case Tiff_Tag::Compression : Element_Info1(Tiff_Compression(Ret16)); break; case Tiff_Tag::PhotometricInterpretation : Element_Info1(Tiff_PhotometricInterpretation(Ret16)); break; default : Element_Info1(Ztring::ToZtring(Ret16)); } #else //MEDIAINFO_TRACE if (Element_Offset+2>Element_Size) { Trusted_IsNot(); break; } if (LittleEndian) Ret16=LittleEndian2int16u(Buffer+Buffer_Offset+(size_t)Element_Offset); else Ret16=BigEndian2int16u(Buffer+Buffer_Offset+(size_t)Element_Offset); Element_Offset+=2; #endif //MEDIAINFO_TRACE Info.push_back(Ztring::ToZtring(Ret16)); } break; case 4: /* 32-bit (4-byte) unsigned integer */ for (int16u Pos=0; Pos<IfdItem.Count; Pos++) { int32u Ret32; #if MEDIAINFO_TRACE if (LittleEndian) Get_L4 (Ret32, Name); else Get_B4 (Ret32, Name); Element_Info1(Ztring::ToZtring(Ret32)); #else //MEDIAINFO_TRACE if (Element_Offset+4>Element_Size) { Trusted_IsNot(); break; } if (LittleEndian) Ret32=LittleEndian2int32u(Buffer+Buffer_Offset+(size_t)Element_Offset); else Ret32=BigEndian2int32u(Buffer+Buffer_Offset+(size_t)Element_Offset); Element_Offset+=4; #endif //MEDIAINFO_TRACE Info.push_back(Ztring::ToZtring(Ret32)); } break; default: //Unknown { if (LittleEndian) Skip_L4( Name); else Skip_B4( Name); Info.clear(); //We actually do not know the type } } }