MythTV  master
videocolourspace.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 class VideoColourSpace : public QObject, public QMatrix4x4, public ReferenceCounter
18 {
19  Q_OBJECT
20 
21  friend class MythVideoOutput;
22 
23  public:
24  explicit VideoColourSpace(VideoColourSpace *Parent = nullptr);
25 
26  bool UpdateColourSpace(const VideoFrame *Frame);
30  void SetAlpha(int Value);
31  QMatrix4x4 GetPrimaryMatrix(void);
32  QStringList GetColourMappingDefines(void);
33  float GetColourGamma(void) const;
34  float GetDisplayGamma(void) const;
36 
38  {
39  float primaries[3][2];
40  float whitepoint[2];
41  };
42 
43  static const ColourPrimaries kBT709;
46  static const ColourPrimaries kBT2020;
47  static bool Similar(const ColourPrimaries &First, const ColourPrimaries &Second,
48  float Fuzz);
49 
50  public slots:
51  int SetPictureAttribute(PictureAttribute Attribute, int Value);
53 
54  signals:
55  void Updated(bool PrimariesChanged);
56  void PictureAttributeChanged(PictureAttribute Attribute, int Value);
57 
58  protected:
59  ~VideoColourSpace() override;
60 
61  private:
62  void SetFullRange(bool FullRange);
63  void SetBrightness(int Value);
64  void SetContrast(int Value);
65  void SetHue(int Value);
66  void SetSaturation(int Value);
67  void SaveValue(PictureAttribute Attribute, int Value);
68  void Update(void);
69  void Debug(void);
70  QMatrix4x4 GetPrimaryConversion(int Source, int Dest);
71  static ColourPrimaries GetPrimaries(int Primary, float &Gamma);
72  static QMatrix4x4 RGBtoXYZ(ColourPrimaries Primaries);
73 
74  private:
76  QMap<PictureAttribute,int> m_dbSettings;
77 
78  bool m_fullRange { true };
79  float m_brightness { 0.0F };
80  float m_contrast { 1.0F };
81  float m_saturation { 1.0F };
82  float m_hue { 0.0F };
83  float m_alpha { 1.0F };
84  int m_colourSpace { AVCOL_SPC_UNSPECIFIED };
85  int m_colourSpaceDepth { 8 };
86  int m_range { AVCOL_RANGE_MPEG };
87  bool m_updatesDisabled { true };
88  bool m_colourShifted { false };
89  int m_colourTransfer { AVCOL_TRC_BT709 };
91  int m_colourPrimaries { AVCOL_PRI_BT709 };
92  int m_displayPrimaries { AVCOL_PRI_BT709 };
93  int m_chromaLocation { AVCHROMA_LOC_LEFT };
94  float m_colourGamma { 2.2F };
95  float m_displayGamma { 2.2F };
96  QMatrix4x4 m_primaryMatrix { };
97  float m_customDisplayGamma { 0.0F };
99  VideoColourSpace *m_parent { nullptr };
100 };
101 
102 #endif
PrimariesMode
PrimariesMode
Definition: videoouttypes.h:127
VideoColourSpace::SetPrimariesMode
void SetPrimariesMode(PrimariesMode Mode)
Definition: videocolourspace.cpp:492
VideoColourSpace::m_colourTransfer
int m_colourTransfer
Definition: videocolourspace.h:89
VideoColourSpace::GetPictureAttribute
int GetPictureAttribute(PictureAttribute Attribute)
Definition: videocolourspace.cpp:146
PrimariesRelaxed
@ PrimariesRelaxed
Definition: videoouttypes.h:130
PictureAttributeSupported
PictureAttributeSupported
Definition: videoouttypes.h:100
MythVideoOutput
Definition: mythvideoout.h:36
VideoColourSpace::Update
void Update(void)
Update the matrix for the current settings and colourspace.
Definition: videocolourspace.cpp:193
VideoColourSpace::RGBtoXYZ
static QMatrix4x4 RGBtoXYZ(ColourPrimaries Primaries)
Create a conversion matrix for RGB to XYZ with the given primaries.
Definition: videocolourspace.cpp:613
VideoColourSpace::GetPrimariesMode
PrimariesMode GetPrimariesMode(void)
Definition: videocolourspace.cpp:487
VideoColourSpace::SetFullRange
void SetFullRange(bool FullRange)
Definition: videocolourspace.cpp:416
VideoColourSpace::m_range
int m_range
Definition: videocolourspace.h:86
VideoColourSpace::m_dbSettings
QMap< PictureAttribute, int > m_dbSettings
Definition: videocolourspace.h:76
VideoColourSpace::ColourPrimaries::primaries
float primaries[3][2]
Definition: videocolourspace.h:39
Frame
Definition: zmdefines.h:93
VideoColourSpace::m_hue
float m_hue
Definition: videocolourspace.h:82
VideoColourSpace::m_updatesDisabled
bool m_updatesDisabled
Definition: videocolourspace.h:87
VideoColourSpace::PictureAttributeChanged
void PictureAttributeChanged(PictureAttribute Attribute, int Value)
VideoColourSpace::kBT610_525
static const ColourPrimaries kBT610_525
Definition: videocolourspace.h:44
slots
unsigned int slots[4]
Definition: element.cpp:38
mythframe.h
VideoFrame
Definition: mythframe.h:137
VideoColourSpace::m_displayPrimaries
int m_displayPrimaries
Definition: videocolourspace.h:92
VideoColourSpace::m_colourSpace
int m_colourSpace
Definition: videocolourspace.h:84
kPictureAttributeSupported_None
@ kPictureAttributeSupported_None
Definition: videoouttypes.h:102
VideoColourSpace::kBT610_625
static const ColourPrimaries kBT610_625
Definition: videocolourspace.h:45
VideoColourSpace::m_customDisplayGamma
float m_customDisplayGamma
Definition: videocolourspace.h:97
VideoColourSpace::m_colourGamma
float m_colourGamma
Definition: videocolourspace.h:94
VideoColourSpace::m_colourPrimaries
int m_colourPrimaries
Definition: videocolourspace.h:91
VideoColourSpace::SetSaturation
void SetSaturation(int Value)
Definition: videocolourspace.cpp:440
VideoColourSpace::m_contrast
float m_contrast
Definition: videocolourspace.h:80
Source
Definition: channelsettings.cpp:68
VideoColourSpace::m_displayGamma
float m_displayGamma
Definition: videocolourspace.h:95
videoouttypes.h
VideoColourSpace::m_colourSpaceDepth
int m_colourSpaceDepth
Definition: videocolourspace.h:85
VideoColourSpace::m_supportedAttributes
PictureAttributeSupported m_supportedAttributes
Definition: videocolourspace.h:75
VideoColourSpace::SetSupportedAttributes
void SetSupportedAttributes(PictureAttributeSupported Supported)
Enable the given set of picture attributes.
Definition: videocolourspace.cpp:140
VideoColourSpace::SetBrightness
void SetBrightness(int Value)
Definition: videocolourspace.cpp:422
VideoColourSpace::SetHue
void SetHue(int Value)
Definition: videocolourspace.cpp:434
VideoColourSpace::kBT709
static const ColourPrimaries kBT709
Definition: videocolourspace.h:43
VideoColourSpace::m_saturation
float m_saturation
Definition: videocolourspace.h:81
VideoColourSpace::SetAlpha
void SetAlpha(int Value)
Definition: videocolourspace.cpp:446
VideoColourSpace::VideoColourSpace
VideoColourSpace(VideoColourSpace *Parent=nullptr)
Definition: videocolourspace.cpp:57
VideoColourSpace::GetPrimaryMatrix
QMatrix4x4 GetPrimaryMatrix(void)
Definition: videocolourspace.cpp:472
VideoColourSpace::GetColourMappingDefines
QStringList GetColourMappingDefines(void)
Definition: videocolourspace.cpp:452
VideoColourSpace::m_brightness
float m_brightness
Definition: videocolourspace.h:79
VideoColourSpace::m_alpha
float m_alpha
Definition: videocolourspace.h:83
VideoColourSpace::m_parent
VideoColourSpace * m_parent
Definition: videocolourspace.h:99
referencecounter.h
VideoColourSpace::SupportedAttributes
PictureAttributeSupported SupportedAttributes(void) const
Definition: videocolourspace.cpp:130
PictureAttribute
PictureAttribute
Definition: videoouttypes.h:87
VideoColourSpace::GetPrimaries
static ColourPrimaries GetPrimaries(int Primary, float &Gamma)
Definition: videocolourspace.cpp:557
VideoColourSpace::m_chromaLocation
int m_chromaLocation
Definition: videocolourspace.h:93
VideoColourSpace::kBT2020
static const ColourPrimaries kBT2020
Definition: videocolourspace.h:46
VideoColourSpace
VideoColourSpace contains a QMatrix4x4 that can convert YCbCr data to RGB.
Definition: videocolourspace.h:17
VideoColourSpace::UpdateColourSpace
bool UpdateColourSpace(const VideoFrame *Frame)
Set the current colourspace to use.
Definition: videocolourspace.cpp:332
VideoColourSpace::SetPictureAttribute
int SetPictureAttribute(PictureAttribute Attribute, int Value)
Set the Value for the given PictureAttribute.
Definition: videocolourspace.cpp:154
VideoColourSpace::m_customDisplayPrimaries
ColourPrimaries * m_customDisplayPrimaries
Definition: videocolourspace.h:98
VideoColourSpace::Updated
void Updated(bool PrimariesChanged)
VideoColourSpace::m_primaryMatrix
QMatrix4x4 m_primaryMatrix
Definition: videocolourspace.h:96
VideoColourSpace::GetDisplayGamma
float GetDisplayGamma(void) const
Definition: videocolourspace.cpp:482
VideoColourSpace::SetContrast
void SetContrast(int Value)
Definition: videocolourspace.cpp:428
VideoColourSpace::Similar
static bool Similar(const ColourPrimaries &First, const ColourPrimaries &Second, float Fuzz)
Definition: videocolourspace.cpp:572
VideoColourSpace::GetPrimaryConversion
QMatrix4x4 GetPrimaryConversion(int Source, int Dest)
Definition: videocolourspace.cpp:521
VideoColourSpace::m_primariesMode
PrimariesMode m_primariesMode
Definition: videocolourspace.h:90
VideoColourSpace::m_fullRange
bool m_fullRange
Definition: videocolourspace.h:78
VideoColourSpace::ColourPrimaries
Definition: videocolourspace.h:37
VideoColourSpace::~VideoColourSpace
~VideoColourSpace() override
Definition: videocolourspace.cpp:123
VideoColourSpace::ColourPrimaries::whitepoint
float whitepoint[2]
Definition: videocolourspace.h:40
VideoColourSpace::GetColourGamma
float GetColourGamma(void) const
Definition: videocolourspace.cpp:477
VideoColourSpace::Debug
void Debug(void)
Definition: videocolourspace.cpp:301
VideoColourSpace::SaveValue
void SaveValue(PictureAttribute Attribute, int Value)
Save the PictureAttribute value to the database.
Definition: videocolourspace.cpp:499
ReferenceCounter
General purpose reference counter.
Definition: referencecounter.h:26
VideoColourSpace::m_colourShifted
bool m_colourShifted
Definition: videocolourspace.h:88