Skip to content
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

DvDif: detect synthetic gray/silence frames #1606

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions Source/MediaInfo/Multiple/File_DvDif.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ File_DvDif::File_DvDif()
Speed_FrameCount_Stts_Fluctuation=0;
Speed_FrameCount_system[0]=0;
Speed_FrameCount_system[1]=0;
FrameIsNotFake=false;
FSC_WasSet_Sum=0;
FSC_WasNotSet_Sum=0;
AbstBf_Current=(0x7FFFFF)<<1;
Expand Down
1 change: 1 addition & 0 deletions Source/MediaInfo/Multiple/File_DvDif.h
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ protected :
Ztring Speed_RecDateZ_First;
Ztring Speed_RecDateZ_Last;
Ztring Speed_RecDateZ_Current;
bool FrameIsNotFake;
std::vector<size_t> Video_STA_Errors; //Per STA type
std::vector<size_t> Video_STA_Errors_ByDseq; //Per Dseq & STA type
std::vector<size_t> Video_STA_Errors_Total; //Per STA type
Expand Down
69 changes: 64 additions & 5 deletions Source/MediaInfo/Multiple/File_DvDif_Analysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,8 @@ void File_DvDif::Read_Buffer_Continue()
Speed_RecDate_Current.Years =Years;
Speed_RecDate_Current.IsValid =true;
}
if (!FrameIsNotFake)
FrameIsNotFake=true;
}
}

Expand Down Expand Up @@ -330,6 +332,8 @@ void File_DvDif::Read_Buffer_Continue()
Speed_RecTime_Current.Time.Hours =Hours;
Speed_RecTime_Current.IsValid =true;
}
if (!FrameIsNotFake)
FrameIsNotFake=true;
}
}
}
Expand Down Expand Up @@ -395,9 +399,9 @@ void File_DvDif::Read_Buffer_Continue()
+ ((Buffer[Buffer_Offset+3+Pos+3]&0x0F) ) ;
int8u Years =((Buffer[Buffer_Offset+3+Pos+4]&0xF0)>>4)*10
+ ((Buffer[Buffer_Offset+3+Pos+4]&0x0F) ) ;
if (Years<100
&& Months<=12
&& Days <=31)
if (Years<=99
&& Months && Months<=12
&& Days && Days<=31)
{
if (Speed_RecDate_Current.IsValid
&& Speed_RecDate_Current.Days !=Days
Expand All @@ -413,6 +417,8 @@ void File_DvDif::Read_Buffer_Continue()
Speed_RecDate_Current.Years =Years;
Speed_RecDate_Current.IsValid =true;
}
if (!FrameIsNotFake)
FrameIsNotFake=true;
}
}

Expand Down Expand Up @@ -447,6 +453,8 @@ void File_DvDif::Read_Buffer_Continue()
Speed_RecTime_Current.Time.Hours =Hours;
Speed_RecTime_Current.IsValid =true;
}
if (!FrameIsNotFake)
FrameIsNotFake=true;
}
}

Expand Down Expand Up @@ -481,6 +489,8 @@ void File_DvDif::Read_Buffer_Continue()
Captions_Flags.set(Caption_ParityIssueAny);
}
}
if (!FrameIsNotFake)
FrameIsNotFake=true;
}
}
}
Expand Down Expand Up @@ -532,8 +542,9 @@ void File_DvDif::Read_Buffer_Continue()
+ ((Buffer[Buffer_Offset+3+3]&0x0F) ) ;
int8u Years =((Buffer[Buffer_Offset+3+4]&0xF0)>>4)*10
+ ((Buffer[Buffer_Offset+3+4]&0x0F) ) ;
if (Months<=12
&& Days <=31)
if (Years<=99
&& Months && Months<=12
&& Days && Days<=31)
{
if (Speed_RecDate_Current.IsValid
&& Speed_RecDate_Current.Days !=Days
Expand All @@ -549,6 +560,8 @@ void File_DvDif::Read_Buffer_Continue()
Speed_RecDate_Current.Years =Years;
Speed_RecDate_Current.IsValid =true;
}
if (!FrameIsNotFake)
FrameIsNotFake=true;
}
}

Expand Down Expand Up @@ -583,6 +596,8 @@ void File_DvDif::Read_Buffer_Continue()
Speed_RecTime_Current.Time.Hours =Hours;
Speed_RecTime_Current.IsValid =true;
}
if (!FrameIsNotFake)
FrameIsNotFake=true;
}
}

Expand Down Expand Up @@ -637,7 +652,39 @@ void File_DvDif::Read_Buffer_Continue()
BlockStatus[(File_Offset+Buffer_Offset-Speed_FrameCount_StartOffset)/80]=BlockStatus_OK;
}
else
{
BlockStatus[(File_Offset+Buffer_Offset-Speed_FrameCount_StartOffset)/80]=BlockStatus_OK;
if (!FrameIsNotFake)
{
if (QU==(int8u)-1)
{
//Let's wait
}
else
{
switch (QU)
{
case 0: //16-bit
{
for (size_t i=8; i<80; i+=2)
{
int16s Value=(int16s)BigEndian2int16u(Buffer+Buffer_Offset+i);
if (Value<=-8 || Value>=8)
{
FrameIsNotFake=true;
break;
}
}
}
break;
//TODO: check 0 and -1 for 12-bit
defaut:
FrameIsNotFake=true;
break;
}
}
}
}
}
}
break;
Expand Down Expand Up @@ -683,6 +730,15 @@ void File_DvDif::Read_Buffer_Continue()
uint8_t Dseq=Buffer[Buffer_Offset+1]>>4;
Video_STA_Errors_ByDseq[(Dseq<<4)|STA_Error]++;
}
if (!FrameIsNotFake)
FrameIsNotFake=true;
}
else
{
//Looking for empty video
static const unsigned char EmptyVideoTemplate[]={0xD1, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xD1, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xD1, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xD1, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x26, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
if (!FrameIsNotFake && memcmp(Buffer+Buffer_Offset+4, EmptyVideoTemplate, sizeof(EmptyVideoTemplate)))
FrameIsNotFake=true;
}
BlockStatus[(File_Offset+Buffer_Offset-Speed_FrameCount_StartOffset)/80]=STA_Error?BlockStatus_NOK:BlockStatus_OK;
}
Expand Down Expand Up @@ -1882,6 +1938,8 @@ void File_DvDif::Errors_Stats_Update()
Event1.BlockStatus=BlockStatus;
Event1.AbstBf=AbstBf_Current;
Event1.MoreFlags=MoreFlags;
if (!FrameIsNotFake)
Event1.MoreFlags|=1<<3;
if (MoreData)
{
Event1.MoreData=MoreData-sizeof(size_t);
Expand Down Expand Up @@ -1983,6 +2041,7 @@ void File_DvDif::Errors_Stats_Update()
Speed_Arb_Current.Clear();
Speed_FrameCount++;
Speed_FrameCount_system[system]++;
FrameIsNotFake=false;
REC_IsValid=false;
DirectionSpeed.clear();
audio_source_mode.clear();
Expand Down