arcstk::v_1_0_0::Calculation class final

Checksum calculation for a requested checksum::type.

To calculate the checksum for a given entirety of samples, an appropriate CalcContext must be set and, optionally, a request for the checksum types to calculate.

The CalcContext is optionally configured with a TOC (for multitrack calculation) and configures the track bounds, if any. If the input is processed as a single track, the CalcContext configures whether it is the first or last track or an intermediate track.

Requesting the checksum types determines whether ARCSsv1 only or ARCSsv1 and ARCSsv2 are calculated. The checksum type can be skipped in which case Calculation will use ARCSv2 as default.

After context and requested types are set, update() must be called for each subsequent sample block until all samples declared in the CalcContext have been processed. After the last call of update(), a call of complete() can do a sanity check of the result().

Note that at least before processing the last block, the total number of samples must be known to the Calculation instance. The instance must be informed about this value either early in the process by the TOC, or, in case the TOC is incomplete, by a callback call of Calculation::update_audiosize() as soon as the total number of input samples is known. The caller is responsible for informing Calculation about the total number of input samples before the last call of update().

Constructors, destructors, conversion operators

Calculation(Calculation&& rhs) noexcept
Move constructor.
Calculation(const Calculation& rhs)
Copy constructor.
Calculation(const checksum::type type, std::unique_ptr<CalcContext> ctx)
Construct calculation for specified checksum type and context.
Calculation(std::unique_ptr<CalcContext> ctx) explicit
Construct calculation for specified context with checksum::type::ARCS2.
~Calculation() noexcept
Default destructor.

Public functions

auto complete() const -> bool noexcept
Returns TRUE iff this Calculation is completed, otherwise FALSE.
auto context() const -> const CalcContext& noexcept
Read the CalcContext of this instance.
auto result() const -> Checksums noexcept
Acquire the resulting Checksums.
auto samples_expected() const -> int64_t noexcept
Returns the total number of expected PCM 32 bit samples.
auto samples_processed() const -> int64_t noexcept
Returns the total number for PCM 32 bit samples yet processed.
auto samples_todo() const -> int64_t noexcept
Returns the total number of PCM 32 bit samples that is yet to be processed.
void set_context(std::unique_ptr<CalcContext> context) noexcept
Set the stream context for the current stream of samples.
auto type() const -> checksum::type noexcept
Returns current type requested.
void update(SampleInputIterator begin, SampleInputIterator end)
Update the calculation with a sequence of samples.
void update_audiosize(const AudioSize& audiosize)
Updates the instance with a new AudioSize.

Function documentation

arcstk::v_1_0_0::Calculation::Calculation(Calculation&& rhs) noexcept

Move constructor.

Parameters
rhs in The Calculation to move

arcstk::v_1_0_0::Calculation::Calculation(const Calculation& rhs)

Copy constructor.

Parameters
rhs in The Calculation to copy

arcstk::v_1_0_0::Calculation::Calculation(const checksum::type type, std::unique_ptr<CalcContext> ctx)

Construct calculation for specified checksum type and context.

Parameters
type in The checksum type to calculate
ctx in The context for this calculation

arcstk::v_1_0_0::Calculation::Calculation(std::unique_ptr<CalcContext> ctx) explicit

Construct calculation for specified context with checksum::type::ARCS2.

Parameters
ctx in The context for this calculation

bool arcstk::v_1_0_0::Calculation::complete() const noexcept

Returns TRUE iff this Calculation is completed, otherwise FALSE.

Returns TRUE if the Calculation is completed, otherwise FALSE

FALSE indicates that the instance expects more updates. If the instance returns TRUE it is safe to call result().

const CalcContext& arcstk::v_1_0_0::Calculation::context() const noexcept

Read the CalcContext of this instance.

Returns The CalcContext of this instance

Checksums arcstk::v_1_0_0::Calculation::result() const noexcept

Acquire the resulting Checksums.

Returns The computed Checksums

int64_t arcstk::v_1_0_0::Calculation::samples_expected() const noexcept

Returns the total number of expected PCM 32 bit samples.

Returns Total number of PCM 32 bit samples expected.

This is just for debugging.

int64_t arcstk::v_1_0_0::Calculation::samples_processed() const noexcept

Returns the total number for PCM 32 bit samples yet processed.

Returns Total number of PCM 32 bit samples processed.

This is just for debugging.

int64_t arcstk::v_1_0_0::Calculation::samples_todo() const noexcept

Returns the total number of PCM 32 bit samples that is yet to be processed.

Returns Total number of PCM 32 bit samples yet to process.

This value is equivalent to samples_expected() - samples_processed().

This is just for debugging.

void arcstk::v_1_0_0::Calculation::set_context(std::unique_ptr<CalcContext> context) noexcept

Set the stream context for the current stream of samples.

Parameters
context in The CalcContext for this instance

checksum::type arcstk::v_1_0_0::Calculation::type() const noexcept

Returns current type requested.

Returns A disjunction of all requested types.

void arcstk::v_1_0_0::Calculation::update(SampleInputIterator begin, SampleInputIterator end)

Update the calculation with a sequence of samples.

Parameters
begin in Iterator pointing to the first sample of the sequence
end in Iterator pointing behind the last sample of the sequence

void arcstk::v_1_0_0::Calculation::update_audiosize(const AudioSize& audiosize)

Updates the instance with a new AudioSize.

Parameters
audiosize in The updated AudioSize

This must be done before the last call of update().