Skip to content

Commit 286d12a

Browse files
DTS Core IMAX detection as Commercial name
1 parent 993216d commit 286d12a

File tree

2 files changed

+161
-3
lines changed

2 files changed

+161
-3
lines changed

Source/MediaInfo/Audio/File_Dts.cpp

Lines changed: 155 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -488,6 +488,7 @@ enum extension
488488
Ext_XCh,
489489
Ext_XBR,
490490
Ext_Aux,
491+
Ext_Rev2Aux,
491492
Ext_Max
492493
};
493494
static int32u DTS_Extension_Mapping[]=
@@ -501,6 +502,7 @@ static int32u DTS_Extension_Mapping[]=
501502
0x5A5A5A5A,
502503
0x655E315E,
503504
0x9A1105A0,
505+
0x7004C070,
504506
};
505507
static_assert(sizeof(DTS_Extension_Mapping)/sizeof(decltype(*DTS_Extension_Mapping))==Ext_Max, "");
506508
static const char* DTS_Extension_Names[]=
@@ -514,6 +516,7 @@ static const char* DTS_Extension_Names[]=
514516
"XCh (6.1 Channels)",
515517
"XBR (Extended Bit Rate)",
516518
"Aux",
519+
"Rev2Aux",
517520
};
518521
static_assert(sizeof(DTS_Extension_Names)/sizeof(decltype(*DTS_Extension_Names))==Ext_Max, "");
519522
static size_t DTS_Extension_Index_Get(int32u SyncWord)
@@ -572,6 +575,8 @@ File_Dts::File_Dts()
572575
ExtendedCoding=false;
573576
ES=false;
574577
Core_Exists=false;
578+
Rev2AuxPresent=false;
579+
Type1CertifiedContent=false;
575580
}
576581

577582
//***************************************************************************
@@ -884,6 +889,10 @@ void File_Dts::Streams_Fill()
884889
if (Data[Profiles].size()==1 && Data[Profiles][0]==__T("Core"))
885890
Data[Profiles].clear(); //Core is the default one
886891

892+
// IMAX in core-only stream
893+
if (Type1CertifiedContent)
894+
Fill(Stream_Audio, 0, Audio_Format_Commercial_IfAny, "DTS with T1-CC (IMAX Enhanced)");
895+
887896
// Filling
888897
bool LegacyStreamDisplay=MediaInfoLib::Config.LegacyStreamDisplay_Get();
889898
Fill(Stream_Audio, 0, Audio_Format_Profile, Data[Profiles].Read());
@@ -1529,7 +1538,6 @@ void File_Dts::Data_Parse()
15291538
Get_SB ( ES, "ES");
15301539
Skip_SB( "Front Sum/Difference");
15311540
Skip_SB( "Surrounds Sum/Difference");
1532-
Skip_S1( 4, "Dialog Normalisation Parameter");
15331541
switch (EncoderSoftwareRevision)
15341542
{
15351543
case 6 :
@@ -1542,7 +1550,50 @@ void File_Dts::Data_Parse()
15421550
Skip_S1( 4, "Unspecified");
15431551
break;
15441552
}
1553+
1554+
Element_Begin1("Primary Audio Coding Header");
1555+
int8u SubFrames, PrimaryChannels;
1556+
Get_S1( 4, SubFrames, "Number of Subframes");
1557+
SubFrames++;
1558+
Param_Info2(SubFrames, " Subframes");
1559+
Get_S1( 3, PrimaryChannels, "Number of Primary Audio Channels");
1560+
PrimaryChannels++;
1561+
Param_Info2(PrimaryChannels, " Channels");
1562+
Skip_S8(PrimaryChannels*5, "Subband Activity Count");
1563+
Skip_S8(PrimaryChannels*5, "High Frequency VQ Start Subband");
1564+
Skip_S8(PrimaryChannels*3, "Joint Intensity Coding Index");
1565+
Skip_S8(PrimaryChannels*2, "Transient Mode Code Book");
1566+
Skip_S8(PrimaryChannels*3, "Scale Factor Code Book");
1567+
Skip_S8(PrimaryChannels*3, "Bit Allocation Quantizer Select");
1568+
1569+
#if MEDIAINFO_TRACE
1570+
auto Trace_Activated_Sav=Trace_Activated;
1571+
Trace_Activated=false; // Hide trace for numerous ABIT selectors
1572+
#endif
1573+
1574+
int ABITBits=SkipABITSelector(PrimaryChannels, 1, 1);
1575+
for (int i=1; i<5; i++)
1576+
ABITBits+=SkipABITSelector(PrimaryChannels, 2, 3);
1577+
for (int i=5; i<10; i++)
1578+
ABITBits+=SkipABITSelector(PrimaryChannels, 3, 7);
1579+
Skip_BS(ABITBits, "Scale Factor Adjustment Indexes");
1580+
1581+
#if MEDIAINFO_TRACE
1582+
Trace_Activated=Trace_Activated_Sav;
1583+
#endif
1584+
1585+
if (crc_present)
1586+
Skip_S2(16, "Audio Header CRC Check Word");
1587+
1588+
Element_End0();
1589+
1590+
// SubSubFrameCount is needed for later parsing of Rev2AUXData
1591+
Get_S1( 2, SubSubFrameCount, "SubSubFrame Count");
1592+
SubSubFrameCount++;
1593+
Param_Info2(SubSubFrameCount, " frames");
1594+
15451595
BS_End();
1596+
Rev2AuxPresent=Rev2AuxProbe();
15461597
}
15471598

15481599
//PTS
@@ -1608,6 +1659,20 @@ void File_Dts::Data_Parse()
16081659
}
16091660
}
16101661

1662+
//---------------------------------------------------------------------------
1663+
int File_Dts::SkipABITSelector(int Channels, int BitCount, int Limit)
1664+
{
1665+
int ABITBits=0;
1666+
for (int Channel=0; Channel<Channels; Channel++)
1667+
{
1668+
int8u Bits;
1669+
Get_S1(BitCount, Bits, "Quantization Index Codebook Select");
1670+
if (Bits < Limit)
1671+
ABITBits+=2;
1672+
}
1673+
return ABITBits;
1674+
}
1675+
16111676
//***************************************************************************
16121677
// Elements
16131678
//***************************************************************************
@@ -1622,7 +1687,7 @@ void File_Dts::Core()
16221687
Presence.set(presence_Core_Core);
16231688

16241689
//Parsing
1625-
if (AuxiliaryData || ExtendedCoding)
1690+
if (AuxiliaryData || ExtendedCoding || Rev2AuxPresent)
16261691
{
16271692
Extensions_Resynch(true);
16281693
Asset_Sizes.push_back(Element_Size-Element_Offset);
@@ -1681,6 +1746,7 @@ void File_Dts::Extensions()
16811746
CASE(XCh);
16821747
CASE(XBR);
16831748
CASE(Aux);
1749+
CASE(Rev2Aux);
16841750
#undef CASE
16851751
default:
16861752
Extensions_Resynch(false);
@@ -1702,7 +1768,12 @@ void File_Dts::Extensions()
17021768

17031769
//No more need data
17041770
if (!IsSub && Config->ParseSpeed<1.0)
1705-
Finish("DTS");
1771+
{
1772+
if (Stream_Offset_Max!=-1)
1773+
GoTo(Stream_Offset_Max);
1774+
else
1775+
Finish("DTS");
1776+
}
17061777
}
17071778
FILLING_END();
17081779

@@ -1772,6 +1843,9 @@ void File_Dts::Extensions_Resynch(bool Known)
17721843
case Ext_Aux:
17731844
IsNok=!AuxiliaryData;
17741845
break;
1846+
case Ext_Rev2Aux:
1847+
IsNok=!Rev2AuxPresent;
1848+
break;
17751849
default:
17761850
IsNok=true;
17771851
}
@@ -2297,6 +2371,84 @@ void File_Dts::XBR()
22972371
Extensions_Padding();
22982372
}
22992373

2374+
//---------------------------------------------------------------------------
2375+
void File_Dts::Rev2Aux()
2376+
{
2377+
// ETSI TS 102 114 v1.6.1 Section 5.8.3.
2378+
// The Rev2 Auxiliary Data Chunk Structure contains the T1CC indicator
2379+
// in the reserved data.
2380+
int8u Rev2Bytes;
2381+
Peek_B1(Rev2Bytes);
2382+
bool DmixIndexPresent=(Rev2Bytes&1)==1;
2383+
Rev2Bytes = (Rev2Bytes>>1)+1;
2384+
if (Element_Size-Element_Offset>=Rev2Bytes && Dts_CRC_CCIT_Compute(Buffer+Buffer_Offset+Element_Offset, Rev2Bytes)==0)
2385+
{
2386+
BS_Begin();
2387+
// Will later use Rev2BitsRemain to skip padding up to CRC
2388+
int Rev2BitsRemain=(Rev2Bytes-2)*8-Data_BS_Remain();
2389+
2390+
Skip_S1(7, "Rev2AUXDataByteSize");
2391+
bool ESMetaDataFlag;
2392+
Get_SB(ESMetaDataFlag, "ESMetaDataFlag");
2393+
if (ESMetaDataFlag)
2394+
Skip_S1(8, "EmbESDownMixScaleIndex");
2395+
2396+
bool BroadcastMetadataPresent = false;
2397+
Get_SB(BroadcastMetadataPresent, "BroadcastMetadataPresent");
2398+
if (BroadcastMetadataPresent)
2399+
{
2400+
bool DRCMetadataPresent, DialnormMetadataPresent;
2401+
Get_SB(DRCMetadataPresent, "DRCMetadataPresent");
2402+
Get_SB(DialnormMetadataPresent, "DialnormMetadata");
2403+
if (DRCMetadataPresent)
2404+
Skip_S1(4, "DRCversion_Rev2AUX");
2405+
auto Remain=Data_BS_Remain()%8;
2406+
if (Remain)
2407+
Skip_S1(Remain, "ByteAlign");
2408+
if (DRCMetadataPresent)
2409+
{
2410+
Element_Begin1("Rev2_DRCs");
2411+
for (int i=0; i<SubSubFrameCount; i++)
2412+
Skip_S1(8, "DRCCoeff_Rev2");
2413+
Element_End0();
2414+
}
2415+
2416+
if (DialnormMetadataPresent)
2417+
Skip_S1(5, "DIALNORM_rev2aux");
2418+
}
2419+
2420+
Rev2BitsRemain+=Data_BS_Remain();
2421+
if (Rev2BitsRemain >= 3)
2422+
{
2423+
Skip_S1(2, "NEOX Encoded Height Info");
2424+
bool T1CC;
2425+
Get_SB(Type1CertifiedContent, "Type 1 Certified Content");
2426+
Rev2BitsRemain-=3;
2427+
}
2428+
if (Rev2BitsRemain)
2429+
Skip_S4(Rev2BitsRemain, "ByteAlign");
2430+
BS_End();
2431+
Skip_B2( "Rev2AUXCRC16");
2432+
Skip_XX(Element_Size-Element_Offset, "Padding");
2433+
}
2434+
}
2435+
2436+
//---------------------------------------------------------------------------
2437+
bool File_Dts::Rev2AuxProbe() const
2438+
{
2439+
auto Base=Buffer+Buffer_Offset;
2440+
auto Offset=Element_Offset;
2441+
auto Offset_Max=Element_Size-3;
2442+
auto AlignmentBytes=Element_Offset%4;
2443+
if (AlignmentBytes)
2444+
Offset+=4-AlignmentBytes;
2445+
2446+
for (; Offset<Offset_Max; Offset+=4)
2447+
if (DTS_Extension_Index_Get(BigEndian2int32u(Base+Offset))==Ext_Rev2Aux)
2448+
return true;
2449+
2450+
return false;
2451+
}
23002452

23012453
//---------------------------------------------------------------------------
23022454
void File_Dts::Extensions2()

Source/MediaInfo/Audio/File_Dts.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,10 @@ private :
8282
void XXCH();
8383
void XBR();
8484
void Aux() { Extensions_Resynch(true); }
85+
void Rev2Aux();
8586
void AfterAssets();
8687
void Extensions2();
88+
int SkipABITSelector(int Channels, int BitCount, int Limit);
8789

8890
//Buffer
8991
bool FrameSynchPoint_Test();
@@ -110,13 +112,16 @@ private :
110112
int8u HD_MaximumSampleRate_Real;
111113
int8u HD_TotalNumberChannels;
112114
int8u HD_ExSSFrameDurationCode;
115+
int8u SubSubFrameCount;
113116
bool AuxiliaryData;
114117
bool ExtendedCoding;
115118
bool Word;
116119
bool BigEndian;
117120
bool ES;
118121
bool Core_Exists;
119122
bool One2OneMapChannels2Speakers;
123+
bool Rev2AuxPresent;
124+
bool Type1CertifiedContent;
120125
enum presence
121126
{
122127
presence_Core_Core,
@@ -161,6 +166,7 @@ private :
161166

162167
//Helpers
163168
float64 BitRate_Get(bool WithHD=false);
169+
bool Rev2AuxProbe() const;
164170
void Streams_Fill_Extension();
165171
void Streams_Fill_Core_ES();
166172
void Streams_Fill_Core(bool With96k=false);

0 commit comments

Comments
 (0)