AJA NTV2 SDK  17.5.0.1242
NTV2 SDK 17.5.0.1242
CNTV2CSCMatrix Class Reference

This class supports the color space conversion matrix described below. More...

#include <ntv2cscmatrix.h>

Public Member Functions

 CNTV2CSCMatrix (const NTV2ColorSpaceMatrixType inPreset=NTV2_Unity_Matrix)
 Instantiates and initializes the instance with a known set of coefficients. More...
 
virtual ~CNTV2CSCMatrix ()
 My destructor. More...
 
virtual void InitMatrix (const NTV2ColorSpaceMatrixType inPreset)
 Replace the current matrix coefficients with a known set of coefficients. More...
 
virtual double GetCoefficient (const NTV2CSCCoeffIndex inCoeffIndex) const
 Returns the value of a requested matrix coefficient. More...
 
virtual void SetCoefficient (const NTV2CSCCoeffIndex inCoeffIndex, const double inCoefficient)
 Changes the specified matrix coefficient to the given value. More...
 
virtual int16_t GetOffset (const NTV2CSCOffsetIndex inOffsetIndex) const
 Returns the value of a requested offset. More...
 
virtual void SetOffset (const NTV2CSCOffsetIndex inOffsetIndex, const int16_t inOffset)
 Changes the specified offset to the given value. More...
 
virtual void PreMultiply (const CNTV2CSCMatrix &inPreInstance)
 Pre-multiply the current 3x3 matrix by the matrix of the given instance. More...
 
virtual void PostMultiply (const CNTV2CSCMatrix &inPostInstance)
 Post-multiply the current 3x3 matrix by the matrix of the given instance. More...
 
virtual void SetGain (const double inGain0, const double inGain1, const double inGain2)
 Set the matrix diagonals (gains). More...
 
virtual void SetHueRotate (const double inDegrees)
 Set matrix for hue rotation. More...
 
virtual void SetPreOffsets (const int16_t inOffset0, const int16_t inOffset1, const int16_t inOffset2)
 Set pre-offsets. More...
 
virtual void AddPreOffsets (const int16_t inIncrement0, const int16_t inIncrement1, const int16_t inIncrement2)
 Add pre-offsets. More...
 
virtual void SetPostOffsets (const int16_t inOffsetA, const int16_t inOffsetB, const int16_t inOffsetC)
 Set post-offsets. More...
 
virtual void AddPostOffsets (const int16_t inIncrementA, const int16_t inIncrementB, const int16_t inIncrementC)
 Add post-offsets. More...
 
virtual bool IsUnityMatrix (void)
 Returns 'true' if this CSC Matrix has unity matrix coefficients. More...
 
virtual bool operator== (const CNTV2CSCMatrix &rhs) const
 Returns true if the matrix coefficients and offsets EXACTLY match those of the specified instance. More...
 
virtual bool operator!= (const CNTV2CSCMatrix &rhs) const
 Returns true if the matrix coefficients and offsets differ from those of the specified instance. More...
 
virtual bool IsEqual (const CNTV2CSCMatrix &inCSCMatrix, const double inMaxDiff=NTV2CSCMatrix_MaxCoeffDiff)
 Tests if the matrix coefficients can all be considered equal to those of the specified instance,. More...
 
virtual bool CoeffEqual (const double inCoeff1, const double inCoeff2, const double inMaxDiff)
 Tests if two coefficients differ by less than the fiven tolerance. More...
 

Detailed Description

This class supports the color space conversion matrix described below.

The CSC matrix consists of a pre-subtractor, a 3x3 matrix multiplier, and a post-adder. It receives up to three components as input (labeled Input0, Input1, and Input2), cross-processes them, and outputs them as OutputA, OutputB, OutputC. The standard component assignment for GBR and YCbCr video is: YCbCr RGB Input0 / OutputA = Y G Input1 / OutputB = Cb B Input2 / OutputC = Cr R

The basic purpose of the pre-subtractor is to remove any DC bias(es) that may be on the input video prior to the matrix multiply. For example, YCbCr video typically has a "black" offset of 0x10 for luminance (Y) and 0x80 for chrominance (Cb/Cr - values given for 8-bit video). In general, these offsets must be subtracted from the video before using the 3x3 matrix.

Similarly, the post-adder is typically used to re-add "black" biases to the output video. Note that both pre- and post-offsets are typically "positive" values, and assume a left-justified representation within a 16-bit integer. In the above example, Y Black offset would be 0x0800 (i.e. 0x10 with an added sign bit and ls-padded to 16 bits). Similarly, C Black Offset is 0x4000 (0x80 with a sign bit and ls-padded to 16 bits).

The 3x3 matrix coefficients are labeled according to the input (0, 1, or 2) and output (A, B, or C) they affect. For example, coefficient "A0" determines the amount of Input0 that is applied to OutputA. The matrix form of the equation can be represented as:

[OutA OutB OutC] = [In0 In1 In2] [ A0 B0 C0 A1 B1 C1 A2 B2 C2 ]

This class has methods for presetting known matrix values (for "typical" RGB <=> YUV conversions), as well as some typical "gain" and "hue rotation" matrices. It also includes methods for combining matrices for more complex effects, including matrix multiplication.

Definition at line 98 of file ntv2cscmatrix.h.

Constructor & Destructor Documentation

◆ CNTV2CSCMatrix()

CNTV2CSCMatrix::CNTV2CSCMatrix ( const NTV2ColorSpaceMatrixType  inPreset = NTV2_Unity_Matrix)
explicit

Instantiates and initializes the instance with a known set of coefficients.

Parameters
[in]inPresetSpecifies an initial setting for the matrix coefficients.

Definition at line 14 of file ntv2cscmatrix.cpp.

◆ ~CNTV2CSCMatrix()

virtual CNTV2CSCMatrix::~CNTV2CSCMatrix ( )
inlinevirtual

My destructor.

Definition at line 111 of file ntv2cscmatrix.h.

Member Function Documentation

◆ AddPostOffsets()

void CNTV2CSCMatrix::AddPostOffsets ( const int16_t  inIncrementA,
const int16_t  inIncrementB,
const int16_t  inIncrementC 
)
virtual

Add post-offsets.

Parameters
[in]inIncrementAThe amount to be added to the existing postOffsetA
[in]inIncrementBThe amount to be added to the existing postOffsetB
[in]inIncrementCThe amount to be added to the existing postOffsetC

Definition at line 573 of file ntv2cscmatrix.cpp.

◆ AddPreOffsets()

void CNTV2CSCMatrix::AddPreOffsets ( const int16_t  inIncrement0,
const int16_t  inIncrement1,
const int16_t  inIncrement2 
)
virtual

Add pre-offsets.

Parameters
[in]inIncrement0The amount to be added to the existing preOffset0
[in]inIncrement1The amount to be added to the existing preOffset1
[in]inIncrement2The amount to be added to the existing preOffset2

Definition at line 556 of file ntv2cscmatrix.cpp.

◆ CoeffEqual()

bool CNTV2CSCMatrix::CoeffEqual ( const double  inCoeff1,
const double  inCoeff2,
const double  inMaxDiff 
)
virtual

Tests if two coefficients differ by less than the fiven tolerance.

Parameters
[in]inCoeff1Specifies the first coefficient to be compared
[in]inCoeff2Specifies the second coefficient to be compared
[in]inMaxDiffSpecifies the amount by which two coefficients can differ and still be considered "equal"
Returns
True if the the two oefficients differ by an amount less than the tolerance; otherwise false

Definition at line 639 of file ntv2cscmatrix.cpp.

◆ GetCoefficient()

double CNTV2CSCMatrix::GetCoefficient ( const NTV2CSCCoeffIndex  inCoeffIndex) const
virtual

Returns the value of a requested matrix coefficient.

Parameters
[in]inCoeffIndexSpecifies which matrix coefficient to return.
Returns
The value of the requested coefficient.

Definition at line 413 of file ntv2cscmatrix.cpp.

◆ GetOffset()

int16_t CNTV2CSCMatrix::GetOffset ( const NTV2CSCOffsetIndex  inOffsetIndex) const
virtual

Returns the value of a requested offset.

Parameters
[in]inOffsetIndexSpecifies which offset to return.
Returns
The value of the requested offset.

Definition at line 451 of file ntv2cscmatrix.cpp.

◆ InitMatrix()

void CNTV2CSCMatrix::InitMatrix ( const NTV2ColorSpaceMatrixType  inPreset)
virtual

Replace the current matrix coefficients with a known set of coefficients.

Parameters
[in]inPresetSpecifies a new setting for the matrix coefficients.

Definition at line 20 of file ntv2cscmatrix.cpp.

◆ IsEqual()

bool CNTV2CSCMatrix::IsEqual ( const CNTV2CSCMatrix inCSCMatrix,
const double  inMaxDiff = NTV2CSCMatrix_MaxCoeffDiff 
)
virtual

Tests if the matrix coefficients can all be considered equal to those of the specified instance,.

Parameters
[in]inCSCMatrixSpecifies a reference to a CNTV2CSCMatrix instance.
[in]inMaxDiffSpecifies the amount by which two coefficients can differ and still be considered "equal"
Returns
True if all the matrix coefficients differ by an amount less than the tolerance; otherwise false
Note
ONLY compares matrix coefficients, NOT offsets.

Definition at line 622 of file ntv2cscmatrix.cpp.

◆ IsUnityMatrix()

bool CNTV2CSCMatrix::IsUnityMatrix ( void  )
virtual

Returns 'true' if this CSC Matrix has unity matrix coefficients.

Returns
True if the matrix is a unity matrix; otherwise false
Note
ONLY compares matrix coefficients, NOT offsets.

Definition at line 582 of file ntv2cscmatrix.cpp.

◆ operator!=()

virtual bool CNTV2CSCMatrix::operator!= ( const CNTV2CSCMatrix rhs) const
inlinevirtual

Returns true if the matrix coefficients and offsets differ from those of the specified instance.

Note
Compares matrix coefficients and offsets.

Definition at line 239 of file ntv2cscmatrix.h.

◆ operator==()

bool CNTV2CSCMatrix::operator== ( const CNTV2CSCMatrix rhs) const
virtual

Returns true if the matrix coefficients and offsets EXACTLY match those of the specified instance.

Note
Compares matrix coefficients and offsets.

Definition at line 601 of file ntv2cscmatrix.cpp.

◆ PostMultiply()

void CNTV2CSCMatrix::PostMultiply ( const CNTV2CSCMatrix inPostInstance)
virtual

Post-multiply the current 3x3 matrix by the matrix of the given instance.

Parameters
[in]inPostInstanceSpecifies a reference to a CNTV2CSCMatrix instance.

Definition at line 505 of file ntv2cscmatrix.cpp.

◆ PreMultiply()

void CNTV2CSCMatrix::PreMultiply ( const CNTV2CSCMatrix inPreInstance)
virtual

Pre-multiply the current 3x3 matrix by the matrix of the given instance.

Parameters
[in]inPreInstanceSpecifies a reference to a CNTV2CSCMatrix instance.

Definition at line 483 of file ntv2cscmatrix.cpp.

◆ SetCoefficient()

void CNTV2CSCMatrix::SetCoefficient ( const NTV2CSCCoeffIndex  inCoeffIndex,
const double  inCoefficient 
)
virtual

Changes the specified matrix coefficient to the given value.

Parameters
[in]inCoeffIndexSpecifies which matrix coefficient to change.
[in]inCoefficientSpecifies the new matrix coefficient value.

Definition at line 433 of file ntv2cscmatrix.cpp.

◆ SetGain()

void CNTV2CSCMatrix::SetGain ( const double  inGain0,
const double  inGain1,
const double  inGain2 
)
virtual

Set the matrix diagonals (gains).

Parameters
[in]inGain0Specifies the amount of gain to be applied to the 1st channel (unity = 1.0)
[in]inGain1Specifies the amount of gain to be applied to the 2nd channel
[in]inGain2Specifies the amount of gain to be applied to the 3rd channel

Definition at line 527 of file ntv2cscmatrix.cpp.

◆ SetHueRotate()

void CNTV2CSCMatrix::SetHueRotate ( const double  inDegrees)
virtual

Set matrix for hue rotation.

Parameters
[in]inDegreesAmount of Cb/Cr "rotation" (in degrees)
Note
Assumes chroma channels in In 1/Out B, In 2/Out C. This will not work for RGB.

Definition at line 536 of file ntv2cscmatrix.cpp.

◆ SetOffset()

void CNTV2CSCMatrix::SetOffset ( const NTV2CSCOffsetIndex  inOffsetIndex,
const int16_t  inOffset 
)
virtual

Changes the specified offset to the given value.

Parameters
[in]inOffsetIndexSpecifies which offset to change.
[in]inOffsetSpecifies the new offset value.

Definition at line 468 of file ntv2cscmatrix.cpp.

◆ SetPostOffsets()

void CNTV2CSCMatrix::SetPostOffsets ( const int16_t  inOffsetA,
const int16_t  inOffsetB,
const int16_t  inOffsetC 
)
virtual

Set post-offsets.

Parameters
[in]inOffsetAThe zero, or "black" level of the 1st output channel
[in]inOffsetBThe zero, or "black" level of the 2nd output channel
[in]inOffsetCThe zero, or "black" level of the 3rd output channel

Definition at line 565 of file ntv2cscmatrix.cpp.

◆ SetPreOffsets()

void CNTV2CSCMatrix::SetPreOffsets ( const int16_t  inOffset0,
const int16_t  inOffset1,
const int16_t  inOffset2 
)
virtual

Set pre-offsets.

Parameters
[in]inOffset0The zero, or "black" level of the 1st input channel
[in]inOffset1The zero, or "black" level of the 2nd input channel
[in]inOffset2The zero, or "black" level of the 3rd input channel

Definition at line 547 of file ntv2cscmatrix.cpp.


The documentation for this class was generated from the following files: