@@ -183,6 +183,28 @@ static const sized_array_string Ac4_content_classifier=
183183 " Associate" , // Generic "Associate"
184184};
185185
186+ static const char * Ac4_content_classifier_ext (const string& language_tag_bytes)
187+ {
188+ if (language_tag_bytes.size () != 3 ) {
189+ return nullptr ;
190+ }
191+ #define CC3 (_A,_B,_C ) ((_A<<16 )|(_B<<8 )|(_C))
192+ auto Language = CC3 (language_tag_bytes[0 ], language_tag_bytes[1 ], language_tag_bytes[2 ]);
193+ const char * ToAdd;
194+ #define CC3_MAP (_A,_B,_C,_D ) case CC3 (_A, _B, _C): return _D;
195+ switch (Language) {
196+ CC3_MAP (' q' , ' a' , ' s' , " audio description with spoken subtitles, decoder mix" );
197+ CC3_MAP (' q' , ' t' , ' x' , " audio description with spoken subtitles, premix" );
198+ CC3_MAP (' q' , ' a' , ' d' , " audio description, decoder mix" );
199+ CC3_MAP (' q' , ' a' , ' x' , " audio description, premix" );
200+ CC3_MAP (' q' , ' s' , ' s' , " spoken subtitles, decoder mix" );
201+ CC3_MAP (' q' , ' s' , ' x' , " spoken subtitles, premix" );
202+ CC3_MAP (' q' , ' e' , ' i' , " audio emergency information, decoder mix" );
203+ CC3_MAP (' q' , ' e' , ' x' , " audio emergency information, premix" );
204+ default : return nullptr ;
205+ }
206+ }
207+
186208static const sized_array_string Ac4_ch_mode_String=
187209{
188210 (const char *)16 ,
@@ -1195,6 +1217,18 @@ void File_Ac4::Streams_Fill()
11951217 Fill (Stream_Audio, 0 , " NumberOfGroups" , Groups.size ());
11961218 if (!AudioSubstreams.empty ())
11971219 Fill (Stream_Audio, 0 , " NumberOfSubstreams" , AudioSubstreams.size ());
1220+ auto BitstreamLevel = 7 ;
1221+ const auto numPresentations = Presentations.size ();
1222+ if (numPresentations <= 64 )
1223+ {
1224+ for (const auto & Presentation : Presentations) {
1225+ if ((Presentation.b_multi_pid_PresentAndValue && Presentation.b_multi_pid_PresentAndValue != (int8u)-1 ) || Presentation.mdcompat > 4 ) {
1226+ continue ;
1227+ }
1228+ BitstreamLevel = min (BitstreamLevel == 4 ? 4 : 3 , BitstreamLevel);
1229+ }
1230+ }
1231+ Fill (Stream_Audio, 0 , " BitstreamLevel" , BitstreamLevel);
11981232
11991233 for (size_t p=0 ; p<Presentations.size (); p++)
12001234 {
@@ -1281,9 +1315,32 @@ void File_Ac4::Streams_Fill()
12811315 // Summary language
12821316 if (!Presentation_Current.Language .empty ())
12831317 {
1284- Summary+=" (" ;
1285- Summary+=MediaInfoLib::Config.Iso639_Translate (Ztring ().From_UTF8 (Presentation_Current.Language )).To_UTF8 ();
1286- Summary+=' )' ;
1318+ string LanguageString;
1319+ LanguageString+=" (" ;
1320+ LanguageString+=Presentation_Current.Language ==" qaa" ?" Original version" :MediaInfoLib::Config.Iso639_Translate (Ztring ().From_UTF8 (Presentation_Current.Language )).To_UTF8 ();
1321+ LanguageString+=' )' ;
1322+ auto MainPos=Summary.find (" Main" );
1323+ auto DialoguePos=Summary.find (" Dialogue" );
1324+ auto AssociatePos=Summary.find (" Associate" );
1325+ size_t InsertPoint;
1326+ if (MainPos!=string::npos)
1327+ InsertPoint=MainPos+4 ;
1328+ else if (DialoguePos!=string::npos)
1329+ InsertPoint=MainPos+8 ;
1330+ else
1331+ InsertPoint=Summary.size ();
1332+ Summary.insert (InsertPoint, LanguageString);
1333+ if (AssociatePos!=string::npos && !Presentation_Current.substream_group_info_specifiers .empty ())
1334+ {
1335+ const group& Group=Groups[Presentation_Current.substream_group_info_specifiers .back ()];
1336+ auto ClassifierExt=Ac4_content_classifier_ext (Group.ContentInfo .language_tag_bytes );
1337+ if (ClassifierExt)
1338+ {
1339+ Summary+=" (" ;
1340+ Summary+=ClassifierExt;
1341+ Summary+=' )' ;
1342+ }
1343+ }
12871344 }
12881345 if (Summary.empty ())
12891346 Summary=' ?' ;
@@ -1297,6 +1354,8 @@ void File_Ac4::Streams_Fill()
12971354 Fill_SetOptions (Stream_Audio, 0 , (P+" Index" ).c_str (), " N NIY" );
12981355 if (Presentation_Current.presentation_id !=(int32u)-1 )
12991356 Fill (Stream_Audio, 0 , (P+" PresentationID" ).c_str (), Presentation_Current.presentation_id );
1357+ if (Presentation_Current.mdcompat != (int8u)-1 )
1358+ Fill (Stream_Audio, 0 , (P+" PresentationLevel" ).c_str (), Presentation_Current.mdcompat );
13001359 if (!ChannelMode.empty ())
13011360 {
13021361 Fill (Stream_Audio, 0 , (P+" ChannelMode" ).c_str (), ChannelMode);
@@ -1319,7 +1378,7 @@ void File_Ac4::Streams_Fill()
13191378 if (!Presentation_Current.Language .empty ())
13201379 {
13211380 Fill (Stream_Audio, 0 , (P+" Language" ).c_str (), Presentation_Current.Language );
1322- Fill (Stream_Audio, 0 , (P+" Language/String" ).c_str (), MediaInfoLib::Config.Iso639_Translate (Ztring ().From_UTF8 (Presentation_Current.Language )));
1381+ Fill (Stream_Audio, 0 , (P+" Language/String" ).c_str (), Presentation_Current. Language == " qaa " ? " Original version " : MediaInfoLib::Config.Iso639_Translate (Ztring ().From_UTF8 (Presentation_Current.Language )));
13231382 Fill_SetOptions (Stream_Audio, 0 , (P+" Language" ).c_str (), " N NTY" );
13241383 Fill_SetOptions (Stream_Audio, 0 , (P+" Language/String" ).c_str (), " Y NTN" );
13251384 }
@@ -1511,15 +1570,27 @@ void File_Ac4::Streams_Fill()
15111570 Summary+=" / " ;
15121571 Summary+=*PresentationConfig;
15131572 }
1573+ bool SkipLanguage = false ;
1574+ auto ClassifierExt = Ac4_content_classifier_ext (Group.ContentInfo .language_tag_bytes );
1575+ if (!Group.ContentInfo .language_tag_bytes .empty ()) {
1576+ Summary += " (" + (Group.ContentInfo .language_tag_bytes == " qaa" ? string (" Original version" ) : MediaInfoLib::Config.Iso639_Translate (Ztring ().From_UTF8 (Group.ContentInfo .language_tag_bytes )).To_UTF8 ()) + ' )' ;
1577+ }
1578+ if (ClassifierExt) {
1579+ Summary += " (" + string (ClassifierExt) + ' )' ;
1580+ SkipLanguage = true ;
1581+ }
15141582 Fill (Stream_Audio, 0 , G.c_str (), Summary);
15151583 Fill (Stream_Audio, 0 , (G+" Pos" ).c_str (), g);
15161584 Fill_SetOptions (Stream_Audio, 0 , (G+" Pos" ).c_str (), " N NIY" );
15171585 if (Group.ContentInfo .content_classifier !=(int8u)-1 )
1518- Fill (Stream_Audio, 0 , (G+" Classifier" ).c_str (), Value (Ac4_content_classifier, Group.ContentInfo .content_classifier ));
1519- if (!Group.ContentInfo .language_tag_bytes .empty ())
1586+ {
1587+ auto Classifier = Value (Ac4_content_classifier, Group.ContentInfo .content_classifier );
1588+ Fill (Stream_Audio, 0 , (G+" Classifier" ).c_str (), Classifier);
1589+ }
1590+ if (!Group.ContentInfo .language_tag_bytes .empty () && !SkipLanguage)
15201591 {
15211592 Fill (Stream_Audio, 0 , (G+" Language" ).c_str (), Group.ContentInfo .language_tag_bytes );
1522- Fill (Stream_Audio, 0 , (G+" Language/String" ).c_str (), MediaInfoLib::Config.Iso639_Translate (Ztring ().From_UTF8 (Group.ContentInfo .language_tag_bytes )));
1593+ Fill (Stream_Audio, 0 , (G+" Language/String" ).c_str (), Group. ContentInfo . language_tag_bytes == " qaa " ? " Original version " : MediaInfoLib::Config.Iso639_Translate (Ztring ().From_UTF8 (Group.ContentInfo .language_tag_bytes )));
15231594 Fill_SetOptions (Stream_Audio, 0 , (G+" Language" ).c_str (), " N NTY" );
15241595 Fill_SetOptions (Stream_Audio, 0 , (G+" Language/String" ).c_str (), " Y NTN" );
15251596 }
@@ -2376,7 +2447,7 @@ void File_Ac4::ac4_presentation_info(presentation& P)
23762447 }
23772448 else
23782449 {
2379- Skip_S1 (3 , " mdcompat" );
2450+ Get_S1 (3 , P. mdcompat , " mdcompat" );
23802451
23812452 TEST_SB_SKIP ( " b_presentation_id" );
23822453 Get_V4 (2 , P.presentation_id , " presentation_id" );
@@ -2494,7 +2565,7 @@ void File_Ac4::ac4_presentation_v1_info(presentation& P)
24942565 else
24952566 {
24962567 if (bitstream_version!=1 )
2497- Skip_S1 (3 , " mdcompat" );
2568+ Get_S1 (3 , P. mdcompat , " mdcompat" );
24982569 TEST_SB_SKIP ( " b_presentation_id" );
24992570 Get_V4 (2 , P.presentation_id , " presentation_id" );
25002571 TEST_SB_END ();
@@ -4865,7 +4936,7 @@ void File_Ac4::ac4_presentation_v1_dsi(presentation& P)
48654936 if (P.presentation_config ==0x1F )
48664937 P.presentation_config =(int8u)-1 ; // 0x1F means not present
48674938 int8u dsi_frame_rate_multiply_info, dsi_frame_rate_fraction_info;
4868- Skip_S1 (3 , " mdcompat" );
4939+ Get_S1 (3 , P. mdcompat , " mdcompat" );
48694940 TEST_SB_SKIP ( " b_presentation_id" );
48704941 Get_S4 (5 , P.presentation_id , " presentation_id" );
48714942 TEST_SB_END ();
0 commit comments