MythTV  master
mythvdpauhelper.cpp
Go to the documentation of this file.
1 // MythTV
2 #include "mythlogging.h"
3 #include "mythvideocolourspace.h"
4 #include "mythvdpauhelper.h"
5 #include "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 #define CHECK_ST \
17 ok &= (status == VDP_STATUS_OK); \
18 if (!ok) \
19 { \
20  LOG(VB_PLAYBACK, LOG_ERR, LOC + QString("Error at %1:%2 (#%3, %4)") \
21  .arg(__FILE__).arg( __LINE__).arg(status) \
22  .arg(m_vdpGetErrorString(status))); \
23 }
24 
25 #define GET_PROC(FUNC_ID, PROC) \
26 status = m_vdpGetProcAddress(m_device, FUNC_ID, reinterpret_cast<void **>(&(PROC))); CHECK_ST
27 
28 VDPAUCodec::VDPAUCodec(MythCodecContext::CodecProfile Profile, QSize Size, uint32_t Macroblocks, uint32_t Level)
29  : m_maxSize(Size),
30  m_maxMacroBlocks(Macroblocks),
31  m_maxLevel(Level)
32 {
33  // Levels don't work for MPEG1/2
34  if (MythCodecContext::MPEG1 <= Profile && Profile <= MythCodecContext::MPEG2SNR)
35  m_maxLevel = 1000;
36 }
37 
38 bool VDPAUCodec::Supported(int Width, int Height, int Level) const
39 {
40  // Note - level checks are now ignored here and in FFmpeg
41  uint32_t macros = static_cast<uint32_t>(((Width + 15) & ~15) * ((Height + 15) & ~15)) / 256;
42  bool result = (Width <= m_maxSize.width()) && (Height <= m_maxSize.height()) &&
43  (macros <= m_maxMacroBlocks) /*&& (static_cast<uint32_t>(Level) <= m_maxLevel)*/;
44  if (!result)
45  {
46  LOG(VB_PLAYBACK, LOG_DEBUG, LOC + QString("Not supported: Size %1x%2 > %3x%4, MBs %5 > %6, Level %7 > %8")
47  .arg(Width).arg(Height).arg(m_maxSize.width()).arg(m_maxSize.height())
48  .arg(macros).arg(m_maxMacroBlocks).arg(Level).arg(m_maxLevel));
49  }
50  return result;
51 }
52 
53 bool MythVDPAUHelper::HaveVDPAU(bool Reinit /*=false*/)
54 {
55  static QMutex s_mutex;
56  static bool s_checked = false;
57  static bool s_available = false;
58 
59  QMutexLocker locker(&s_mutex);
60  if (s_checked && !Reinit)
61  return s_available;
62 
63  {
64  MythVDPAUHelper vdpau;
65  s_available = vdpau.IsValid();
66  }
67 
68  s_checked = true;
69  if (s_available)
70  {
71  LOG(VB_GENERAL, LOG_INFO, LOC + "Supported/available VDPAU decoders:");
72  const VDPAUProfiles& profiles = MythVDPAUHelper::GetProfiles();
73  for (auto profile : qAsConst(profiles))
74  LOG(VB_GENERAL, LOG_INFO, LOC +
76  }
77  else
78  {
79  LOG(VB_GENERAL, LOG_INFO, LOC + "VDPAU is NOT available");
80  }
81  return s_available;
82 }
83 
84 bool MythVDPAUHelper::ProfileCheck(VdpDecoderProfile Profile, uint32_t &Level,
85  uint32_t &Macros, uint32_t &Width, uint32_t &Height)
86 {
87  if (!m_device)
88  return false;
89 
90  INIT_ST
91  VdpBool supported = VDP_FALSE;
92  status = m_vdpDecoderQueryCapabilities(m_device, Profile, &supported,
93  &Level, &Macros, &Width, &Height);
94  CHECK_ST
95 
96  LOG(VB_PLAYBACK, LOG_DEBUG, LOC + QString("ProfileCheck: Prof %1 Supp %2 Level %3 Macros %4 Width %5 Height %6 Status %7")
97  .arg(Profile).arg(supported).arg(Level).arg(Macros).arg(Width).arg(Height).arg(status));
98 
99  if (((supported != VDP_TRUE) || (status != VDP_STATUS_OK)) &&
100  (Profile == VDP_DECODER_PROFILE_H264_CONSTRAINED_BASELINE ||
101  Profile == VDP_DECODER_PROFILE_H264_BASELINE))
102  {
103  LOG(VB_GENERAL, LOG_INFO, LOC + QString("Driver does not report support for H264 %1Baseline")
104  .arg(Profile == VDP_DECODER_PROFILE_H264_CONSTRAINED_BASELINE ? "Constrained " : ""));
105 
106  // H264 Constrained baseline is reported as not supported on older chipsets but
107  // works due to support for H264 Main. Test for H264 main if constrained baseline
108  // fails - which mimics the fallback in FFmpeg.
109  // Updated to included baseline... not so sure about that:)
110  status = m_vdpDecoderQueryCapabilities(m_device, VDP_DECODER_PROFILE_H264_MAIN, &supported,
111  &Level, &Macros, &Width, &Height);
112  CHECK_ST
113  if (supported == VDP_TRUE)
114  LOG(VB_GENERAL, LOG_INFO, LOC + "... but assuming available as H264 Main is supported");
115  }
116 
117  return supported == VDP_TRUE;
118 }
119 
121 {
122  static const std::array<const VdpDecoderProfile,15> MainProfiles
123  {
124  VDP_DECODER_PROFILE_MPEG1, VDP_DECODER_PROFILE_MPEG2_SIMPLE, VDP_DECODER_PROFILE_MPEG2_MAIN,
125  VDP_DECODER_PROFILE_MPEG4_PART2_SP, VDP_DECODER_PROFILE_MPEG4_PART2_ASP,
126  VDP_DECODER_PROFILE_VC1_SIMPLE, VDP_DECODER_PROFILE_VC1_MAIN, VDP_DECODER_PROFILE_VC1_ADVANCED,
127  VDP_DECODER_PROFILE_H264_BASELINE, VDP_DECODER_PROFILE_H264_MAIN, VDP_DECODER_PROFILE_H264_HIGH,
128  VDP_DECODER_PROFILE_H264_EXTENDED, VDP_DECODER_PROFILE_H264_CONSTRAINED_BASELINE,
129  VDP_DECODER_PROFILE_H264_CONSTRAINED_HIGH, VDP_DECODER_PROFILE_H264_HIGH_444_PREDICTIVE
130  };
131 
132  static const std::array<const VdpDecoderProfile,4> HEVCProfiles
133  {
134  VDP_DECODER_PROFILE_HEVC_MAIN, VDP_DECODER_PROFILE_HEVC_MAIN_10,
135  VDP_DECODER_PROFILE_HEVC_MAIN_STILL, VDP_DECODER_PROFILE_HEVC_MAIN_444
136  };
137 
138  auto VDPAUToMythProfile = [](VdpDecoderProfile Profile)
139  {
140  switch (Profile)
141  {
142  case VDP_DECODER_PROFILE_MPEG1: return MythCodecContext::MPEG1;
143  case VDP_DECODER_PROFILE_MPEG2_SIMPLE: return MythCodecContext::MPEG2Simple;
144  case VDP_DECODER_PROFILE_MPEG2_MAIN: return MythCodecContext::MPEG2Main;
145 
146  case VDP_DECODER_PROFILE_MPEG4_PART2_SP: return MythCodecContext::MPEG4Simple;
147  case VDP_DECODER_PROFILE_MPEG4_PART2_ASP: return MythCodecContext::MPEG4AdvancedSimple;
148 
149  case VDP_DECODER_PROFILE_VC1_SIMPLE: return MythCodecContext::VC1Simple;
150  case VDP_DECODER_PROFILE_VC1_MAIN: return MythCodecContext::VC1Main;
151  case VDP_DECODER_PROFILE_VC1_ADVANCED: return MythCodecContext::VC1Advanced;
152 
153  case VDP_DECODER_PROFILE_H264_BASELINE: return MythCodecContext::H264Baseline;
154  case VDP_DECODER_PROFILE_H264_MAIN: return MythCodecContext::H264Main;
155  case VDP_DECODER_PROFILE_H264_HIGH: return MythCodecContext::H264High;
156  case VDP_DECODER_PROFILE_H264_EXTENDED: return MythCodecContext::H264Extended;
157  case VDP_DECODER_PROFILE_H264_CONSTRAINED_BASELINE: return MythCodecContext::H264ConstrainedBaseline;
158  case VDP_DECODER_PROFILE_H264_CONSTRAINED_HIGH: return MythCodecContext::H264ConstrainedHigh;
159  case VDP_DECODER_PROFILE_H264_HIGH_444_PREDICTIVE: return MythCodecContext::H264High444; // ?
160 
161  case VDP_DECODER_PROFILE_HEVC_MAIN: return MythCodecContext::HEVCMain;
162  case VDP_DECODER_PROFILE_HEVC_MAIN_10: return MythCodecContext::HEVCMain10;
163  case VDP_DECODER_PROFILE_HEVC_MAIN_STILL: return MythCodecContext::HEVCMainStill;
164  case VDP_DECODER_PROFILE_HEVC_MAIN_444: return MythCodecContext::HEVCRext;
165  }
167  };
168 
169 #if QT_VERSION < QT_VERSION_CHECK(5,14,0)
170  static QMutex lock(QMutex::Recursive);
171 #else
172  static QRecursiveMutex lock;
173 #endif
174  static bool s_initialised = false;
175  static VDPAUProfiles s_profiles;
176 
177  QMutexLocker locker(&lock);
178  if (s_initialised)
179  return s_profiles;
180  s_initialised = true;
181 
182  MythVDPAUHelper helper;
183  if (!helper.IsValid())
184  return s_profiles;
185 
186  uint32_t level = 0;
187  uint32_t macros = 0;
188  uint32_t width = 0;
189  uint32_t height = 0;
190  for (VdpDecoderProfile profile : MainProfiles)
191  {
192  if (helper.ProfileCheck(profile, level, macros, width, height))
193  {
194  MythCodecContext::CodecProfile prof = VDPAUToMythProfile(profile);
195  s_profiles.push_back(VDPAUProfile(prof,
196  VDPAUCodec(prof, QSize(static_cast<int>(width), static_cast<int>(height)), macros, level)));
197  }
198  }
199 
200  if (helper.HEVCSupported())
201  {
202  for (VdpDecoderProfile profile : HEVCProfiles)
203  {
204  if (helper.ProfileCheck(profile, level, macros, width, height))
205  {
206  MythCodecContext::CodecProfile prof = VDPAUToMythProfile(profile);
207  s_profiles.push_back(VDPAUProfile(prof,
208  VDPAUCodec(prof, QSize(static_cast<int>(width), static_cast<int>(height)), macros, level)));
209  }
210  }
211  }
212 
213  return s_profiles;
214 }
215 
216 void MythVDPAUHelper::GetDecoderList(QStringList &Decoders)
217 {
218  const VDPAUProfiles& profiles = MythVDPAUHelper::GetProfiles();
219  if (profiles.empty())
220  return;
221 
222  Decoders.append("VDPAU:");
223  for (auto profile : qAsConst(profiles))
224  if (profile.first != MythCodecContext::MJPEG)
225  Decoders.append(MythCodecContext::GetProfileDescription(profile.first, profile.second.m_maxSize));
226 }
227 
228 static void vdpau_preemption_callback(VdpDevice /*unused*/, void* Opaque)
229 {
230  auto* helper = static_cast<MythVDPAUHelper*>(Opaque);
231  if (helper)
232  helper->SetPreempted();
233 }
234 
238 MythVDPAUHelper::MythVDPAUHelper(AVVDPAUDeviceContext* Context)
239  : m_device(Context->device),
240  m_vdpGetProcAddress(Context->get_proc_address)
241 {
242  m_valid = InitProcs();
243  if (m_valid)
244  {
245  INIT_ST
247  CHECK_ST
248  if (!ok)
249  LOG(VB_PLAYBACK, LOG_ERR, LOC + "Failed to register preemption callback");
250  }
251 }
252 
253 static const char* DummyGetError(VdpStatus /*status*/)
254 {
255  return "Unknown";
256 }
257 
259  : m_createdDevice(true)
260 {
262  if (!m_display)
263  return;
264 
265  INIT_ST
267  XLOCK(m_display, status = vdp_device_create_x11(m_display->GetDisplay(),
268  m_display->GetScreen(),
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:104
INIT_ST
#define INIT_ST
Definition: mythvdpauhelper.cpp:12
MythCodecContext::MPEG4Simple
@ MPEG4Simple
Definition: mythcodeccontext.h:68
MythVDPAUHelper::GetProfiles
static const VDPAUProfiles & GetProfiles(void)
Definition: mythvdpauhelper.cpp:120
MythVDPAUHelper::m_vdpVideoMixerQueryAttributeSupport
VdpVideoMixerQueryAttributeSupport * m_vdpVideoMixerQueryAttributeSupport
Definition: mythvdpauhelper.h:114
MythVDPAUHelper::~MythVDPAUHelper
~MythVDPAUHelper(void) override
Definition: mythvdpauhelper.cpp:279
MythVDPAUHelper::m_vdpVideoMixerQueryFeatureSupport
VdpVideoMixerQueryFeatureSupport * m_vdpVideoMixerQueryFeatureSupport
Definition: mythvdpauhelper.h:113
MythCodecContext::H264Baseline
@ H264Baseline
Definition: mythcodeccontext.h:86
MythCodecContext::MPEG2Simple
@ MPEG2Simple
Definition: mythcodeccontext.h:61
DEINT_MEDIUM
@ DEINT_MEDIUM
Definition: mythframe.h:71
MythVDPAUHelper::m_vdpOutputSurfaceDestroy
VdpOutputSurfaceDestroy * m_vdpOutputSurfaceDestroy
Definition: mythvdpauhelper.h:116
MythCodecContext::VC1Advanced
@ VC1Advanced
Definition: mythcodeccontext.h:107
MythVDPAUHelper::m_vdpDecoderQueryCapabilities
VdpDecoderQueryCapabilities * m_vdpDecoderQueryCapabilities
Definition: mythvdpauhelper.h:105
MythXDisplay::GetDisplay
Display * GetDisplay()
Definition: mythxdisplay.h:31
VDPAUCodec::m_maxSize
QSize m_maxSize
Definition: mythvdpauhelper.h:37
MythVDPAUHelper::SetCSCMatrix
void SetCSCMatrix(VdpVideoMixer Mixer, MythVideoColourSpace *ColourSpace)
Definition: mythvdpauhelper.cpp:551
MythCodecContext::HEVCMain10
@ HEVCMain10
Definition: mythcodeccontext.h:98
VDPAUCodec::m_maxMacroBlocks
uint32_t m_maxMacroBlocks
Definition: mythvdpauhelper.h:38
VDPAUProfiles
std::vector< VDPAUProfile > VDPAUProfiles
Definition: mythvdpauhelper.h:43
MythXDisplay::GetScreen
int GetScreen() const
Definition: mythxdisplay.h:33
MythCodecContext::NoProfile
@ NoProfile
Definition: mythcodeccontext.h:58
MythCodecContext::MPEG4AdvancedSimple
@ MPEG4AdvancedSimple
Definition: mythcodeccontext.h:83
VDPAUCodec::m_maxLevel
uint32_t m_maxLevel
Definition: mythvdpauhelper.h:39
MythCodecContext::CodecProfile
CodecProfile
Definition: mythcodeccontext.h:56
MythVDPAUHelper::m_vdpGetErrorString
VdpGetErrorString * m_vdpGetErrorString
Definition: mythvdpauhelper.h:102
MythVDPAUHelper::MythVDPAUHelper
MythVDPAUHelper(void)
Definition: mythvdpauhelper.cpp:258
MythCodecContext::HEVCRext
@ HEVCRext
Definition: mythcodeccontext.h:100
MythCodecContext::VC1Main
@ VC1Main
Definition: mythcodeccontext.h:105
Surface
Definition: surface.h:4
FrameScanType
FrameScanType
Definition: videoouttypes.h:94
MythVDPAUHelper::HaveVDPAU
static bool HaveVDPAU(bool Reinit=false)
Definition: mythvdpauhelper.cpp:53
MythVDPAUHelper::m_valid
bool m_valid
Definition: mythvdpauhelper.h:96
LOG
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
Definition: mythlogging.h:23
MythVDPAUHelper::m_vdpVideoMixerDestroy
VdpVideoMixerDestroy * m_vdpVideoMixerDestroy
Definition: mythvdpauhelper.h:109
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:99
MythVDPAUHelper::InitProcs
bool InitProcs(void)
Definition: mythvdpauhelper.cpp:288
MythCodecContext::H264Extended
@ H264Extended
Definition: mythcodeccontext.h:92
MythCodecContext::H264ConstrainedBaseline
@ H264ConstrainedBaseline
Definition: mythcodeccontext.h:87
MythDate::current
QDateTime current(bool stripped)
Returns current Date and Time in UTC.
Definition: mythdate.cpp:10
true
VERBOSE_PREAMBLE Most true
Definition: verbosedefs.h:91
MythXDisplay::OpenMythXDisplay
static MythXDisplay * OpenMythXDisplay(bool Warn=true)
Definition: mythxdisplay.cpp:25
tmp
static guint32 * tmp
Definition: goom_core.cpp:31
MythVDPAUHelper::m_createdDevice
bool m_createdDevice
Definition: mythvdpauhelper.h:97
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:16
MythVDPAUHelper::m_display
MythXDisplay * m_display
Definition: mythvdpauhelper.h:99
mythlogging.h
LOC
#define LOC
Definition: mythvdpauhelper.cpp:10
MythVDPAUHelper::GetDecoderList
static void GetDecoderList(QStringList &Decoders)
Definition: mythvdpauhelper.cpp:216
hardwareprofile.scan.profile
profile
Definition: scan.py:99
Source
Definition: channelsettings.cpp:68
mythvdpauhelper.h
MythVDPAUHelper::DisplayPreempted
void DisplayPreempted(void)
MythCodecContext::MPEG2SNR
@ MPEG2SNR
Definition: mythcodeccontext.h:66
MythVDPAUHelper::SetPreempted
void SetPreempted(void)
Definition: mythvdpauhelper.cpp:322
vdpau_preemption_callback
static void vdpau_preemption_callback(VdpDevice, void *Opaque)
Definition: mythvdpauhelper.cpp:228
MythVDPAUHelper
A simple wrapper around VDPAU functionality.
Definition: mythvdpauhelper.h:45
MythCodecContext::H264Main
@ H264Main
Definition: mythcodeccontext.h:88
MythVDPAUHelper::m_vdpVideoMixerRender
VdpVideoMixerRender * m_vdpVideoMixerRender
Definition: mythvdpauhelper.h:110
MythVDPAUHelper::DeleteMixer
void DeleteMixer(VdpVideoMixer Mixer)
Definition: mythvdpauhelper.cpp:541
MythCodecContext::MPEG1
@ MPEG1
Definition: mythcodeccontext.h:59
MythVDPAUHelper::GetSurfaceParameters
QSize GetSurfaceParameters(VdpVideoSurface Surface, VdpChromaType &Chroma)
Definition: mythvdpauhelper.cpp:588
MythVDPAUHelper::m_vdpGetProcAddress
VdpGetProcAddress * m_vdpGetProcAddress
Definition: mythvdpauhelper.h:101
MythVDPAUHelper::IsValid
bool IsValid(void) const
Definition: mythvdpauhelper.cpp:317
VDPAUProfile
QPair< MythCodecContext::CodecProfile, VDPAUCodec > VDPAUProfile
Definition: mythvdpauhelper.h:42
uint
unsigned int uint
Definition: compat.h:140
MythVDPAUHelper::m_vdpVideoMixerSetFeatureEnables
VdpVideoMixerSetFeatureEnables * m_vdpVideoMixerSetFeatureEnables
Definition: mythvdpauhelper.h:112
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:94
mythxdisplay.h
DummyGetError
static const char * DummyGetError(VdpStatus)
Definition: mythvdpauhelper.cpp:253
MythDeintType
MythDeintType
Definition: mythframe.h:67
MythVDPAUHelper::m_vdpGetInformationString
VdpGetInformationString * m_vdpGetInformationString
Definition: mythvdpauhelper.h:103
MythVDPAUHelper::m_vdpDeviceDestroy
VdpDeviceDestroy * m_vdpDeviceDestroy
Definition: mythvdpauhelper.h:104
MythCodecContext::MPEG2Main
@ MPEG2Main
Definition: mythcodeccontext.h:62
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:84
MythVDPAUHelper::m_vdpDecoderCreate
VdpDecoderCreate * m_vdpDecoderCreate
Definition: mythvdpauhelper.h:106
DEINT_HIGH
@ DEINT_HIGH
Definition: mythframe.h:72
MythVDPAUHelper::m_vdpVideoMixerCreate
VdpVideoMixerCreate * m_vdpVideoMixerCreate
Definition: mythvdpauhelper.h:108
MythCodecContext::MJPEG
@ MJPEG
Definition: mythcodeccontext.h:122
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:90
MythCodecContext::GetProfileDescription
static QString GetProfileDescription(CodecProfile Profile, QSize Size, VideoFrameType Format=FMT_NONE, uint ColorDepth=0)
Definition: mythcodeccontext.cpp:783
VDPAUCodec::VDPAUCodec
VDPAUCodec(MythCodecContext::CodecProfile Profile, QSize Size, uint32_t Macroblocks, uint32_t Level)
Definition: mythvdpauhelper.cpp:28
MythVDPAUHelper::m_vdpVideoMixerSetAttributeValues
VdpVideoMixerSetAttributeValues * m_vdpVideoMixerSetAttributeValues
Definition: mythvdpauhelper.h:111
VDPAUCodec::Supported
bool Supported(int Width, int Height, int Level) const
Definition: mythvdpauhelper.cpp:38
VDPAUCodec
Definition: mythvdpauhelper.h:31
MythVDPAUHelper::m_vdpDecoderDestroy
VdpDecoderDestroy * m_vdpDecoderDestroy
Definition: mythvdpauhelper.h:107
MythVDPAUHelper::m_vdpVideoSurfaceGetParameters
VdpVideoSurfaceGetParameters * m_vdpVideoSurfaceGetParameters
Definition: mythvdpauhelper.h:117
GET_PROC
#define GET_PROC(FUNC_ID, PROC)
Definition: mythvdpauhelper.cpp:25
MythVDPAUHelper::m_vdpOutputSurfaceCreate
VdpOutputSurfaceCreate * m_vdpOutputSurfaceCreate
Definition: mythvdpauhelper.h:115
MythVDPAUHelper::m_vdpPreemptionCallbackRegister
VdpPreemptionCallbackRegister * m_vdpPreemptionCallbackRegister
Definition: mythvdpauhelper.h:118
MythVDPAUHelper::m_device
VdpDevice m_device
Definition: mythvdpauhelper.h:98
MythCodecContext::H264ConstrainedHigh
@ H264ConstrainedHigh
Definition: mythcodeccontext.h:95
MythVideoColourSpace
MythVideoColourSpace contains a QMatrix4x4 that can convert YCbCr data to RGB.
Definition: mythvideocolourspace.h:18
MythCodecContext::HEVCMain
@ HEVCMain
Definition: mythcodeccontext.h:97
XLOCK
#define XLOCK(dpy, arg)
Definition: mythxdisplay.h:19