From 144f97a92d06d7348de69b3394d1e28525fdf2e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Martinez?= Date: Fri, 1 Dec 2023 16:23:39 +0100 Subject: [PATCH] + GXF: support of AVC and VC-3 --- Source/MediaInfo/File__Analyze_Buffer.cpp | 2 +- .../File__Analyze_Streams_Finish.cpp | 92 +++++++++---------- Source/MediaInfo/Multiple/File_Gxf.cpp | 30 ++++++ Source/MediaInfo/Multiple/File_Mxf.cpp | 4 +- 4 files changed, 79 insertions(+), 49 deletions(-) diff --git a/Source/MediaInfo/File__Analyze_Buffer.cpp b/Source/MediaInfo/File__Analyze_Buffer.cpp index cfbe5d1d5..016262bcf 100644 --- a/Source/MediaInfo/File__Analyze_Buffer.cpp +++ b/Source/MediaInfo/File__Analyze_Buffer.cpp @@ -2049,7 +2049,7 @@ void File__Analyze::Skip_XX(int64u Bytes, const char* Name) { if (Element_Offset+Bytes!=Element_TotalSize_Get()) //Exception for seek to end of the element { - INTEGRITY_SIZE_ATLEAST(Bytes); + //INTEGRITY_SIZE_ATLEAST(Bytes); } if (Trace_Activated && Bytes) Param(Name, Ztring("(")+Ztring::ToZtring(Bytes)+Ztring(" bytes)")); Element_Offset+=Bytes; diff --git a/Source/MediaInfo/File__Analyze_Streams_Finish.cpp b/Source/MediaInfo/File__Analyze_Streams_Finish.cpp index 15ea87116..ff49be84e 100644 --- a/Source/MediaInfo/File__Analyze_Streams_Finish.cpp +++ b/Source/MediaInfo/File__Analyze_Streams_Finish.cpp @@ -32,7 +32,7 @@ #include "MediaInfo/MediaInfo_Config_MediaInfo.h" #include "MediaInfo/MediaInfo_Internal.h" #include "MediaInfo/TimeCode.h" -#include "MediaInfo/ExternalCommandHelpers.h" +#include "MediaInfo/ExternalCommandHelpers.h" #if MEDIAINFO_IBI #include "MediaInfo/Multiple/File_Ibi.h" #endif //MEDIAINFO_IBI @@ -232,55 +232,55 @@ void File__Analyze::Streams_Finish_Global() if (!ExternalMetadata.empty()) { ZtringListList List; - List.Separator_Set(0, MediaInfoLib::Config.LineSeparator_Get()); - List.Separator_Set(1, __T(";")); - List.Write(ExternalMetadata); - - for (size_t i=0; i5) - { - MediaInfoLib::Config.Log_Send(0xC0, 0xFF, 0, "Invalid column size for external metadata"); - continue; - } - - Ztring StreamKindZ=Ztring(List[i][0]).MakeLowerCase(); - stream_t StreamKind; - size_t Offset; - if (List[i].size()<4) - { - StreamKind=Stream_General; - Offset=2; - } - else - { - Offset=0; - if (StreamKindZ==__T("general")) StreamKind=Stream_General; - else if (StreamKindZ==__T("video")) StreamKind=Stream_Video; - else if (StreamKindZ==__T("audio")) StreamKind=Stream_Audio; - else if (StreamKindZ==__T("text")) StreamKind=Stream_Text; - else if (StreamKindZ==__T("other")) StreamKind=Stream_Other; - else if (StreamKindZ==__T("image")) StreamKind=Stream_Image; - else if (StreamKindZ==__T("menu")) StreamKind=Stream_Menu; - else - { - MediaInfoLib::Config.Log_Send(0xC0, 0xFF, 0, "Invalid column 0 for external metadata"); - continue; - } - } - size_t StreamPos=(size_t)List[i][1].To_int64u(); - bool ShouldReplace=List[i].size()>4-Offset && List[i][4-Offset].To_int64u(); - if (ShouldReplace || Retrieve_Const(StreamKind, StreamPos, List[i][2-Offset].To_UTF8().c_str()).empty()) - Fill(StreamKind, StreamPos, List[i][2-Offset].To_UTF8().c_str(), List[i][3-Offset], ShouldReplace); - } - } - } + // 5 (optional): replace instead of ignoring if field is already present (metadata from the file) + if (List[i].size()<2 || List[i].size()>5) + { + MediaInfoLib::Config.Log_Send(0xC0, 0xFF, 0, "Invalid column size for external metadata"); + continue; + } + + Ztring StreamKindZ=Ztring(List[i][0]).MakeLowerCase(); + stream_t StreamKind; + size_t Offset; + if (List[i].size()<4) + { + StreamKind=Stream_General; + Offset=2; + } + else + { + Offset=0; + if (StreamKindZ==__T("general")) StreamKind=Stream_General; + else if (StreamKindZ==__T("video")) StreamKind=Stream_Video; + else if (StreamKindZ==__T("audio")) StreamKind=Stream_Audio; + else if (StreamKindZ==__T("text")) StreamKind=Stream_Text; + else if (StreamKindZ==__T("other")) StreamKind=Stream_Other; + else if (StreamKindZ==__T("image")) StreamKind=Stream_Image; + else if (StreamKindZ==__T("menu")) StreamKind=Stream_Menu; + else + { + MediaInfoLib::Config.Log_Send(0xC0, 0xFF, 0, "Invalid column 0 for external metadata"); + continue; + } + } + size_t StreamPos=(size_t)List[i][1].To_int64u(); + bool ShouldReplace=List[i].size()>4-Offset && List[i][4-Offset].To_int64u(); + if (ShouldReplace || Retrieve_Const(StreamKind, StreamPos, List[i][2-Offset].To_UTF8().c_str()).empty()) + Fill(StreamKind, StreamPos, List[i][2-Offset].To_UTF8().c_str(), List[i][3-Offset], ShouldReplace); + } + } + } #endif //MEDIAINFO_ADVANCED #if MEDIAINFO_ADVANCED diff --git a/Source/MediaInfo/Multiple/File_Gxf.cpp b/Source/MediaInfo/Multiple/File_Gxf.cpp index 05c4bbda8..116fa889c 100644 --- a/Source/MediaInfo/Multiple/File_Gxf.cpp +++ b/Source/MediaInfo/Multiple/File_Gxf.cpp @@ -32,9 +32,15 @@ #if defined(MEDIAINFO_GXF_YES) #include "MediaInfo/Multiple/File_Umf.h" #endif +#if defined(MEDIAINFO_AVC_YES) + #include "MediaInfo/Video/File_Avc.h" +#endif #if defined(MEDIAINFO_MPEGV_YES) #include "MediaInfo/Video/File_Mpegv.h" #endif +#if defined(MEDIAINFO_VC3_YES) + #include "MediaInfo/Video/File_Vc3.h" +#endif #if defined(MEDIAINFO_AC3_YES) #include "MediaInfo/Audio/File_Ac3.h" #endif @@ -112,6 +118,8 @@ static const char* Gxf_MediaTypes(int8u Type) case 23 : return "MPEG-1 Video"; //625 lines case 24 : return "SMPTE 12M"; //HD case 25 : return "DV"; //DVCPRO HD + case 29 : return "AVC"; + case 30 : return "VC-3"; default : return ""; } } @@ -142,6 +150,8 @@ static stream_t Gxf_MediaTypes_StreamKind(int8u Type) case 23 : return Stream_Video; case 24 : return Stream_Max; case 25 : return Stream_Video; + case 29 : return Stream_Video; + case 30 : return Stream_Video; default : return Stream_Max; } } @@ -1079,6 +1089,26 @@ void File_Gxf::map() #endif //MEDIAINFO_RIFF_YES } break; + case 29 : //AVC + { + File__Analyze* Parser=new File_Avc(); + Open_Buffer_Init(Parser); + Streams[TrackID].Parsers.push_back(Parser); + + Parsers_Count++; + Streams[TrackID].Searching_Payload=true; + } + break; + case 30 : //VC-3 + { + File__Analyze* Parser=new File_Vc3(); + Open_Buffer_Init(Parser); + Streams[TrackID].Parsers.push_back(Parser); + + Parsers_Count++; + Streams[TrackID].Searching_Payload=true; + } + break; default : ; } diff --git a/Source/MediaInfo/Multiple/File_Mxf.cpp b/Source/MediaInfo/Multiple/File_Mxf.cpp index 779f28682..6c09290c6 100644 --- a/Source/MediaInfo/Multiple/File_Mxf.cpp +++ b/Source/MediaInfo/Multiple/File_Mxf.cpp @@ -6277,7 +6277,7 @@ void File_Mxf::Data_Parse() Element_WaitForMoreData(); \ return; \ } \ - Skip_XX(Element_Size, "Data"); \ + Skip_XX(Element_Size-Element_Offset, "Data"); \ } \ Element_Name(_NAME); \ switch (Code_Compare2>>24) \ @@ -6306,7 +6306,7 @@ void File_Mxf::Data_Parse() } \ break; \ case 0x63 : _ELEMENT(); break; \ - default : Skip_XX(Element_Size, "Unknown"); \ + default : Skip_XX(Element_Size-Element_Offset, "Unknown"); \ } \ } \ } \