MythTV  master
mythvideodrmutils.cpp
Go to the documentation of this file.
1 // MythTV
2 #include "mythlogging.h"
3 #include "mythedid.h"
5 
6 // libavutil
7 extern "C" {
8 #include "libavutil/pixfmt.h"
9 #include "libavutil/pixdesc.h"
10 }
11 
12 #define LOC QString("DRMUtils: ")
13 
15 {
16  // Default to limited range
17  uint64_t result = 0;
18 
19  // Pull out enums
20  auto rangeprop = dynamic_cast<MythDRMEnumProperty*>(Property.get());
21  if (!rangeprop)
22  return result;
23 
24  auto searchstring = (Range == AVCOL_RANGE_MPEG) ? "limited" : "full";
25  for (const auto & [value,name] : rangeprop->m_enums)
26  {
27  if (name.contains(searchstring, Qt::CaseInsensitive))
28  {
29  LOG(VB_PLAYBACK, LOG_INFO, LOC + QString("Using '%1' as color range for '%2'")
30  .arg(name).arg(av_color_range_name(static_cast<AVColorRange>(Range))));
31  return value;
32  }
33  }
34  return result;
35 }
36 
38 {
39  // Default to BT.601
40  uint64_t result = 0;
41 
42  // Pull out enums
43  auto rangeprop = dynamic_cast<MythDRMEnumProperty*>(Property.get());
44  if (!rangeprop)
45  return result;
46 
47  auto searchstring = "601";
48  switch (Encoding)
49  {
50  case AVCOL_SPC_BT709: searchstring = "709"; break;
51  // I've only seen 2020 available on amdgpu with a Ryzen3400G. If selected
52  // it produces an EINVAL - which breaks Qt rendering. Probably needs to be
53  // used in conjunction with HDR. Needs investigating.
54  //case AVCOL_SPC_BT2020_NCL:
55  //case AVCOL_SPC_BT2020_CL:
56  //case AVCOL_SPC_CHROMA_DERIVED_NCL:
57  //case AVCOL_SPC_CHROMA_DERIVED_CL: searchstring = "2020"; break;
58  default: break;
59  }
60 
61  for (const auto & [value,name] : rangeprop->m_enums)
62  {
63  if (name.contains(searchstring, Qt::CaseInsensitive))
64  {
65  LOG(VB_PLAYBACK, LOG_INFO, LOC + QString("Using '%1' as color encoding for '%2'")
66  .arg(name).arg(av_color_space_name(static_cast<AVColorSpace>(Encoding))));
67  return value;
68  }
69  }
70  return result;
71 }
mythvideodrmutils.h
LOG
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
Definition: mythlogging.h:23
Property
Definition: upnpcdsobjects.h:44
MythDRMEnumProperty
Definition: mythdrmproperty.h:62
MythVideoDRMUtils::FFmpegColorEncodingToDRM
static uint64_t FFmpegColorEncodingToDRM(DRMProp Property, int Encoding)
Definition: mythvideodrmutils.cpp:37
mythlogging.h
DRMProp
std::shared_ptr< class MythDRMProperty > DRMProp
Definition: mythdrmproperty.h:7
MythVideoDRMUtils::FFmpegColorRangeToDRM
static uint64_t FFmpegColorRangeToDRM(DRMProp Property, int Range)
Definition: mythvideodrmutils.cpp:14
mythedid.h
LOC
#define LOC
Definition: mythvideodrmutils.cpp:12