Skip to content

Commit

Permalink
Merge pull request #329 from JeromeMartinez/Info
Browse files Browse the repository at this point in the history
New --info option
  • Loading branch information
JeromeMartinez authored Jan 3, 2021
2 parents 2d5501b + 409f18a commit 602b054
Show file tree
Hide file tree
Showing 13 changed files with 144 additions and 66 deletions.
15 changes: 12 additions & 3 deletions Project/GNU/CLI/test/paddingbits.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,23 @@ Features/AV_Package/818_DCDM_P3_IA_FIC_000918/818_OV 1 pass --all
Features/AV_Package/818_DCDM_P3_IA_FIC_000918/818_OV 1 fail --check --no-check-padding
Features/AV_Package/818_DCDM_P3_IA_FIC_000918/818_OV 1 pass --check --no-check-padding --quick-check-padding
Features/HashCheck/HashTest_BuggyFileHash.mkv X pass --check --no-hash
Features/HashCheck/HashTest_BuggyHashInternal.mkv X pass --check --no-hash
Features/HashCheck/HashTest_BuggyHashInternal_BuggyFileHash.mkv X pass --check --no-hash
Features/HashCheck/HashTest_BuggyHashInternal_FileHash.mkv X pass --check --no-hash
Features/HashCheck/HashTest_BuggyHashInternal.mkv X fail --check --no-hash
Features/HashCheck/HashTest_BuggyHashInternal_BuggyFileHash.mkv X fail --check --no-hash
Features/HashCheck/HashTest_BuggyHashInternal_FileHash.mkv X fail --check --no-hash
Features/HashCheck/HashTest_FileHash.mkv X pass --check --no-hash
Features/HashCheck/HashTest_HashInternal.mkv X pass --check --no-hash
Features/HashCheck/HashTest_HashInternal_BuggyFileHash.mkv X pass --check --no-hash
Features/HashCheck/HashTest_HashInternal_FileHash.mkv X pass --check --no-hash
Features/HashCheck/HashTest_NoHash.mkv X pass --check --no-hash
Features/HashCheck/HashTest_BuggyFileHash.mkv X pass --check --info
Features/HashCheck/HashTest_BuggyHashInternal.mkv X fail --check --info
Features/HashCheck/HashTest_BuggyHashInternal_BuggyFileHash.mkv X fail --check --info
Features/HashCheck/HashTest_BuggyHashInternal_FileHash.mkv X fail --check --info
Features/HashCheck/HashTest_FileHash.mkv X pass --check --info
Features/HashCheck/HashTest_HashInternal.mkv X pass --check --info
Features/HashCheck/HashTest_HashInternal_BuggyFileHash.mkv X pass --check --info
Features/HashCheck/HashTest_HashInternal_FileHash.mkv X pass --check --info
Features/HashCheck/HashTest_NoHash.mkv X pass --check --info
Features/HashCheck/HashTest_BuggyFileHash.mkv X pass --check
Features/HashCheck/HashTest_BuggyHashInternal.mkv X fail --check
Features/HashCheck/HashTest_BuggyHashInternal_BuggyFileHash.mkv X fail --check
Expand Down
26 changes: 25 additions & 1 deletion Source/CLI/Global.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ int global::SetCheck(bool Value)
{
Actions.set(Action_Check, Value);
Actions.set(Action_CheckOptionIsSet);
if (Value)
return SetDecode(false);
return 0;
}

Expand Down Expand Up @@ -152,6 +154,15 @@ int global::SetEncode(bool Value)
return 0;
}

//---------------------------------------------------------------------------
int global::SetInfo(bool Value)
{
Actions.set(Action_Info, Value);
if (Value)
return SetDecode(false);
return 0;
}

//---------------------------------------------------------------------------
int global::SetFrameMd5(bool Value)
{
Expand All @@ -170,13 +181,14 @@ int global::SetFrameMd5FileName(const char* FileName)
int global::SetHash(bool Value)
{
Actions.set(Action_Hash, Value);
Actions.set(Action_HashOptionIsSet);
return 0;
}

//---------------------------------------------------------------------------
int global::SetAll(bool Value)
{
if (int ReturnValue = SetInfo(Value))
return ReturnValue;
if (int ReturnValue = (Value?SetCheck(true):SetQuickCheck())) // Never implicitely set no check
return ReturnValue;
if (int ReturnValue = (Value && SetCheckPadding(Value))) // Never implicitely set no check padding
Expand Down Expand Up @@ -543,6 +555,12 @@ int global::ManageCommandLine(const char* argv[], int argc)
if (Value)
return Value;
}
else if (strcmp(argv[i], "--info") == 0)
{
int Value = SetInfo(true);
if (Value)
return Value;
}
else if ((strcmp(argv[i], "--license") == 0 || strcmp(argv[i], "--licence") == 0))
{
if (i + 1 == argc)
Expand Down Expand Up @@ -593,6 +611,12 @@ int global::ManageCommandLine(const char* argv[], int argc)
if (Value)
return Value;
}
else if (strcmp(argv[i], "--no-info") == 0)
{
int Value = SetInfo(false);
if (Value)
return Value;
}
else if (strcmp(argv[i], "--none") == 0)
{
int Value = SetAll(false);
Expand Down
1 change: 1 addition & 0 deletions Source/CLI/Global.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ class global
int SetConch(bool Value);
int SetDecode(bool Value);
int SetEncode(bool Value);
int SetInfo(bool Value);
int SetFrameMd5(bool Value);
int SetFrameMd5FileName(const char* FileName);
int SetHash(bool Value);
Expand Down
41 changes: 20 additions & 21 deletions Source/CLI/Help.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,18 +110,19 @@ ReturnValue Help(const char* Name)
cout << endl;
cout << "ACTIONS" << endl;
cout << " --all" << endl;
cout << " Same as --decode --encode --hash --conch --coherency" << endl;
cout << " --check-padding --check"<< endl;
cout << " Same as --info --decode --encode --hash --conch" << endl;
cout << " --coherency --check-padding --check"<< endl;
cout << " --none" << endl;
cout << " Same as --no-decode --no-encode --no-hash --no-conch" << endl;
cout << " --no-coherency --quick-check" << endl;
cout << " Same as --no-info --no-decode --no-encode --no-hash" << endl;
cout << " --no-conch --no-coherency --quick-check-padding --quick-check" << endl;
cout << endl;
cout << " --check" << endl;
cout << " Check that the encoded file can be correctly decoded." << endl;
cout << " If input is raw content, encode then decode input and check" << endl;
cout << " that output is same as the input content." << endl;
cout << " If input is compressed content, decode input and check" << endl;
cout << " that output is same as the decoded content." << endl;
cout << " If input is raw content, encode then check that output" << endl;
cout << " would be same as the input content." << endl;
cout << " If input is compressed content, check that output" << endl;
cout << " would be same as the original content." << endl;
cout << " Disable decoding." << endl;
cout << " --quick-check" << endl;
cout << " Do quick coherency checks of the encoded file." << endl;
cout << " It permits to check that the file seems healthy" << endl;
Expand All @@ -131,6 +132,14 @@ ReturnValue Help(const char* Name)
cout << " --no-check" << endl;
cout << " Don't do checks (see above)." << endl;
cout << endl;
cout << " --info" << endl;
cout << " Provide some extra information about the compresssed file," << endl;
cout << " for example the presence of hash of the raw data." << endl;
cout << " Disable decoding." << endl;
cout << " --no-info" << endl;
cout << " Don't provide some extra information (see above)." << endl;
cout << " Is default (it may change in the future)" << endl;
cout << endl;
cout << " --check-padding" << endl;
cout << " Run padding checks. Be aware check function can be demanding" << endl;
cout << " of time and processor usage." << endl;
Expand Down Expand Up @@ -176,23 +185,13 @@ ReturnValue Help(const char* Name)
cout << " Don't encode (see above)." << endl;
cout << endl;
cout << " --hash" << endl;
cout << " Compute or test the hash of files." << endl;
cout << " Compute the hash of audio-visual RAW data files." << endl;
cout << " If input is raw content, do the hash and store hashes in RAWcooked" << endl;
cout << " metadata." << endl;
cout << " If an hash file is in the raw content, test that the hash file is" << endl;
cout << " valid." << endl;
cout << " If input is a Matroska container and RAWcooked metadata contains" << endl;
cout << " hashes decode input and check hashes (issue considered as decoding" << endl;
cout << " error)." << endl;
cout << " If input is a Matroska container and with hash files in" << endl;
cout << " attachment, decode input and check hashes (issue considered as" << endl;
cout << " invalid data)." << endl;
cout << " Is default if input is a Matroska container and RAWcooked metadata" << endl;
cout << " contains hashes or if input is a Matroska container and with hash" << endl;
cout << " files in attachment (it may change in the future)" << endl;
cout << " This permits a reversibility check without the original files." << endl;
cout << " --no-hash" << endl;
cout << " Don't do compute or test of hash of files. (see above)." << endl;
cout << " Is default if input is raw content (it may change in the future)" << endl;
cout << " Is default (it may change in the future)" << endl;
cout << endl;
cout << " --framemd5" << endl;
cout << " Compute the framemd5 of input frames and store it to a sidecar" << endl;
Expand Down
36 changes: 29 additions & 7 deletions Source/CLI/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -386,25 +386,47 @@ int ParseFile_Compressed(parse_info& ParseInfo)

matroska* M = new matroska(OutputDirectoryName, &Global.Mode, Ask_Callback, Thread_Pool, &Global.Errors);
M->Quiet = Global.Quiet;
M->NoWrite = Global.Actions[Action_Check] || !Global.Actions[Action_Decode];
M->NoOutputCheck = NoOutputCheck;
M->NoHashCheck = Global.Actions[Action_HashOptionIsSet] && !Global.Actions[Action_Hash];
if (ParseInfo.ParseFile_Input(*M))
{
ReturnValue = 1;
}
if (!HasCheckedReversibility && M->Hashes_FromRAWcooked)
HasCheckedReversibility = true;
else if (M->IsDetected())
{
if (!HasCheckedReversibility && M->Hashes_FromRAWcooked)
HasCheckedReversibility = true;

if (Global.Actions[Action_Info])
{
if (!M->RAWcooked_LibraryNameVersion_Get().empty())
{
cout << "\nInfo: Reversibility data created by " << M->RAWcooked_LibraryNameVersion_Get() << '.';
}
else
{
cout << "\nInfo: No reversibility data found.";
}
if (M->Hashes_FromRAWcooked)
{
cout << "\nInfo: Uncompressed file hashes (used by reversibility check) present.";
}
if (M->Hashes_FromAttachments && M->Hashes_FromAttachments->HashFiles_Count())
{
cout << "\nInfo: " << M->Hashes_FromAttachments->HashFiles_Count() << " hash file (used by conformance check) found.";
}
cout << endl;
}
}
delete M;
delete Thread_Pool;
}

// End
if (ParseInfo.IsDetected && !Global.Quiet)
{
if (!Global.Actions[Action_Check] && Global.Actions[Action_Decode])
if (Global.Actions[Action_Decode])
cout << "\nFiles are in " << OutputDirectoryName << '.' << endl;
else if (Global.Actions[Action_Check] && !Global.Errors.HasErrors())
if (Global.Actions[Action_Check] && !Global.Errors.HasErrors())
cout << '\n' << (HasCheckedReversibility ? "Reversability" : "Decoding") << " was checked, no issue detected." << endl;
}
if (Global.Actions[Action_Check] && Global.Errors.HasErrors())
Expand Down Expand Up @@ -550,7 +572,7 @@ int main(int argc, const char* argv[])

// Parse (check mode)
Global.Actions.set(Action_QuickCheckAfterEncode, !Global.Actions[Action_Check]);
Global.Actions.set(Action_Decode, true); // Override config
Global.Actions.set(Action_Decode, false); // Override config
Value = ParseFile_Compressed(ParseInfo);
if (!Value && !ParseInfo.IsDetected)
{
Expand Down
34 changes: 19 additions & 15 deletions Source/CLI/rawcooked.1
Original file line number Diff line number Diff line change
Expand Up @@ -92,17 +92,19 @@ Assume \fIno\fR as answer to all prompts, and run non-interactively.
.SS ACTIONS
.TP
.B --all
Same as --decode --encode --hash --conch --coherency --check-padding --check (see below)
Same as --info --decode --encode --hash --conch --coherency --check-padding --check (see below)
.TP
.B --none
Same as --no-decode --no-encode --no-hash --no-conch --no-coherency --quick-check (see below)
Same as --no-info --no-decode --no-encode --no-hash --no-conch --no-coherency --quick-check-padding --quick-check (see below)
.TP
.B --check
Check that the encoded file can be correctly decoded.
.br
If the input is raw content such as DPX, encode then decode the raw input, before checking that the original raw content and the decoded files are identical.
If input is raw content, encode then check that output would be same as the input content.
.br
If the input is a Matroska container, decode the input and check that the output is same as the decoded content.
If input is compressed content, check that output would be same as the original content.
.br
Disable decoding.
.TP
.B --quick-check
Do quick coherency checks of the encoded file. It permits to check that the file seems healthy without the time and processor usage of the full check.
Expand All @@ -116,6 +118,16 @@ Don't run any checks (see above).
.br
This is the default, but may change in the future.
.TP
.B --info
Provide extra information about the compresssed file, for example the presence of hash of the raw data.
.br
Disable decoding.
.TP
.B --no-info
Don't provide extra information (see above).
.br
This is the default, but may change in the future.
.TP
.B --check-padding
Run padding checks. Be aware check function can be demanding of time and processor usage.
.br
Expand Down Expand Up @@ -170,22 +182,14 @@ This is default.
Do not carry out encode (see above).
.TP
.B --hash
Can be used to either compute, or test, the hash of files.
Compute the hash of audio-visual RAW data files.
.br
To compute a hash use with the audio-visual RAW data. A hash is generated and stored in the RAWcooked metadata.
.br
Repeat the command with the RAW data to test that the previously generated hash file is valid.
.br
If the input is a Matroska container with metadata that contains computed hashes then decode the Matroska input and check hashes. Any issue raised by the check is considered a decoding error.
.br
If the input is a Matroska container with computed hash files stored in an attachment, then decode the Matroska input and check hashes. Any issue raised by the check is considered as invalid data.
.br
This is default when the input is a Matroska container and RAWcooked metadata contains hashes, and when the input is a Matroska container with hash files in the attachment. This default may change in the future.
This permits a reversibility check without the original files.
.TP
.B --no-hash
Do not compute or test the hash of the file (see above).
.br
This is default when the input is RAW content, but may change in the future.
This is default, but may change in the future.
.TP
.B --framemd5
Compute the framemd5 of input frames and store it to a sidecar file.
Expand Down
Loading

0 comments on commit 602b054

Please sign in to comment.