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);
34  float GetDisplayGamma(void);
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  int m_colourShifted { 0 };
89  int m_colourTransfer { AVCOL_TRC_BT709 };
91  int m_colourPrimaries { AVCOL_PRI_BT709 };
92  int m_displayPrimaries { AVCOL_PRI_BT709 };
93  float m_colourGamma { 2.2F };
94  float m_displayGamma { 2.2F };
95  QMatrix4x4 m_primaryMatrix { };
96  float m_customDisplayGamma { 0.0F };
98  VideoColourSpace *m_parent { nullptr };
99 };
100 
101 #endif
PrimariesMode GetPrimariesMode(void)
static const ColourPrimaries kBT610_525
VideoColourSpace contains a QMatrix4x4 that can convert YCbCr data to RGB.
PrimariesMode
unsigned int slots[4]
Definition: element.c:38
~VideoColourSpace() override
QMap< PictureAttribute, int > m_dbSettings
float GetColourGamma(void)
void SetPrimariesMode(PrimariesMode Mode)
PictureAttributeSupported
General purpose reference counter.
void SetSaturation(int Value)
int GetPictureAttribute(PictureAttribute Attribute)
void SetFullRange(bool FullRange)
void PictureAttributeChanged(PictureAttribute Attribute, int Value)
static const ColourPrimaries kBT610_625
VideoColourSpace(VideoColourSpace *Parent=nullptr)
QMatrix4x4 GetPrimaryMatrix(void)
float GetDisplayGamma(void)
void SetAlpha(int Value)
QStringList GetColourMappingDefines(void)
PictureAttribute
Definition: videoouttypes.h:87
ColourPrimaries * m_customDisplayPrimaries
void SetHue(int Value)
static const ColourPrimaries kBT709
void Updated(bool PrimariesChanged)
PictureAttributeSupported m_supportedAttributes
void SetBrightness(int Value)
void SetSupportedAttributes(PictureAttributeSupported Supported)
Enable the given set of picture attributes.
QMatrix4x4 GetPrimaryConversion(int Source, int Dest)
static const ColourPrimaries kBT2020
VideoColourSpace * m_parent
PictureAttributeSupported SupportedAttributes(void) const
void SaveValue(PictureAttribute Attribute, int Value)
Save the PictureAttribute value to the database.
static ColourPrimaries GetPrimaries(int Primary, float &Gamma)
int SetPictureAttribute(PictureAttribute Attribute, int Value)
Set the Value for the given PictureAttribute.
QMatrix4x4 m_primaryMatrix
void SetContrast(int Value)
void Update(void)
Update the matrix for the current settings and colourspace.
PrimariesMode m_primariesMode
bool UpdateColourSpace(const VideoFrame *Frame)
Set the current colourspace to use.
static QMatrix4x4 RGBtoXYZ(ColourPrimaries Primaries)
Create a conversion matrix for RGB to XYZ with the given primaries.
static bool Similar(const ColourPrimaries &First, const ColourPrimaries &Second, float Fuzz)