MythTV  master
mythvideocolourspace.h
Go to the documentation of this file.
1 #ifndef VIDEOCOLOURSPACE_H
2 #define VIDEOCOLOURSPACE_H
3 
4 // Qt
5 #include <QMap>
6 #include <QObject>
7 #include <QMatrix4x4>
8 
9 // MythTV
10 #include "mythframe.h"
11 #include "videoouttypes.h"
12 #include "referencecounter.h"
13 
14 // FFmpeg
15 #include "libavutil/pixfmt.h" // For AVCOL_xxx defines
16 
17 using PrimarySpace = std::array<std::array<float,2>,3>;
18 using WhiteSpace = std::array<float,2>;
19 
20 class MythVideoColourSpace : public QObject, public QMatrix4x4, public ReferenceCounter
21 {
22  Q_OBJECT
23 
24  friend class MythVideoOutput;
25 
26  public slots:
27  int ChangePictureAttribute(PictureAttribute Attribute, bool Direction, int Value);
29 
30  signals:
31  void Updated(bool PrimariesChanged);
32  void PictureAttributeChanged(PictureAttribute Attribute, int Value);
33 
34  public:
40  void SetAlpha(int Value);
41  QMatrix4x4 GetPrimaryMatrix(void);
42  QStringList GetColourMappingDefines(void);
43  float GetColourGamma(void) const;
44  float GetDisplayGamma(void) const;
46 
48  {
51  };
52 
53  static const ColourPrimaries kBT709;
56  static const ColourPrimaries kBT2020;
57  static bool Similar(const ColourPrimaries &First, const ColourPrimaries &Second,
58  float Fuzz);
59 
60  protected:
61  ~MythVideoColourSpace() override;
62 
63  private:
64  void SetFullRange(bool FullRange);
65  void SetBrightness(int Value);
66  void SetContrast(int Value);
67  void SetHue(int Value);
68  void SetSaturation(int Value);
69  void SaveValue(PictureAttribute Attribute, int Value);
70  void Update(void);
71  void Debug(void);
72  QMatrix4x4 GetPrimaryConversion(int Source, int Dest);
73  static ColourPrimaries GetPrimaries(int Primary, float &Gamma);
74  static QMatrix4x4 RGBtoXYZ(const ColourPrimaries& Primaries);
75 
76  private:
78  QMap<PictureAttribute,int> m_dbSettings;
79 
80  bool m_fullRange { true };
81  float m_brightness { 0.0F };
82  float m_contrast { 1.0F };
83  float m_saturation { 1.0F };
84  float m_hue { 0.0F };
85  float m_alpha { 1.0F };
86  int m_colourSpace { AVCOL_SPC_UNSPECIFIED };
87  int m_colourSpaceDepth { 8 };
88  int m_range { AVCOL_RANGE_MPEG };
89  bool m_updatesDisabled { true };
90  bool m_colourShifted { false };
91  int m_colourTransfer { AVCOL_TRC_BT709 };
93  int m_colourPrimaries { AVCOL_PRI_BT709 };
94  int m_displayPrimaries { AVCOL_PRI_BT709 };
95  int m_chromaLocation { AVCHROMA_LOC_LEFT };
96  float m_colourGamma { 2.2F };
97  float m_displayGamma { 2.2F };
98  QMatrix4x4 m_primaryMatrix { };
99  float m_customDisplayGamma { 0.0F };
101 };
102 
103 #endif
PrimariesMode
PrimariesMode
Definition: videoouttypes.h:143
PrimarySpace
std::array< std::array< float, 2 >, 3 > PrimarySpace
Definition: mythvideocolourspace.h:17
MythVideoColourSpace::PictureAttributeChanged
void PictureAttributeChanged(PictureAttribute Attribute, int Value)
PrimariesRelaxed
@ PrimariesRelaxed
Definition: videoouttypes.h:145
PictureAttributeSupported
PictureAttributeSupported
Definition: videoouttypes.h:117
MythVideoOutput
Definition: mythvideoout.h:31
MythVideoColourSpace::Update
void Update(void)
Update the matrix for the current settings and colourspace.
Definition: mythvideocolourspace.cpp:141
MythVideoColourSpace::m_primaryMatrix
QMatrix4x4 m_primaryMatrix
Definition: mythvideocolourspace.h:98
Frame
Definition: zmdefines.h:94
MythVideoColourSpace::ColourPrimaries
Definition: mythvideocolourspace.h:48
MythVideoColourSpace::m_hue
float m_hue
Definition: mythvideocolourspace.h:84
MythVideoColourSpace::UpdateColourSpace
bool UpdateColourSpace(const MythVideoFrame *Frame)
Set the current colourspace to use.
Definition: mythvideocolourspace.cpp:329
MythVideoColourSpace::m_updatesDisabled
bool m_updatesDisabled
Definition: mythvideocolourspace.h:89
MythVideoColourSpace::SetFullRange
void SetFullRange(bool FullRange)
Definition: mythvideocolourspace.cpp:413
MythVideoColourSpace::m_displayGamma
float m_displayGamma
Definition: mythvideocolourspace.h:97
MythVideoColourSpace::SetSupportedAttributes
void SetSupportedAttributes(PictureAttributeSupported Supported)
Enable the given set of picture attributes.
Definition: mythvideocolourspace.cpp:122
MythVideoColourSpace::SetContrast
void SetContrast(int Value)
Definition: mythvideocolourspace.cpp:425
MythVideoColourSpace::m_colourShifted
bool m_colourShifted
Definition: mythvideocolourspace.h:90
MythVideoColourSpace::m_fullRange
bool m_fullRange
Definition: mythvideocolourspace.h:80
mythframe.h
MythVideoColourSpace::m_customDisplayPrimaries
ColourPrimaries * m_customDisplayPrimaries
Definition: mythvideocolourspace.h:100
MythVideoColourSpace::GetPrimaryConversion
QMatrix4x4 GetPrimaryConversion(int Source, int Dest)
Definition: mythvideocolourspace.cpp:514
kPictureAttributeSupported_None
@ kPictureAttributeSupported_None
Definition: videoouttypes.h:118
MythVideoColourSpace::SetPrimariesMode
void SetPrimariesMode(PrimariesMode Mode)
Definition: mythvideocolourspace.cpp:489
MythVideoColourSpace::m_colourTransfer
int m_colourTransfer
Definition: mythvideocolourspace.h:91
MythVideoColourSpace::GetColourMappingDefines
QStringList GetColourMappingDefines(void)
Definition: mythvideocolourspace.cpp:449
MythVideoColourSpace::Debug
void Debug(void)
Definition: mythvideocolourspace.cpp:249
WhiteSpace
std::array< float, 2 > WhiteSpace
Definition: mythvideocolourspace.h:18
MythVideoColourSpace::GetPictureAttribute
int GetPictureAttribute(PictureAttribute Attribute)
Definition: mythvideocolourspace.cpp:128
Source
Definition: channelsettings.cpp:69
videoouttypes.h
MythVideoColourSpace::ColourPrimaries::whitepoint
WhiteSpace whitepoint
Definition: mythvideocolourspace.h:50
MythVideoColourSpace::Similar
static bool Similar(const ColourPrimaries &First, const ColourPrimaries &Second, float Fuzz)
Definition: mythvideocolourspace.cpp:565
MythVideoColourSpace::kBT709
static const ColourPrimaries kBT709
Definition: mythvideocolourspace.h:53
MythVideoColourSpace::GetColourGamma
float GetColourGamma(void) const
Definition: mythvideocolourspace.cpp:474
MythVideoColourSpace::SetHue
void SetHue(int Value)
Definition: mythvideocolourspace.cpp:431
MythVideoColourSpace::SaveValue
void SaveValue(PictureAttribute Attribute, int Value)
Save the PictureAttribute value to the database.
Definition: mythvideocolourspace.cpp:496
MythVideoColourSpace::ColourPrimaries::primaries
PrimarySpace primaries
Definition: mythvideocolourspace.h:49
MythVideoColourSpace::m_dbSettings
QMap< PictureAttribute, int > m_dbSettings
Definition: mythvideocolourspace.h:78
MythVideoColourSpace::GetDisplayGamma
float GetDisplayGamma(void) const
Definition: mythvideocolourspace.cpp:479
MythVideoColourSpace::GetPrimariesMode
PrimariesMode GetPrimariesMode(void)
Definition: mythvideocolourspace.cpp:484
MythVideoColourSpace::kBT610_525
static const ColourPrimaries kBT610_525
Definition: mythvideocolourspace.h:54
MythVideoColourSpace::m_displayPrimaries
int m_displayPrimaries
Definition: mythvideocolourspace.h:94
MythVideoColourSpace::m_primariesMode
PrimariesMode m_primariesMode
Definition: mythvideocolourspace.h:92
MythVideoColourSpace::m_colourSpaceDepth
int m_colourSpaceDepth
Definition: mythvideocolourspace.h:87
referencecounter.h
MythVideoColourSpace::m_alpha
float m_alpha
Definition: mythvideocolourspace.h:85
MythVideoColourSpace::m_colourPrimaries
int m_colourPrimaries
Definition: mythvideocolourspace.h:93
MythVideoColourSpace::m_saturation
float m_saturation
Definition: mythvideocolourspace.h:83
PictureAttribute
PictureAttribute
Definition: videoouttypes.h:104
MythVideoColourSpace::MythVideoColourSpace
MythVideoColourSpace()
Definition: mythvideocolourspace.cpp:57
MythVideoColourSpace::m_colourGamma
float m_colourGamma
Definition: mythvideocolourspace.h:96
MythVideoColourSpace::m_supportedAttributes
PictureAttributeSupported m_supportedAttributes
Definition: mythvideocolourspace.h:77
MythVideoColourSpace::~MythVideoColourSpace
~MythVideoColourSpace() override
Definition: mythvideocolourspace.cpp:107
MythVideoColourSpace::kBT2020
static const ColourPrimaries kBT2020
Definition: mythvideocolourspace.h:56
MythVideoColourSpace::SetAlpha
void SetAlpha(int Value)
Definition: mythvideocolourspace.cpp:443
MythVideoColourSpace::ChangePictureAttribute
int ChangePictureAttribute(PictureAttribute Attribute, bool Direction, int Value)
Definition: mythvideocolourspace.cpp:274
MythVideoColourSpace::Updated
void Updated(bool PrimariesChanged)
MythVideoColourSpace::m_customDisplayGamma
float m_customDisplayGamma
Definition: mythvideocolourspace.h:99
MythVideoColourSpace::GetPrimaries
static ColourPrimaries GetPrimaries(int Primary, float &Gamma)
Definition: mythvideocolourspace.cpp:550
MythVideoColourSpace::m_contrast
float m_contrast
Definition: mythvideocolourspace.h:82
MythVideoColourSpace::kBT610_625
static const ColourPrimaries kBT610_625
Definition: mythvideocolourspace.h:55
MythVideoColourSpace::GetPrimaryMatrix
QMatrix4x4 GetPrimaryMatrix(void)
Definition: mythvideocolourspace.cpp:469
MythVideoColourSpace::m_brightness
float m_brightness
Definition: mythvideocolourspace.h:81
MythVideoColourSpace::m_chromaLocation
int m_chromaLocation
Definition: mythvideocolourspace.h:95
MythVideoColourSpace::SetBrightness
void SetBrightness(int Value)
Definition: mythvideocolourspace.cpp:419
MythVideoFrame
Definition: mythframe.h:83
MythVideoColourSpace::m_colourSpace
int m_colourSpace
Definition: mythvideocolourspace.h:86
MythVideoColourSpace::RGBtoXYZ
static QMatrix4x4 RGBtoXYZ(const ColourPrimaries &Primaries)
Create a conversion matrix for RGB to XYZ with the given primaries.
Definition: mythvideocolourspace.cpp:606
MythVideoColourSpace::m_range
int m_range
Definition: mythvideocolourspace.h:88
MythVideoColourSpace::SupportedAttributes
PictureAttributeSupported SupportedAttributes(void) const
Definition: mythvideocolourspace.cpp:112
MythVideoColourSpace
MythVideoColourSpace contains a QMatrix4x4 that can convert YCbCr data to RGB.
Definition: mythvideocolourspace.h:21
ReferenceCounter
General purpose reference counter.
Definition: referencecounter.h:27
MythVideoColourSpace::SetSaturation
void SetSaturation(int Value)
Definition: mythvideocolourspace.cpp:437