MythTV  master
videodisplayprofile.cpp
Go to the documentation of this file.
1 // MythTV
2 #include "videodisplayprofile.h"
3 #include "mythcorecontext.h"
4 #include "mythdb.h"
5 #include "mythlogging.h"
6 #include "mythvideoout.h"
7 #include "avformatdecoder.h"
8 
9 // Std
10 #include <algorithm>
11 #include <utility>
12 
14 {
15  m_pref.clear();
16 }
17 
19 {
20  m_profileid = Id;
21 }
22 
23 void ProfileItem::Set(const QString &Value, const QString &Data)
24 {
25  m_pref[Value] = Data;
26 }
27 
29 {
30  return m_profileid;
31 }
32 
33 QMap<QString,QString> ProfileItem::GetAll(void) const
34 {
35  return m_pref;
36 }
37 
38 QString ProfileItem::Get(const QString &Value) const
39 {
40  QMap<QString,QString>::const_iterator it = m_pref.find(Value);
41  if (it != m_pref.end())
42  return *it;
43  return QString();
44 }
45 
47 {
48  QString tmp = Get("pref_priority");
49  return tmp.isEmpty() ? 0 : tmp.toUInt();
50 }
51 
52 // options are NNN NNN-MMM 0-MMM NNN-99999 >NNN >=NNN <MMM <=MMM or blank
53 // If string is blank then assumes a match.
54 // If value is 0 or negative assume a match (i.e. value unknown assumes a match)
55 // float values must be no more than 3 decimals.
56 bool ProfileItem::CheckRange(const QString &Key, float Value, bool *Ok) const
57 {
58  return CheckRange(Key, Value, 0, true, Ok);
59 }
60 
61 bool ProfileItem::CheckRange(const QString &Key, int Value, bool *Ok) const
62 {
63  return CheckRange(Key, 0.0, Value, false, Ok);
64 }
65 
66 bool ProfileItem::CheckRange(const QString& Key,
67  float FValue, int IValue, bool IsFloat, bool *Ok) const
68 {
69  bool match = true;
70  bool isOK = true;
71  if (IsFloat)
72  IValue = int(FValue * 1000.0F);
73  QString cmp = Get(Key);
74  if (!cmp.isEmpty())
75  {
76  cmp.replace(QLatin1String(" "),QLatin1String(""));
77  QStringList expr = cmp.split("&");
78  for (int ix = 0; ix < expr.size(); ++ix)
79  {
80  if (expr[ix].isEmpty())
81  {
82  isOK = false;
83  continue;
84  }
85  if (IValue > 0)
86  {
87  QRegularExpression regex("^([0-9.]*)([^0-9.]*)([0-9.]*)$");
88  QRegularExpressionMatch rmatch = regex.match(expr[ix]);
89 
90  int value1 = 0;
91  int value2 = 0;
92  QString oper;
93  QString capture1 = rmatch.captured(1);
94  QString capture3;
95  if (!capture1.isEmpty())
96  {
97  if (IsFloat)
98  {
99  int dec=capture1.indexOf('.');
100  if (dec > -1 && (capture1.length()-dec) > 4)
101  isOK = false;
102  if (isOK)
103  {
104  double double1 = capture1.toDouble(&isOK);
105  if (double1 > 2000000.0 || double1 < 0.0)
106  isOK = false;
107  value1 = int(double1 * 1000.0);
108  }
109  }
110  else
111  value1 = capture1.toInt(&isOK);
112  }
113  if (isOK)
114  {
115  oper = rmatch.captured(2);
116  capture3 = rmatch.captured(3);
117  if (!capture3.isEmpty())
118  {
119  if (IsFloat)
120  {
121  int dec=capture3.indexOf('.');
122  if (dec > -1 && (capture3.length()-dec) > 4)
123  isOK = false;
124  if (isOK)
125  {
126  double double1 = capture3.toDouble(&isOK);
127  if (double1 > 2000000.0 || double1 < 0.0)
128  isOK = false;
129  value2 = int(double1 * 1000.0);
130  }
131  }
132  else
133  value2 = capture3.toInt(&isOK);
134  }
135  }
136  if (isOK)
137  {
138  // Invalid string
139  if (value1 == 0 && value2 == 0 && oper.isEmpty())
140  isOK=false;
141  }
142  if (isOK)
143  {
144  // Case NNN
145  if (value1 != 0 && oper.isEmpty() && value2 == 0)
146  {
147  value2 = value1;
148  oper = "-";
149  }
150  // NNN-MMM 0-MMM NNN-99999 NNN- -MMM
151  else if (oper == "-")
152  {
153  // NNN- or -NNN
154  if (capture1.isEmpty() || capture3.isEmpty())
155  isOK = false;
156  // NNN-MMM
157  if (value2 < value1)
158  isOK = false;
159  }
160  else if (capture1.isEmpty())
161  {
162  // Other operators == > < >= <=
163  // Convert to a range
164  if (oper == "==")
165  value1 = value2;
166  else if (oper == ">")
167  {
168  value1 = value2 + 1;
169  value2 = 99999999;
170  }
171  else if (oper == ">=")
172  {
173  value1 = value2;
174  value2 = 99999999;
175  }
176  else if (oper == "<")
177  value2 = value2 - 1;
178  else if (oper == "<=")
179  ;
180  else isOK = false;
181  oper = "-";
182  }
183  }
184  if (isOK)
185  {
186  if (oper == "-")
187  match = match && (IValue >= value1 && IValue <= value2);
188  else isOK = false;
189  }
190  }
191  }
192  }
193  if (Ok != nullptr)
194  *Ok = isOK;
195  if (!isOK)
196  match=false;
197  return match;
198 }
199 
200 bool ProfileItem::IsMatch(QSize Size, float Framerate, const QString &CodecName,
201  const QStringList &DisallowedDecoders) const
202 {
203  bool match = true;
204 
205  // cond_width, cond_height, cond_codecs, cond_framerate.
206  // These replace old settings pref_cmp0 and pref_cmp1
207  match &= CheckRange("cond_width",Size.width());
208  match &= CheckRange("cond_height",Size.height());
209  match &= CheckRange("cond_framerate",Framerate);
210  // codec
211  QString cmp = Get(QString("cond_codecs"));
212  if (!cmp.isEmpty())
213  {
214 #if QT_VERSION < QT_VERSION_CHECK(5,14,0)
215  QStringList clist = cmp.split(" ", QString::SkipEmptyParts);
216 #else
217  QStringList clist = cmp.split(" ", Qt::SkipEmptyParts);
218 #endif
219  if (!clist.empty())
220  match &= clist.contains(CodecName,Qt::CaseInsensitive);
221  }
222 
223  QString decoder = Get("pref_decoder");
224  if (DisallowedDecoders.contains(decoder))
225  match = false;
226  return match;
227 }
228 
229 bool ProfileItem::IsValid(QString *Reason) const
230 {
231 
232  bool isOK = true;
233  CheckRange("cond_width",1,&isOK);
234  if (!isOK)
235  {
236  if (Reason)
237  *Reason = QString("Invalid width condition");
238  return false;
239  }
240  CheckRange("cond_height",1,&isOK);
241  if (!isOK)
242  {
243  if (Reason)
244  *Reason = QString("Invalid height condition");
245  return false;
246  }
247  CheckRange("cond_framerate",1.0F,&isOK);
248  if (!isOK)
249  {
250  if (Reason)
251  *Reason = QString("Invalid framerate condition");
252  return false;
253  }
254 
255  QString decoder = Get("pref_decoder");
256  QString renderer = Get("pref_videorenderer");
257  if (decoder.isEmpty() || renderer.isEmpty())
258  {
259  if (Reason)
260  *Reason = "Need a decoder and renderer";
261  return false;
262  }
263 
264  QStringList decoders = VideoDisplayProfile::GetDecoders();
265  if (!decoders.contains(decoder))
266  {
267  if (Reason)
268  *Reason = QString("decoder %1 is not available").arg(decoder);
269  return false;
270  }
271 
272  QStringList renderers = VideoDisplayProfile::GetVideoRenderers(decoder);
273  if (!renderers.contains(renderer))
274  {
275  if (Reason)
276  *Reason = QString("renderer %1 is not supported with decoder %2")
277  .arg(renderer).arg(decoder);
278  return false;
279  }
280 
281  if (Reason)
282  *Reason = QString();
283 
284  return true;
285 }
286 
287 bool ProfileItem::operator< (const ProfileItem &Other) const
288 {
289  return GetPriority() < Other.GetPriority();
290 }
291 
292 QString ProfileItem::toString(void) const
293 {
294  QString cmp0 = Get("pref_cmp0");
295  QString cmp1 = Get("pref_cmp1");
296  QString width = Get("cond_width");
297  QString height = Get("cond_height");
298  QString framerate = Get("cond_framerate");
299  QString codecs = Get("cond_codecs");
300  QString decoder = Get("pref_decoder");
301  uint max_cpus = Get("pref_max_cpus").toUInt();
302  bool skiploop = Get("pref_skiploop").toInt() != 0;
303  QString renderer = Get("pref_videorenderer");
304  QString deint0 = Get("pref_deint0");
305  QString deint1 = Get("pref_deint1");
306 
307  QString cond = QString("w(%1) h(%2) framerate(%3) codecs(%4)")
308  .arg(width).arg(height).arg(framerate).arg(codecs);
309  QString str = QString("cmp(%1%2) %7 dec(%3) cpus(%4) skiploop(%5) rend(%6) ")
310  .arg(cmp0).arg(QString(cmp1.isEmpty() ? "" : ",") + cmp1)
311  .arg(decoder).arg(max_cpus).arg((skiploop) ? "enabled" : "disabled").arg(renderer)
312  .arg(cond);
313  str += QString("deint(%1,%2)").arg(deint0).arg(deint1);
314 
315  return str;
316 }
317 
319 
320 #define LOC QString("VDP: ")
321 
322 QMutex VideoDisplayProfile::s_safe_lock(QMutex::Recursive);
324 QMap<QString,QStringList> VideoDisplayProfile::s_safe_renderer;
325 QMap<QString,QStringList> VideoDisplayProfile::s_safe_renderer_group;
326 QMap<QString,QStringList> VideoDisplayProfile::s_safe_equiv_dec;
329 QMap<QString,QString> VideoDisplayProfile::s_dec_name;
330 QMap<QString,QString> VideoDisplayProfile::s_rend_name;
332 QList<QPair<QString,QString> > VideoDisplayProfile::s_deinterlacer_options;
333 
335 {
336  QMutexLocker locker(&s_safe_lock);
337  InitStatics();
338 
339  QString hostname = gCoreContext->GetHostName();
340  QString cur_profile = GetDefaultProfileName(hostname);
341  uint groupid = GetProfileGroupID(cur_profile, hostname);
342 
343  vector<ProfileItem> items = LoadDB(groupid);
344  vector<ProfileItem>::const_iterator it;
345  for (it = items.begin(); it != items.end(); ++it)
346  {
347  QString err;
348  if (!(*it).IsValid(&err))
349  {
350  LOG(VB_GENERAL, LOG_ERR, LOC + "Rejecting: " + (*it).toString() + "\n\t\t\t" + err);
351  continue;
352  }
353 
354  LOG(VB_PLAYBACK, LOG_INFO, LOC + "Accepting: " + (*it).toString());
355  m_allowedPreferences.push_back(*it);
356  }
357 }
358 
359 void VideoDisplayProfile::SetInput(QSize Size, float Framerate, const QString &CodecName,
360  const QStringList &DisallowedDecoders)
361 {
362  QMutexLocker locker(&m_lock);
363  bool change = !DisallowedDecoders.isEmpty();
364 
365  if (Size != m_lastSize)
366  {
367  m_lastSize = Size;
368  change = true;
369  }
370  if (Framerate > 0.0F && !qFuzzyCompare(Framerate + 1.0F, m_lastRate + 1.0F))
371  {
372  m_lastRate = Framerate;
373  change = true;
374  }
375  if (!CodecName.isEmpty() && CodecName != m_lastCodecName)
376  {
377  m_lastCodecName = CodecName;
378  change = true;
379  }
380  if (change)
382 }
383 
384 void VideoDisplayProfile::SetOutput(float Framerate)
385 {
386  QMutexLocker locker(&m_lock);
387  if (!qFuzzyCompare(Framerate + 1.0F, m_lastRate + 1.0F))
388  {
389  m_lastRate = Framerate;
391  }
392 }
393 
395 {
396  return m_lastRate;
397 }
398 
400 {
401  return GetPreference("pref_decoder");
402 }
403 
405 {
406  return GetPreference("pref_deint0");
407 }
408 
410 {
411  return GetPreference("pref_deint1");
412 }
413 
415 {
416  return qBound(1U, GetPreference("pref_max_cpus").toUInt(), VIDEO_MAX_CPUS);
417 }
418 
420 {
421  return GetPreference("pref_skiploop").toInt() != 0;
422 }
423 
425 {
426  return GetPreference("pref_videorenderer");
427 }
428 
430 {
431  return m_lastVideoRenderer;
432 }
433 
434 void VideoDisplayProfile::SetVideoRenderer(const QString &VideoRenderer)
435 {
436  QMutexLocker locker(&m_lock);
437 
438  LOG(VB_PLAYBACK, LOG_INFO, LOC +
439  QString("SetVideoRenderer(%1)").arg(VideoRenderer));
440 
441  m_lastVideoRenderer = VideoRenderer;
442  if (VideoRenderer == GetVideoRenderer())
443  {
444  LOG(VB_PLAYBACK, LOG_INFO, LOC +
445  QString("SetVideoRender(%1) == GetVideoRenderer()").arg(VideoRenderer));
446  return; // already made preferences safe...
447  }
448 
449  // Make preferences safe...
450  LOG(VB_PLAYBACK, LOG_INFO, LOC + "Old preferences: " + toString());
451 
452  SetPreference("pref_videorenderer", VideoRenderer);
453 
454  LOG(VB_PLAYBACK, LOG_INFO, LOC + "New preferences: " + toString());
455 }
456 
457 bool VideoDisplayProfile::CheckVideoRendererGroup(const QString &Renderer)
458 {
459  if (m_lastVideoRenderer == Renderer || m_lastVideoRenderer == "null")
460  return true;
461 
462  LOG(VB_PLAYBACK, LOG_INFO, LOC +
463  QString("Preferred video renderer: %1 (current: %2)")
464  .arg(Renderer).arg(m_lastVideoRenderer));
465 
466  return std::any_of(s_safe_renderer_group.cbegin(), s_safe_renderer_group.cend(),
467  [this,Renderer](const auto& group)
468  { return group.contains(m_lastVideoRenderer) &&
469  group.contains(Renderer); } );
470 }
471 
473 {
474  const QString dec = GetDecoder();
475  if (dec == Decoder)
476  return true;
477 
478  QMutexLocker locker(&s_safe_lock);
479  return (s_safe_equiv_dec[dec].contains(Decoder));
480 }
481 
482 QString VideoDisplayProfile::GetPreference(const QString &Key) const
483 {
484  QMutexLocker locker(&m_lock);
485 
486  if (Key.isEmpty())
487  return QString();
488 
489  QMap<QString,QString>::const_iterator it = m_currentPreferences.find(Key);
490  if (it == m_currentPreferences.end())
491  return QString();
492 
493  return *it;
494 }
495 
496 void VideoDisplayProfile::SetPreference(const QString &Key, const QString &Value)
497 {
498  QMutexLocker locker(&m_lock);
499 
500  if (!Key.isEmpty())
501  m_currentPreferences[Key] = Value;
502 }
503 
504 vector<ProfileItem>::const_iterator VideoDisplayProfile::FindMatch
505  (const QSize Size, float Framerate, const QString &CodecName, const QStringList& DisallowedDecoders)
506 {
507  for (auto it = m_allowedPreferences.cbegin(); it != m_allowedPreferences.cend(); ++it)
508  if ((*it).IsMatch(Size, Framerate, CodecName, DisallowedDecoders))
509  return it;
510  return m_allowedPreferences.end();
511 }
512 
514  (const QSize Size, float Framerate, const QString &CodecName, const QStringList &DisallowedDecoders)
515 {
516  LOG(VB_PLAYBACK, LOG_INFO, LOC + QString("LoadBestPreferences(%1x%2, %3, %4)")
517  .arg(Size.width()).arg(Size.height())
518  .arg(static_cast<double>(Framerate), 0, 'f', 3).arg(CodecName));
519 
520  m_currentPreferences.clear();
521  auto it = FindMatch(Size, Framerate, CodecName, DisallowedDecoders);
522  if (it != m_allowedPreferences.end())
523  {
524  m_currentPreferences = (*it).GetAll();
525  }
526  else
527  {
528  int threads = qBound(1, QThread::idealThreadCount(), 4);
529  LOG(VB_PLAYBACK, LOG_INFO, LOC + "No useable profile. Using defaults.");
530  SetPreference("pref_decoder", "ffmpeg");
531  SetPreference("pref_max_cpus", QString::number(threads));
532  SetPreference("pref_videorenderer", "opengl-yv12");
533  SetPreference("pref_deint0", DEINT_QUALITY_LOW);
534  SetPreference("pref_deint1", DEINT_QUALITY_LOW);
535  }
536 
537  LOG(VB_PLAYBACK, LOG_INFO, LOC + QString("LoadBestPreferences result: "
538  "priority:%1 width:%2 height:%3 fps:%4 codecs:%5")
539  .arg(GetPreference("pref_priority")).arg(GetPreference("cond_width"))
540  .arg(GetPreference("cond_height")).arg(GetPreference("cond_framerate"))
541  .arg(GetPreference("cond_codecs")));
542  LOG(VB_PLAYBACK, LOG_INFO, LOC + QString("decoder:%1 renderer:%2 deint0:%3 deint1:%4 cpus:%5")
543  .arg(GetPreference("pref_decoder")).arg(GetPreference("pref_videorenderer"))
544  .arg(GetPreference("pref_deint0")).arg(GetPreference("pref_deint1"))
545  .arg(GetPreference("pref_max_cpus")));
546 }
547 
548 vector<ProfileItem> VideoDisplayProfile::LoadDB(uint GroupId)
549 {
551  vector<ProfileItem> list;
552 
554  query.prepare(
555  "SELECT profileid, value, data "
556  "FROM displayprofiles "
557  "WHERE profilegroupid = :GROUPID "
558  "ORDER BY profileid");
559  query.bindValue(":GROUPID", GroupId);
560  if (!query.exec())
561  {
562  MythDB::DBError("loaddb 1", query);
563  return list;
564  }
565 
566  uint profileid = 0;
567 
568  while (query.next())
569  {
570  if (query.value(0).toUInt() != profileid)
571  {
572  if (profileid)
573  {
574  tmp.SetProfileID(profileid);
575  QString error;
576  bool valid = tmp.IsValid(&error);
577  if (valid)
578  list.push_back(tmp);
579  else
580  LOG(VB_PLAYBACK, LOG_NOTICE, LOC + QString("Ignoring profile %1 (%2)")
581  .arg(profileid).arg(error));
582  }
583  tmp.Clear();
584  profileid = query.value(0).toUInt();
585  }
586  tmp.Set(query.value(1).toString(), query.value(2).toString());
587  }
588 
589  if (profileid)
590  {
591  tmp.SetProfileID(profileid);
592  QString error;
593  bool valid = tmp.IsValid(&error);
594  if (valid)
595  list.push_back(tmp);
596  else
597  LOG(VB_PLAYBACK, LOG_NOTICE, LOC + QString("Ignoring profile %1 (%2)")
598  .arg(profileid).arg(error));
599  }
600 
601  sort(list.begin(), list.end());
602  return list;
603 }
604 
605 bool VideoDisplayProfile::DeleteDB(uint GroupId, const vector<ProfileItem> &Items)
606 {
608  query.prepare(
609  "DELETE FROM displayprofiles "
610  "WHERE profilegroupid = :GROUPID AND "
611  " profileid = :PROFILEID");
612 
613  bool ok = true;
614  for (const auto & item : Items)
615  {
616  if (!item.GetProfileID())
617  continue;
618 
619  query.bindValue(":GROUPID", GroupId);
620  query.bindValue(":PROFILEID", item.GetProfileID());
621  if (!query.exec())
622  {
623  MythDB::DBError("vdp::deletedb", query);
624  ok = false;
625  }
626  }
627 
628  return ok;
629 }
630 
631 bool VideoDisplayProfile::SaveDB(uint GroupId, vector<ProfileItem> &Items)
632 {
634 
635  MSqlQuery update(MSqlQuery::InitCon());
636  update.prepare(
637  "UPDATE displayprofiles "
638  "SET data = :DATA "
639  "WHERE profilegroupid = :GROUPID AND "
640  " profileid = :PROFILEID AND "
641  " value = :VALUE");
642 
643  MSqlQuery insert(MSqlQuery::InitCon());
644  insert.prepare(
645  "INSERT INTO displayprofiles "
646  " ( profilegroupid, profileid, value, data) "
647  "VALUES "
648  " (:GROUPID, :PROFILEID, :VALUE, :DATA) ");
649 
650  MSqlQuery sqldelete(MSqlQuery::InitCon());
651  sqldelete.prepare(
652  "DELETE FROM displayprofiles "
653  "WHERE profilegroupid = :GROUPID AND "
654  " profileid = :PROFILEID AND "
655  " value = :VALUE");
656 
657  bool ok = true;
658  for (auto & item : Items)
659  {
660  QMap<QString,QString> list = item.GetAll();
661  if (list.begin() == list.end())
662  continue;
663 
664  QMap<QString,QString>::const_iterator lit = list.cbegin();
665 
666  if (!item.GetProfileID())
667  {
668  // create new profileid
669  if (!query.exec("SELECT MAX(profileid) FROM displayprofiles"))
670  {
671  MythDB::DBError("save_profile 1", query);
672  ok = false;
673  continue;
674  }
675  if (query.next())
676  {
677  item.SetProfileID(query.value(0).toUInt() + 1);
678  }
679 
680  for (; lit != list.cend(); ++lit)
681  {
682  if ((*lit).isEmpty())
683  continue;
684 
685  insert.bindValue(":GROUPID", GroupId);
686  insert.bindValue(":PROFILEID", item.GetProfileID());
687  insert.bindValue(":VALUE", lit.key());
688  insert.bindValue(":DATA", ((*lit).isNull()) ? "" : (*lit));
689  if (!insert.exec())
690  {
691  MythDB::DBError("save_profile 2", insert);
692  ok = false;
693  continue;
694  }
695  }
696  continue;
697  }
698 
699  for (; lit != list.cend(); ++lit)
700  {
701  query.prepare(
702  "SELECT count(*) "
703  "FROM displayprofiles "
704  "WHERE profilegroupid = :GROUPID AND "
705  " profileid = :PROFILEID AND "
706  " value = :VALUE");
707  query.bindValue(":GROUPID", GroupId);
708  query.bindValue(":PROFILEID", item.GetProfileID());
709  query.bindValue(":VALUE", lit.key());
710 
711  if (!query.exec())
712  {
713  MythDB::DBError("save_profile 3", query);
714  ok = false;
715  continue;
716  }
717  if (query.next() && (1 == query.value(0).toUInt()))
718  {
719  if (lit->isEmpty())
720  {
721  sqldelete.bindValue(":GROUPID", GroupId);
722  sqldelete.bindValue(":PROFILEID", item.GetProfileID());
723  sqldelete.bindValue(":VALUE", lit.key());
724  if (!sqldelete.exec())
725  {
726  MythDB::DBError("save_profile 5a", sqldelete);
727  ok = false;
728  continue;
729  }
730  }
731  else
732  {
733  update.bindValue(":GROUPID", GroupId);
734  update.bindValue(":PROFILEID", item.GetProfileID());
735  update.bindValue(":VALUE", lit.key());
736  update.bindValue(":DATA", ((*lit).isNull()) ? "" : (*lit));
737  if (!update.exec())
738  {
739  MythDB::DBError("save_profile 5b", update);
740  ok = false;
741  continue;
742  }
743  }
744  }
745  else
746  {
747  insert.bindValue(":GROUPID", GroupId);
748  insert.bindValue(":PROFILEID", item.GetProfileID());
749  insert.bindValue(":VALUE", lit.key());
750  insert.bindValue(":DATA", ((*lit).isNull()) ? "" : (*lit));
751  if (!insert.exec())
752  {
753  MythDB::DBError("save_profile 4", insert);
754  ok = false;
755  continue;
756  }
757  }
758  }
759  }
760 
761  return ok;
762 }
763 
765 {
766  InitStatics();
767  return s_safe_decoders;
768 }
769 
771 {
772  InitStatics();
773  return std::accumulate(s_safe_decoders.cbegin(), s_safe_decoders.cend(), QStringList{},
774  [](QStringList Res, const QString& Dec) { return Res << GetDecoderName(Dec); });
775 }
776 
778 {
779  if (Decoder.isEmpty())
780  return "";
781 
782  QMutexLocker locker(&s_safe_lock);
783  if (s_dec_name.empty())
784  {
785  s_dec_name["ffmpeg"] = QObject::tr("Standard");
786  s_dec_name["vdpau"] = QObject::tr("NVIDIA VDPAU acceleration");
787  s_dec_name["vdpau-dec"] = QObject::tr("NVIDIA VDPAU acceleration (decode only)");
788  s_dec_name["vaapi"] = QObject::tr("VAAPI acceleration");
789  s_dec_name["vaapi-dec"] = QObject::tr("VAAPI acceleration (decode only)");
790  s_dec_name["dxva2"] = QObject::tr("Windows hardware acceleration");
791  s_dec_name["mediacodec"] = QObject::tr("Android MediaCodec acceleration");
792  s_dec_name["mediacodec-dec"] = QObject::tr("Android MediaCodec acceleration (decode only)");
793  s_dec_name["nvdec"] = QObject::tr("NVIDIA NVDEC acceleration");
794  s_dec_name["nvdec-dec"] = QObject::tr("NVIDIA NVDEC acceleration (decode only)");
795  s_dec_name["vtb"] = QObject::tr("VideoToolbox acceleration");
796  s_dec_name["vtb-dec"] = QObject::tr("VideoToolbox acceleration (decode only)");
797  s_dec_name["v4l2"] = QObject::tr("V4L2 acceleration");
798  s_dec_name["v4l2-dec"] = QObject::tr("V4L2 acceleration (decode only)");
799  s_dec_name["mmal"] = QObject::tr("MMAL acceleration");
800  s_dec_name["mmal-dec"] = QObject::tr("MMAL acceleration (decode only)");
801  s_dec_name["drmprime"] = QObject::tr("DRM PRIME acceleration");
802  }
803 
804  QString ret = Decoder;
805  QMap<QString,QString>::const_iterator it = s_dec_name.constFind(Decoder);
806  if (it != s_dec_name.constEnd())
807  ret = *it;
808  return ret;
809 }
810 
811 
813 {
814  QString msg = QObject::tr("Processing method used to decode video.");
815 
816  if (Decoder.isEmpty())
817  return msg;
818 
819  msg += "\n";
820 
821  if (Decoder == "ffmpeg")
822  msg += QObject::tr("Standard will use the FFmpeg library for software decoding.");
823 
824  if (Decoder.startsWith("vdpau"))
825  {
826  msg += QObject::tr(
827  "VDPAU will attempt to use the graphics hardware to "
828  "accelerate video decoding.");
829  }
830 
831  if (Decoder.startsWith("vaapi"))
832  {
833  msg += QObject::tr(
834  "VAAPI will attempt to use the graphics hardware to "
835  "accelerate video decoding and playback.");
836  }
837 
838  if (Decoder.startsWith("dxva2"))
839  {
840  msg += QObject::tr(
841  "DXVA2 will use the graphics hardware to "
842  "accelerate video decoding and playback. ");
843  }
844 
845  if (Decoder.startsWith("mediacodec"))
846  {
847  msg += QObject::tr(
848  "Mediacodec will use Android graphics hardware to "
849  "accelerate video decoding and playback. ");
850  }
851 
852  if (Decoder.startsWith("nvdec"))
853  {
854  msg += QObject::tr(
855  "Nvdec uses the NVDEC API to "
856  "accelerate video decoding and playback with NVIDIA Graphics Adapters. ");
857  }
858 
859  if (Decoder.startsWith("vtb"))
860  msg += QObject::tr(
861  "The VideoToolbox library is used to accelerate video decoding. ");
862 
863  if (Decoder.startsWith("mmal"))
864  msg += QObject::tr(
865  "MMAL is used to accelerated video decoding (Raspberry Pi only). ");
866 
867  if (Decoder == "v4l2")
868  msg += "Highly experimental: ";
869 
870  if (Decoder.startsWith("v4l2"))
871  {
872  msg += QObject::tr(
873  "Video4Linux codecs are used to accelerate video decoding on "
874  "supported platforms. ");
875  }
876 
877  if (Decoder == "drmprime")
878  {
879  msg += QObject::tr(
880  "DRM-PRIME decoders are used to accelerate video decoding on "
881  "supported platforms. ");
882  }
883 
884  if (Decoder.endsWith("-dec"))
885  {
886  msg += QObject::tr("The decoder will transfer frames back to system memory "
887  "which will significantly reduce performance but may allow "
888  "other functionality to be used (such as automatic "
889  "letterbox detection). ");
890  }
891  return msg;
892 }
893 
894 QString VideoDisplayProfile::GetVideoRendererName(const QString &Renderer)
895 {
896  QMutexLocker locker(&s_safe_lock);
897  if (s_rend_name.empty())
898  {
899  s_rend_name["opengl"] = QObject::tr("OpenGL");
900  s_rend_name["opengl-yv12"] = QObject::tr("OpenGL YV12");
901  s_rend_name["opengl-hw"] = QObject::tr("OpenGL Hardware");
902  s_rend_name["vulkan"] = QObject::tr("Vulkan");
903  }
904 
905  QString ret = Renderer;
906  QMap<QString,QString>::const_iterator it = s_rend_name.constFind(Renderer);
907  if (it != s_rend_name.constEnd())
908  ret = *it;
909  return ret;
910 }
911 
912 QStringList VideoDisplayProfile::GetProfiles(const QString &HostName)
913 {
914  InitStatics();
915  QStringList list;
917  query.prepare(
918  "SELECT name "
919  "FROM displayprofilegroups "
920  "WHERE hostname = :HOST ");
921  query.bindValue(":HOST", HostName);
922  if (!query.exec() || !query.isActive())
923  MythDB::DBError("get_profiles", query);
924  else
925  {
926  while (query.next())
927  list += query.value(0).toString();
928  }
929  return list;
930 }
931 
932 QString VideoDisplayProfile::GetDefaultProfileName(const QString &HostName)
933 {
934  QString tmp =
935  gCoreContext->GetSettingOnHost("DefaultVideoPlaybackProfile", HostName);
936 
937  QStringList profiles = GetProfiles(HostName);
938 
939  tmp = (profiles.contains(tmp)) ? tmp : QString();
940 
941  if (tmp.isEmpty())
942  {
943  if (!profiles.empty())
944  tmp = profiles[0];
945 
946  tmp = (profiles.contains("Normal")) ? "Normal" : tmp;
947 
948  if (!tmp.isEmpty())
949  {
951  "DefaultVideoPlaybackProfile", tmp, HostName);
952  }
953  }
954 
955  return tmp;
956 }
957 
958 void VideoDisplayProfile::SetDefaultProfileName(const QString &ProfileName, const QString &HostName)
959 {
960  gCoreContext->SaveSettingOnHost("DefaultVideoPlaybackProfile", ProfileName, HostName);
961 }
962 
963 uint VideoDisplayProfile::GetProfileGroupID(const QString &ProfileName,
964  const QString &HostName)
965 {
967  query.prepare(
968  "SELECT profilegroupid "
969  "FROM displayprofilegroups "
970  "WHERE name = :NAME AND "
971  " hostname = :HOST ");
972  query.bindValue(":NAME", ProfileName);
973  query.bindValue(":HOST", HostName);
974 
975  if (!query.exec() || !query.isActive())
976  MythDB::DBError("get_profile_group_id", query);
977  else if (query.next())
978  return query.value(0).toUInt();
979 
980  return 0;
981 }
982 
984  const QString& Width, const QString& Height, const QString& Codecs,
985  const QString& Decoder, uint MaxCpus, bool SkipLoop, const QString& VideoRenderer,
986  const QString& Deint1, const QString& Deint2)
987 {
989 
990  // create new profileid
991  uint profileid = 1;
992  if (!query.exec("SELECT MAX(profileid) FROM displayprofiles"))
993  MythDB::DBError("create_profile 1", query);
994  else if (query.next())
995  profileid = query.value(0).toUInt() + 1;
996 
997  query.prepare(
998  "INSERT INTO displayprofiles "
999  "VALUES (:GRPID, :PROFID, 'pref_priority', :PRIORITY)");
1000  query.bindValue(":GRPID", GroupId);
1001  query.bindValue(":PROFID", profileid);
1002  query.bindValue(":PRIORITY", Priority);
1003  if (!query.exec())
1004  MythDB::DBError("create_profile 2", query);
1005 
1006  QStringList queryValue;
1007  QStringList queryData;
1008 
1009  queryValue += "cond_width";
1010  queryData += Width;
1011 
1012  queryValue += "cond_height";
1013  queryData += Height;
1014 
1015  queryValue += "cond_codecs";
1016  queryData += Codecs;
1017 
1018  queryValue += "pref_decoder";
1019  queryData += Decoder;
1020 
1021  queryValue += "pref_max_cpus";
1022  queryData += QString::number(MaxCpus);
1023 
1024  queryValue += "pref_skiploop";
1025  queryData += (SkipLoop) ? "1" : "0";
1026 
1027  queryValue += "pref_videorenderer";
1028  queryData += VideoRenderer;
1029 
1030  queryValue += "pref_deint0";
1031  queryData += Deint1;
1032 
1033  queryValue += "pref_deint1";
1034  queryData += Deint2;
1035 
1036  QStringList::const_iterator itV = queryValue.cbegin();
1037  QStringList::const_iterator itD = queryData.cbegin();
1038  for (; itV != queryValue.cend() && itD != queryData.cend(); ++itV,++itD)
1039  {
1040  if (itD->isEmpty())
1041  continue;
1042  query.prepare(
1043  "INSERT INTO displayprofiles "
1044  "VALUES (:GRPID, :PROFID, :VALUE, :DATA)");
1045  query.bindValue(":GRPID", GroupId);
1046  query.bindValue(":PROFID", profileid);
1047  query.bindValue(":VALUE", *itV);
1048  query.bindValue(":DATA", *itD);
1049  if (!query.exec())
1050  MythDB::DBError("create_profile 3", query);
1051  }
1052 }
1053 
1054 uint VideoDisplayProfile::CreateProfileGroup(const QString &ProfileName, const QString &HostName)
1055 {
1057  query.prepare(
1058  "INSERT INTO displayprofilegroups (name, hostname) "
1059  "VALUES (:NAME,:HOST)");
1060 
1061  query.bindValue(":NAME", ProfileName);
1062  query.bindValue(":HOST", HostName);
1063 
1064  if (!query.exec())
1065  {
1066  MythDB::DBError("create_profile_group", query);
1067  return 0;
1068  }
1069 
1070  return GetProfileGroupID(ProfileName, HostName);
1071 }
1072 
1073 bool VideoDisplayProfile::DeleteProfileGroup(const QString &GroupName, const QString &HostName)
1074 {
1075  bool ok = true;
1077  MSqlQuery query2(MSqlQuery::InitCon());
1078 
1079  query.prepare(
1080  "SELECT profilegroupid "
1081  "FROM displayprofilegroups "
1082  "WHERE name = :NAME AND "
1083  " hostname = :HOST ");
1084 
1085  query.bindValue(":NAME", GroupName);
1086  query.bindValue(":HOST", HostName);
1087 
1088  if (!query.exec() || !query.isActive())
1089  {
1090  MythDB::DBError("delete_profile_group 1", query);
1091  ok = false;
1092  }
1093  else
1094  {
1095  while (query.next())
1096  {
1097  query2.prepare("DELETE FROM displayprofiles "
1098  "WHERE profilegroupid = :PROFID");
1099  query2.bindValue(":PROFID", query.value(0).toUInt());
1100  if (!query2.exec())
1101  {
1102  MythDB::DBError("delete_profile_group 2", query2);
1103  ok = false;
1104  }
1105  }
1106  }
1107 
1108  query.prepare(
1109  "DELETE FROM displayprofilegroups "
1110  "WHERE name = :NAME AND "
1111  " hostname = :HOST");
1112 
1113  query.bindValue(":NAME", GroupName);
1114  query.bindValue(":HOST", HostName);
1115 
1116  if (!query.exec())
1117  {
1118  MythDB::DBError("delete_profile_group 3", query);
1119  ok = false;
1120  }
1121 
1122  return ok;
1123 }
1124 
1125 void VideoDisplayProfile::CreateProfiles(const QString &HostName)
1126 {
1127  QStringList profiles = GetProfiles(HostName);
1128 
1129 #ifdef USING_OPENGL
1130  if (!profiles.contains("OpenGL High Quality"))
1131  {
1132  (void) QObject::tr("OpenGL High Quality",
1133  "Sample: OpenGL high quality");
1134  uint groupid = CreateProfileGroup("OpenGL High Quality", HostName);
1135  CreateProfile(groupid, 1, "", "", "",
1136  "ffmpeg", 2, true, "opengl-yv12",
1137  "shader:high", "shader:high");
1138  }
1139 
1140  if (!profiles.contains("OpenGL Normal"))
1141  {
1142  (void) QObject::tr("OpenGL Normal", "Sample: OpenGL medium quality");
1143  uint groupid = CreateProfileGroup("OpenGL Normal", HostName);
1144  CreateProfile(groupid, 1, "", "", "",
1145  "ffmpeg", 2, true, "opengl-yv12",
1146  "shader:medium", "shader:medium");
1147  }
1148 
1149  if (!profiles.contains("OpenGL Slim"))
1150  {
1151  (void) QObject::tr("OpenGL Slim", "Sample: OpenGL low power GPU");
1152  uint groupid = CreateProfileGroup("OpenGL Slim", HostName);
1153  CreateProfile(groupid, 1, "", "", "",
1154  "ffmpeg", 1, true, "opengl",
1155  "medium", "medium");
1156  }
1157 #endif
1158 
1159 #ifdef USING_VAAPI
1160  if (!profiles.contains("VAAPI Normal"))
1161  {
1162  (void) QObject::tr("VAAPI Normal", "Sample: VAAPI average quality");
1163  uint groupid = CreateProfileGroup("VAAPI Normal", HostName);
1164  CreateProfile(groupid, 1, "", "", "",
1165  "vaapi", 2, true, "opengl-hw",
1166  "shader:driver:high", "shader:driver:high");
1167  CreateProfile(groupid, 1, "", "", "",
1168  "ffmpeg", 2, true, "opengl-yv12",
1169  "shader:medium", "shader:medium");
1170  }
1171 #endif
1172 
1173 #ifdef USING_VDPAU
1174  if (!profiles.contains("VDPAU Normal"))
1175  {
1176  (void) QObject::tr("VDPAU Normal", "Sample: VDPAU medium quality");
1177  uint groupid = CreateProfileGroup("VDPAU Normal", HostName);
1178  CreateProfile(groupid, 1, "", "", "",
1179  "vdpau", 1, true, "opengl-hw",
1180  "driver:medium", "driver:medium");
1181  CreateProfile(groupid, 1, "", "", "",
1182  "ffmpeg", 2, true, "opengl-yv12",
1183  "shader:medium", "shader:medium");
1184  }
1185 #endif
1186 
1187 #ifdef USING_MEDIACODEC
1188  if (!profiles.contains("MediaCodec Normal"))
1189  {
1190  (void) QObject::tr("MediaCodec Normal",
1191  "Sample: MediaCodec Normal");
1192  uint groupid = CreateProfileGroup("MediaCodec Normal", HostName);
1193  CreateProfile(groupid, 1, "", "", "",
1194  "mediacodec-dec", 4, true, "opengl-yv12",
1195  "shader:driver:medium", "shader:driver:medium");
1196  CreateProfile(groupid, 1, "", "", "",
1197  "ffmpeg", 2, true, "opengl-yv12",
1198  "shader:medium", "shader:medium");
1199 
1200  }
1201 #endif
1202 
1203 #if defined(USING_NVDEC) && defined(USING_OPENGL)
1204  if (!profiles.contains("NVDEC Normal"))
1205  {
1206  (void) QObject::tr("NVDEC Normal", "Sample: NVDEC Normal");
1207  uint groupid = CreateProfileGroup("NVDEC Normal", HostName);
1208  CreateProfile(groupid, 1, "", "", "",
1209  "nvdec", 1, true, "opengl-hw",
1210  "shader:driver:high", "shader:driver:high");
1211  CreateProfile(groupid, 1, "", "", "",
1212  "ffmpeg", 2, true, "opengl-yv12",
1213  "shader:high", "shader:high");
1214  }
1215 #endif
1216 
1217 #if defined(USING_VTB) && defined(USING_OPENGL)
1218  if (!profiles.contains("VideoToolBox Normal")) {
1219  (void) QObject::tr("VideoToolBox Normal", "Sample: VideoToolBox Normal");
1220  uint groupid = CreateProfileGroup("VideoToolBox Normal", HostName);
1221  CreateProfile(groupid, 1, "", "", "",
1222  "vtb", 1, true, "opengl-hw",
1223  "shader:driver:medium", "shader:driver:medium");
1224  CreateProfile(groupid, 1, "", "", "",
1225  "ffmpeg", 2, true, "opengl-yv12",
1226  "shader:medium", "shader:medium");
1227  }
1228 #endif
1229 
1230 #if defined(USING_MMAL) && defined(USING_OPENGL)
1231  if (!profiles.contains("MMAL"))
1232  {
1233  (void) QObject::tr("MMAL", "Sample: MMAL");
1234  uint groupid = CreateProfileGroup("MMAL", HostName);
1235  CreateProfile(groupid, 1, "", "", "",
1236  "mmal", 1, true, "opengl-hw",
1237  "shader:driver:medium", "shader:driver:medium");
1238  CreateProfile(groupid, 1, "", "", "",
1239  "ffmpeg", 2, true, "opengl-yv12",
1240  "shader:medium", "shader:medium");
1241  }
1242 #endif
1243 
1244 #if defined(USING_V4L2)
1245  if (!profiles.contains("V4L2 Codecs"))
1246  {
1247  (void) QObject::tr("V4L2 Codecs", "Sample: V4L2");
1248  uint groupid = CreateProfileGroup("V4L2 Codecs", HostName);
1249  CreateProfile(groupid, 2, "", "", "",
1250  "v4l2", 1, true, "opengl-hw",
1251  "shader:driver:medium", "shader:driver:medium");
1252  CreateProfile(groupid, 1, "", "", "",
1253  "ffmpeg", 2, true, "opengl-yv12",
1254  "shader:medium", "shader:medium");
1255  }
1256 #endif
1257 }
1258 
1260 {
1261  QMutexLocker locker(&s_safe_lock);
1262  InitStatics();
1263 
1264  QMap<QString,QStringList>::const_iterator it = s_safe_renderer.constFind(Decoder);
1265  QStringList tmp;
1266  if (it != s_safe_renderer.constEnd())
1267  tmp = *it;
1268  return tmp;
1269 }
1270 
1271 QString VideoDisplayProfile::GetVideoRendererHelp(const QString &Renderer)
1272 {
1273  QString msg = QObject::tr("Video rendering method");
1274 
1275  if (Renderer.isEmpty())
1276  return msg;
1277 
1278  if (Renderer == "null")
1279  msg = QObject::tr(
1280  "Render video offscreen. Used internally.");
1281 
1282  if (Renderer == "direct3d")
1283  {
1284  msg = QObject::tr(
1285  "Windows video renderer based on Direct3D. Requires "
1286  "video card compatible with Direct3D 9. This is the preferred "
1287  "renderer for current Windows systems.");
1288  }
1289 
1290  if (Renderer == "opengl")
1291  {
1292  msg = QObject::tr(
1293  "Video is converted to an intermediate format by the CPU (YUV2) "
1294  "before OpenGL is used for color conversion, scaling, picture controls"
1295  " and optionally deinterlacing. Processing is balanced between the CPU "
1296  "and GPU.");
1297  }
1298 
1299  if (Renderer == "opengl-yv12")
1300  {
1301  msg = QObject::tr(
1302  "OpenGL is used for all color conversion, scaling, picture "
1303  "controls and optionally deinterlacing. CPU load is low but a slightly more "
1304  "powerful GPU is needed for deinterlacing.");
1305  }
1306 
1307  if (Renderer == "opengl-hw")
1308  {
1309  msg = QObject::tr(
1310  "This video renderer is used by hardware decoders to display "
1311  "frames using OpenGL.");
1312  }
1313 
1314  return msg;
1315 }
1316 
1318 {
1320 }
1321 
1322 bool VideoDisplayProfile::IsFilterAllowed(const QString &VideoRenderer)
1323 {
1324  QMutexLocker locker(&s_safe_lock);
1325  InitStatics();
1326  return s_safe_custom.contains(VideoRenderer);
1327 }
1328 
1329 QStringList VideoDisplayProfile::GetFilteredRenderers(const QString &Decoder, const QStringList &Renderers)
1330 {
1331  const QStringList dec_list = GetVideoRenderers(Decoder);
1332  LOG(VB_PLAYBACK, LOG_INFO, LOC + QString("Safe renderers for '%1': %2")
1333  .arg(Decoder).arg(dec_list.join(",")));
1334  QStringList new_list;
1335 
1336  for (const auto& dec : qAsConst(dec_list))
1337  if (Renderers.contains(dec))
1338  new_list.push_back(dec);
1339 
1340  return new_list;
1341 }
1342 
1343 QString VideoDisplayProfile::GetBestVideoRenderer(const QStringList &Renderers)
1344 {
1345  QMutexLocker locker(&s_safe_lock);
1346  InitStatics();
1347 
1348  uint top_priority = 0;
1349  QString top_renderer;
1350 
1351  for (const auto& renderer : qAsConst(Renderers))
1352  {
1353  QMap<QString,uint>::const_iterator p = s_safe_renderer_priority.constFind(renderer);
1354  if ((p != s_safe_renderer_priority.constEnd()) && (*p >= top_priority))
1355  {
1356  top_priority = *p;
1357  top_renderer = renderer;
1358  }
1359  }
1360 
1361  return top_renderer;
1362 }
1363 
1365 {
1366  QString renderer = GetPreference("pref_videorenderer");
1367  QString deint0 = GetPreference("pref_deint0");
1368  QString deint1 = GetPreference("pref_deint1");
1369  QString cpus = GetPreference("pref_max_cpus");
1370  return QString("rend:%1 deint:%2/%3 CPUs: %4")
1371  .arg(renderer).arg(deint0).arg(deint1).arg(cpus);
1372 }
1373 
1374 QList<QPair<QString,QString> > VideoDisplayProfile::GetDeinterlacers(void)
1375 {
1376  InitStatics();
1377  return s_deinterlacer_options;
1378 }
1379 
1380 void VideoDisplayProfile::InitStatics(bool Reinit /*= false*/)
1381 {
1382  if (Reinit)
1383  {
1384  s_safe_custom.clear();
1385  s_safe_renderer.clear();
1386  s_safe_renderer_group.clear();
1387  s_safe_renderer_priority.clear();
1388  s_safe_decoders.clear();
1389  s_safe_equiv_dec.clear();
1390  s_deinterlacer_options.clear();
1391  }
1392  else if (s_safe_initialized)
1393  {
1394  return;
1395  }
1396  s_safe_initialized = true;
1397 
1399  options.renderers = &s_safe_custom;
1400  options.safe_renderers = &s_safe_renderer;
1401  options.render_group = &s_safe_renderer_group;
1402  options.priorities = &s_safe_renderer_priority;
1403  options.decoders = &s_safe_decoders;
1404  options.equiv_decoders = &s_safe_equiv_dec;
1405 
1406  // N.B. assumes DummyDecoder always present
1409 
1410  for (const QString& decoder : qAsConst(s_safe_decoders))
1411  {
1412  LOG(VB_PLAYBACK, LOG_INFO, LOC +
1413  QString("decoder<->render support: %1%2")
1414  .arg(decoder, -12).arg(GetVideoRenderers(decoder).join(" ")));
1415  }
1416 
1417  s_deinterlacer_options.append(QPair<QString,QString>(DEINT_QUALITY_NONE, QObject::tr("None")));
1418  s_deinterlacer_options.append(QPair<QString,QString>(DEINT_QUALITY_LOW, QObject::tr("Low quality")));
1419  s_deinterlacer_options.append(QPair<QString,QString>(DEINT_QUALITY_MEDIUM, QObject::tr("Medium quality")));
1420  s_deinterlacer_options.append(QPair<QString,QString>(DEINT_QUALITY_HIGH, QObject::tr("High quality")));
1421 }
VideoDisplayProfile::m_lastRate
float m_lastRate
Definition: videodisplayprofile.h:131
MSqlQuery::isActive
bool isActive(void) const
Definition: mythdbcon.h:204
MSqlQuery::next
bool next(void)
Wrap QSqlQuery::next() so we can display the query results.
Definition: mythdbcon.cpp:783
MSqlQuery
QSqlQuery wrapper that fetches a DB connection from the connection pool.
Definition: mythdbcon.h:126
VideoDisplayProfile::CreateProfiles
static void CreateProfiles(const QString &HostName)
Definition: videodisplayprofile.cpp:1125
mythvideoout.h
error
static void error(const char *str,...)
Definition: vbi.cpp:42
VideoDisplayProfile::LoadBestPreferences
void LoadBestPreferences(QSize Size, float Framerate, const QString &CodecName, const QStringList &DisallowedDecoders=QStringList())
Definition: videodisplayprofile.cpp:514
VideoDisplayProfile::GetPreferredVideoRenderer
static QString GetPreferredVideoRenderer(const QString &Decoder)
Definition: videodisplayprofile.cpp:1317
mythdb.h
VideoDisplayProfile::m_lock
QMutex m_lock
Definition: videodisplayprofile.h:129
VideoDisplayProfile::GetOutput
float GetOutput(void) const
Definition: videodisplayprofile.cpp:394
VideoDisplayProfile::toString
QString toString(void) const
Definition: videodisplayprofile.cpp:1364
ProfileItem::CheckRange
bool CheckRange(const QString &Key, float Value, bool *Ok=nullptr) const
Definition: videodisplayprofile.cpp:56
VideoDisplayProfile::SetOutput
void SetOutput(float Framerate)
Definition: videodisplayprofile.cpp:384
ProfileItem
Definition: videodisplayprofile.h:37
VideoDisplayProfile::DeleteProfileGroup
static bool DeleteProfileGroup(const QString &GroupName, const QString &HostName)
Definition: videodisplayprofile.cpp:1073
MSqlQuery::value
QVariant value(int i) const
Definition: mythdbcon.h:198
arg
arg(title).arg(filename).arg(doDelete))
VideoDisplayProfile::GetActualVideoRenderer
QString GetActualVideoRenderer(void) const
Definition: videodisplayprofile.cpp:429
VideoDisplayProfile::InitStatics
static void InitStatics(bool Reinit=false)
Definition: videodisplayprofile.cpp:1380
MSqlQuery::exec
bool exec(void)
Wrap QSqlQuery::exec() so we can display SQL.
Definition: mythdbcon.cpp:603
VideoDisplayProfile::IsSkipLoopEnabled
bool IsSkipLoopEnabled(void) const
Definition: videodisplayprofile.cpp:419
VideoDisplayProfile::s_safe_equiv_dec
static QMap< QString, QStringList > s_safe_equiv_dec
Definition: videodisplayprofile.h:141
LOG
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
Definition: mythlogging.h:23
ProfileItem::GetProfileID
uint GetProfileID(void) const
Definition: videodisplayprofile.cpp:28
VideoDisplayProfile::GetDecoder
QString GetDecoder(void) const
Definition: videodisplayprofile.cpp:399
ProfileItem::GetPriority
uint GetPriority(void) const
Definition: videodisplayprofile.cpp:46
VideoDisplayProfile::VideoDisplayProfile
VideoDisplayProfile()
Definition: videodisplayprofile.cpp:334
VideoDisplayProfile::s_safe_renderer_priority
static QMap< QString, uint > s_safe_renderer_priority
Definition: videodisplayprofile.h:143
ProfileItem::m_profileid
uint m_profileid
Definition: videodisplayprofile.h:64
VideoDisplayProfile::GetVideoRendererHelp
static QString GetVideoRendererHelp(const QString &Renderer)
Definition: videodisplayprofile.cpp:1271
VideoDisplayProfile::SetPreference
void SetPreference(const QString &Key, const QString &Value)
Definition: videodisplayprofile.cpp:496
tmp
static guint32 * tmp
Definition: goom_core.cpp:31
VideoDisplayProfile::m_lastCodecName
QString m_lastCodecName
Definition: videodisplayprofile.h:132
videodisplayprofile.h
VideoDisplayProfile::SetInput
void SetInput(QSize Size, float Framerate=0, const QString &CodecName=QString(), const QStringList &DisallowedDecoders=QStringList())
Definition: videodisplayprofile.cpp:359
VideoDisplayProfile::SetDefaultProfileName
static void SetDefaultProfileName(const QString &ProfileName, const QString &HostName)
Definition: videodisplayprofile.cpp:958
LOC
#define LOC
Definition: videodisplayprofile.cpp:320
Decoder
Definition: decoder.h:66
mythlogging.h
RenderOptions
Definition: videodisplayprofile.h:27
VideoDisplayProfile::GetDoubleRatePreferences
QString GetDoubleRatePreferences(void) const
Definition: videodisplayprofile.cpp:409
DEINT_QUALITY_HIGH
#define DEINT_QUALITY_HIGH
Definition: videodisplayprofile.h:20
VideoDisplayProfile::GetMaxCPUs
uint GetMaxCPUs(void) const
Definition: videodisplayprofile.cpp:414
VideoDisplayProfile::GetFilteredRenderers
static QStringList GetFilteredRenderers(const QString &Decoder, const QStringList &Renderers)
Definition: videodisplayprofile.cpp:1329
hardwareprofile.config.p
p
Definition: config.py:33
MSqlQuery::InitCon
static MSqlQueryInfo InitCon(ConnectionReuse _reuse=kNormalConnection)
Only use this in combination with MSqlQuery constructor.
Definition: mythdbcon.cpp:535
VideoDisplayProfile::DeleteDB
static bool DeleteDB(uint GroupId, const std::vector< ProfileItem > &Items)
Definition: videodisplayprofile.cpp:605
MythDB::DBError
static void DBError(const QString &where, const MSqlQuery &query)
Definition: mythdb.cpp:178
VideoDisplayProfile::IsFilterAllowed
static bool IsFilterAllowed(const QString &VideoRenderer)
Definition: videodisplayprofile.cpp:1322
VideoDisplayProfile::s_safe_initialized
static bool s_safe_initialized
Definition: videodisplayprofile.h:138
ProfileItem::Get
QString Get(const QString &Value) const
Definition: videodisplayprofile.cpp:38
ProfileItem::GetAll
QMap< QString, QString > GetAll(void) const
Definition: videodisplayprofile.cpp:33
ProfileItem::Set
void Set(const QString &Value, const QString &Data)
Definition: videodisplayprofile.cpp:23
DEINT_QUALITY_NONE
#define DEINT_QUALITY_NONE
Definition: videodisplayprofile.h:17
VideoDisplayProfile::SetVideoRenderer
void SetVideoRenderer(const QString &VideoRenderer)
Definition: videodisplayprofile.cpp:434
VideoDisplayProfile::s_deinterlacer_options
static QList< QPair< QString, QString > > s_deinterlacer_options
Definition: videodisplayprofile.h:147
VideoDisplayProfile::m_currentPreferences
QMap< QString, QString > m_currentPreferences
Definition: videodisplayprofile.h:134
uint
unsigned int uint
Definition: compat.h:141
gCoreContext
MythCoreContext * gCoreContext
This global variable contains the MythCoreContext instance for the app.
Definition: mythcorecontext.cpp:60
ProfileItem::Clear
void Clear(void)
Definition: videodisplayprofile.cpp:13
VideoDisplayProfile::GetProfileGroupID
static uint GetProfileGroupID(const QString &ProfileName, const QString &HostName)
Definition: videodisplayprofile.cpp:963
ProfileItem::toString
QString toString(void) const
Definition: videodisplayprofile.cpp:292
VideoDisplayProfile::m_lastSize
QSize m_lastSize
Definition: videodisplayprofile.h:130
VideoDisplayProfile::CreateProfileGroup
static uint CreateProfileGroup(const QString &ProfileName, const QString &HostName)
Definition: videodisplayprofile.cpp:1054
VideoDisplayProfile::GetDeinterlacers
static QList< QPair< QString, QString > > GetDeinterlacers(void)
Definition: videodisplayprofile.cpp:1374
VideoDisplayProfile::GetProfiles
static QStringList GetProfiles(const QString &HostName)
Definition: videodisplayprofile.cpp:912
VideoDisplayProfile::IsDecoderCompatible
bool IsDecoderCompatible(const QString &Decoder) const
Definition: videodisplayprofile.cpp:472
VideoDisplayProfile::s_safe_renderer_group
static QMap< QString, QStringList > s_safe_renderer_group
Definition: videodisplayprofile.h:140
VideoDisplayProfile::GetDecoderHelp
static QString GetDecoderHelp(const QString &Decoder=QString())
Definition: videodisplayprofile.cpp:812
VideoDisplayProfile::GetDecoderNames
static QStringList GetDecoderNames(void)
Definition: videodisplayprofile.cpp:770
VideoDisplayProfile::s_safe_renderer
static QMap< QString, QStringList > s_safe_renderer
Definition: videodisplayprofile.h:139
VideoDisplayProfile::s_safe_decoders
static QStringList s_safe_decoders
Definition: videodisplayprofile.h:146
ProfileItem::IsValid
bool IsValid(QString *Reason=nullptr) const
Definition: videodisplayprofile.cpp:229
ProfileItem::SetProfileID
void SetProfileID(uint Id)
Definition: videodisplayprofile.cpp:18
AvFormatDecoder::GetDecoders
static void GetDecoders(RenderOptions &opts)
Definition: avformatdecoder.cpp:307
VideoDisplayProfile::GetVideoRenderer
QString GetVideoRenderer(void) const
Definition: videodisplayprofile.cpp:424
mythcorecontext.h
VideoDisplayProfile::CreateProfile
static void CreateProfile(uint GroupId, uint Priority, const QString &Width, const QString &Height, const QString &Codecs, const QString &Decoder, uint MaxCpus, bool SkipLoop, const QString &VideoRenderer, const QString &Deint1, const QString &Deint2)
Definition: videodisplayprofile.cpp:983
MythCoreContext::GetSettingOnHost
QString GetSettingOnHost(const QString &key, const QString &host, const QString &defaultval="")
Definition: mythcorecontext.cpp:947
avformatdecoder.h
ProfileItem::IsMatch
bool IsMatch(QSize Size, float Framerate, const QString &CodecName, const QStringList &DisallowedDecoders=QStringList()) const
Definition: videodisplayprofile.cpp:200
VIDEO_MAX_CPUS
#define VIDEO_MAX_CPUS
Definition: videodisplayprofile.h:24
MSqlQuery::bindValue
void bindValue(const QString &placeholder, const QVariant &val)
Add a single binding.
Definition: mythdbcon.cpp:864
VideoDisplayProfile::GetDecoderName
static QString GetDecoderName(const QString &Decoder)
Definition: videodisplayprofile.cpp:777
VideoDisplayProfile::s_safe_custom
static QStringList s_safe_custom
Definition: videodisplayprofile.h:142
DEINT_QUALITY_LOW
#define DEINT_QUALITY_LOW
Definition: videodisplayprofile.h:18
VideoDisplayProfile::s_safe_lock
static QMutex s_safe_lock
Definition: videodisplayprofile.h:137
VideoDisplayProfile::s_dec_name
static QMap< QString, QString > s_dec_name
Definition: videodisplayprofile.h:144
VideoDisplayProfile::m_allowedPreferences
std::vector< ProfileItem > m_allowedPreferences
Definition: videodisplayprofile.h:135
VideoDisplayProfile::SaveDB
static bool SaveDB(uint GroupId, std::vector< ProfileItem > &Items)
Definition: videodisplayprofile.cpp:631
VideoDisplayProfile::GetVideoRenderers
static QStringList GetVideoRenderers(const QString &Decoder)
Definition: videodisplayprofile.cpp:1259
MythCoreContext::GetHostName
QString GetHostName(void)
Definition: mythcorecontext.cpp:859
VideoDisplayProfile::GetPreference
QString GetPreference(const QString &Key) const
Definition: videodisplayprofile.cpp:482
MythVideoOutput::GetRenderOptions
static void GetRenderOptions(RenderOptions &Options)
Definition: mythvideoout.cpp:37
ProfileItem::m_pref
QMap< QString, QString > m_pref
Definition: videodisplayprofile.h:65
VideoDisplayProfile::GetVideoRendererName
static QString GetVideoRendererName(const QString &Renderer)
Definition: videodisplayprofile.cpp:894
musicbrainzngs.caa.hostname
string hostname
Definition: caa.py:17
VideoDisplayProfile::m_lastVideoRenderer
QString m_lastVideoRenderer
Definition: videodisplayprofile.h:133
VideoDisplayProfile::LoadDB
static std::vector< ProfileItem > LoadDB(uint GroupId)
Definition: videodisplayprofile.cpp:548
VideoDisplayProfile::s_rend_name
static QMap< QString, QString > s_rend_name
Definition: videodisplayprofile.h:145
VideoDisplayProfile::GetSingleRatePreferences
QString GetSingleRatePreferences(void) const
Definition: videodisplayprofile.cpp:404
query
MSqlQuery query(MSqlQuery::InitCon())
build_compdb.options
options
Definition: build_compdb.py:11
MythCoreContext::SaveSettingOnHost
bool SaveSettingOnHost(const QString &key, const QString &newValue, const QString &host)
Definition: mythcorecontext.cpp:912
ProfileItem::operator<
bool operator<(const ProfileItem &Other) const
Definition: videodisplayprofile.cpp:287
VideoDisplayProfile::GetDefaultProfileName
static QString GetDefaultProfileName(const QString &HostName)
Definition: videodisplayprofile.cpp:932
DEINT_QUALITY_MEDIUM
#define DEINT_QUALITY_MEDIUM
Definition: videodisplayprofile.h:19
Priority
Definition: channelsettings.cpp:192
VideoDisplayProfile::CheckVideoRendererGroup
bool CheckVideoRendererGroup(const QString &Renderer)
Definition: videodisplayprofile.cpp:457
VideoDisplayProfile::FindMatch
std::vector< ProfileItem >::const_iterator FindMatch(QSize Size, float Framerate, const QString &CodecName, const QStringList &DisallowedDecoders=QStringList())
Definition: videodisplayprofile.cpp:505
VideoDisplayProfile::GetDecoders
static QStringList GetDecoders(void)
Definition: videodisplayprofile.cpp:764
VideoDisplayProfile::GetBestVideoRenderer
static QString GetBestVideoRenderer(const QStringList &Renderers)
Definition: videodisplayprofile.cpp:1343
MSqlQuery::prepare
bool prepare(const QString &query)
QSqlQuery::prepare() is not thread safe in Qt <= 3.3.2.
Definition: mythdbcon.cpp:808