/* 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. */ //--------------------------------------------------------------------------- // Pre-compilation #include "MediaInfo/PreComp.h" #ifdef __BORLANDC__ #pragma hdrstop #endif //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/Setup.h" //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #if defined(MEDIAINFO_IAB_YES) //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/Audio/File_Iab.h" using namespace std; //--------------------------------------------------------------------------- namespace MediaInfoLib { //*************************************************************************** // Infos //*************************************************************************** //--------------------------------------------------------------------------- const int32u Iab_SampleRate[4]= { 48000, 96000, 0, 0, }; //--------------------------------------------------------------------------- const int8u Iab_BitDepth[4]= { 16, 24, 0, 0, }; //--------------------------------------------------------------------------- const float32 Iab_FrameRate[16]= { 24, 25, 30, 48, 50, 60, 96, 100, 120, 24000.0/1001.0, 0, 0, 0, 0, 0, 0, }; //--------------------------------------------------------------------------- const char* Iab_Channel(int32u Code) { static const char* Iab_Channel_Values[]= { "L", "Lc", "C", "Rc", "R", "Lss", "Ls", "Lb", "Rb", "Rss", "Rs", "Tsl", "Tsr", "LFE", "Left Height", "Right Height", "Center Height", "Left Surround Height", "Right Surround Height", "Left Side Surround Height", "Right Side Surround Height", "Left Rear Surround Height", "Right Rear Surround Height", "Tc", //0x18-0x7F reserved "Tfl", "Tfr", "Tbl", "Tbr", "Tsl", "Tsr", "LFE1", "LFE2", "Lw", "Rw", }; if (Code<0x18) return Iab_Channel_Values[Code]; if (Code>=0x80 && Code=Element_TotalSize_Get(Element_Level-1)) { Frame.Objects=std::move(F.Objects); Frame_Count++; if (!Status[IsFilled] && Frame_Count>=Frame_Count_Valid) Finish(); } } //--------------------------------------------------------------------------- void File_Iab::IAFrame() { //Parsing int32u MaxRendered, SubElementCount; Get_B1 (Version, "Version"); if (Version==1) { BS_Begin(); Get_S1 (2, SampleRate, "SampleRate"); Param_Info2C(Iab_SampleRate[SampleRate], Iab_SampleRate[SampleRate], " Hz"); Get_S1 (2, BitDepth, "BitDepth"); Param_Info2C(Iab_BitDepth[BitDepth], Iab_BitDepth[BitDepth], " bits"); Get_S1 (4, FrameRate, "FrameRate"); Param_Info2C(Iab_FrameRate[FrameRate], Iab_FrameRate[FrameRate], " FPS"); BS_End(); Get_Plex8 (MaxRendered, "MaxRendered"); Get_Plex8 (SubElementCount, "SubElementCount"); Element_ThisIsAList(); Frame.Objects=std::move(F.Objects); } else Skip_XX(Element_Size-Element_Offset, "Unknown"); } //--------------------------------------------------------------------------- void File_Iab::BedDefinition() { F.Objects.resize(F.Objects.size()+1); //Parsing int32u ChannelCount; int8u AudioDescription; bool ConditionalBed; Skip_Plex8( "MetaID"); BS_Begin(); Get_SB (ConditionalBed, "ConditionalBed"); if (ConditionalBed) { Skip_S1(8, "BedUseCase"); } Get_Plex(4, ChannelCount, "ChannelCount"); for (int32u n=0; n1) Skip_S1(10, "ChannelGain"); Get_SB (ChannelDecorInfoExists, "ChannelDecorInfoExists"); if (ChannelDecorInfoExists) { int8u ChannelDecorCoefPrefix; Skip_S2(2, "Reserved"); Get_S1 (2, ChannelDecorCoefPrefix, "ChannelDecorCoefPrefix"); if (ChannelDecorCoefPrefix>1) Skip_S1(10, "ChannelDecorCoef"); } Element_End0(); F.Objects.back().ChannelLayout.push_back(ChannelID); } Skip_S2(10, "0x180"); if (Data_BS_Remain()%8) Skip_S1(Data_BS_Remain()%8, "AlignBits"); BS_End(); Get_B1 (AudioDescription, "AudioDescription"); if (AudioDescription&0x80) { size_t Pos=(size_t)Element_Offset+1; while (Pos1) Skip_S1(10, "ObjectGainPrefix"); Skip_S1( 3, "b001"); Skip_S2(16, "ObjectPosX"); Skip_S2(16, "ObjectPosY"); Skip_S2(16, "ObjectPosZ"); Get_SB (ObjectSnap, "ObjectSnap"); if (ObjectSnap) { bool ObjectSnapTolExists; Get_SB (ObjectSnapTolExists, "ObjectSnapTolExists"); if (ObjectSnapTolExists) { Skip_S2(12, "ObjectSnapTolerance"); } Skip_SB( "0"); } Get_SB (ObjectZoneControl, "ObjectZoneControl"); if (ObjectZoneControl) { for (int n=0; n<9; n++) { int8u ZoneGainPrefix; Get_S1 (2, ZoneGainPrefix, "ZoneGainPrefix"); if (ZoneGainPrefix>1) Skip_S1(10, "ZoneGain"); } } int8u ObjectSpreadMode; Get_S1 (2, ObjectSpreadMode, "ObjectSpreadMode"); switch (ObjectSpreadMode) { case 0: case 2: { Skip_S1( 8, "ObjectSpread"); } break; case 3: { Skip_S2(12, "ObjectSpreadX"); Skip_S2(12, "ObjectSpreadY"); Skip_S2(12, "ObjectSpreadZ"); } break; default: ; } Skip_S1(4, "0"); int8u ObjectDecorCoefPrefix; Get_S1 (2, ObjectDecorCoefPrefix, "ObjectDecorCoefPrefix"); if (ObjectDecorCoefPrefix>1) Skip_S1(8, "ObjectDecorCoefPrefix"); } Element_End0(); } BS_End(); Get_B1 (AudioDescription, "AudioDescription"); if (AudioDescription&0x80) { size_t Pos=(size_t)Element_Offset+1; while (Pos1) Skip_S1(10, "RemapGain"); } } } Element_End0(); } BS_End(); } //--------------------------------------------------------------------------- void File_Iab::AudioDataPCM() { //Parsing Skip_Plex8( "MetaID"); Skip_XX(Element_Size-Element_Offset, "PCMData"); } //*************************************************************************** // Helpers //*************************************************************************** //--------------------------------------------------------------------------- void File_Iab::Get_Plex(int8u Bits, int32u& Info, const char* Name) { for (;;) { Peek_BS(Bits, Info); if (Info!=(1<=32) { Get_BS(Bits, Info, Name); return; } BS->Skip(Bits); Bits<<=1; } } //--------------------------------------------------------------------------- void File_Iab::Get_Plex8(int32u& Info, const char* Name) { //Element size int8u Info8; Peek_B1(Info8); if (Info8!=0xFF) { Get_B1(Info8, Name); Info=Info8; return; } Element_Offset++; int16u Info16; Peek_B2(Info16); if (Info16!=0xFFFF) { Get_B2(Info16, Name); Info=Info16; return; } Element_Offset+=2; Get_B4(Info, Name); } } //NameSpace #endif //MEDIAINFO_IAB_YES