Skip to content
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
6 changes: 3 additions & 3 deletions Source/Lib/CoDec/FFV1/FFV1_Frame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,17 +224,17 @@ 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;
}

//***************************************************************************
// Errors
//***************************************************************************

//---------------------------------------------------------------------------
const char* ffv1_frame::ErrorMessage()
const char* ffv1_frame::ErrorMessage() const
{
return P.error_message;
return P.Error();
}

//***************************************************************************
Expand Down
2 changes: 1 addition & 1 deletion Source/Lib/CoDec/FFV1/FFV1_Frame.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class ffv1_frame
raw_frame* RawFrame;

// Error message
const char* ErrorMessage();
const char* ErrorMessage() const;

private:
// Parameters
Expand Down
20 changes: 20 additions & 0 deletions Source/Lib/CoDec/FFV1/FFV1_Parameters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
6 changes: 4 additions & 2 deletions Source/Lib/CoDec/FFV1/FFV1_Parameters.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <atomic>
#include <cstring>
using namespace std;
//---------------------------------------------------------------------------
Expand All @@ -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;
Expand Down Expand Up @@ -67,7 +69,7 @@ struct parameters
bool IsOverflow16bit;

// Error message
const char* error_message = nullptr;
std::atomic<const char*> error_message = { nullptr };

private:
bool QuantizationTableSet(rangecoder& E, size_t i);
Expand Down
2 changes: 1 addition & 1 deletion Source/Lib/CoDec/FFV1/FFV1_Slice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
31 changes: 16 additions & 15 deletions Source/Lib/CoDec/Wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}

//---------------------------------------------------------------------------
Expand All @@ -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);
Expand Down Expand Up @@ -200,20 +201,20 @@ 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;

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;
}
}

Expand Down Expand Up @@ -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();
}

//---------------------------------------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions Source/Lib/CoDec/Wrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
7 changes: 6 additions & 1 deletion Source/Lib/Compressed/RAWcooked/Track.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down
2 changes: 1 addition & 1 deletion Source/Lib/Uncompressed/HashSum/HashSum.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ const char** ErrorTexts[] =

static_assert(error::type_Max == sizeof(ErrorTexts) / sizeof(const char**), IncoherencyMessage);

} // filechecker_issue
} // hashes_issue

//***************************************************************************
// Hashes
Expand Down
1 change: 1 addition & 0 deletions Source/Lib/Utils/FileIO/FileChecker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)",
Expand Down
1 change: 1 addition & 0 deletions Source/Lib/Utils/FileIO/FileChecker.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 3 additions & 1 deletion Source/Lib/Utils/RawFrame/RawFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ size_t raw_frame::TotalSize() const
}

//---------------------------------------------------------------------------
void raw_frame::Process()
bool raw_frame::Process()
{
MergeIn();
In_.Clear();
Expand All @@ -176,6 +176,8 @@ void raw_frame::Process()

Pre_.Clear();
Post_.Clear();

return false;
}

//---------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion Source/Lib/Utils/RawFrame/RawFrame.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down