diff --git a/Source/Lib/CoDec/FFV1/FFV1_Frame.cpp b/Source/Lib/CoDec/FFV1/FFV1_Frame.cpp index 2fad72a7..f5da10d0 100644 --- a/Source/Lib/CoDec/FFV1/FFV1_Frame.cpp +++ b/Source/Lib/CoDec/FFV1/FFV1_Frame.cpp @@ -224,7 +224,7 @@ bool ffv1_frame::Process(const uint8_t* Buffer, size_t Buffer_Size) RawFrame->Finalize(P.num_h_slices, P.num_v_slices); - return false; + return P.Error() ? true : false; } //*************************************************************************** @@ -232,9 +232,9 @@ bool ffv1_frame::Process(const uint8_t* Buffer, size_t Buffer_Size) //*************************************************************************** //--------------------------------------------------------------------------- -const char* ffv1_frame::ErrorMessage() +const char* ffv1_frame::ErrorMessage() const { - return P.error_message; + return P.Error(); } //*************************************************************************** diff --git a/Source/Lib/CoDec/FFV1/FFV1_Frame.h b/Source/Lib/CoDec/FFV1/FFV1_Frame.h index bf6ede1d..44c9afc6 100644 --- a/Source/Lib/CoDec/FFV1/FFV1_Frame.h +++ b/Source/Lib/CoDec/FFV1/FFV1_Frame.h @@ -39,7 +39,7 @@ class ffv1_frame raw_frame* RawFrame; // Error message - const char* ErrorMessage(); + const char* ErrorMessage() const; private: // Parameters diff --git a/Source/Lib/CoDec/FFV1/FFV1_Parameters.cpp b/Source/Lib/CoDec/FFV1/FFV1_Parameters.cpp index c01b73a4..ad240990 100644 --- a/Source/Lib/CoDec/FFV1/FFV1_Parameters.cpp +++ b/Source/Lib/CoDec/FFV1/FFV1_Parameters.cpp @@ -182,6 +182,26 @@ bool parameters::Parse(rangecoder& E, bool ConfigurationRecord_IsPresent) return false; } +//--------------------------------------------------------------------------- +bool parameters::Error(const char* Error) +{ + const char* expected = nullptr; + error_message.compare_exchange_strong( + expected, + Error, + std::memory_order_release, + std::memory_order_relaxed + ); + + return true; +} + +//--------------------------------------------------------------------------- +const char* parameters::Error() const +{ + return error_message.load(std::memory_order_acquire); +} + //--------------------------------------------------------------------------- bool parameters::QuantizationTableSet(rangecoder& E, size_t i) { diff --git a/Source/Lib/CoDec/FFV1/FFV1_Parameters.h b/Source/Lib/CoDec/FFV1/FFV1_Parameters.h index 81a81e48..00569e18 100644 --- a/Source/Lib/CoDec/FFV1/FFV1_Parameters.h +++ b/Source/Lib/CoDec/FFV1/FFV1_Parameters.h @@ -13,6 +13,7 @@ #include "Lib/CoDec/FFV1/FFV1_RangeCoder.h" #include "Lib/CoDec/FFV1/Coder/FFV1_Coder_RangeCoder.h" #include "Lib/CoDec/FFV1/Coder/FFV1_Coder.h" +#include #include using namespace std; //--------------------------------------------------------------------------- @@ -32,7 +33,8 @@ struct parameters // Run bool Parse(rangecoder& E, bool ConfigurationRecord_IsPresent); - bool Error(const char* Error) { error_message = Error; return true; } + bool Error(const char* Error); + const char* Error() const; // Common content uint32_t version; @@ -67,7 +69,7 @@ struct parameters bool IsOverflow16bit; // Error message - const char* error_message = nullptr; + std::atomic error_message = { nullptr }; private: bool QuantizationTableSet(rangecoder& E, size_t i); diff --git a/Source/Lib/CoDec/FFV1/FFV1_Slice.cpp b/Source/Lib/CoDec/FFV1/FFV1_Slice.cpp index 550f15d9..e5071a40 100644 --- a/Source/Lib/CoDec/FFV1/FFV1_Slice.cpp +++ b/Source/Lib/CoDec/FFV1/FFV1_Slice.cpp @@ -246,7 +246,7 @@ bool slice::Parse() // CRC check if (P->ec == 1 && ZenCRC32(Buffer, Buffer_Size)) - return P->Error("FFV1-SLICE-slice_crc_parity:1"); + P->Error("FFV1-SLICE-slice_crc_parity:1"); // We do not stop here, to try to decode the slice anyway // RangeCoder reset Buffer_Size -= P->TailSize; diff --git a/Source/Lib/CoDec/Wrapper.cpp b/Source/Lib/CoDec/Wrapper.cpp index 876136d5..212938e8 100644 --- a/Source/Lib/CoDec/Wrapper.cpp +++ b/Source/Lib/CoDec/Wrapper.cpp @@ -80,8 +80,8 @@ class ffv1_wrapper : public video_wrapper void SetHeight(uint32_t Height); // Actions - void Process(const uint8_t* Data, size_t Size); - void OutOfBand(const uint8_t* Data, size_t Size); + bool Process(const uint8_t* Data, size_t Size); + bool OutOfBand(const uint8_t* Data, size_t Size); private: ffv1_frame* Ffv1Frame; @@ -112,18 +112,19 @@ void ffv1_wrapper::SetHeight(uint32_t Height) } //--------------------------------------------------------------------------- -void ffv1_wrapper::Process(const uint8_t* Data, size_t Size) +bool ffv1_wrapper::Process(const uint8_t* Data, size_t Size) { Ffv1Frame->RawFrame = RawFrame; - Ffv1Frame->Process(Data, Size); + auto Value = Ffv1Frame->Process(Data, Size); RawFrame->Process(); + return Value; } //--------------------------------------------------------------------------- -void ffv1_wrapper::OutOfBand(const uint8_t* Data, size_t Size) +bool ffv1_wrapper::OutOfBand(const uint8_t* Data, size_t Size) { Ffv1Frame->RawFrame = RawFrame; - Ffv1Frame->OutOfBand(Data, Size); + return Ffv1Frame->OutOfBand(Data, Size); } //--------------------------------------------------------------------------- @@ -134,8 +135,8 @@ class flac_wrapper : public audio_wrapper ~flac_wrapper(); // Actions - void OutOfBand(const uint8_t* Data, size_t Size) { return Process(Data, Size); } - void Process(const uint8_t* Data, size_t Size); + bool OutOfBand(const uint8_t* Data, size_t Size) { return Process(Data, Size); } + bool Process(const uint8_t* Data, size_t Size); // libFLAC related helping functions void FLAC_Read(uint8_t buffer[], size_t* bytes); @@ -200,7 +201,7 @@ flac_wrapper::~flac_wrapper() FLAC__stream_decoder_delete(Decoder_); } -void flac_wrapper::Process(const uint8_t* Data, size_t Size) +bool flac_wrapper::Process(const uint8_t* Data, size_t Size) { Data_ = Data; Size_ = Size; @@ -208,12 +209,12 @@ void flac_wrapper::Process(const uint8_t* Data, size_t Size) for (;;) { if (!FLAC__stream_decoder_process_single(Decoder_)) - break; + return true; FLAC__uint64 Pos; if (!FLAC__stream_decoder_get_decode_position(Decoder_, &Pos)) - break; + return true; if (Pos == absolute_byte_offset_) - break; + return false; } } @@ -376,14 +377,14 @@ class pcm_wrapper : public audio_wrapper { public: // Actions - void Process(const uint8_t* Data, size_t Size); + bool Process(const uint8_t* Data, size_t Size); }; //--------------------------------------------------------------------------- -void pcm_wrapper::Process(const uint8_t* Data, size_t Size) +bool pcm_wrapper::Process(const uint8_t* Data, size_t Size) { RawFrame->AssignBufferView(Data, Size); - RawFrame->Process(); + return RawFrame->Process(); } //--------------------------------------------------------------------------- diff --git a/Source/Lib/CoDec/Wrapper.h b/Source/Lib/CoDec/Wrapper.h index 0eae19e2..bb48a4c3 100644 --- a/Source/Lib/CoDec/Wrapper.h +++ b/Source/Lib/CoDec/Wrapper.h @@ -33,8 +33,8 @@ class base_wrapper virtual ~base_wrapper() {} // Actions - virtual void Process(const uint8_t* Data, size_t Size) = 0; - inline virtual void OutOfBand(const uint8_t* /*Data*/, size_t /*Size*/) {}; + virtual bool Process(const uint8_t* Data, size_t Size) = 0; + inline virtual bool OutOfBand(const uint8_t* /*Data*/, size_t /*Size*/) { return true; }; public: raw_frame* RawFrame = nullptr; diff --git a/Source/Lib/Compressed/RAWcooked/Track.cpp b/Source/Lib/Compressed/RAWcooked/Track.cpp index 567b44ba..3cca6985 100644 --- a/Source/Lib/Compressed/RAWcooked/Track.cpp +++ b/Source/Lib/Compressed/RAWcooked/Track.cpp @@ -99,7 +99,12 @@ bool track_info::Process(const uint8_t* Data, size_t Size) Errors->Error(IO_FileChecker, error::type::Undecodable, (error::generic::code)filechecker_issue::undecodable::Format_Undetected, string()); return true; } - Wrapper->Process(Data, Size); + if (Wrapper->Process(Data, Size)) + { + string OutputFileName = ReversibilityData->Data(reversibility::element::FileName); + FormatPath(OutputFileName); + Errors->Error(IO_FileChecker, error::type::Undecodable, (error::generic::code)filechecker_issue::undecodable::Frame_Compressed_Issue, OutputFileName); + } if (ReversibilityData && !ReversibilityData->Unique()) { if (Actions[Action_Conch] || Actions[Action_Coherency]) diff --git a/Source/Lib/Uncompressed/HashSum/HashSum.cpp b/Source/Lib/Uncompressed/HashSum/HashSum.cpp index 6e123b04..e662170b 100644 --- a/Source/Lib/Uncompressed/HashSum/HashSum.cpp +++ b/Source/Lib/Uncompressed/HashSum/HashSum.cpp @@ -66,7 +66,7 @@ const char** ErrorTexts[] = static_assert(error::type_Max == sizeof(ErrorTexts) / sizeof(const char**), IncoherencyMessage); -} // filechecker_issue +} // hashes_issue //*************************************************************************** // Hashes diff --git a/Source/Lib/Utils/FileIO/FileChecker.cpp b/Source/Lib/Utils/FileIO/FileChecker.cpp index e33e08c4..b25ae7d2 100644 --- a/Source/Lib/Utils/FileIO/FileChecker.cpp +++ b/Source/Lib/Utils/FileIO/FileChecker.cpp @@ -24,6 +24,7 @@ namespace filechecker_issue { "extra attachments in source (missing attachments in compressed file)", "missing frame in compressed file", "extra frame in compressed file", + "frame (encoder can not decode it)", "missing frame in source (extra frames in compressed file)", "extra frame in source (missing frames in compressed file)", "track format (unsupported)", diff --git a/Source/Lib/Utils/FileIO/FileChecker.h b/Source/Lib/Utils/FileIO/FileChecker.h index 51b2b1e2..65018d84 100644 --- a/Source/Lib/Utils/FileIO/FileChecker.h +++ b/Source/Lib/Utils/FileIO/FileChecker.h @@ -29,6 +29,7 @@ namespace filechecker_issue Attachment_Source_Extra, Frame_Compressed_Missing, Frame_Compressed_Extra, + Frame_Compressed_Issue, Frame_Source_Missing, Frame_Source_Extra, Format_Undetected, diff --git a/Source/Lib/Utils/RawFrame/RawFrame.cpp b/Source/Lib/Utils/RawFrame/RawFrame.cpp index cf4977a3..fb95ca74 100644 --- a/Source/Lib/Utils/RawFrame/RawFrame.cpp +++ b/Source/Lib/Utils/RawFrame/RawFrame.cpp @@ -166,7 +166,7 @@ size_t raw_frame::TotalSize() const } //--------------------------------------------------------------------------- -void raw_frame::Process() +bool raw_frame::Process() { MergeIn(); In_.Clear(); @@ -176,6 +176,8 @@ void raw_frame::Process() Pre_.Clear(); Post_.Clear(); + + return false; } //--------------------------------------------------------------------------- diff --git a/Source/Lib/Utils/RawFrame/RawFrame.h b/Source/Lib/Utils/RawFrame/RawFrame.h index b4c4bb1c..60bc30be 100644 --- a/Source/Lib/Utils/RawFrame/RawFrame.h +++ b/Source/Lib/Utils/RawFrame/RawFrame.h @@ -247,7 +247,7 @@ class raw_frame size_t TotalSize() const; // Processing - void Process(); + bool Process(); raw_frame_process* FrameProcess = nullptr; void Finalize(size_t num_h_slices, size_t num_v_slices) { if (Finalize_Function) Finalize_Function(this, num_h_slices, num_v_slices); } void (*Finalize_Function)(raw_frame*, size_t, size_t) = nullptr;