@@ -183,6 +183,35 @@ static const sized_array_string Ac4_content_classifier=
183183 " Associate" , // Generic "Associate"
184184};
185185
186+ static string Ac4_Language (const string& language_tag_bytes) {
187+ if (language_tag_bytes == " qaa" ) {
188+ return " Original version" ;
189+ }
190+ return MediaInfoLib::Config.Iso639_Translate (Ztring ().From_UTF8 (language_tag_bytes)).To_UTF8 ();
191+ }
192+
193+ static const char * Ac4_content_classifier_ext (const string& language_tag_bytes)
194+ {
195+ if (language_tag_bytes.size () != 3 ) {
196+ return nullptr ;
197+ }
198+ #define CC3 (_A,_B,_C ) ((_A<<16 )|(_B<<8 )|(_C))
199+ auto Language = CC3 (language_tag_bytes[0 ], language_tag_bytes[1 ], language_tag_bytes[2 ]);
200+ const char * ToAdd;
201+ #define CC3_MAP (_A,_B,_C,_D ) case CC3 (_A, _B, _C): return _D;
202+ switch (Language) {
203+ CC3_MAP (' q' , ' a' , ' s' , " audio description with spoken subtitles, decoder mix" );
204+ CC3_MAP (' q' , ' t' , ' x' , " audio description with spoken subtitles, premix" );
205+ CC3_MAP (' q' , ' a' , ' d' , " audio description, decoder mix" );
206+ CC3_MAP (' q' , ' a' , ' x' , " audio description, premix" );
207+ CC3_MAP (' q' , ' s' , ' s' , " spoken subtitles, decoder mix" );
208+ CC3_MAP (' q' , ' s' , ' x' , " spoken subtitles, premix" );
209+ CC3_MAP (' q' , ' e' , ' i' , " audio emergency information, decoder mix" );
210+ CC3_MAP (' q' , ' e' , ' x' , " audio emergency information, premix" );
211+ default : return nullptr ;
212+ }
213+ }
214+
186215static const sized_array_string Ac4_ch_mode_String=
187216{
188217 (const char *)16 ,
@@ -1281,9 +1310,32 @@ void File_Ac4::Streams_Fill()
12811310 // Summary language
12821311 if (!Presentation_Current.Language .empty ())
12831312 {
1284- Summary+=" (" ;
1285- Summary+=MediaInfoLib::Config.Iso639_Translate (Ztring ().From_UTF8 (Presentation_Current.Language )).To_UTF8 ();
1286- Summary+=' )' ;
1313+ string LanguageString;
1314+ LanguageString+=" (" ;
1315+ LanguageString+=Ac4_Language (Presentation_Current.Language );
1316+ LanguageString+=' )' ;
1317+ auto MainPos=Summary.find (" Main" );
1318+ auto DialoguePos=Summary.find (" Dialogue" );
1319+ auto AssociatePos=Summary.find (" Associate" );
1320+ size_t InsertPoint;
1321+ if (MainPos!=string::npos)
1322+ InsertPoint=MainPos+4 ;
1323+ else if (DialoguePos!=string::npos)
1324+ InsertPoint=MainPos+8 ;
1325+ else
1326+ InsertPoint=Summary.size ();
1327+ Summary.insert (InsertPoint, LanguageString);
1328+ if (AssociatePos!=string::npos && !Presentation_Current.substream_group_info_specifiers .empty ())
1329+ {
1330+ const group& Group=Groups[Presentation_Current.substream_group_info_specifiers .back ()];
1331+ auto ClassifierExt=Ac4_content_classifier_ext (Group.ContentInfo .language_tag_bytes );
1332+ if (ClassifierExt)
1333+ {
1334+ Summary+=" (" ;
1335+ Summary+=ClassifierExt;
1336+ Summary+=' )' ;
1337+ }
1338+ }
12871339 }
12881340 if (Summary.empty ())
12891341 Summary=' ?' ;
@@ -1319,7 +1371,7 @@ void File_Ac4::Streams_Fill()
13191371 if (!Presentation_Current.Language .empty ())
13201372 {
13211373 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 ) ));
1374+ Fill (Stream_Audio, 0 , (P+" Language/String" ).c_str (), Ac4_Language ( Presentation_Current.Language ));
13231375 Fill_SetOptions (Stream_Audio, 0 , (P+" Language" ).c_str (), " N NTY" );
13241376 Fill_SetOptions (Stream_Audio, 0 , (P+" Language/String" ).c_str (), " Y NTN" );
13251377 }
@@ -1511,15 +1563,33 @@ void File_Ac4::Streams_Fill()
15111563 Summary+=" / " ;
15121564 Summary+=*PresentationConfig;
15131565 }
1566+ bool SkipLanguage = false ;
1567+ if (!Group.ContentInfo .language_tag_bytes .empty ()) {
1568+ auto ClassifierExt = Ac4_content_classifier_ext (Group.ContentInfo .language_tag_bytes );
1569+ Summary += " (" ;
1570+ if (ClassifierExt) {
1571+ Summary += ClassifierExt;
1572+ SkipLanguage = true ;
1573+ }
1574+ else {
1575+ Summary += Ac4_Language (Group.ContentInfo .language_tag_bytes );
1576+ }
1577+ Summary += ' )' ;
1578+ }
15141579 Fill (Stream_Audio, 0 , G.c_str (), Summary);
15151580 Fill (Stream_Audio, 0 , (G+" Pos" ).c_str (), g);
15161581 Fill_SetOptions (Stream_Audio, 0 , (G+" Pos" ).c_str (), " N NIY" );
15171582 if (Group.ContentInfo .content_classifier !=(int8u)-1 )
15181583 Fill (Stream_Audio, 0 , (G+" Classifier" ).c_str (), Value (Ac4_content_classifier, Group.ContentInfo .content_classifier ));
15191584 if (!Group.ContentInfo .language_tag_bytes .empty ())
1585+ {
1586+ auto Classifier = Value (Ac4_content_classifier, Group.ContentInfo .content_classifier );
1587+ Fill (Stream_Audio, 0 , (G+" Classifier" ).c_str (), Classifier);
1588+ }
1589+ if (!Group.ContentInfo .language_tag_bytes .empty () && !SkipLanguage)
15201590 {
15211591 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 ) ));
1592+ Fill (Stream_Audio, 0 , (G+" Language/String" ).c_str (), Ac4_Language ( Group.ContentInfo .language_tag_bytes ));
15231593 Fill_SetOptions (Stream_Audio, 0 , (G+" Language" ).c_str (), " N NTY" );
15241594 Fill_SetOptions (Stream_Audio, 0 , (G+" Language/String" ).c_str (), " Y NTN" );
15251595 }
0 commit comments