MythTV  master
mythvdpauhelper.cpp
Go to the documentation of this file.
1 // MythTV
3 #include "mythvideocolourspace.h"
4 #include "mythvdpauhelper.h"
5 #include "libmythui/platforms/mythxdisplay.h" // always last
6 
7 // Std
8 #include <cmath>
9 
10 #define LOC QString("VDPAUHelp: ")
11 
12 #define INIT_ST \
13 VdpStatus status; \
14 bool ok = true;
15 
16 // NOLINTBEGIN(cppcoreguidelines-macro-usage)
17 #define CHECK_ST \
18 ok &= (status == VDP_STATUS_OK); \
19 if (!ok) \
20 { \
21  LOG(VB_PLAYBACK, LOG_ERR, LOC + QString("Error at %1:%2 (#%3, %4)") \
22  .arg(__FILE__).arg( __LINE__).arg(status) \
23  .arg(m_vdpGetErrorString(status))); \
24 }
25 
26 #define GET_PROC(FUNC_ID, PROC) \
27 status = m_vdpGetProcAddress(m_device, FUNC_ID, reinterpret_cast<void **>(&(PROC))); CHECK_ST
28 // NOLINTEND(cppcoreguidelines-macro-usage)
29 
30 VDPAUCodec::VDPAUCodec(MythCodecContext::CodecProfile Profile, QSize Size, uint32_t Macroblocks, uint32_t Level)
31  : m_maxSize(Size),
32  m_maxMacroBlocks(Macroblocks),
33  m_maxLevel(Level)
34 {
35  // Levels don't work for MPEG1/2
36  if (MythCodecContext::MPEG1 <= Profile && Profile <= MythCodecContext::MPEG2SNR)
37  m_maxLevel = 1000;
38 }
39 
40 bool VDPAUCodec::Supported(int Width, int Height, int Level) const
41 {
42  // Note - level checks are now ignored here and in FFmpeg
43  uint32_t macros = static_cast<uint32_t>(((Width + 15) & ~15) * ((Height + 15) & ~15)) / 256;
44  bool result = (Width <= m_maxSize.width()) && (Height <= m_maxSize.height()) &&
45  (macros <= m_maxMacroBlocks) /*&& (static_cast<uint32_t>(Level) <= m_maxLevel)*/;
46  if (!result)
47  {
48  LOG(VB_PLAYBACK, LOG_DEBUG, LOC + QString("Not supported: Size %1x%2 > %3x%4, MBs %5 > %6, Level %7 > %8")
49  .arg(Width).arg(Height).arg(m_maxSize.width()).arg(m_maxSize.height())
50  .arg(macros).arg(m_maxMacroBlocks).arg(Level).arg(m_maxLevel));
51  }
52  return result;
53 }
54 
55 bool MythVDPAUHelper::HaveVDPAU(bool Reinit /*=false*/)
56 {
57  static QMutex s_mutex;
58  static bool s_checked = false;
59  static bool s_available = false;
60 
61  QMutexLocker locker(&s_mutex);
62  if (s_checked && !Reinit)
63  return s_available;
64 
65  {
66  MythVDPAUHelper vdpau;
67  s_available = vdpau.IsValid();
68  }
69 
70  s_checked = true;
71  if (s_available)
72  {
73  LOG(VB_GENERAL, LOG_INFO, LOC + "Supported/available VDPAU decoders:");
74  const VDPAUProfiles& profiles = MythVDPAUHelper::GetProfiles();
75  for (const auto& profile : std::as_const(profiles))
76  LOG(VB_GENERAL, LOG_INFO, LOC +
78  }
79  else
80  {
81  LOG(VB_GENERAL, LOG_INFO, LOC + "VDPAU is NOT available");
82  }
83  return s_available;
84 }
85 
86 bool MythVDPAUHelper::ProfileCheck(VdpDecoderProfile Profile, uint32_t &Level,
87  uint32_t &Macros, uint32_t &Width, uint32_t &Height)
88 {
89  if (!m_device)
90  return false;
91 
92  INIT_ST
93  VdpBool supported = VDP_FALSE;
94  status = m_vdpDecoderQueryCapabilities(m_device, Profile, &supported,
95  &Level, &Macros, &Width, &Height);
96  CHECK_ST
97 
98  LOG(VB_PLAYBACK, LOG_DEBUG, LOC + QString("ProfileCheck: Prof %1 Supp %2 Level %3 Macros %4 Width %5 Height %6 Status %7")
99  .arg(Profile).arg(supported).arg(Level).arg(Macros).arg(Width).arg(Height).arg(status));
100 
101  if (((supported != VDP_TRUE) || (status != VDP_STATUS_OK)) &&
102  (Profile == VDP_DECODER_PROFILE_H264_CONSTRAINED_BASELINE ||
103  Profile == VDP_DECODER_PROFILE_H264_BASELINE))
104  {
105  LOG(VB_GENERAL, LOG_INFO, LOC + QString("Driver does not report support for H264 %1Baseline")
106  .arg(Profile == VDP_DECODER_PROFILE_H264_CONSTRAINED_BASELINE ? "Constrained " : ""));
107 
108  // H264 Constrained baseline is reported as not supported on older chipsets but
109  // works due to support for H264 Main. Test for H264 main if constrained baseline
110  // fails - which mimics the fallback in FFmpeg.
111  // Updated to included baseline... not so sure about that:)
112  status = m_vdpDecoderQueryCapabilities(m_device, VDP_DECODER_PROFILE_H264_MAIN, &supported,
113  &Level, &Macros, &Width, &Height);
114  CHECK_ST
115  if (supported == VDP_TRUE)
116  LOG(VB_GENERAL, LOG_INFO, LOC + "... but assuming available as H264 Main is supported");
117  }
118 
119  return supported == VDP_TRUE;
120 }
121 
123 {
124  static const std::array<const VdpDecoderProfile,15> MainProfiles
125  {
126  VDP_DECODER_PROFILE_MPEG1, VDP_DECODER_PROFILE_MPEG2_SIMPLE, VDP_DECODER_PROFILE_MPEG2_MAIN,
127  VDP_DECODER_PROFILE_MPEG4_PART2_SP, VDP_DECODER_PROFILE_MPEG4_PART2_ASP,
128  VDP_DECODER_PROFILE_VC1_SIMPLE, VDP_DECODER_PROFILE_VC1_MAIN, VDP_DECODER_PROFILE_VC1_ADVANCED,
129  VDP_DECODER_PROFILE_H264_BASELINE, VDP_DECODER_PROFILE_H264_MAIN, VDP_DECODER_PROFILE_H264_HIGH,
130  VDP_DECODER_PROFILE_H264_EXTENDED, VDP_DECODER_PROFILE_H264_CONSTRAINED_BASELINE,
131  VDP_DECODER_PROFILE_H264_CONSTRAINED_HIGH, VDP_DECODER_PROFILE_H264_HIGH_444_PREDICTIVE
132  };
133 
134  static const std::array<const VdpDecoderProfile,4> HEVCProfiles
135  {
136  VDP_DECODER_PROFILE_HEVC_MAIN, VDP_DECODER_PROFILE_HEVC_MAIN_10,
137  VDP_DECODER_PROFILE_HEVC_MAIN_STILL, VDP_DECODER_PROFILE_HEVC_MAIN_444
138  };
139 
140  auto VDPAUToMythProfile = [](VdpDecoderProfile Profile)
141  {
142  switch (Profile)
143  {
144  case VDP_DECODER_PROFILE_MPEG1: return MythCodecContext::MPEG1;
145  case VDP_DECODER_PROFILE_MPEG2_SIMPLE: return MythCodecContext::MPEG2Simple;
146  case VDP_DECODER_PROFILE_MPEG2_MAIN: return MythCodecContext::MPEG2Main;
147 
148  case VDP_DECODER_PROFILE_MPEG4_PART2_SP: return MythCodecContext::MPEG4Simple;
149  case VDP_DECODER_PROFILE_MPEG4_PART2_ASP: return MythCodecContext::MPEG4AdvancedSimple;
150 
151  case VDP_DECODER_PROFILE_VC1_SIMPLE: return MythCodecContext::VC1Simple;
152  case VDP_DECODER_PROFILE_VC1_MAIN: return MythCodecContext::VC1Main;
153  case VDP_DECODER_PROFILE_VC1_ADVANCED: return MythCodecContext::VC1Advanced;
154 
155  case VDP_DECODER_PROFILE_H264_BASELINE: return MythCodecContext::H264Baseline;
156  case VDP_DECODER_PROFILE_H264_MAIN: return MythCodecContext::H264Main;
157  case VDP_DECODER_PROFILE_H264_HIGH: return MythCodecContext::H264High;
158  case VDP_DECODER_PROFILE_H264_EXTENDED: return MythCodecContext::H264Extended;
159  case VDP_DECODER_PROFILE_H264_CONSTRAINED_BASELINE: return MythCodecContext::H264ConstrainedBaseline;
160  case VDP_DECODER_PROFILE_H264_CONSTRAINED_HIGH: return MythCodecContext::H264ConstrainedHigh;
161  case VDP_DECODER_PROFILE_H264_HIGH_444_PREDICTIVE: return MythCodecContext::H264High444; // ?
162 
163  case VDP_DECODER_PROFILE_HEVC_MAIN: return MythCodecContext::HEVCMain;
164  case VDP_DECODER_PROFILE_HEVC_MAIN_10: return MythCodecContext::HEVCMain10;
165  case VDP_DECODER_PROFILE_HEVC_MAIN_STILL: return MythCodecContext::HEVCMainStill;
166  case VDP_DECODER_PROFILE_HEVC_MAIN_444: return MythCodecContext::HEVCRext;
167  }
169  };
170 
171  static QRecursiveMutex lock;
172  static bool s_initialised = false;
173  static VDPAUProfiles s_profiles;
174 
175  QMutexLocker locker(&lock);
176  if (s_initialised)
177  return s_profiles;
178  s_initialised = true;
179 
180  MythVDPAUHelper helper;
181  if (!helper.IsValid())
182  return s_profiles;
183 
184  uint32_t level = 0;
185  uint32_t macros = 0;
186  uint32_t width = 0;
187  uint32_t height = 0;
188  for (VdpDecoderProfile profile : MainProfiles)
189  {
190  if (helper.ProfileCheck(profile, level, macros, width, height))
191  {
192  MythCodecContext::CodecProfile prof = VDPAUToMythProfile(profile);
193  s_profiles.emplace_back(prof,
194  VDPAUCodec(prof, QSize(static_cast<int>(width), static_cast<int>(height)), macros, level));
195  }
196  }
197 
198  if (helper.HEVCSupported())
199  {
200  for (VdpDecoderProfile profile : HEVCProfiles)
201  {
202  if (helper.ProfileCheck(profile, level, macros, width, height))
203  {
204  MythCodecContext::CodecProfile prof = VDPAUToMythProfile(profile);
205  s_profiles.emplace_back(prof,
206  VDPAUCodec(prof, QSize(static_cast<int>(width), static_cast<int>(height)), macros, level));
207  }
208  }
209  }
210 
211  return s_profiles;
212 }
213 
214 void MythVDPAUHelper::GetDecoderList(QStringList &Decoders)
215 {
216  const VDPAUProfiles& profiles = MythVDPAUHelper::GetProfiles();
217  if (profiles.empty())
218  return;
219 
220  Decoders.append("VDPAU:");
221  for (const auto& profile : std::as_const(profiles))
222  if (profile.first != MythCodecContext::MJPEG)
223  Decoders.append(MythCodecContext::GetProfileDescription(profile.first, profile.second.m_maxSize));
224 }
225 
226 static void vdpau_preemption_callback(VdpDevice /*unused*/, void* Opaque)
227 {
228  auto* helper = static_cast<MythVDPAUHelper*>(Opaque);
229  if (helper)
230  helper->SetPreempted();
231 }
232 
236 MythVDPAUHelper::MythVDPAUHelper(AVVDPAUDeviceContext* Context)
237  : m_device(Context->device),
238  m_vdpGetProcAddress(Context->get_proc_address)
239 {
240  m_valid = InitProcs();
241  if (m_valid)
242  {
243  INIT_ST
245  CHECK_ST
246  if (!ok)
247  LOG(VB_PLAYBACK, LOG_ERR, LOC + "Failed to register preemption callback");
248  }
249 }
250 
251 static const char* DummyGetError(VdpStatus /*status*/)
252 {
253  return "Unknown";
254 }
255 
257  : m_createdDevice(true)
258 {
260  if (!m_display)
261  return;
262 
263  INIT_ST
265  m_display->Lock();
266  status = vdp_device_create_x11(m_display->GetDisplay(),
267  m_display->GetScreen(),
269  m_display->Unlock();
270  CHECK_ST
271  if (!ok)
272  {
273  LOG(VB_PLAYBACK, LOG_ERR, LOC + "Failed to create VDPAU device.");
274  return;
275  }
276  m_valid = InitProcs();
277 }
278 
280 {
282  m_vdpPreemptionCallbackRegister(m_device, nullptr, nullptr);
285  delete m_display;
286 }
287 
289 {
290  INIT_ST
291  GET_PROC(VDP_FUNC_ID_GET_ERROR_STRING, m_vdpGetErrorString)
292  if (!ok)
293  {
295  ok = true;
296  }
297  GET_PROC(VDP_FUNC_ID_GET_INFORMATION_STRING, m_vdpGetInformationString)
298  GET_PROC(VDP_FUNC_ID_DEVICE_DESTROY, m_vdpDeviceDestroy)
299  GET_PROC(VDP_FUNC_ID_DECODER_QUERY_CAPABILITIES, m_vdpDecoderQueryCapabilities)
300  GET_PROC(VDP_FUNC_ID_DECODER_CREATE, m_vdpDecoderCreate)
301  GET_PROC(VDP_FUNC_ID_DECODER_DESTROY, m_vdpDecoderDestroy)
302  GET_PROC(VDP_FUNC_ID_VIDEO_MIXER_CREATE, m_vdpVideoMixerCreate)
303  GET_PROC(VDP_FUNC_ID_VIDEO_MIXER_DESTROY, m_vdpVideoMixerDestroy)
304  GET_PROC(VDP_FUNC_ID_VIDEO_MIXER_RENDER, m_vdpVideoMixerRender)
305  GET_PROC(VDP_FUNC_ID_VIDEO_MIXER_SET_ATTRIBUTE_VALUES, m_vdpVideoMixerSetAttributeValues)
306  GET_PROC(VDP_FUNC_ID_VIDEO_MIXER_SET_FEATURE_ENABLES, m_vdpVideoMixerSetFeatureEnables)
307  GET_PROC(VDP_FUNC_ID_VIDEO_MIXER_QUERY_FEATURE_SUPPORT, m_vdpVideoMixerQueryFeatureSupport)
308  GET_PROC(VDP_FUNC_ID_VIDEO_MIXER_QUERY_ATTRIBUTE_SUPPORT, m_vdpVideoMixerQueryAttributeSupport)
309  GET_PROC(VDP_FUNC_ID_OUTPUT_SURFACE_CREATE, m_vdpOutputSurfaceCreate)
310  GET_PROC(VDP_FUNC_ID_OUTPUT_SURFACE_DESTROY, m_vdpOutputSurfaceDestroy)
311  GET_PROC(VDP_FUNC_ID_VIDEO_SURFACE_GET_PARAMETERS, m_vdpVideoSurfaceGetParameters)
312  GET_PROC(VDP_FUNC_ID_PREEMPTION_CALLBACK_REGISTER, m_vdpPreemptionCallbackRegister)
313 
314  return ok;
315 }
316 
317 bool MythVDPAUHelper::IsValid(void) const
318 {
319  return m_valid;
320 }
321 
323 {
324  emit DisplayPreempted();
325 }
326 
328 {
329  if (!m_valid)
330  return false;
331 
332  // FFmpeg will disallow HEVC VDPAU for driver versions < 410
333  const char* infostring = nullptr;
334  INIT_ST
335  status = m_vdpGetInformationString(&infostring);
336  CHECK_ST
337  if (!ok || !infostring)
338  return false;
339 
340  if (!QString(infostring).contains("NVIDIA", Qt::CaseInsensitive))
341  return true;
342 
343  int driver = 0;
344  sscanf(infostring, "NVIDIA VDPAU Driver Shared Library %d", &driver);
345  return !(driver < 410);
346 }
347 
348 bool MythVDPAUHelper::CheckH264Decode(AVCodecContext *Context)
349 {
350  if (!Context)
351  return false;
352 
353  int mbs = static_cast<int>(ceil(static_cast<double>(Context->width) / 16.0));
354  if (mbs != 49 && mbs != 54 && mbs != 59 && mbs != 64 &&
355  mbs != 113 && mbs != 118 &&mbs != 123 && mbs != 128)
356  {
357  return true;
358  }
359 
360  VdpDecoderProfile profile = 0;
361  switch (Context->profile & ~FF_PROFILE_H264_INTRA)
362  {
363  case FF_PROFILE_H264_BASELINE: profile = VDP_DECODER_PROFILE_H264_BASELINE; break;
364  case FF_PROFILE_H264_CONSTRAINED_BASELINE: profile = VDP_DECODER_PROFILE_H264_CONSTRAINED_BASELINE; break;
365  case FF_PROFILE_H264_MAIN: profile = VDP_DECODER_PROFILE_H264_MAIN; break;
366  case FF_PROFILE_H264_HIGH: profile = VDP_DECODER_PROFILE_H264_HIGH; break;
367 #ifdef VDP_DECODER_PROFILE_H264_EXTENDED
368  case FF_PROFILE_H264_EXTENDED: profile = VDP_DECODER_PROFILE_H264_EXTENDED; break;
369 #endif
370  case FF_PROFILE_H264_HIGH_10: profile = VDP_DECODER_PROFILE_H264_HIGH; break;
371 #ifdef VDP_DECODER_PROFILE_H264_HIGH_444_PREDICTIVE
372  case FF_PROFILE_H264_HIGH_422:
373  case FF_PROFILE_H264_HIGH_444_PREDICTIVE:
374  case FF_PROFILE_H264_CAVLC_444: profile = VDP_DECODER_PROFILE_H264_HIGH_444_PREDICTIVE; break;
375 #endif
376  default: return false;
377  }
378 
379  // Create an instance
380  MythVDPAUHelper helper;
381  if (helper.IsValid())
382  return helper.H264DecodeCheck(profile, Context);
383  return false;
384 }
385 
386 bool MythVDPAUHelper::H264DecodeCheck(VdpDecoderProfile Profile, AVCodecContext *Context)
387 {
388  if (!m_valid || !Context)
389  return false;
390 
391  INIT_ST
392  VdpDecoder tmp = 0;
393  status = m_vdpDecoderCreate(m_device, Profile, static_cast<uint>(Context->width),
394  static_cast<uint>(Context->height), 2, &tmp);
395  CHECK_ST
396  if (tmp)
398  if (!ok)
399  {
400  LOG(VB_GENERAL, LOG_INFO, LOC + QString("No H264 decoder support for %1x%2")
401  .arg(Context->width).arg(Context->height));
402  }
403  return ok;
404 }
405 
406 VdpOutputSurface MythVDPAUHelper::CreateOutputSurface(QSize Size)
407 {
408  if (!m_valid)
409  return 0;
410 
411  VdpOutputSurface result = 0;
412  INIT_ST
413  status = m_vdpOutputSurfaceCreate(m_device, VDP_RGBA_FORMAT_B8G8R8A8,
414  static_cast<uint>(Size.width()),
415  static_cast<uint>(Size.height()), &result);
416  CHECK_ST
417  return result;
418 }
419 
421 {
422  if (!Surface)
423  return;
424 
425  INIT_ST
427  CHECK_ST
428 }
429 
430 VdpVideoMixer MythVDPAUHelper::CreateMixer(QSize Size, VdpChromaType ChromaType,
431  MythDeintType Deinterlacer)
432 {
433  if (!m_valid || Size.isEmpty())
434  return 0;
435 
436  VdpVideoMixer result = 0;
437 
438  static const std::array<const VdpVideoMixerParameter,3> parameters {
439  VDP_VIDEO_MIXER_PARAMETER_VIDEO_SURFACE_WIDTH,
440  VDP_VIDEO_MIXER_PARAMETER_VIDEO_SURFACE_HEIGHT,
441  VDP_VIDEO_MIXER_PARAMETER_CHROMA_TYPE
442  };
443 
444 
445  uint width = static_cast<uint>(Size.width());
446  uint height = static_cast<uint>(Size.height());
447  std::array<void const *,3> parametervalues { &width, &height, &ChromaType};
448 
449  uint32_t featurecount = 0;
450  std::array<VdpVideoMixerFeature,2> features {};
451  VdpBool enable = VDP_TRUE;
452  const std::array<VdpBool,2> enables = { enable, enable };
453 
454  if (DEINT_MEDIUM == Deinterlacer || DEINT_HIGH == Deinterlacer)
455  {
456  features[featurecount] = VDP_VIDEO_MIXER_FEATURE_DEINTERLACE_TEMPORAL;
457  featurecount++;
458  }
459 
460  if (DEINT_HIGH== Deinterlacer)
461  {
462  features[featurecount] = VDP_VIDEO_MIXER_FEATURE_DEINTERLACE_TEMPORAL_SPATIAL;
463  featurecount++;
464  }
465 
466  INIT_ST
467  status = m_vdpVideoMixerCreate(m_device, featurecount, featurecount ? features.data() : nullptr,
468  3, parameters.data(), parametervalues.data(), &result);
469  CHECK_ST
470 
471  if (!ok || !result)
472  {
473  LOG(VB_GENERAL, LOG_ERR, LOC + "Failed to create video mixer");
474  return result;
475  }
476 
477  if (featurecount)
478  {
479  status = m_vdpVideoMixerSetFeatureEnables(result, featurecount, features.data(), enables.data());
480  CHECK_ST
481  }
482  return result;
483 }
484 
485 void MythVDPAUHelper::MixerRender(VdpVideoMixer Mixer, VdpVideoSurface Source,
486  VdpOutputSurface Dest, FrameScanType Scan, int TopFieldFirst,
487  QVector<AVBufferRef*>& Frames)
488 {
489  if (!m_valid || !Mixer || !Source || !Dest)
490  return;
491 
492  VdpVideoMixerPictureStructure field = VDP_VIDEO_MIXER_PICTURE_STRUCTURE_FRAME;
493  if (kScan_Interlaced == Scan)
494  {
495  field = TopFieldFirst ? VDP_VIDEO_MIXER_PICTURE_STRUCTURE_TOP_FIELD :
496  VDP_VIDEO_MIXER_PICTURE_STRUCTURE_BOTTOM_FIELD;
497  }
498  else if (kScan_Intr2ndField == Scan)
499  {
500  field = TopFieldFirst ? VDP_VIDEO_MIXER_PICTURE_STRUCTURE_BOTTOM_FIELD :
501  VDP_VIDEO_MIXER_PICTURE_STRUCTURE_TOP_FIELD;
502  }
503 
504  int count = Frames.size();
505  if ((count < 1) || (field == VDP_VIDEO_MIXER_PICTURE_STRUCTURE_FRAME))
506  {
507  INIT_ST
508  status = m_vdpVideoMixerRender(Mixer, VDP_INVALID_HANDLE, nullptr, field,
509  0, nullptr, Source, 0, nullptr, nullptr, Dest, nullptr, nullptr, 0, nullptr);
510  CHECK_ST
511  }
512  else
513  {
514  std::array<VdpVideoSurface,2> past = { VDP_INVALID_HANDLE, VDP_INVALID_HANDLE };
515  std::array<VdpVideoSurface,1> future = { VDP_INVALID_HANDLE };
516 
517  auto next = static_cast<VdpVideoSurface>(reinterpret_cast<uintptr_t>(Frames[0]->data));
518  auto current = static_cast<VdpVideoSurface>(reinterpret_cast<uintptr_t>(Frames[count > 1 ? 1 : 0]->data));
519  auto last = static_cast<VdpVideoSurface>(reinterpret_cast<uintptr_t>(Frames[count > 2 ? 2 : 0]->data));
520 
521  if (field == VDP_VIDEO_MIXER_PICTURE_STRUCTURE_BOTTOM_FIELD)
522  {
523  future[0] = current;
524  past[0] = past[1] = last;
525  }
526  else
527  {
528  future[0] = next;
529  past[0] = current;
530  past[1] = last;
531  }
532 
533  INIT_ST
534  status = m_vdpVideoMixerRender(Mixer, VDP_INVALID_HANDLE, nullptr, field,
535  2, past.data(), current, 1, future.data(),
536  nullptr, Dest, nullptr, nullptr, 0, nullptr);
537  CHECK_ST
538  }
539 }
540 
541 void MythVDPAUHelper::DeleteMixer(VdpVideoMixer Mixer)
542 {
543  if (!Mixer)
544  return;
545 
546  INIT_ST
547  status = m_vdpVideoMixerDestroy(Mixer);
548  CHECK_ST
549 }
550 
551 void MythVDPAUHelper::SetCSCMatrix(VdpVideoMixer Mixer, MythVideoColourSpace *ColourSpace)
552 {
553  if (!Mixer || !ColourSpace)
554  return;
555 
556  VdpVideoMixerAttribute attr = { VDP_VIDEO_MIXER_ATTRIBUTE_CSC_MATRIX };
557  void const* val = { ColourSpace->data() };
558 
559  INIT_ST
560  status = m_vdpVideoMixerSetAttributeValues(Mixer, 1, &attr, &val);
561  CHECK_ST
562 }
563 
565 {
566  if (!m_valid)
567  return false;
568 
569  INIT_ST
570  auto supported = static_cast<VdpBool>(false);
571  status = m_vdpVideoMixerQueryFeatureSupport(m_device, Feature, &supported);
572  CHECK_ST
573  return ok && static_cast<bool>(supported);
574 }
575 
577 {
578  if (!m_valid)
579  return false;
580 
581  INIT_ST
582  auto supported = static_cast<VdpBool>(false);
583  status = m_vdpVideoMixerQueryAttributeSupport(m_device, Attribute, &supported);
584  CHECK_ST
585  return ok && static_cast<bool>(supported);
586 }
587 
588 QSize MythVDPAUHelper::GetSurfaceParameters(VdpVideoSurface Surface, VdpChromaType &Chroma)
589 {
590  if (!Surface)
591  return {};
592 
593  uint width = 0;
594  uint height = 0;
595  INIT_ST
596  status = m_vdpVideoSurfaceGetParameters(Surface, &Chroma, &width, &height);
597  CHECK_ST
598 
599  return {static_cast<int>(width), static_cast<int>(height)};
600 }
MythCodecContext::VC1Simple
@ VC1Simple
Definition: mythcodeccontext.h:103
INIT_ST
#define INIT_ST
Definition: mythvdpauhelper.cpp:12
MythCodecContext::MPEG4Simple
@ MPEG4Simple
Definition: mythcodeccontext.h:67
MythVDPAUHelper::GetProfiles
static const VDPAUProfiles & GetProfiles(void)
Definition: mythvdpauhelper.cpp:122
MythVDPAUHelper::m_vdpVideoMixerQueryAttributeSupport
VdpVideoMixerQueryAttributeSupport * m_vdpVideoMixerQueryAttributeSupport
Definition: mythvdpauhelper.h:121
MythVDPAUHelper::~MythVDPAUHelper
~MythVDPAUHelper(void) override
Definition: mythvdpauhelper.cpp:279
MythVDPAUHelper::m_vdpVideoMixerQueryFeatureSupport
VdpVideoMixerQueryFeatureSupport * m_vdpVideoMixerQueryFeatureSupport
Definition: mythvdpauhelper.h:120
MythCodecContext::H264Baseline
@ H264Baseline
Definition: mythcodeccontext.h:85
MythXDisplay::Lock
void Lock()
Definition: mythxdisplay.h:28
MythCodecContext::MPEG2Simple
@ MPEG2Simple
Definition: mythcodeccontext.h:60
DEINT_MEDIUM
@ DEINT_MEDIUM
Definition: mythframe.h:71
MythVDPAUHelper::m_vdpOutputSurfaceDestroy
VdpOutputSurfaceDestroy * m_vdpOutputSurfaceDestroy
Definition: mythvdpauhelper.h:123
MythCodecContext::VC1Advanced
@ VC1Advanced
Definition: mythcodeccontext.h:106
MythVDPAUHelper::m_vdpDecoderQueryCapabilities
VdpDecoderQueryCapabilities * m_vdpDecoderQueryCapabilities
Definition: mythvdpauhelper.h:112
MythXDisplay::GetDisplay
Display * GetDisplay()
Definition: mythxdisplay.h:25
VDPAUCodec::m_maxSize
QSize m_maxSize
Definition: mythvdpauhelper.h:44
MythVDPAUHelper::SetCSCMatrix
void SetCSCMatrix(VdpVideoMixer Mixer, MythVideoColourSpace *ColourSpace)
Definition: mythvdpauhelper.cpp:551
MythCodecContext::HEVCMain10
@ HEVCMain10
Definition: mythcodeccontext.h:97
VDPAUCodec::m_maxMacroBlocks
uint32_t m_maxMacroBlocks
Definition: mythvdpauhelper.h:45
VDPAUProfiles
std::vector< VDPAUProfile > VDPAUProfiles
Definition: mythvdpauhelper.h:50
MythXDisplay::GetScreen
int GetScreen() const
Definition: mythxdisplay.h:27
MythCodecContext::NoProfile
@ NoProfile
Definition: mythcodeccontext.h:57
MythCodecContext::MPEG4AdvancedSimple
@ MPEG4AdvancedSimple
Definition: mythcodeccontext.h:82
VDPAUCodec::m_maxLevel
uint32_t m_maxLevel
Definition: mythvdpauhelper.h:46
MythCodecContext::CodecProfile
CodecProfile
Definition: mythcodeccontext.h:55
MythVDPAUHelper::m_vdpGetErrorString
VdpGetErrorString * m_vdpGetErrorString
Definition: mythvdpauhelper.h:109
MythVDPAUHelper::MythVDPAUHelper
MythVDPAUHelper(void)
Definition: mythvdpauhelper.cpp:256
MythCodecContext::HEVCRext
@ HEVCRext
Definition: mythcodeccontext.h:99
MythCodecContext::VC1Main
@ VC1Main
Definition: mythcodeccontext.h:104
Surface
Definition: surface.h:4
FrameScanType
FrameScanType
Definition: videoouttypes.h:94
MythVDPAUHelper::HaveVDPAU
static bool HaveVDPAU(bool Reinit=false)
Definition: mythvdpauhelper.cpp:55
MythVDPAUHelper::m_valid
bool m_valid
Definition: mythvdpauhelper.h:103
LOG
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
Definition: mythlogging.h:39
MythVDPAUHelper::m_vdpVideoMixerDestroy
VdpVideoMixerDestroy * m_vdpVideoMixerDestroy
Definition: mythvdpauhelper.h:116
MythVDPAUHelper::IsFeatureAvailable
bool IsFeatureAvailable(uint Feature)
Definition: mythvdpauhelper.cpp:564
MythVDPAUHelper::IsAttributeAvailable
bool IsAttributeAvailable(uint Attribute)
Definition: mythvdpauhelper.cpp:576
MythVDPAUHelper::CreateOutputSurface
VdpOutputSurface CreateOutputSurface(QSize Size)
Definition: mythvdpauhelper.cpp:406
MythCodecContext::HEVCMainStill
@ HEVCMainStill
Definition: mythcodeccontext.h:98
MythVDPAUHelper::InitProcs
bool InitProcs(void)
Definition: mythvdpauhelper.cpp:288
MythCodecContext::H264Extended
@ H264Extended
Definition: mythcodeccontext.h:91
MythCodecContext::H264ConstrainedBaseline
@ H264ConstrainedBaseline
Definition: mythcodeccontext.h:86
MythDate::current
QDateTime current(bool stripped)
Returns current Date and Time in UTC.
Definition: mythdate.cpp:14
true
VERBOSE_PREAMBLE Most true
Definition: verbosedefs.h:95
MythXDisplay::OpenMythXDisplay
static MythXDisplay * OpenMythXDisplay(bool Warn=true)
Definition: mythxdisplay.cpp:25
tmp
static guint32 * tmp
Definition: goom_core.cpp:26
MythVDPAUHelper::m_createdDevice
bool m_createdDevice
Definition: mythvdpauhelper.h:104
MythVDPAUHelper::DeleteOutputSurface
void DeleteOutputSurface(VdpOutputSurface Surface)
Definition: mythvdpauhelper.cpp:420
mythvideocolourspace.h
kScan_Intr2ndField
@ kScan_Intr2ndField
Definition: videoouttypes.h:99
CHECK_ST
#define CHECK_ST
Definition: mythvdpauhelper.cpp:17
MythVDPAUHelper::m_display
MythXDisplay * m_display
Definition: mythvdpauhelper.h:106
mythlogging.h
LOC
#define LOC
Definition: mythvdpauhelper.cpp:10
MythVDPAUHelper::GetDecoderList
static void GetDecoderList(QStringList &Decoders)
Definition: mythvdpauhelper.cpp:214
hardwareprofile.scan.profile
profile
Definition: scan.py:97
Source
Definition: channelsettings.cpp:93
mythvdpauhelper.h
MythVDPAUHelper::DisplayPreempted
void DisplayPreempted(void)
MythCodecContext::MPEG2SNR
@ MPEG2SNR
Definition: mythcodeccontext.h:65
MythVDPAUHelper::SetPreempted
void SetPreempted(void)
Definition: mythvdpauhelper.cpp:322
vdpau_preemption_callback
static void vdpau_preemption_callback(VdpDevice, void *Opaque)
Definition: mythvdpauhelper.cpp:226
MythVDPAUHelper
A simple wrapper around VDPAU functionality.
Definition: mythvdpauhelper.h:52
MythCodecContext::H264Main
@ H264Main
Definition: mythcodeccontext.h:87
MythVDPAUHelper::m_vdpVideoMixerRender
VdpVideoMixerRender * m_vdpVideoMixerRender
Definition: mythvdpauhelper.h:117
MythVDPAUHelper::DeleteMixer
void DeleteMixer(VdpVideoMixer Mixer)
Definition: mythvdpauhelper.cpp:541
MythCodecContext::MPEG1
@ MPEG1
Definition: mythcodeccontext.h:58
MythVDPAUHelper::GetSurfaceParameters
QSize GetSurfaceParameters(VdpVideoSurface Surface, VdpChromaType &Chroma)
Definition: mythvdpauhelper.cpp:588
MythVDPAUHelper::m_vdpGetProcAddress
VdpGetProcAddress * m_vdpGetProcAddress
Definition: mythvdpauhelper.h:108
MythVDPAUHelper::IsValid
bool IsValid(void) const
Definition: mythvdpauhelper.cpp:317
uint
unsigned int uint
Definition: compat.h:81
MythVDPAUHelper::m_vdpVideoMixerSetFeatureEnables
VdpVideoMixerSetFeatureEnables * m_vdpVideoMixerSetFeatureEnables
Definition: mythvdpauhelper.h:119
MythVDPAUHelper::CreateMixer
VdpVideoMixer CreateMixer(QSize Size, VdpChromaType ChromaType=VDP_CHROMA_TYPE_420, MythDeintType Deinterlacer=DEINT_BASIC)
Definition: mythvdpauhelper.cpp:430
MythCodecContext::H264High444
@ H264High444
Definition: mythcodeccontext.h:93
mythxdisplay.h
MythXDisplay::Unlock
void Unlock()
Definition: mythxdisplay.h:29
DummyGetError
static const char * DummyGetError(VdpStatus)
Definition: mythvdpauhelper.cpp:251
MythDeintType
MythDeintType
Definition: mythframe.h:67
MythVDPAUHelper::m_vdpGetInformationString
VdpGetInformationString * m_vdpGetInformationString
Definition: mythvdpauhelper.h:110
MythVDPAUHelper::m_vdpDeviceDestroy
VdpDeviceDestroy * m_vdpDeviceDestroy
Definition: mythvdpauhelper.h:111
MythCodecContext::MPEG2Main
@ MPEG2Main
Definition: mythcodeccontext.h:61
kScan_Interlaced
@ kScan_Interlaced
Definition: videoouttypes.h:98
MythVDPAUHelper::HEVCSupported
bool HEVCSupported(void)
Definition: mythvdpauhelper.cpp:327
MythVDPAUHelper::ProfileCheck
bool ProfileCheck(VdpDecoderProfile Profile, uint32_t &Level, uint32_t &Macros, uint32_t &Width, uint32_t &Height)
Definition: mythvdpauhelper.cpp:86
MythVDPAUHelper::m_vdpDecoderCreate
VdpDecoderCreate * m_vdpDecoderCreate
Definition: mythvdpauhelper.h:113
DEINT_HIGH
@ DEINT_HIGH
Definition: mythframe.h:72
MythVDPAUHelper::m_vdpVideoMixerCreate
VdpVideoMixerCreate * m_vdpVideoMixerCreate
Definition: mythvdpauhelper.h:115
MythCodecContext::MJPEG
@ MJPEG
Definition: mythcodeccontext.h:121
MythVDPAUHelper::H264DecodeCheck
bool H264DecodeCheck(VdpDecoderProfile Profile, AVCodecContext *Context)
Definition: mythvdpauhelper.cpp:386
MythVDPAUHelper::CheckH264Decode
static bool CheckH264Decode(AVCodecContext *Context)
Definition: mythvdpauhelper.cpp:348
MythVDPAUHelper::MixerRender
void MixerRender(VdpVideoMixer Mixer, VdpVideoSurface Source, VdpOutputSurface Dest, FrameScanType Scan, int TopFieldFirst, QVector< AVBufferRef * > &Frames)
Definition: mythvdpauhelper.cpp:485
MythCodecContext::H264High
@ H264High
Definition: mythcodeccontext.h:89
MythCodecContext::GetProfileDescription
static QString GetProfileDescription(CodecProfile Profile, QSize Size, VideoFrameType Format=FMT_NONE, uint ColorDepth=0)
Definition: mythcodeccontext.cpp:787
VDPAUCodec::VDPAUCodec
VDPAUCodec(MythCodecContext::CodecProfile Profile, QSize Size, uint32_t Macroblocks, uint32_t Level)
Definition: mythvdpauhelper.cpp:30
MythVDPAUHelper::m_vdpVideoMixerSetAttributeValues
VdpVideoMixerSetAttributeValues * m_vdpVideoMixerSetAttributeValues
Definition: mythvdpauhelper.h:118
VDPAUCodec::Supported
bool Supported(int Width, int Height, int Level) const
Definition: mythvdpauhelper.cpp:40
VDPAUCodec
Definition: mythvdpauhelper.h:38
MythVDPAUHelper::m_vdpDecoderDestroy
VdpDecoderDestroy * m_vdpDecoderDestroy
Definition: mythvdpauhelper.h:114
MythVDPAUHelper::m_vdpVideoSurfaceGetParameters
VdpVideoSurfaceGetParameters * m_vdpVideoSurfaceGetParameters
Definition: mythvdpauhelper.h:124
GET_PROC
#define GET_PROC(FUNC_ID, PROC)
Definition: mythvdpauhelper.cpp:26
MythVDPAUHelper::m_vdpOutputSurfaceCreate
VdpOutputSurfaceCreate * m_vdpOutputSurfaceCreate
Definition: mythvdpauhelper.h:122
MythVDPAUHelper::m_vdpPreemptionCallbackRegister
VdpPreemptionCallbackRegister * m_vdpPreemptionCallbackRegister
Definition: mythvdpauhelper.h:125
MythVDPAUHelper::m_device
VdpDevice m_device
Definition: mythvdpauhelper.h:105
MythCodecContext::H264ConstrainedHigh
@ H264ConstrainedHigh
Definition: mythcodeccontext.h:94
MythVideoColourSpace
MythVideoColourSpace contains a QMatrix4x4 that can convert YCbCr data to RGB.
Definition: mythvideocolourspace.h:18
MythCodecContext::HEVCMain
@ HEVCMain
Definition: mythcodeccontext.h:96