Skip to content

Commit

Permalink
Merge pull request #2049 from JeromeMartinez/Conformance_Span
Browse files Browse the repository at this point in the history
Conformance checker: span of frames & frame/timestamp/byte offset
  • Loading branch information
JeromeMartinez committed May 22, 2024
2 parents 1a1f867 + 79b0cd0 commit 482c885
Show file tree
Hide file tree
Showing 8 changed files with 235 additions and 105 deletions.
2 changes: 1 addition & 1 deletion Source/MediaInfo/Audio/File_DolbyE.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1058,7 +1058,7 @@ void File_DolbyE::Streams_Fill_PerProgram(size_t program)
}

Fill(Stream_Audio, program, Audio_FrameRate, Mpegv_frame_rate[frame_rate_code]);
if (FrameInfo.PTS!=(int64u)-1 && bit_depth)
if (bit_depth)
{
float BitRate=(float)(96000*bit_depth);

Expand Down
267 changes: 196 additions & 71 deletions Source/MediaInfo/File__Analyze.cpp

Large diffs are not rendered by default.

27 changes: 0 additions & 27 deletions Source/MediaInfo/MediaInfo_Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,6 @@ void MediaInfo_Config::Init(bool Force)
#if MEDIAINFO_CONFORMANCE
Usac_Profile=(int8u)-1;
Warning_Error=false;
Conformance_Timestamp=false;
#endif //MEDIAINFO_CONFORMANCE
#if defined(MEDIAINFO_LIBCURL_YES)
URLEncode=URLEncode_Guess;
Expand Down Expand Up @@ -1674,16 +1673,6 @@ Ztring MediaInfo_Config::Option (const String &Option, const String &Value_Raw)
return __T("conformance features are disabled due to compilation options");
#endif // MEDIAINFO_CONFORMANCE
}
if (Option_Lower==__T("conformance_timestamp"))
{
#if MEDIAINFO_CONFORMANCE
Conformance_Timestamp_Set(Value.empty() || Value.To_int8u());
return Ztring();
#else // MEDIAINFO_CONFORMANCE
return __T("conformance features are disabled due to compilation options");
#endif // MEDIAINFO_CONFORMANCE
}

if (Option_Lower==__T("info_canhandleurls"))
{
#if defined(MEDIAINFO_LIBCURL_YES)
Expand Down Expand Up @@ -4040,22 +4029,6 @@ bool MediaInfo_Config::WarningError()
}
#endif //MEDIAINFO_CONFORMANCE

#if MEDIAINFO_CONFORMANCE
void MediaInfo_Config::Conformance_Timestamp_Set(bool Value)
{
CriticalSectionLocker CSL(CS);
Conformance_Timestamp=Value;
}
#endif //MEDIAINFO_CONFORMANCE

#if MEDIAINFO_CONFORMANCE
bool MediaInfo_Config::Conformance_Timestamp_Get()
{
CriticalSectionLocker CSL(CS);
return Conformance_Timestamp;
}
#endif //MEDIAINFO_CONFORMANCE

//***************************************************************************
// Curl
//***************************************************************************
Expand Down
3 changes: 0 additions & 3 deletions Source/MediaInfo/MediaInfo_Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -392,8 +392,6 @@ public :
string Profile_List();
void WarningError(bool Value);
bool WarningError();
void Conformance_Timestamp_Set(bool Value);
bool Conformance_Timestamp_Get();
#endif

#if defined(MEDIAINFO_LIBCURL_YES)
Expand Down Expand Up @@ -555,7 +553,6 @@ private :
string Mp4_Profile;
int8u Usac_Profile;
bool Warning_Error;
bool Conformance_Timestamp;
#endif

#if defined(MEDIAINFO_LIBCURL_YES)
Expand Down
1 change: 1 addition & 0 deletions Source/MediaInfo/Multiple/File_Flv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1233,6 +1233,7 @@ void File_Flv::video_AVC(int8u PacketType_plus1)
{
Stream[Stream_Video].Parser=new File_Avc;
Open_Buffer_Init(Stream[Stream_Video].Parser);
((File_Avc*)Stream[Stream_Video].Parser)->FrameIsAlwaysComplete=true;
((File_Avc*)Stream[Stream_Video].Parser)->MustParse_SPS_PPS=true;
((File_Avc*)Stream[Stream_Video].Parser)->SizedBlocks=true;
((File_Avc*)Stream[Stream_Video].Parser)->MustSynchronize=false;
Expand Down
6 changes: 6 additions & 0 deletions Source/MediaInfo/Multiple/File_MpegPs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -875,7 +875,13 @@ bool File_MpegPs::Synched_Test()
|| Buffer[Buffer_Offset+1]!=0x00
|| Buffer[Buffer_Offset+2]!=0x01)
{
Frame_Count=(int64u)-1;
Frame_Count_NotParsedIncluded=(int64u)-1;
if (Streams[stream_id].TimeStamp_End.PTS.TimeStamp!=(int64u)-1 && Streams[stream_id].TimeStamp_Start.PTS.TimeStamp!=(int64u)-1)
FrameInfo.PTS=(Streams[stream_id].TimeStamp_End.PTS.TimeStamp-Streams[stream_id].TimeStamp_Start.PTS.TimeStamp)*100000/9;
SynchLost("MPEG-PS");
Frame_Count=0;
FrameInfo=frame_info();
return true;
}

Expand Down
12 changes: 12 additions & 0 deletions Source/MediaInfo/Multiple/File_MpegTs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1509,7 +1509,10 @@ bool File_MpegTs::Synched_Test()
//Synchro testing
if (Buffer[Buffer_Offset+BDAV_Size]!=0x47)
{
Frame_Count=(int64u)-1;
Frame_Count_NotParsedIncluded=(int64u)-1;
SynchLost("MPEG-TS");
Frame_Count=0;
#if MEDIAINFO_DUPLICATE
if (File__Duplicate_Get())
Trusted++; //We don't want to stop parsing if duplication is requested, TS is not a lot stable, normal...
Expand Down Expand Up @@ -1805,8 +1808,17 @@ bool File_MpegTs::Synched_Test()
{
int64u Current_Offset=File_Offset+Buffer_Offset;
if (Current_Offset!=File_Size)
{
IsTruncated(Current_Offset+TS_Size, true, "MPEG-TS");
auto LastPacket_Size=File_Size-Current_Offset;
auto LastPacker_Missing=TS_Size-LastPacket_Size;
if (LastPacker_Missing>=TSP_Size)
TSP_Size=0; // Last bytes of a content and partial TS packet without the content after the TS content
else
TSP_Size-=LastPacker_Missing;
}
}
return true;
}

return false; //Not enough data
Expand Down
22 changes: 19 additions & 3 deletions Source/MediaInfo/Multiple/File_Mxf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2616,6 +2616,8 @@ void File_Mxf::Streams_Fill()
//---------------------------------------------------------------------------
void File_Mxf::Streams_Finish()
{
Frame_Count=Frame_Count_NotParsedIncluded=FrameInfo.PTS=FrameInfo.DTS=(int64u)-1;

#if MEDIAINFO_NEXTPACKET && defined(MEDIAINFO_REFERENCES_YES)
//Locators only
if (ReferenceFiles_IsParsing)
Expand Down Expand Up @@ -3005,6 +3007,8 @@ void File_Mxf::Streams_Finish()

//Commercial names
Streams_Finish_CommercialNames();

Merge_Conformance();
}

//---------------------------------------------------------------------------
Expand Down Expand Up @@ -6315,6 +6319,12 @@ void File_Mxf::Data_Parse()
{
//Clearing
InstanceUID=0;
if (!Essences_FirstEssence_Parsed)
{
Frame_Count=(int64u)-1;
Frame_Count_NotParsedIncluded=(int64u)-1;
FrameInfo=frame_info();
}

//Parsing
int32u Code_Compare1=Code.hi>>32;
Expand Down Expand Up @@ -6554,6 +6564,10 @@ void File_Mxf::Data_Parse()
}
#endif //MEDIAINFO_DEMUX || MEDIAINFO_SEEK

Frame_Count=0;
Frame_Count_NotParsedIncluded=0;
FrameInfo=frame_info();
FrameInfo.DTS=0;
Essences_FirstEssence_Parsed=true;
}

Expand Down Expand Up @@ -10512,7 +10526,7 @@ void File_Mxf::GenericPictureEssenceDescriptor_VideoLineMap()
// odd even field 1 upper
// even odd field 1 upper
// even even field 2 upper
if (Length2==8+2*4 && !VideoLineMapEntry_IsZero) //2 values
if (Count==2 && !VideoLineMapEntry_IsZero) //2 values
Descriptors[InstanceUID].FieldTopness=(VideoLineMapEntries_Total%2)?1:2;
FILLING_END();
}
Expand Down Expand Up @@ -12161,9 +12175,11 @@ void File_Mxf::PartitionMetadata()
Element_Size_WithPadding+=KAGSize_Corrected;
}

auto ExpectedSize=File_Offset+Buffer_Offset-Header_Size+Element_Size_WithPadding+HeaderByteCount+IndexByteCount;
auto ExpectedSize=File_Offset+Buffer_Offset-Header_Size+Element_Size_WithPadding;
if ((Code.lo&0xFF0000)==0x020000) //If Header Partition Pack
ExpectedSize+=HeaderByteCount+IndexByteCount;
if (ExpectedSize>File_Size)
IsTruncated(ExpectedSize);
IsTruncated(ExpectedSize, true);
}
#endif //MEDIAINFO_ADVANCED
}
Expand Down

0 comments on commit 482c885

Please sign in to comment.