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