MythTV  master
Public Slots | Signals | Public Member Functions | Protected Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | Friends | List of all members
MythVideoColourSpace Class Reference

MythVideoColourSpace contains a QMatrix4x4 that can convert YCbCr data to RGB. More...

#include <mythvideocolourspace.h>

Inheritance diagram for MythVideoColourSpace:
Inheritance graph
[legend]
Collaboration diagram for MythVideoColourSpace:
Collaboration graph
[legend]

Public Slots

int ChangePictureAttribute (PictureAttribute Attribute, bool Direction, int Value)
 
void SetPrimariesMode (PrimariesMode Mode)
 
void RefreshState ()
 

Signals

void Updated (bool PrimariesChanged)
 
void PictureAttributeChanged (PictureAttribute Attribute, int Value)
 
void SupportedAttributesChanged (PictureAttributeSupported Supported)
 
void PictureAttributesUpdated (const std::map< PictureAttribute, int > &Values)
 

Public Member Functions

 MythVideoColourSpace ()
 
bool UpdateColourSpace (const MythVideoFrame *Frame)
 Set the current colourspace to use. More...
 
PictureAttributeSupported SupportedAttributes (void) const
 
void SetSupportedAttributes (PictureAttributeSupported Supported)
 Enable the given set of picture attributes. More...
 
int GetPictureAttribute (PictureAttribute Attribute)
 
void SetAlpha (int Value)
 
QMatrix4x4 GetPrimaryMatrix (void)
 
QStringList GetColourMappingDefines (void)
 
float GetColourGamma (void) const
 
float GetDisplayGamma (void) const
 
PrimariesMode GetPrimariesMode (void)
 
int GetRange () const
 
int GetColourSpace () const
 
- Public Member Functions inherited from ReferenceCounter
 ReferenceCounter (const QString &debugName, bool logDebug=true)
 Creates reference counter with an initial value of 1. More...
 
virtual int IncrRef (void)
 Increments reference count. More...
 
virtual int DecrRef (void)
 Decrements reference count and deletes on 0. More...
 

Protected Member Functions

 ~MythVideoColourSpace () override
 
- Protected Member Functions inherited from ReferenceCounter
virtual ~ReferenceCounter (void)
 Called on destruction, will warn if object deleted with references in place. More...
 

Private Member Functions

void SetFullRange (bool FullRange)
 
void SetBrightness (int Value)
 
void SetContrast (int Value)
 
void SetHue (int Value)
 
void SetSaturation (int Value)
 
void SaveValue (PictureAttribute Attribute, int Value)
 Save the PictureAttribute value to the database. More...
 
void Update (void)
 Update the matrix for the current settings and colourspace. More...
 
void Debug (void)
 
QMatrix4x4 GetPrimaryConversion (int Source, int Dest)
 

Static Private Member Functions

static MythColourSpace GetPrimaries (int Primary, float &Gamma)
 

Private Attributes

PictureAttributeSupported m_supportedAttributes { kPictureAttributeSupported_None }
 
std::map< PictureAttribute, int > m_dbSettings
 
bool m_fullRange { true }
 
float m_brightness { 0.0F }
 
float m_contrast { 1.0F }
 
float m_saturation { 1.0F }
 
float m_hue { 0.0F }
 
float m_alpha { 1.0F }
 
int m_colourSpace { AVCOL_SPC_UNSPECIFIED }
 
int m_colourSpaceDepth { 8 }
 
int m_range { AVCOL_RANGE_MPEG }
 
bool m_updatesDisabled { true }
 
bool m_colourShifted { false }
 
int m_colourTransfer { AVCOL_TRC_BT709 }
 
PrimariesMode m_primariesMode { PrimariesRelaxed }
 
int m_colourPrimaries { AVCOL_PRI_BT709 }
 
int m_displayPrimaries { AVCOL_PRI_BT709 }
 
int m_chromaLocation { AVCHROMA_LOC_LEFT }
 
float m_colourGamma { 2.2F }
 
float m_displayGamma { 2.2F }
 
QMatrix4x4 m_primaryMatrix { }
 
float m_customDisplayGamma { 0.0F }
 
MythColourSpacem_customDisplayPrimaries { nullptr }
 

Friends

class MythVideoOutput
 

Additional Inherited Members

- Static Public Member Functions inherited from ReferenceCounter
static void PrintDebug (void)
 Print out any leaks if that level of debugging is enabled. More...
 
- Protected Attributes inherited from ReferenceCounter
bool m_logDebug
 This is used to suppress creating LoggingItem classes for LoggingItem reference count changes. More...
 
QAtomicInt m_referenceCount {1}
 

Detailed Description

MythVideoColourSpace contains a QMatrix4x4 that can convert YCbCr data to RGB.

A 4x4 matrix is created that is customised for the source colourspace and user defined adjustments for brightness, contrast, hue, saturation (colour) and 'levels'.

An alpha value is also added for rendering purposes. This assumes the raw data is in the form YCbCrA.

Levels are expanded to the full RGB colourspace range by default but enabling studio levels will ensure there is no adjustment. In both cases it is assumed the display device is setup appropriately.

Note
This class is not complete and will have limitations for certain source material and displays. It currently assumes an 8bit display (and GPU framebuffer) with a 'traditional' gamma of 2.2 (most colourspace standards have a reference gamma of 2.2). Hence colour rendition may not be optimal for material that specificies a colourspace that has a different reference gamma (e.g. Rec 2020) or when using an HDR display. Futher work is required.

Definition at line 18 of file mythvideocolourspace.h.

Constructor & Destructor Documentation

◆ MythVideoColourSpace()

MythVideoColourSpace::MythVideoColourSpace ( )

Definition at line 40 of file mythvideocolourspace.cpp.

◆ ~MythVideoColourSpace()

MythVideoColourSpace::~MythVideoColourSpace ( )
overrideprotected

Definition at line 90 of file mythvideocolourspace.cpp.

Member Function Documentation

◆ ChangePictureAttribute

int MythVideoColourSpace::ChangePictureAttribute ( PictureAttribute  Attribute,
bool  Direction,
int  Value 
)
slot

Definition at line 266 of file mythvideocolourspace.cpp.

Referenced by MythVideoOutputGPU::MythVideoOutputGPU().

◆ SetPrimariesMode

void MythVideoColourSpace::SetPrimariesMode ( PrimariesMode  Mode)
slot

Definition at line 489 of file mythvideocolourspace.cpp.

◆ RefreshState

void MythVideoColourSpace::RefreshState ( )
slot

Definition at line 95 of file mythvideocolourspace.cpp.

Referenced by MythVideoOutputGPU::MythVideoOutputGPU().

◆ Updated

void MythVideoColourSpace::Updated ( bool  PrimariesChanged)
signal

◆ PictureAttributeChanged

void MythVideoColourSpace::PictureAttributeChanged ( PictureAttribute  Attribute,
int  Value 
)
signal

◆ SupportedAttributesChanged

void MythVideoColourSpace::SupportedAttributesChanged ( PictureAttributeSupported  Supported)
signal

◆ PictureAttributesUpdated

void MythVideoColourSpace::PictureAttributesUpdated ( const std::map< PictureAttribute, int > &  Values)
signal

◆ UpdateColourSpace()

bool MythVideoColourSpace::UpdateColourSpace ( const MythVideoFrame Frame)

Set the current colourspace to use.

We rely on FFmpeg to detect and report the correct colourspace. In the event that no colourspace is found we use sensible defaults for standard and high definition content (BT470BG/BT601 and BT709 respectively).

Definition at line 321 of file mythvideocolourspace.cpp.

Referenced by MythMediaCodecInterop::Acquire(), MythMMALInterop::Acquire(), MythDRMPRIMEInterop::Acquire(), MythVAAPIInteropDRM::Acquire(), MythNVDECInterop::Acquire(), MythVDPAUInterop::Acquire(), MythVideoVulkan::PrepareFrame(), MythOpenGLVideo::PrepareFrame(), and MythVTBInterop::Verify().

◆ SupportedAttributes()

PictureAttributeSupported MythVideoColourSpace::SupportedAttributes ( void  ) const

◆ SetSupportedAttributes()

void MythVideoColourSpace::SetSupportedAttributes ( PictureAttributeSupported  Supported)

Enable the given set of picture attributes.

This is determined by the video rendering classes and is usually dependant upon the rendering method in use and type of video frame (e.g. hardware decoded or not).

Definition at line 111 of file mythvideocolourspace.cpp.

Referenced by MythMediaCodecInterop::Acquire(), MythMMALInterop::Acquire(), MythDRMPRIMEInterop::Acquire(), MythVAAPIInteropDRM::Acquire(), MythNVDECInterop::Acquire(), MythVDPAUInterop::Acquire(), MythVAAPIInteropGLX::InitPictureAttributes(), MythVideoOutputGPU::InitPictureAttributes(), MythVideoDRM::MythVideoDRM(), and MythVTBInterop::Verify().

◆ GetPictureAttribute()

int MythVideoColourSpace::GetPictureAttribute ( PictureAttribute  Attribute)

◆ SetAlpha()

void MythVideoColourSpace::SetAlpha ( int  Value)

Definition at line 435 of file mythvideocolourspace.cpp.

◆ GetPrimaryMatrix()

QMatrix4x4 MythVideoColourSpace::GetPrimaryMatrix ( void  )

◆ GetColourMappingDefines()

QStringList MythVideoColourSpace::GetColourMappingDefines ( void  )

Definition at line 441 of file mythvideocolourspace.cpp.

Referenced by MythOpenGLVideo::CreateVideoShader().

◆ GetColourGamma()

float MythVideoColourSpace::GetColourGamma ( void  ) const

Definition at line 464 of file mythvideocolourspace.cpp.

Referenced by MythOpenGLVideo::ColourSpaceUpdate().

◆ GetDisplayGamma()

float MythVideoColourSpace::GetDisplayGamma ( void  ) const

Definition at line 469 of file mythvideocolourspace.cpp.

Referenced by MythOpenGLVideo::ColourSpaceUpdate().

◆ GetPrimariesMode()

PrimariesMode MythVideoColourSpace::GetPrimariesMode ( void  )

Definition at line 474 of file mythvideocolourspace.cpp.

◆ GetRange()

int MythVideoColourSpace::GetRange ( ) const

Definition at line 479 of file mythvideocolourspace.cpp.

Referenced by MythVideoDRM::ColourSpaceUpdated().

◆ GetColourSpace()

int MythVideoColourSpace::GetColourSpace ( ) const

Definition at line 484 of file mythvideocolourspace.cpp.

Referenced by MythVideoDRM::ColourSpaceUpdated().

◆ SetFullRange()

void MythVideoColourSpace::SetFullRange ( bool  FullRange)
private

Definition at line 405 of file mythvideocolourspace.cpp.

Referenced by MythVideoColourSpace().

◆ SetBrightness()

void MythVideoColourSpace::SetBrightness ( int  Value)
private

Definition at line 411 of file mythvideocolourspace.cpp.

Referenced by ChangePictureAttribute(), and MythVideoColourSpace().

◆ SetContrast()

void MythVideoColourSpace::SetContrast ( int  Value)
private

Definition at line 417 of file mythvideocolourspace.cpp.

Referenced by ChangePictureAttribute(), and MythVideoColourSpace().

◆ SetHue()

void MythVideoColourSpace::SetHue ( int  Value)
private

Definition at line 423 of file mythvideocolourspace.cpp.

Referenced by ChangePictureAttribute(), and MythVideoColourSpace().

◆ SetSaturation()

void MythVideoColourSpace::SetSaturation ( int  Value)
private

Definition at line 429 of file mythvideocolourspace.cpp.

Referenced by ChangePictureAttribute(), and MythVideoColourSpace().

◆ SaveValue()

void MythVideoColourSpace::SaveValue ( PictureAttribute  Attribute,
int  Value 
)
private

Save the PictureAttribute value to the database.

Definition at line 496 of file mythvideocolourspace.cpp.

Referenced by ChangePictureAttribute().

◆ Update()

void MythVideoColourSpace::Update ( void  )
private

Update the matrix for the current settings and colourspace.

The matrix is built from first principles to help with maintainability. This is an expensive task but it is only recalculated when a change is detected or notified.

Definition at line 133 of file mythvideocolourspace.cpp.

Referenced by MythVideoColourSpace(), SetAlpha(), SetBrightness(), SetContrast(), SetFullRange(), SetHue(), SetPrimariesMode(), SetSaturation(), and UpdateColourSpace().

◆ Debug()

void MythVideoColourSpace::Debug ( void  )
private

Definition at line 241 of file mythvideocolourspace.cpp.

Referenced by Update().

◆ GetPrimaryConversion()

QMatrix4x4 MythVideoColourSpace::GetPrimaryConversion ( int  Source,
int  Dest 
)
private

Definition at line 514 of file mythvideocolourspace.cpp.

Referenced by Update().

◆ GetPrimaries()

MythColourSpace MythVideoColourSpace::GetPrimaries ( int  Primary,
float &  Gamma 
)
staticprivate

Definition at line 551 of file mythvideocolourspace.cpp.

Referenced by GetPrimaryConversion().

Friends And Related Function Documentation

◆ MythVideoOutput

friend class MythVideoOutput
friend

Definition at line 22 of file mythvideocolourspace.h.

Member Data Documentation

◆ m_supportedAttributes

PictureAttributeSupported MythVideoColourSpace::m_supportedAttributes { kPictureAttributeSupported_None }
private

◆ m_dbSettings

std::map<PictureAttribute,int> MythVideoColourSpace::m_dbSettings
private

◆ m_fullRange

bool MythVideoColourSpace::m_fullRange { true }
private

Definition at line 69 of file mythvideocolourspace.h.

Referenced by Debug(), SetFullRange(), Update(), and UpdateColourSpace().

◆ m_brightness

float MythVideoColourSpace::m_brightness { 0.0F }
private

Definition at line 70 of file mythvideocolourspace.h.

Referenced by Debug(), SetBrightness(), and Update().

◆ m_contrast

float MythVideoColourSpace::m_contrast { 1.0F }
private

Definition at line 71 of file mythvideocolourspace.h.

Referenced by Debug(), SetContrast(), and Update().

◆ m_saturation

float MythVideoColourSpace::m_saturation { 1.0F }
private

Definition at line 72 of file mythvideocolourspace.h.

Referenced by Debug(), SetSaturation(), and Update().

◆ m_hue

float MythVideoColourSpace::m_hue { 0.0F }
private

Definition at line 73 of file mythvideocolourspace.h.

Referenced by Debug(), SetHue(), and Update().

◆ m_alpha

float MythVideoColourSpace::m_alpha { 1.0F }
private

Definition at line 74 of file mythvideocolourspace.h.

Referenced by Debug(), SetAlpha(), and Update().

◆ m_colourSpace

int MythVideoColourSpace::m_colourSpace { AVCOL_SPC_UNSPECIFIED }
private

Definition at line 75 of file mythvideocolourspace.h.

Referenced by GetColourSpace(), Update(), and UpdateColourSpace().

◆ m_colourSpaceDepth

int MythVideoColourSpace::m_colourSpaceDepth { 8 }
private

Definition at line 76 of file mythvideocolourspace.h.

Referenced by Update(), and UpdateColourSpace().

◆ m_range

int MythVideoColourSpace::m_range { AVCOL_RANGE_MPEG }
private

Definition at line 77 of file mythvideocolourspace.h.

Referenced by GetRange(), Update(), and UpdateColourSpace().

◆ m_updatesDisabled

bool MythVideoColourSpace::m_updatesDisabled { true }
private

Definition at line 78 of file mythvideocolourspace.h.

Referenced by MythVideoColourSpace(), and Update().

◆ m_colourShifted

bool MythVideoColourSpace::m_colourShifted { false }
private

Definition at line 79 of file mythvideocolourspace.h.

Referenced by Update(), and UpdateColourSpace().

◆ m_colourTransfer

int MythVideoColourSpace::m_colourTransfer { AVCOL_TRC_BT709 }
private

Definition at line 80 of file mythvideocolourspace.h.

Referenced by UpdateColourSpace().

◆ m_primariesMode

PrimariesMode MythVideoColourSpace::m_primariesMode { PrimariesRelaxed }
private

◆ m_colourPrimaries

int MythVideoColourSpace::m_colourPrimaries { AVCOL_PRI_BT709 }
private

Definition at line 82 of file mythvideocolourspace.h.

Referenced by Update(), and UpdateColourSpace().

◆ m_displayPrimaries

int MythVideoColourSpace::m_displayPrimaries { AVCOL_PRI_BT709 }
private

Definition at line 83 of file mythvideocolourspace.h.

Referenced by Update(), and UpdateColourSpace().

◆ m_chromaLocation

int MythVideoColourSpace::m_chromaLocation { AVCHROMA_LOC_LEFT }
private

Definition at line 84 of file mythvideocolourspace.h.

Referenced by GetColourMappingDefines(), and UpdateColourSpace().

◆ m_colourGamma

float MythVideoColourSpace::m_colourGamma { 2.2F }
private

Definition at line 85 of file mythvideocolourspace.h.

Referenced by GetColourGamma(), GetPrimaryConversion(), and Update().

◆ m_displayGamma

float MythVideoColourSpace::m_displayGamma { 2.2F }
private

Definition at line 86 of file mythvideocolourspace.h.

Referenced by GetDisplayGamma(), GetPrimaryConversion(), and Update().

◆ m_primaryMatrix

QMatrix4x4 MythVideoColourSpace::m_primaryMatrix { }
private

◆ m_customDisplayGamma

float MythVideoColourSpace::m_customDisplayGamma { 0.0F }
private

Definition at line 88 of file mythvideocolourspace.h.

Referenced by GetPrimaryConversion().

◆ m_customDisplayPrimaries

MythColourSpace* MythVideoColourSpace::m_customDisplayPrimaries { nullptr }
private

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