Skip to content

AVC: improved detection of AVC-Intra #2125

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions Source/MediaInfo/Multiple/File_Mxf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4402,13 +4402,13 @@ void File_Mxf::Streams_Finish_CommercialNames ()
Fill(Stream_General, 0, General_Format_Commercial_IfAny, "DV");
Fill(Stream_General, 0, General_Format_Commercial, "MXF DV");
}
else if (Retrieve(Stream_Video, 0, Video_Format)==__T("AVC") && Retrieve(Stream_Video, 0, Video_Format_Settings_GOP)==__T("N=1") && Retrieve(Stream_Video, 0, Video_ChromaSubsampling)==__T("4:2:0") && Retrieve(Stream_Video, 0, Video_BitRate)==__T("56064000"))
else if (Retrieve(Stream_Video, 0, Video_Format)==__T("AVC") && Retrieve(Stream_Video, 0, Video_Format_Settings_GOP)==__T("N=1") && Retrieve(Stream_Video, 0, Video_ChromaSubsampling)==__T("4:2:0") && Retrieve(Stream_Video, 0, Video_Format_Settings_SliceCount)==__T("10") && Retrieve(Stream_Video, 0, Video_BitRate)==__T("56064000"))
{
Fill(Stream_General, 0, General_Format_Commercial_IfAny, "AVC-Intra 50");
Fill(Stream_General, 0, General_Format_Commercial, "MXF AVC-Intra 50");
Fill(Stream_Video, 0, Video_Format_Commercial_IfAny, "AVC-Intra 50");
}
else if (Retrieve(Stream_Video, 0, Video_Format)==__T("AVC") && Retrieve(Stream_Video, 0, Video_Format_Settings_GOP)==__T("N=1") && Retrieve(Stream_Video, 0, Video_ChromaSubsampling)==__T("4:2:2") && Retrieve(Stream_Video, 0, Video_BitRate)==__T("113664000"))
else if (Retrieve(Stream_Video, 0, Video_Format)==__T("AVC") && Retrieve(Stream_Video, 0, Video_Format_Settings_GOP)==__T("N=1") && Retrieve(Stream_Video, 0, Video_ChromaSubsampling)==__T("4:2:2") && Retrieve(Stream_Video, 0, Video_Format_Settings_SliceCount)==__T("10") && Retrieve(Stream_Video, 0, Video_BitRate)==__T("113664000"))
{
Fill(Stream_General, 0, General_Format_Commercial_IfAny, "AVC-Intra 100");
Fill(Stream_General, 0, General_Format_Commercial, "MXF AVC-Intra 100");
Expand Down Expand Up @@ -6812,6 +6812,8 @@ void File_Mxf::Data_Parse()
ChooseParser(Essence, Descriptor); //Searching by the descriptor
if (Essence->second.Parsers.empty())
ChooseParser__FromEssence(Essence, Descriptor); //Searching by the track identifier
if (Essence->second.Parsers.size()==1 && Descriptor->second.Infos["Format_Settings_Wrapping"].rfind(__T("Frame"), 0)==0 || Essence->second.Infos["Format_Settings_Wrapping"].rfind(__T("Frame"), 0)==0) //TODO: Parsers.size()==1 is for avoiding Dolby E issues, it should be fixed instead
Essence->second.Parsers[0]->FrameIsAlwaysComplete=true;

#ifdef MEDIAINFO_DEMUX
if (Ztring().From_UTF8(Mxf_EssenceContainer(Descriptor->second.EssenceContainer))==__T("AVC"))
Expand All @@ -6824,7 +6826,11 @@ void File_Mxf::Data_Parse()

//Searching by the track identifier
if (Essence->second.Parsers.empty())
{
ChooseParser__FromEssence(Essence, Descriptors.end());
if (Essence->second.Parsers.size()==1 && Essence->second.Infos["Format_Settings_Wrapping"].rfind(__T("Frame"), 0)==0) //TODO: Parsers.size()==1 is for avoiding Dolby E issues, it should be fixed instead
Essence->second.Parsers[0]->FrameIsAlwaysComplete=true;
}

//Check of Essence used as a reference for frame count
if (Essences_UsedForFrameCount==(int32u)-1)
Expand Down
15 changes: 13 additions & 2 deletions Source/MediaInfo/Video/File_Avc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -911,6 +911,7 @@ void File_Avc::Streams_Fill(std::vector<seq_parameter_set_struct*>::iterator seq

//From vui_parameters
float64 PixelAspectRatio=1;
float64 FrameRate=0;
if ((*seq_parameter_set_Item)->vui_parameters)
{
if ((*seq_parameter_set_Item)->vui_parameters->aspect_ratio_info_present_flag)
Expand All @@ -925,7 +926,10 @@ void File_Avc::Streams_Fill(std::vector<seq_parameter_set_struct*>::iterator seq
if (!(*seq_parameter_set_Item)->vui_parameters->fixed_frame_rate_flag)
Fill(Stream_Video, StreamPos_Last, Video_FrameRate_Mode, "VFR");
else if ((*seq_parameter_set_Item)->vui_parameters->timing_info_present_flag && (*seq_parameter_set_Item)->vui_parameters->time_scale && (*seq_parameter_set_Item)->vui_parameters->num_units_in_tick)
Fill(Stream_Video, StreamPos_Last, Video_FrameRate, (float64)(*seq_parameter_set_Item)->vui_parameters->time_scale/(*seq_parameter_set_Item)->vui_parameters->num_units_in_tick/((*seq_parameter_set_Item)->frame_mbs_only_flag?2:(((*seq_parameter_set_Item)->pic_order_cnt_type==2 && Structure_Frame/2>Structure_Field)?1:2))/FrameRate_Divider);
{
FrameRate=(float64)(*seq_parameter_set_Item)->vui_parameters->time_scale/(*seq_parameter_set_Item)->vui_parameters->num_units_in_tick/((*seq_parameter_set_Item)->frame_mbs_only_flag?2:(((*seq_parameter_set_Item)->pic_order_cnt_type==2 && Structure_Frame/2>Structure_Field)?1:2))/FrameRate_Divider;
Fill(Stream_Video, StreamPos_Last, Video_FrameRate, FrameRate);
}
}

//Colour description
Expand Down Expand Up @@ -1098,6 +1102,11 @@ void File_Avc::Streams_Fill(std::vector<seq_parameter_set_struct*>::iterator seq
}
}
Fill(Stream_Video, 0, Video_Format_Settings_GOP, GOP_Detect(PictureTypes));
if (Retrieve_Const(Stream_Video, 0, Video_BitRate).empty() && Retrieve_Const(Stream_Video, 0, Video_Format_Settings_GOP)==__T("N=1") && FrameRate && FrameSizes.size()==1)
{
Fill(Stream_Video, 0, Video_BitRate, FrameSizes.begin()->first*FrameRate*8, 0);
Fill(Stream_Video, 0, Video_BitRate_Mode, "CBR");
}

Fill(Stream_General, 0, General_Encoded_Library, Encoded_Library);
Fill(Stream_General, 0, General_Encoded_Library_Name, Encoded_Library_Name);
Expand Down Expand Up @@ -1926,7 +1935,7 @@ bool File_Avc::Header_Parser_Fill_Size()
return false;
}

if (Buffer[Buffer_Offset_Temp-1]==0x00)
if (!FrameIsAlwaysComplete && Buffer[Buffer_Offset_Temp-1]==0x00)
Buffer_Offset_Temp--;

//OK, we continue
Expand Down Expand Up @@ -2792,6 +2801,8 @@ void File_Avc::slice_header()
if (!IsSub && !Streams[(size_t)Element_Code].ShouldDuplicate && Config->ParseSpeed<1.0)
Finish("AVC");
}
if (FrameIsAlwaysComplete && !first_mb_in_slice && FrameSizes.size()<=1)
FrameSizes[Buffer_Size]++;
}
FILLING_END();
}
Expand Down
1 change: 1 addition & 0 deletions Source/MediaInfo/Video/File_Avc.h
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,7 @@ private :
int8u preferred_transfer_characteristics;
bool FirstPFrameInGop_IsParsed;
bool Config_IsRepeated;
std::map<size_t, int> FrameSizes;
#if MEDIAINFO_ADVANCED2
std::vector<std::string> Dump_SPS;
std::vector<std::string> Dump_PPS;
Expand Down
Loading