Checksum Calculation module

Public API for checksum calculation.

An API to calculate different types of checksums for CDDA conforming audio tracks.

A Calculation represents a (stateful) concrete checksum calculation that must be configured with a CalcContext specific to the input audio file and a checksum::type that specifies the calculation algorithm. The input of the audio file must be represented as a succession of iterable SampleSequences and the Calculation is sequentially updated with these sequences in order. After the last update, the Calculation returns the calculation result on request. The calculated Checksums are represented as an iterable aggregate of ChecksumSets.

A Checksum refers to a particular track and a particular checksum::type.

ChecksumSet is a set of Checksums of different checksum::types of the same track.

Checksums represent a calculation result for all requested checksum types and all tracks of the audio input. It is an aggregation of the ChecksumSets for each track of an respective audio input. Depending on the input, it can represent either an entire album or a single track.

Considering the input of a Calculation, a CalcContext represents the per-file metadata information that is used during calculation. The CalcContext informs the Calculation about technical aspects like the encoding of the samples and the channel order, and as well about semantic aspects like the precise track bounds and the total number of samples.

SampleInputIterator wraps the concrete iterator of the input sample sequence so any class with a compatible iterator can be used for generating the audio input.

AudioSize represents the size of the audio input in frames, samples or bytes.

The CDDA constants provide some CDDA-related constants that are frequently reused throughout the code.

Namespaces

namespace arcstk::v_1_0_0::checksum
Everything regarding operation with Checksums.

Classes

class arcstk::v_1_0_0::AudioSize
Uniform access to the size of the input audio information.
class arcstk::v_1_0_0::CalcContext
Interface for information about the current audio input.
class arcstk::v_1_0_0::Calculation
Checksum calculation for a requested checksum::type.
struct arcstk::v_1_0_0::CDDA
Constants related to the CDDA format.
class arcstk::v_1_0_0::Checksum
An AccurateRip checksum for a single file or track.
class arcstk::v_1_0_0::Checksums
The result of a Calculation, an iterable list of ChecksumSets.
class arcstk::v_1_0_0::ChecksumSet
A set of Checksum instances of different types for a single track.
class arcstk::v_1_0_0::SampleInputIterator
Type erasing interface for iterators over PCM 32 bit samples.
template<typename T, bool is_planar>
class arcstk::v_1_0_0::SampleSequence
A sequence of samples represented by 16 or 32 bit integral types.

Typedefs

template<typename T>
using InterleavedSamples = SampleSequence<T, false>
Interleaved sample sequence with samples of type T.
using lba_count_t = int32_t
Type to represent amounts of LBA frames.
template<typename T>
using PlanarSamples = SampleSequence<T, true>
Planar sample sequence with samples of type T.
using sample_count_t = int32_t
Type to represent amounts of PCM 32 bit samples.
using sample_t = uint32_t
Type to represent a 32 bit PCM stereo sample.
using TrackNo = int
Type to represent 1-based track numbers.

Functions

auto make_context(const bool& skip_front, const bool& skip_back) -> std::unique_ptr<CalcContext>
Create a CalcContext from two skip flags.
auto make_context(const bool& skip_front, const bool& skip_back, const std::string& audiofilename) -> std::unique_ptr<CalcContext>
Create a CalcContext from an audio filename and two skip flags.
auto make_context(const std::unique_ptr<TOC>& toc) -> std::unique_ptr<CalcContext>
Create a CalcContext from a TOC.
auto make_context(const std::unique_ptr<TOC>& toc, const std::string& audiofilename) -> std::unique_ptr<CalcContext>
Create a CalcContext from an audio filename and a TOC.
auto make_context(const TOC& toc) -> std::unique_ptr<CalcContext>
Create a CalcContext from a TOC.
auto make_context(const TOC& toc, const std::string& audiofilename) -> std::unique_ptr<CalcContext>
Create a CalcContext from an audio filename and a TOC.

Variables

const Checksum EmptyChecksum
Global instance of an empty Checksum.

Typedef documentation

template<typename T>
using InterleavedSamples = SampleSequence<T, false>

Interleaved sample sequence with samples of type T.

An interleaved sequence has one input buffer, in which the samples for each channel occurr in order.

T can only be some signed or unsigned integral type of either 16 or 32 bit width.

using lba_count_t = int32_t

Type to represent amounts of LBA frames.

A signed integer of at least 32 bit length.

The type is required to be able to express the maximum frame count in a medium. The value is CDDA::MAX_BLOCK_ADDRESS == 449.999 frames.

The type is intended to perform arithmetic operations on it.

template<typename T>
using PlanarSamples = SampleSequence<T, true>

Planar sample sequence with samples of type T.

A planar sequence has two separated input buffers, one for each channel.

T can only be some signed or unsigned integral type of either 16 or 32 bit width.

using sample_count_t = int32_t

Type to represent amounts of PCM 32 bit samples.

A signed integer of at least 32 bit length.

The type is required to express the maximum sample count in a medium, which is MAX_BLOCK_ADDRESS * SAMPLES_PER_FRAME == 264.599.412 samples.

The type is intended to perform arithmetic operations on it.

using sample_t = uint32_t

Type to represent a 32 bit PCM stereo sample.

An unsigned integer of 32 bit length.

The type is not intended to do arithmetic operations on it.

Bitwise operators are required to work as on unsigned types.

using TrackNo = int

Type to represent 1-based track numbers.

A signed integer type.

Valid track numbers are in the range of 1-99. Note that 0 is not a valid TrackNo. Hence, a TrackNo is not suitable to represent a total number of tracks or a counter for tracks.

The intention of this typedef is to provide a marker for parameters that expect 1-based track numbers instead of 0-based track indices. TrackNo will not occurr as a return type in the API.

A validation check is not provided, though. Every function that accepts a TrackNo will in fact accept 0 but will then either throw or return a default error value.

It is not encouraged to use TrackNo in client code.

Function documentation

std::unique_ptr<CalcContext> make_context(const bool& skip_front, const bool& skip_back)

Create a CalcContext from two skip flags.

Parameters
skip_front in Tell wether to skip the front samples
skip_back in Tell wether to skip the back samples
Returns CalcContext for the input

This addresses a situation where a single track has to be checksummed.

std::unique_ptr<CalcContext> make_context(const bool& skip_front, const bool& skip_back, const std::string& audiofilename)

Create a CalcContext from an audio filename and two skip flags.

Parameters
skip_front in Tell wether to skip the front samples
skip_back in Tell wether to skip the back samples
audiofilename in The name of the audiofile
Returns CalcContext for the input

This addresses a situation where a single track has to be checksummed.

The file will not be opened, it is just declared as part of the metadata.

std::unique_ptr<CalcContext> make_context(const std::unique_ptr<TOC>& toc)

Create a CalcContext from a TOC.

Parameters
toc in The TOC to use
Returns CalcContext for the input

std::unique_ptr<CalcContext> make_context(const std::unique_ptr<TOC>& toc, const std::string& audiofilename)

Create a CalcContext from an audio filename and a TOC.

Parameters
toc in The TOC to use
audiofilename in The name of the audiofile, empty be default
Returns CalcContext for the input

The file will not be opened, it is just declared as part of the metadata.

std::unique_ptr<CalcContext> make_context(const TOC& toc)

Create a CalcContext from a TOC.

Parameters
toc in The TOC to use
Returns CalcContext for the input

std::unique_ptr<CalcContext> make_context(const TOC& toc, const std::string& audiofilename)

Create a CalcContext from an audio filename and a TOC.

Parameters
toc in The TOC to use
audiofilename in The name of the audiofile, empty be default
Returns CalcContext for the input

The file will not be opened, it is just declared as part of the metadata.

Variable documentation

const Checksum EmptyChecksum

Global instance of an empty Checksum.

This is for convenience since in most cases, the creation of an empty Checksum can be avoided when a reference instance is at hand.

This instance defines emptyness for checksums since Checksum::empty() just compares the instance with this instance.