MythTV  master
mythvideoout.cpp
Go to the documentation of this file.
1 // MythTV
2 #include "osd.h"
3 #include "mythplayer.h"
4 #include "videodisplayprofile.h"
5 #include "decoderbase.h"
6 #include "mythcorecontext.h"
7 #include "mythlogging.h"
8 #include "mythmainwindow.h"
9 #include "mythuihelper.h"
10 #include "mythavutil.h"
11 #include "mthreadpool.h"
12 #include "mythcodeccontext.h"
13 #ifdef _WIN32
14 #include "videoout_d3d.h"
15 #endif
16 #ifdef USING_OPENGL
17 #include "mythvideooutopengl.h"
18 #endif
19 #include "mythvideooutnull.h"
20 #include "mythvideoout.h"
21 
22 // std
23 #include <cmath>
24 #include <cstdlib>
25 
26 #define LOC QString("VideoOutput: ")
27 
29 {
31 
32 #ifdef _WIN32
34 #endif
35 
36 #ifdef USING_OPENGL
38 #endif // USING_OPENGL
39 }
40 
47  PIPState PiPState, const QSize &VideoDim,
48  const QSize &VideoDispDim, float VideoAspect,
49  QWidget *ParentWidget, const QRect &EmbedRect,
50  float FrameRate, uint PlayerFlags,
51  QString &Codec, int ReferenceFrames)
52 {
53  QStringList renderers;
54 
55  // select the best available output
57  {
58  // plain null output
59  renderers += "null";
60  }
61  else
62  {
63 #ifdef _WIN32
64  renderers += VideoOutputD3D::GetAllowedRenderers(CodecID, VideoDispDim);
65 #endif
66 
67 #ifdef USING_OPENGL
68  renderers += MythVideoOutputOpenGL::GetAllowedRenderers(CodecID, VideoDispDim);
69 #endif // USING_OPENGL
70  }
71 
72  LOG(VB_PLAYBACK, LOG_INFO, LOC + QString("Allowed renderers: %1").arg(renderers.join(",")));
73  renderers = VideoDisplayProfile::GetFilteredRenderers(Decoder, renderers);
74  LOG(VB_PLAYBACK, LOG_INFO, LOC + QString("Allowed renderers (filt: %1): %2")
75  .arg(Decoder).arg(renderers.join(",")));
76 
77  QString renderer;
78 
79  auto *vprof = new VideoDisplayProfile();
80 
81  if (!renderers.empty())
82  {
83  vprof->SetInput(VideoDispDim, FrameRate, Codec);
84  QString tmp = vprof->GetVideoRenderer();
85  if (vprof->IsDecoderCompatible(Decoder) && renderers.contains(tmp))
86  {
87  renderer = tmp;
88  LOG(VB_PLAYBACK, LOG_INFO, LOC + "Preferred renderer: " + renderer);
89  }
90  }
91 
92  if (renderer.isEmpty())
93  renderer = VideoDisplayProfile::GetBestVideoRenderer(renderers);
94 
95  while (!renderers.empty())
96  {
97  LOG(VB_PLAYBACK, LOG_INFO, LOC +
98  QString("Trying video renderer: '%1'").arg(renderer));
99  int index = renderers.indexOf(renderer);
100  if (index >= 0)
101  renderers.removeAt(index);
102  else
103  break;
104 
105  MythVideoOutput *vo = nullptr;
106 
107  /* these cases are mutually exlusive */
108  if (renderer == "null")
109  {
110  vo = new MythVideoOutputNull();
111  }
112 
113 #ifdef _WIN32
114  else if (renderer == "direct3d")
115  {
116  vo = new VideoOutputD3D();
117  }
118 #endif // _WIN32
119 
120 #ifdef USING_OPENGL
121  else if (renderer.contains("opengl"))
122  {
123  vo = new MythVideoOutputOpenGL(renderer);
124  }
125 #endif // USING_OPENGL
126 
127  if (vo)
128  vo->m_dbDisplayProfile = vprof;
129 
130  if (vo && !(PlayerFlags & kVideoIsNull))
131  {
132  // ensure we have a window to display into
133  QWidget *widget = ParentWidget;
134  MythMainWindow *window = GetMythMainWindow();
135  if (!widget && window)
136  widget = window->findChild<QWidget*>("video playback window");
137 
138  if (!widget)
139  {
140  LOG(VB_GENERAL, LOG_ERR, LOC + "No window for video output.");
141  delete vo;
142  vo = nullptr;
143  return nullptr;
144  }
145 
146  if (!widget->winId())
147  {
148  LOG(VB_GENERAL, LOG_ERR, LOC + "No window for video output.");
149  delete vo;
150  vo = nullptr;
151  return nullptr;
152  }
153 
154  // determine the display rectangle
155  QRect display_rect = QRect(0, 0, widget->width(), widget->height());
156  if (PiPState == kPIPStandAlone)
157  display_rect = EmbedRect;
158 
159  vo->SetPIPState(PiPState);
161  vo->SetReferenceFrames(ReferenceFrames);
162  if (vo->Init(VideoDim, VideoDispDim, VideoAspect,
163  MythDisplay::AcquireRelease(), display_rect, CodecID))
164  {
165  vo->SetVideoScalingAllowed(true);
166  return vo;
167  }
168 
169  vo->m_dbDisplayProfile = nullptr;
170  delete vo;
171  vo = nullptr;
172  }
173  else if (vo && (PlayerFlags & kVideoIsNull))
174  {
175  if (vo->Init(VideoDim, VideoDispDim, VideoAspect, nullptr, QRect(), CodecID))
176  return vo;
177 
178  vo->m_dbDisplayProfile = nullptr;
179  delete vo;
180  vo = nullptr;
181  }
182 
183  renderer = VideoDisplayProfile::GetBestVideoRenderer(renderers);
184  }
185 
186  LOG(VB_GENERAL, LOG_ERR, LOC +
187  "Not compiled with any useable video output method.");
188  delete vprof;
189  return nullptr;
190 }
191 
262  : m_display(nullptr)
263 {
264  m_dbAspectOverride = static_cast<AspectOverrideMode>(gCoreContext->GetNumSetting("AspectOverride", 0));
265  m_dbAdjustFill = static_cast<AdjustFillMode>(gCoreContext->GetNumSetting("AdjustFill", 0));
266  m_dbLetterboxColour = static_cast<LetterBoxColour>(gCoreContext->GetNumSetting("LetterboxColour", 0));
267 }
268 
274 {
275  delete m_dbDisplayProfile;
276  if (m_display)
278 }
279 
285 bool MythVideoOutput::Init(const QSize &VideoDim, const QSize &VideoDispDim,
286  float VideoAspect, MythDisplay *Display,
287  const QRect &WindowRect, MythCodecID CodecID)
288 {
289  m_display = Display;
290  m_videoCodecID = CodecID;
291  bool wasembedding = m_window.IsEmbedding();
292  QRect oldrect;
293  if (wasembedding)
294  {
295  oldrect = m_window.GetEmbeddingRect();
296  StopEmbedding();
297  }
298 
299  bool mainSuccess = m_window.Init(VideoDim, VideoDispDim,
300  VideoAspect, WindowRect,
302  m_display);
303 
304  if (m_dbDisplayProfile)
306 
307  if (wasembedding)
308  EmbedInWidget(oldrect);
309 
310  VideoAspectRatioChanged(VideoAspect); // apply aspect ratio and letterbox mode
311 
312  return mainSuccess;
313 }
314 
315 void MythVideoOutput::SetVideoFrameRate(float playback_fps)
316 {
317  if (m_dbDisplayProfile)
318  m_dbDisplayProfile->SetOutput(playback_fps);
319 }
320 
321 void MythVideoOutput::SetReferenceFrames(int ReferenceFrames)
322 {
323  m_maxReferenceFrames = ReferenceFrames;
324 }
325 
327 {
328  MythDeintType result = DEINT_NONE;
329 
330  if (Deinterlacer.contains(DEINT_QUALITY_HIGH))
331  result = DEINT_HIGH;
332  else if (Deinterlacer.contains(DEINT_QUALITY_MEDIUM))
333  result = DEINT_MEDIUM;
334  else if (Deinterlacer.contains(DEINT_QUALITY_LOW))
335  result = DEINT_BASIC;
336 
337  if (result != DEINT_NONE)
338  {
339  result = result | DEINT_CPU; // NB always assumed
340  if (Deinterlacer.contains(DEINT_QUALITY_SHADER))
341  result = result | DEINT_SHADER;
342  if (Deinterlacer.contains(DEINT_QUALITY_DRIVER))
343  result = result | DEINT_DRIVER;
344  }
345 
346  return result;
347 }
348 
349 void MythVideoOutput::SetDeinterlacing(bool Enable, bool DoubleRate, MythDeintType Force /*=DEINT_NONE*/)
350 {
351  if (!Enable)
352  {
354  LOG(VB_PLAYBACK, LOG_INFO, LOC + "Disabled all deinterlacing");
355  return;
356  }
357 
358  MythDeintType singlerate = DEINT_NONE;
359  MythDeintType doublerate = DEINT_NONE;
360  if (DEINT_NONE != Force)
361  {
362  singlerate = Force;
363  if (DoubleRate)
364  doublerate = Force;
365  LOG(VB_PLAYBACK, LOG_INFO, LOC + "Overriding deinterlacers");
366  }
367  else if (m_dbDisplayProfile)
368  {
370  if (DoubleRate)
372  }
373 
374  LOG(VB_GENERAL, LOG_INFO, LOC + QString("SetDeinterlacing (Doublerate %1): Single %2 Double %3")
375  .arg(DoubleRate).arg(DeinterlacerPref(singlerate)).arg(DeinterlacerPref(doublerate)));
376  m_videoBuffers.SetDeinterlacing(singlerate, doublerate, m_videoCodecID);
377 }
378 
386 {
387  m_window.VideoAspectRatioChanged(VideoAspect);
388 }
389 
395 bool MythVideoOutput::InputChanged(const QSize &VideoDim, const QSize &VideoDispDim,
396  float VideoAspect, MythCodecID CodecID,
397  bool &/*AspectOnly*/, MythMultiLocker* /*Locks*/,
398  int ReferenceFrames, bool /*ForceChange*/)
399 {
400  m_window.InputChanged(VideoDim, VideoDispDim, VideoAspect);
401  m_maxReferenceFrames = ReferenceFrames;
402  AVCodecID avCodecId = myth2av_codecid(CodecID);
403  AVCodec *codec = avcodec_find_decoder(avCodecId);
404  QString codecName;
405  if (codec)
406  codecName = codec->name;
407  if (m_dbDisplayProfile)
409  m_videoCodecID = CodecID;
410  DiscardFrames(true, true);
411  return true;
412 }
416 void MythVideoOutput::ResizeDisplayWindow(const QRect &Rect, bool SaveVisible)
417 {
418  m_window.ResizeDisplayWindow(Rect, SaveVisible);
419 }
420 
425 void MythVideoOutput::EmbedInWidget(const QRect &EmbedRect)
426 {
427  m_window.EmbedInWidget(EmbedRect);
428 }
429 
436 {
438 }
439 
440 void MythVideoOutput::GetOSDBounds(QRect &Total, QRect &Visible,
441  float &VisibleAspect,
442  float &FontScaling,
443  float ThemeAspect) const
444 {
445  Total = GetTotalOSDBounds();
446  Visible = GetVisibleOSDBounds(VisibleAspect, FontScaling, ThemeAspect);
447 }
448 
455 QRect MythVideoOutput::GetVisibleOSDBounds(float &VisibleAspect,
456  float &FontScaling,
457  float ThemeAspect) const
458 {
459  QRect dvr = m_window.GetDisplayVisibleRect();
460  float dispPixelAdj = 1.0F;
461  if (dvr.height() && dvr.width())
462  dispPixelAdj = (m_window.GetDisplayAspect() * dvr.height()) / dvr.width();
463 
464  float ova = m_window.GetOverridenVideoAspect();
465  QRect vr = m_window.GetVideoRect();
466  float vs = vr.height() ? static_cast<float>(vr.width()) / vr.height() : 1.0F;
467  VisibleAspect = ThemeAspect * (ova > 0.0F ? vs / ova : 1.F) * dispPixelAdj;
468 
469  FontScaling = 1.0F;
470  return { QPoint(0,0), dvr.size() };
471 }
472 
478 {
480 }
481 
483 {
484  return m_window.GetDisplayVideoRect();
485 }
486 
498 {
500 }
501 
509 {
510  m_window.Zoom(Direction);
511 }
512 
519 {
521 }
522 
528 {
530 }
531 
540 {
541  m_window.ToggleAspectOverride(AspectMode);
542 }
543 
552 {
553  m_window.ToggleAdjustFill(FillMode);
554 }
555 
557 {
558  return m_window.GetZoomString();
559 }
560 
562 {
564 }
565 
567 {
568  int curVal = GetPictureAttribute(AttributeType);
569  if (curVal < 0)
570  return -1;
571 
572  int newVal = curVal + ((Direction) ? +1 : -1);
573 
574  if (kPictureAttribute_Hue == AttributeType)
575  newVal = newVal % 100;
576 
577  if ((kPictureAttribute_Range == AttributeType) && newVal > 1)
578  newVal = 1;
579 
580  newVal = min(max(newVal, 0), 100);
581 
582  return SetPictureAttribute(AttributeType, newVal);
583 }
584 
593 {
594  return m_videoColourSpace.SetPictureAttribute(Attribute, NewValue);
595 }
596 
598 {
599  return m_videoColourSpace.GetPictureAttribute(AttributeType);
600 }
601 
602 void MythVideoOutput::SetFramesPlayed(long long FramesPlayed)
603 {
604  m_framesPlayed = FramesPlayed;
605 }
606 
608 {
609  return m_framesPlayed;
610 }
611 
613 {
614  return m_errorState != kError_None;
615 }
616 
618 {
619  return m_errorState;
620 }
621 
624 {
626 }
627 
630 {
632 }
633 
636 {
637  return static_cast<int>(m_videoBuffers.ValidVideoFrames());
638 }
639 
642 {
643  return static_cast<int>(m_videoBuffers.FreeVideoFrames());
644 }
645 
648 {
650 }
651 
655 {
657 }
658 
660 QRect MythVideoOutput::GetPIPRect(PIPLocation Location, MythPlayer *PiPPlayer, bool DoPixelAdj) const
661 {
662  return m_window.GetPIPRect(Location, PiPPlayer, DoPixelAdj);
663 }
664 
666 {
667  for (auto it = PiPPlayers.cbegin(); it != PiPPlayers.cend(); ++it)
668  ShowPIP(Frame, it.key(), *it);
669 }
670 
672 {
673  return m_window.GetAspectOverride();
674 }
675 
677 {
678  return m_window.GetAdjustFill();
679 }
680 
683 {
685 }
686 
689 {
690  return m_videoBuffers.GetStatus();
691 }
692 
696 {
698 }
699 
701 void MythVideoOutput::SetVideoResize(const QRect &VideoRect)
702 {
703  m_window.SetITVResize(VideoRect);
704 }
705 
710 {
712 }
713 
715  const QString &Name)
716 {
717  if (!Enable)
718  {
720  return false;
721  }
722  return SetupVisualisation(Audio, nullptr, Name);
723 }
724 
726 {
727  return VideoVisual::CanVisualise(Audio, Render);
728 }
729 
731  const QString &Name)
732 {
734  m_visual = VideoVisual::Create(Name, Audio, Render);
735  return m_visual;
736 }
737 
739 {
740  if (m_visual)
741  return m_visual->Name();
742  return QString("");
743 }
744 
746 {
747  return QStringList();
748 }
749 
751 {
752  delete m_visual;
753  m_visual = nullptr;
754 }
755 
765 {
766  if (To == nullptr || From == nullptr)
767  return;
768 
769  To->frameNumber = From->frameNumber;
770  To->disp_timecode = From->disp_timecode;
771  To->frameCounter = From->frameCounter;
772 
773  copy(To, From);
774 }
775 
777 QRect MythVideoOutput::GetImageRect(const QRect &Rect, QRect *DisplayRect)
778 {
779  qreal hscale = 0.0;
780  QSize video_size = m_window.GetVideoDispDim();
781  int image_height = video_size.height();
782  int image_width = (image_height > 720) ? 1920 :
783  (image_height > 576) ? 1280 : 720;
784  qreal image_aspect = static_cast<qreal>(image_width) / image_height;
785  qreal pixel_aspect = static_cast<qreal>(video_size.width()) / video_size.height();
786 
787  QRect rect1 = Rect;
788  if (DisplayRect && DisplayRect->isValid())
789  {
790  QMatrix m0;
791  m0.scale(static_cast<qreal>(image_width) / DisplayRect->width(),
792  static_cast<qreal>(image_height) / DisplayRect->height());
793  rect1 = m0.mapRect(rect1);
794  rect1.translate(DisplayRect->left(), DisplayRect->top());
795  }
796  QRect result = rect1;
797 
798  QRect dvr_rec = m_window.GetDisplayVideoRect();
799  QRect vid_rec = m_window.GetVideoRect();
800 
801  hscale = image_aspect / pixel_aspect;
802  if (hscale < 0.99 || hscale > 1.01)
803  {
804  vid_rec.setLeft(static_cast<int>(lround(static_cast<qreal>(vid_rec.left()) * hscale)));
805  vid_rec.setWidth(static_cast<int>(lround(static_cast<qreal>(vid_rec.width()) * hscale)));
806  }
807 
808  qreal vscale = static_cast<qreal>(dvr_rec.width()) / image_width;
809  hscale = static_cast<qreal>(dvr_rec.height()) / image_height;
810  QMatrix m1;
811  m1.translate(dvr_rec.left(), dvr_rec.top());
812  m1.scale(vscale, hscale);
813 
814  vscale = static_cast<qreal>(image_width) / vid_rec.width();
815  hscale = static_cast<qreal>(image_height) / vid_rec.height();
816  QMatrix m2;
817  m2.scale(vscale, hscale);
818  m2.translate(-vid_rec.left(), -vid_rec.top());
819 
820  result = m2.mapRect(result);
821  result = m1.mapRect(result);
822  return result;
823 }
824 
832 {
833  static constexpr float kSafeMargin = 0.05F;
834  float dummy = NAN;
835  QRect result = GetVisibleOSDBounds(dummy, dummy, 1.0F);
836  int safex = static_cast<int>(static_cast<float>(result.width()) * kSafeMargin);
837  int safey = static_cast<int>(static_cast<float>(result.height()) * kSafeMargin);
838  return { result.left() + safex, result.top() + safey,
839  result.width() - (2 * safex), result.height() - (2 * safey) };
840 }
841 
843 {
845 }
846 
848 {
849  static VideoFrameType s_defaultFormats[] = { FMT_YV12, FMT_NONE };
850  return &s_defaultFormats[0];
851 }
852 
857 {
859 }
860 
864 {
866 }
867 
870 {
872 }
873 
876 {
877  return m_window.IsEmbedding();
878 }
879 
883 {
885 }
886 
890 {
892 }
893 
897 {
899 }
900 
903 void MythVideoOutput::DiscardFrames(bool KeyFrame, bool /*Flushed*/)
904 {
905  m_videoBuffers.DiscardFrames(KeyFrame);
906 }
907 
920 {
921  if (!m_display)
922  return;
923  if (!m_display->UsingVideoModes())
924  return;
925 
926  if (Size.isEmpty())
927  {
928  Size = m_window.GetVideoDispDim();
929  if (Size.isEmpty())
930  return;
931  }
932 
933  float rate = m_dbDisplayProfile ? m_dbDisplayProfile->GetOutput() : 0.0F;
934 
935  bool hide = m_display->NextModeIsLarger(Size);
936  MythMainWindow* window = GetMythMainWindow();
937  if (hide)
938  window->hide();
939 
940  if (m_display->SwitchToVideo(Size, static_cast<double>(rate)))
941  {
942  // Switching to custom display resolution succeeded
943  // Make a note of the new size
944  QString source;
945  double aspect = m_display->GetAspectRatio(source);
946  LOG(VB_PLAYBACK, LOG_INFO, LOC + QString("Aspect ratio: %1 (%2)")
947  .arg(aspect).arg(source));
948  m_window.SetDisplayAspect(static_cast<float>(aspect));
950 
951  bool fullscreen = !m_window.UsingGuiSize();
952 
953  // if width && height are zero users expect fullscreen playback
954  if (!fullscreen)
955  {
956  int gui_width = 0;
957  int gui_height = 0;
958  gCoreContext->GetResolutionSetting("Gui", gui_width, gui_height);
959  fullscreen |= (0 == gui_width && 0 == gui_height);
960  }
961 
962  if (fullscreen)
963  {
964  QSize sz = m_display->GetResolution();
965  QRect display_visible_rect = QRect(GetMythMainWindow()->geometry().topLeft(), sz);
966  if (HasMythMainWindow())
967  {
968  if (hide)
969  {
970  window->Show();
971  hide = false;
972  }
973  GetMythMainWindow()->MoveResize(display_visible_rect);
974  }
975  }
976  }
977  if (hide)
978  window->Show();
979 }
980 
987 {
988  if (!m_display)
989  return;
990 
991  // Retrieve the display aspect ratio.
992  // This will be, in priority order:-
993  // - aspect ratio override when using resolution/mode switching (if not 'Default')
994  // - aspect ratio override for setups where detection does not work/is broken (multiscreen, broken EDID etc)
995  // - aspect ratio based on detected physical size (this should be the common/default value)
996  // - aspect ratio fallback using screen resolution
997  // - 16:9
998  QString source;
999  double displayaspect = m_display->GetAspectRatio(source);
1000  LOG(VB_PLAYBACK, LOG_INFO, LOC + QString("Display aspect ratio: %1 (%2)")
1001  .arg(displayaspect).arg(source));
1002 
1003  // Get the window and screen resolutions
1004  QSize window = m_window.GetWindowRect().size();
1005  QSize screen = m_display->GetResolution();
1006 
1007  // If not running fullscreen, adjust for window size and ignore any video
1008  // mode overrides as they do not apply when in a window
1009  if (!window.isEmpty() && !screen.isEmpty() && window != screen)
1010  {
1011  displayaspect = m_display->GetAspectRatio(source, true);
1012  double screenaspect = screen.width() / static_cast<double>(screen.height());
1013  double windowaspect = window.width() / static_cast<double>(window.height());
1014  displayaspect = displayaspect * (1.0 / screenaspect) * windowaspect;
1015  LOG(VB_PLAYBACK, LOG_INFO, LOC + QString("Window aspect ratio: %1").arg(displayaspect));
1016  }
1017 
1018  m_window.SetDisplayAspect(static_cast<float>(displayaspect));
1019 }
1020 
1022 int MythVideoOutput::CalcHueBase(const QString &AdaptorName)
1023 {
1024  int defaulthue = 50;
1025 
1026  QString lower = AdaptorName.toLower();
1027  // Hue base for different adaptors
1028  // This can probably now be removed as it is only relevant to VAAPI
1029  // which always uses 50
1030  if (lower.contains("radeon") ||
1031  lower.contains("g3d") ||
1032  lower.contains("xvba") /* VAAPI */ ||
1033  lower.startsWith("intel") ||
1034  lower.contains("splitted"))
1035  {
1036  defaulthue = 50;
1037  }
1038  else if (lower.startsWith("nv17")) /* nVidia */
1039  {
1040  defaulthue = 0;
1041  }
1042  else
1043  {
1044  LOG(VB_GENERAL, LOG_INFO, LOC +
1045  QString("CalcHueBase(%1): Unknown adaptor, hue may be wrong.")
1046  .arg(AdaptorName));
1047  }
1048 
1049  return defaulthue;
1050 }
virtual VideoFrame * GetLastDecodedFrame(void)
bool IsEmbedding(void)
Returns if videooutput is embedding.
void ToggleAspectOverride(AspectOverrideMode AspectMode=kAspect_Toggle)
Enforce different aspect ration than detected, then calls VideoAspectRatioChanged(float) to apply the...
virtual void VideoAspectRatioChanged(float VideoAspect)
QString GetZoomString(void) const
void ClearAfterSeek(void)
Clear used frames after seeking.
void SetPrebuffering(bool Normal)
Sets whether to use a normal number of buffers or fewer buffers.
QMap< MythPlayer *, PIPLocation > PIPMap
Definition: mythvideoout.h:32
AVCodecID myth2av_codecid(MythCodecID codec_id)
virtual void ResizeDisplayWindow(const QRect &Rect, bool SaveVisible)
Resize Display Window.
QRect GetImageRect(const QRect &Rect, QRect *DisplayRect=nullptr)
translates caption/dvd button rectangle into 'screen' space
void SetInput(const QSize &Size, float Framerate=0, const QString &CodecName=QString())
void ReleaseFrame(VideoFrame *Frame)
Frame is ready to be for filtering or OSD application.
AdjustFillMode GetAdjustFill(void) const
static MythVideoOutput * Create(const QString &Decoder, MythCodecID CodecID, PIPState PiPState, const QSize &VideoDim, const QSize &VideoDispDim, float VideoAspect, QWidget *ParentWidget, const QRect &EmbedRect, float FrameRate, uint PlayerFlags, QString &Codec, int ReferenceFrames)
Depending on compile-time configure settings and run-time renderer settings, create a relevant VideoO...
void MoveResize(QRect &Geometry)
QRect GetVisibleOSDBounds(float &VisibleAspect, float &FontScaling, float ThemeAspect) const
Returns visible portions of total OSD bounds.
MythCodecID m_videoCodecID
Definition: mythvideoout.h:164
static void GetRenderOptions(RenderOptions &Options)
virtual void ToggleMoveBottomLine(void)
virtual void MoveResize(void)
PlayerFlags
Definition: mythplayer.h:86
virtual void DeLimboFrame(VideoFrame *Frame)
Releases a frame for reuse if it is in limbo.
VideoColourSpace m_videoColourSpace
Definition: mythvideoout.h:160
static QStringList GetAllowedRenderers(MythCodecID CodecId, const QSize &VideoDim)
Generate a list of supported OpenGL profiles.
QString GetStatus(uint Num=0) const
virtual QStringList GetVisualiserList(void)
bool Init(const QSize &VideoDim, const QSize &VideoDispDim, float Aspect, const QRect &WindowRect, AspectOverrideMode AspectOverride, AdjustFillMode AdjustFill, MythDisplay *Display)
QRect GetMHEGBounds(void)
static QStringList GetFilteredRenderers(const QString &Decoder, const QStringList &Renderers)
PictureAttributeSupported
QRect GetTotalOSDBounds(void) const
virtual QString Name(void)=0
virtual void SetFramesPlayed(long long FramesPlayed)
void Zoom(ZoomDirection Direction)
Sets up zooming into to different parts of the video.
void SetOutput(float Framerate)
MythCodecID
Definition: mythcodecid.h:10
virtual bool CanVisualise(AudioPlayer *Audio, MythRender *Render)
static void GetRenderOptions(RenderOptions &Options)
static bool CanVisualise(AudioPlayer *audio, MythRender *render)
Definition: videovisual.cpp:7
#define DEINT_QUALITY_SHADER
virtual void StartDisplayingFrame(void)
Tell GetLastShownFrame() to return the next frame from the head of the queue of frames to display.
VideoDisplayProfile * m_dbDisplayProfile
Definition: mythvideoout.h:166
VideoVisual * m_visual
Definition: mythvideoout.h:170
float GetOutput(void) const
QRect GetVideoRect(void) const
void ResizeDisplayWindow(const QRect &Rect, bool SaveVisibleRect)
Resize Display Window.
static VideoVisual * Create(const QString &name, AudioPlayer *audio, MythRender *render)
Definition: videovisual.cpp:27
virtual bool InputChanged(const QSize &VideoDim, const QSize &VideoDispDim, float VideoAspect, MythCodecID CodecID, bool &AspectChanged, MythMultiLocker *Locks, int ReferenceFrames, bool ForceChange)
Tells video output to discard decoded frames and wait for new ones.
int GetPictureAttribute(PictureAttribute Attribute)
AdjustFillMode m_dbAdjustFill
Definition: mythvideoout.h:162
void DestroyVisualisation(void)
void GetResolutionSetting(const QString &type, int &width, int &height, double &forced_aspect, double &refresh_rate, int index=-1)
uint ValidVideoFrames(void) const
VideoFrameType
Definition: mythframe.h:23
virtual int ValidVideoFrames(void) const
Returns number of frames that are fully decoded.
MythCoreContext * gCoreContext
This global variable contains the MythCoreContext instance for the app.
AspectOverrideMode GetAspectOverride(void) const
virtual int SetPictureAttribute(PictureAttribute Attribute, int NewValue)
VideoErrorState
#define DEINT_QUALITY_DRIVER
#define DEINT_QUALITY_HIGH
void DoneDisplayingFrame(VideoFrame *Frame)
Removes frame from used queue and adds it to the available list.
bool SwitchToVideo(QSize Size, double Rate=0.0)
Switches to the resolution and refresh rate defined in the database for the specified video resolutio...
QRect GetPIPRect(PIPLocation Location, MythPlayer *PiPPlayer=nullptr, bool DoPixelAdjustment=true) const
long long copy(QFile &dst, QFile &src, uint block_size)
Copies src file to dst file.
static guint32 * tmp
Definition: goom_core.c:35
virtual VideoFrame * GetNextFreeFrame(void)
Blocks until it is possible to return a frame for decoding onto.
QRect GetSafeRect(void)
Returns a QRect describing an area of the screen on which it is 'safe' to render the On Screen Displa...
virtual void SetPIPState(PIPState Setting)
VideoErrorState GetError(void) const
virtual void SaveBottomLine(void)
bool EnoughFreeFrames(void) const
float GetDisplayAspect(void) const
MythDeintType
Definition: mythframe.h:120
virtual void ClearAfterSeek(void)
Tells video output to toss decoded buffers due to a seek.
virtual VideoFrameType * DirectRenderFormats(void)
void EmbedInWidget(const QRect &Rect)
Tells video output to embed video in an existing window.
virtual void ReleaseFrame(VideoFrame *Frame)
Releases a frame from the ready for decoding queue onto the queue of frames ready for display.
double GetAspectRatio(QString &Source, bool IgnoreModeOverride=false)
Returns current screen aspect ratio.
void SetPrebuffering(bool Normal)
Sets prebuffering state to normal, or small.
static MythDisplay * AcquireRelease(bool Acquire=true)
Definition: mythdisplay.cpp:69
virtual bool UsingVideoModes(void)
Definition: mythdisplay.h:29
AspectOverrideMode
Definition: videoouttypes.h:44
LetterBoxColour m_dbLetterboxColour
Definition: mythvideoout.h:163
static MythDeintType ParseDeinterlacer(const QString &Deinterlacer)
virtual bool Init(const QSize &VideoDim, const QSize &VideoDispDim, float VideoAspect, MythDisplay *Display, const QRect &WindowRect, MythCodecID CodecID)
bool UsingGuiSize(void) const
void SetVideoResize(const QRect &VideoRect)
Tells the player to resize the video frame (used for ITV)
virtual ~MythVideoOutput()
void SetDeinterlacing(MythDeintType Single, MythDeintType Double, MythCodecID CodecID)
VideoOutWindow m_window
Definition: mythvideoout.h:159
VideoErrorState m_errorState
Definition: mythvideoout.h:168
VideoFrame * GetLastShownFrame(void)
void SaveBottomLine(void)
VideoBuffers m_videoBuffers
Definition: mythvideoout.h:167
static int CalcHueBase(const QString &AdaptorName)
void VideoAspectRatioChanged(float Aspect)
Calls SetVideoAspectRatio(float aspect), then calls MoveResize() to apply changes.
void SetWindowSize(QSize Size)
QRect GetEmbeddingRect(void) const
virtual void EmbedInWidget(const QRect &EmbedRect)
Tells video output to embed video in an existing window.
MythDisplay * m_display
Definition: mythvideoout.h:158
bool IsErrored() const
virtual void SetDeinterlacing(bool Enable, bool DoubleRate, MythDeintType Force=DEINT_NONE)
virtual void StopEmbedding(void)
void StartDisplayingFrame(void)
Sets rpos to index of videoframe at head of used queue.
int FreeVideoFrames(void)
Returns number of frames available for decoding onto.
void DiscardFrame(VideoFrame *Frame)
Frame is ready to be reused by decoder.
void SetReferenceFrames(int ReferenceFrames)
bool IsEmbedding(void) const
bool NextModeIsLarger(QSize Size)
Check whether the next mode is larger in size than the current mode.
PictureAttribute
Definition: videoouttypes.h:87
VideoFrame * GetNextFreeFrame(BufferType EnqueueTo=kVideoBuffer_limbo)
Gets a frame from available buffers list.
#define LOC
void DeLimboFrame(VideoFrame *Frame)
If the frame is still in the limbo state it is added to the available queue.
unsigned int uint
Definition: compat.h:140
bool EnoughFreeFrames(void)
Returns true iff enough frames are available to decode onto.
QSize GetVideoDispDim(void) const
virtual void ToggleAdjustFill(AdjustFillMode FillMode=kAdjustFill_Toggle)
virtual void ResizeForVideo(QSize Size=QSize())
QRect GetDisplayVideoRect(void) const
QString DeinterlacerPref(MythDeintType Deint)
Definition: mythavutil.cpp:182
QSize GetResolution(void)
void SetPIPState(PIPState Setting)
QString GetFrameStatus(void) const
Returns string with status of each frame for debugging.
virtual void ToggleAspectOverride(AspectOverrideMode AspectMode=kAspect_Toggle)
virtual void SetVideoFrameRate(float playback_fps)
static void GetRenderOptions(RenderOptions &Options)
Generate the list of available OpenGL profiles.
void SetDisplayAspect(float DisplayAspect)
bool HasMythMainWindow(void)
bool EnableVisualisation(AudioPlayer *Audio, bool Enable, const QString &Name=QString(""))
virtual void DiscardFrames(bool KeyFrame, bool Flushed)
Releases all frames not being actively displayed from any queue onto the queue of frames ready for de...
long long frameNumber
Definition: mythframe.h:147
long long m_framesPlayed
Definition: mythvideoout.h:169
MythMainWindow * GetMythMainWindow(void)
VideoFrame * GetLastDecodedFrame(void)
AdjustFillMode GetAdjustFill(void) const
AspectOverrideMode GetAspectOverride(void) const
PIPLocation
Definition: videoouttypes.h:17
int64_t disp_timecode
Definition: mythframe.h:150
AdjustFillMode
Definition: videoouttypes.h:55
virtual long long GetFramesPlayed(void)
int GetNumSetting(const QString &key, int defaultval=0)
static void GetRenderOptions(RenderOptions &Options)
#define LOG(_MASK_, _LEVEL_, _STRING_)
Definition: mythlogging.h:41
static QStringList GetAllowedRenderers(MythCodecID myth_codec_id, const QSize &video_dim)
virtual void ShowPIPs(VideoFrame *Frame, const PIPMap &PiPPlayers)
long long frameCounter
raw frame counter/ticker for discontinuity checks
Definition: mythframe.h:148
PictureAttributeSupported GetSupportedPictureAttributes(void)
virtual void ShowPIP(VideoFrame *, MythPlayer *, PIPLocation)
Definition: mythvideoout.h:149
PIPState
Definition: videoouttypes.h:8
virtual QRect GetPIPRect(PIPLocation Location, MythPlayer *PiPPlayer=nullptr, bool DoPixelAdj=true) const
returns QRect of PIP based on PIPLocation
virtual void GetOSDBounds(QRect &Total, QRect &Visible, float &VisibleAspect, float &FontScaling, float ThemeAspect) const
QString GetSingleRatePreferences(void) const
void ToggleMoveBottomLine(void)
float GetOverridenVideoAspect(void) const
virtual void DiscardFrame(VideoFrame *frame)
Releases frame from any queue onto the queue of frames ready for decoding onto.
static QString GetBestVideoRenderer(const QStringList &Renderers)
void MoveResize(void)
performs all the calculations for video framing and any resizing.
void ToggleAdjustFill(AdjustFillMode AdjustFillMode=kAdjustFill_Toggle)
Sets up letterboxing for various standard video frame and monitor dimensions, then calls MoveResize()...
PictureAttributeSupported SupportedAttributes(void) const
QString GetVisualiserName(void)
void DiscardFrames(bool NextFrameIsKeyFrame)
Mark all used frames as ready to be reused, this is for seek.
QRect GetDisplayVisibleRect(void) const
int SetPictureAttribute(PictureAttribute Attribute, int Value)
Set the Value for the given PictureAttribute.
QRect GetWindowRect(void) const
virtual VideoFrame * GetLastShownFrame(void)
Returns frame from the head of the ready to be displayed queue, if StartDisplayingFrame has been call...
int GetPictureAttribute(PictureAttribute AttributeType)
virtual bool SetupVisualisation(AudioPlayer *Audio, MythRender *Render, const QString &Name)
bool EnoughDecodedFrames(void) const
QString GetZoomString(void) const
void InputChanged(const QSize &VideoDim, const QSize &VideoDispDim, float Aspect)
Tells video output to discard decoded frames and wait for new ones.
int ChangePictureAttribute(PictureAttribute AttributeType, bool Direction)
bool EnoughDecodedFrames(void)
Returns true iff there are plenty of decoded frames ready for display.
#define DEINT_QUALITY_MEDIUM
#define DEINT_QUALITY_LOW
void SetVideoScalingAllowed(bool Allow)
Disable or enable underscan/overscan.
AspectOverrideMode m_dbAspectOverride
Definition: mythvideoout.h:161
ZoomDirection
Definition: videoouttypes.h:26
QString GetDoubleRatePreferences(void) const
virtual void DoneDisplayingFrame(VideoFrame *Frame)
Releases frame returned from GetLastShownFrame() onto the queue of frames ready for decoding onto.
void StopEmbedding(void)
Tells video output to stop embedding video in an existing window.
uint FreeVideoFrames(void) const
virtual void Zoom(ZoomDirection Direction)
void InitDisplayMeasurements(void)
Initialise display measurement.
static void CopyFrame(VideoFrame *To, const VideoFrame *From)
void SetITVResize(QRect Rect)
void SetVideoScalingAllowed(bool Change)
Disable or enable underscan/overscan.
QMap< QString, bool > Setting