Skip to content

Commit

Permalink
Merge pull request #1922 from JeromeMartinez/Gxf_Avc_Vc3
Browse files Browse the repository at this point in the history
GXF: support of AVC and VC-3
  • Loading branch information
JeromeMartinez authored Dec 1, 2023
2 parents 743c97e + 144f97a commit 06a842b
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 49 deletions.
2 changes: 1 addition & 1 deletion Source/MediaInfo/File__Analyze_Buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
92 changes: 46 additions & 46 deletions Source/MediaInfo/File__Analyze_Streams_Finish.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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; i<List.size(); i++)
{
// col 1&2 can be removed, conidered as "General;0"
List.Separator_Set(0, MediaInfoLib::Config.LineSeparator_Get());
List.Separator_Set(1, __T(";"));
List.Write(ExternalMetadata);

for (size_t i=0; i<List.size(); i++)
{
// col 1&2 can be removed, conidered as "General;0"
// 1: stream kind (General, Video, Audio, Text...)
// 2: 0-based stream number
// 3: field name
// 4: field value
// 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);
}
}
}
// 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
Expand Down
30 changes: 30 additions & 0 deletions Source/MediaInfo/Multiple/File_Gxf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 "";
}
}
Expand Down Expand Up @@ -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;
}
}
Expand Down Expand Up @@ -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 : ;
}

Expand Down
4 changes: 2 additions & 2 deletions Source/MediaInfo/Multiple/File_Mxf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) \
Expand Down Expand Up @@ -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"); \
} \
} \
} \
Expand Down

0 comments on commit 06a842b

Please sign in to comment.