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 for %1 %2 (Decoder: %3): '%4'")
73  .arg(get_encoding_type(CodecID)).arg(get_decoder_name(CodecID))
74  .arg(Decoder).arg(renderers.join(",")));
75  renderers = VideoDisplayProfile::GetFilteredRenderers(Decoder, renderers);
76  LOG(VB_PLAYBACK, LOG_INFO, LOC + QString("Allowed renderers (filt: %1): %2")
77  .arg(Decoder).arg(renderers.join(",")));
78 
79  QString renderer;
80 
81  auto *vprof = new VideoDisplayProfile();
82 
83  if (!renderers.empty())
84  {
85  vprof->SetInput(VideoDispDim, FrameRate, Codec);
86  QString tmp = vprof->GetVideoRenderer();
87  if (vprof->IsDecoderCompatible(Decoder) && renderers.contains(tmp))
88  {
89  renderer = tmp;
90  LOG(VB_PLAYBACK, LOG_INFO, LOC + "Preferred renderer: " + renderer);
91  }
92  else
93  {
94  LOG(VB_PLAYBACK, LOG_INFO, LOC +
95  QString("No preferred renderer for decoder '%1' - profile renderer: '%2'")
96  .arg(Decoder).arg(tmp));
97  }
98  }
99 
100  if (renderer.isEmpty())
101  renderer = VideoDisplayProfile::GetBestVideoRenderer(renderers);
102 
103  if (renderer.isEmpty() && !(PlayerFlags & kVideoIsNull))
104  {
105  QString fallback;
106 #ifdef USING_OPENGL
107  fallback = "opengl";
108 #endif
109  LOG(VB_GENERAL, LOG_WARNING, LOC + "No renderer found. This should not happen!.");
110  LOG(VB_GENERAL, LOG_WARNING, LOC + QString("Falling back to '%1'").arg(fallback));
111  renderer = fallback;
112  }
113 
114  while (!renderers.empty())
115  {
116  LOG(VB_PLAYBACK, LOG_INFO, LOC +
117  QString("Trying video renderer: '%1'").arg(renderer));
118  int index = renderers.indexOf(renderer);
119  if (index >= 0)
120  renderers.removeAt(index);
121  else
122  break;
123 
124  MythVideoOutput *vo = nullptr;
125 
126  /* these cases are mutually exlusive */
127  if (renderer == "null")
128  {
129  vo = new MythVideoOutputNull();
130  }
131 
132 #ifdef _WIN32
133  else if (renderer == "direct3d")
134  {
135  vo = new VideoOutputD3D();
136  }
137 #endif // _WIN32
138 
139 #ifdef USING_OPENGL
140  else if (renderer.contains("opengl"))
141  {
142  vo = new MythVideoOutputOpenGL(renderer);
143  }
144 #endif // USING_OPENGL
145 
146  if (vo)
147  vo->m_dbDisplayProfile = vprof;
148 
149  if (vo && !(PlayerFlags & kVideoIsNull))
150  {
151  // ensure we have a window to display into
152  QWidget *widget = ParentWidget;
153  MythMainWindow *window = GetMythMainWindow();
154  if (!widget && window)
155  widget = window->findChild<QWidget*>("video playback window");
156 
157  if (!widget)
158  {
159  LOG(VB_GENERAL, LOG_ERR, LOC + "No window for video output.");
160  delete vo;
161  vo = nullptr;
162  return nullptr;
163  }
164 
165  if (!widget->winId())
166  {
167  LOG(VB_GENERAL, LOG_ERR, LOC + "No window for video output.");
168  delete vo;
169  vo = nullptr;
170  return nullptr;
171  }
172 
173  // determine the display rectangle
174  QRect display_rect = QRect(0, 0, widget->width(), widget->height());
175  if (PiPState == kPIPStandAlone)
176  display_rect = EmbedRect;
177 
178  vo->SetPIPState(PiPState);
180  vo->SetReferenceFrames(ReferenceFrames);
181  if (vo->Init(VideoDim, VideoDispDim, VideoAspect,
182  MythDisplay::AcquireRelease(), display_rect, CodecID))
183  {
184  vo->SetVideoScalingAllowed(true);
185  return vo;
186  }
187 
188  vo->m_dbDisplayProfile = nullptr;
189  delete vo;
190  vo = nullptr;
191  }
192  else if (vo && (PlayerFlags & kVideoIsNull))
193  {
194  if (vo->Init(VideoDim, VideoDispDim, VideoAspect, nullptr, QRect(), CodecID))
195  return vo;
196 
197  vo->m_dbDisplayProfile = nullptr;
198  delete vo;
199  vo = nullptr;
200  }
201 
202  renderer = VideoDisplayProfile::GetBestVideoRenderer(renderers);
203  }
204 
205  LOG(VB_GENERAL, LOG_ERR, LOC +
206  "Not compiled with any useable video output method.");
207  delete vprof;
208  return nullptr;
209 }
210 
281 {
282  m_dbAspectOverride = static_cast<AspectOverrideMode>(gCoreContext->GetNumSetting("AspectOverride", 0));
283  m_dbAdjustFill = static_cast<AdjustFillMode>(gCoreContext->GetNumSetting("AdjustFill", 0));
284  m_dbLetterboxColour = static_cast<LetterBoxColour>(gCoreContext->GetNumSetting("LetterboxColour", 0));
285 }
286 
292 {
293  delete m_dbDisplayProfile;
294  if (m_display)
296 }
297 
303 bool MythVideoOutput::Init(const QSize &VideoDim, const QSize &VideoDispDim,
304  float VideoAspect, MythDisplay *Display,
305  const QRect &WindowRect, MythCodecID CodecID)
306 {
307  m_display = Display;
308  m_videoCodecID = CodecID;
309  bool wasembedding = m_window.IsEmbedding();
310  QRect oldrect;
311  if (wasembedding)
312  {
313  oldrect = m_window.GetEmbeddingRect();
314  StopEmbedding();
315  }
316 
317  bool mainSuccess = m_window.Init(VideoDim, VideoDispDim,
318  VideoAspect, WindowRect,
320  m_display);
321 
322  if (m_dbDisplayProfile)
324 
325  if (wasembedding)
326  EmbedInWidget(oldrect);
327 
328  VideoAspectRatioChanged(VideoAspect); // apply aspect ratio and letterbox mode
329 
330  return mainSuccess;
331 }
332 
333 void MythVideoOutput::SetVideoFrameRate(float playback_fps)
334 {
335  if (m_dbDisplayProfile)
336  m_dbDisplayProfile->SetOutput(playback_fps);
337 }
338 
339 void MythVideoOutput::SetReferenceFrames(int ReferenceFrames)
340 {
341  m_maxReferenceFrames = ReferenceFrames;
342 }
343 
345 {
346  MythDeintType result = DEINT_NONE;
347 
348  if (Deinterlacer.contains(DEINT_QUALITY_HIGH))
349  result = DEINT_HIGH;
350  else if (Deinterlacer.contains(DEINT_QUALITY_MEDIUM))
351  result = DEINT_MEDIUM;
352  else if (Deinterlacer.contains(DEINT_QUALITY_LOW))
353  result = DEINT_BASIC;
354 
355  if (result != DEINT_NONE)
356  {
357  result = result | DEINT_CPU; // NB always assumed
358  if (Deinterlacer.contains(DEINT_QUALITY_SHADER))
359  result = result | DEINT_SHADER;
360  if (Deinterlacer.contains(DEINT_QUALITY_DRIVER))
361  result = result | DEINT_DRIVER;
362  }
363 
364  return result;
365 }
366 
367 void MythVideoOutput::SetDeinterlacing(bool Enable, bool DoubleRate, MythDeintType Force /*=DEINT_NONE*/)
368 {
369  if (!Enable)
370  {
372  LOG(VB_PLAYBACK, LOG_INFO, LOC + "Disabled all deinterlacing");
373  return;
374  }
375 
376  MythDeintType singlerate = DEINT_NONE;
377  MythDeintType doublerate = DEINT_NONE;
378  if (DEINT_NONE != Force)
379  {
380  singlerate = Force;
381  if (DoubleRate)
382  doublerate = Force;
383  LOG(VB_PLAYBACK, LOG_INFO, LOC + "Overriding deinterlacers");
384  }
385  else if (m_dbDisplayProfile)
386  {
388  if (DoubleRate)
390  }
391 
392  LOG(VB_GENERAL, LOG_INFO, LOC + QString("SetDeinterlacing (Doublerate %1): Single %2 Double %3")
393  .arg(DoubleRate).arg(DeinterlacerPref(singlerate)).arg(DeinterlacerPref(doublerate)));
394  m_videoBuffers.SetDeinterlacing(singlerate, doublerate, m_videoCodecID);
395 }
396 
404 {
405  m_window.VideoAspectRatioChanged(VideoAspect);
406 }
407 
413 bool MythVideoOutput::InputChanged(const QSize &VideoDim, const QSize &VideoDispDim,
414  float VideoAspect, MythCodecID CodecID,
415  bool &/*AspectOnly*/, MythMultiLocker* /*Locks*/,
416  int ReferenceFrames, bool /*ForceChange*/)
417 {
418  m_window.InputChanged(VideoDim, VideoDispDim, VideoAspect);
419  m_maxReferenceFrames = ReferenceFrames;
420  AVCodecID avCodecId = myth2av_codecid(CodecID);
421  AVCodec *codec = avcodec_find_decoder(avCodecId);
422  QString codecName;
423  if (codec)
424  codecName = codec->name;
425  if (m_dbDisplayProfile)
427  m_videoCodecID = CodecID;
428  DiscardFrames(true, true);
429  return true;
430 }
434 void MythVideoOutput::ResizeDisplayWindow(const QRect &Rect, bool SaveVisible)
435 {
436  m_window.ResizeDisplayWindow(Rect, SaveVisible);
437 }
438 
443 void MythVideoOutput::EmbedInWidget(const QRect &EmbedRect)
444 {
445  m_window.EmbedInWidget(EmbedRect);
446 }
447 
454 {
456 }
457 
458 void MythVideoOutput::GetOSDBounds(QRect &Total, QRect &Visible,
459  float &VisibleAspect,
460  float &FontScaling,
461  float ThemeAspect) const
462 {
463  Total = GetTotalOSDBounds();
464  Visible = GetVisibleOSDBounds(VisibleAspect, FontScaling, ThemeAspect);
465 }
466 
473 QRect MythVideoOutput::GetVisibleOSDBounds(float &VisibleAspect,
474  float &FontScaling,
475  float ThemeAspect) const
476 {
477  QRect dvr = m_window.GetDisplayVisibleRect();
478  float dispPixelAdj = 1.0F;
479  if (dvr.height() && dvr.width())
480  dispPixelAdj = (m_window.GetDisplayAspect() * dvr.height()) / dvr.width();
481 
482  float ova = m_window.GetOverridenVideoAspect();
483  QRect vr = m_window.GetVideoRect();
484  float vs = vr.height() ? static_cast<float>(vr.width()) / vr.height() : 1.0F;
485  VisibleAspect = ThemeAspect * (ova > 0.0F ? vs / ova : 1.F) * dispPixelAdj;
486 
487  FontScaling = 1.0F;
488  return { QPoint(0,0), dvr.size() };
489 }
490 
496 {
498 }
499 
501 {
502  return m_window.GetDisplayVideoRect();
503 }
504 
516 {
518 }
519 
527 {
528  m_window.Zoom(Direction);
529 }
530 
537 {
539 }
540 
546 {
548 }
549 
558 {
559  m_window.ToggleAspectOverride(AspectMode);
560 }
561 
570 {
571  m_window.ToggleAdjustFill(FillMode);
572 }
573 
575 {
576  return m_window.GetZoomString();
577 }
578 
580 {
582 }
583 
585 {
586  int curVal = GetPictureAttribute(AttributeType);
587  if (curVal < 0)
588  return -1;
589 
590  int newVal = curVal + ((Direction) ? +1 : -1);
591 
592  if (kPictureAttribute_Hue == AttributeType)
593  newVal = newVal % 100;
594 
595  if ((kPictureAttribute_Range == AttributeType) && newVal > 1)
596  newVal = 1;
597 
598  newVal = min(max(newVal, 0), 100);
599 
600  return SetPictureAttribute(AttributeType, newVal);
601 }
602 
611 {
612  return m_videoColourSpace.SetPictureAttribute(Attribute, NewValue);
613 }
614 
616 {
617  return m_videoColourSpace.GetPictureAttribute(AttributeType);
618 }
619 
620 void MythVideoOutput::SetFramesPlayed(long long FramesPlayed)
621 {
622  m_framesPlayed = FramesPlayed;
623 }
624 
626 {
627  return m_framesPlayed;
628 }
629 
631 {
632  return m_errorState != kError_None;
633 }
634 
636 {
637  return m_errorState;
638 }
639 
642 {
644 }
645 
648 {
650 }
651 
654 {
655  return static_cast<int>(m_videoBuffers.ValidVideoFrames());
656 }
657 
660 {
661  return static_cast<int>(m_videoBuffers.FreeVideoFrames());
662 }
663 
666 {
668 }
669 
673 {
675 }
676 
678 QRect MythVideoOutput::GetPIPRect(PIPLocation Location, MythPlayer *PiPPlayer, bool DoPixelAdj) const
679 {
680  return m_window.GetPIPRect(Location, PiPPlayer, DoPixelAdj);
681 }
682 
684 {
685  for (auto it = PiPPlayers.cbegin(); it != PiPPlayers.cend(); ++it)
686  ShowPIP(Frame, it.key(), *it);
687 }
688 
690 {
691  return m_window.GetAspectOverride();
692 }
693 
695 {
696  return m_window.GetAdjustFill();
697 }
698 
701 {
703 }
704 
707 {
708  return m_videoBuffers.GetStatus();
709 }
710 
714 {
716 }
717 
719 void MythVideoOutput::SetVideoResize(const QRect &VideoRect)
720 {
721  m_window.SetITVResize(VideoRect);
722 }
723 
728 {
730 }
731 
733  const QString &Name)
734 {
735  if (!Enable)
736  {
738  return false;
739  }
740  return SetupVisualisation(Audio, nullptr, Name);
741 }
742 
744 {
745  return VideoVisual::CanVisualise(Audio, Render);
746 }
747 
749  const QString &Name)
750 {
752  m_visual = VideoVisual::Create(Name, Audio, Render);
753  return m_visual;
754 }
755 
757 {
758  if (m_visual)
759  return m_visual->Name();
760  return QString("");
761 }
762 
764 {
765  return QStringList();
766 }
767 
769 {
770  delete m_visual;
771  m_visual = nullptr;
772 }
773 
783 {
784  if (To == nullptr || From == nullptr)
785  return;
786 
787  To->frameNumber = From->frameNumber;
788  To->disp_timecode = From->disp_timecode;
789  To->frameCounter = From->frameCounter;
790 
791  copy(To, From);
792 }
793 
795 QRect MythVideoOutput::GetImageRect(const QRect &Rect, QRect *DisplayRect)
796 {
797  qreal hscale = 0.0;
798  QSize video_size = m_window.GetVideoDispDim();
799  int image_height = video_size.height();
800  int image_width = (image_height > 720) ? 1920 :
801  (image_height > 576) ? 1280 : 720;
802  qreal image_aspect = static_cast<qreal>(image_width) / image_height;
803  qreal pixel_aspect = static_cast<qreal>(video_size.width()) / video_size.height();
804 
805  QRect rect1 = Rect;
806  if (DisplayRect && DisplayRect->isValid())
807  {
808  QMatrix m0;
809  m0.scale(static_cast<qreal>(image_width) / DisplayRect->width(),
810  static_cast<qreal>(image_height) / DisplayRect->height());
811  rect1 = m0.mapRect(rect1);
812  rect1.translate(DisplayRect->left(), DisplayRect->top());
813  }
814  QRect result = rect1;
815 
816  QRect dvr_rec = m_window.GetDisplayVideoRect();
817  QRect vid_rec = m_window.GetVideoRect();
818 
819  hscale = image_aspect / pixel_aspect;
820  if (hscale < 0.99 || hscale > 1.01)
821  {
822  vid_rec.setLeft(static_cast<int>(lround(static_cast<qreal>(vid_rec.left()) * hscale)));
823  vid_rec.setWidth(static_cast<int>(lround(static_cast<qreal>(vid_rec.width()) * hscale)));
824  }
825 
826  qreal vscale = static_cast<qreal>(dvr_rec.width()) / image_width;
827  hscale = static_cast<qreal>(dvr_rec.height()) / image_height;
828  QMatrix m1;
829  m1.translate(dvr_rec.left(), dvr_rec.top());
830  m1.scale(vscale, hscale);
831 
832  vscale = static_cast<qreal>(image_width) / vid_rec.width();
833  hscale = static_cast<qreal>(image_height) / vid_rec.height();
834  QMatrix m2;
835  m2.scale(vscale, hscale);
836  m2.translate(-vid_rec.left(), -vid_rec.top());
837 
838  result = m2.mapRect(result);
839  result = m1.mapRect(result);
840  return result;
841 }
842 
850 {
851  static constexpr float kSafeMargin = 0.05F;
852  float dummy = NAN;
853  QRect result = GetVisibleOSDBounds(dummy, dummy, 1.0F);
854  int safex = static_cast<int>(static_cast<float>(result.width()) * kSafeMargin);
855  int safey = static_cast<int>(static_cast<float>(result.height()) * kSafeMargin);
856  return { result.left() + safex, result.top() + safey,
857  result.width() - (2 * safex), result.height() - (2 * safey) };
858 }
859 
861 {
863 }
864 
866 {
867  static VideoFrameType s_defaultFormats[] = { FMT_YV12, FMT_NONE };
868  return &s_defaultFormats[0];
869 }
870 
875 {
877 }
878 
882 {
884 }
885 
888 {
890 }
891 
894 {
895  return m_window.IsEmbedding();
896 }
897 
901 {
903 }
904 
908 {
910 }
911 
915 {
917 }
918 
921 void MythVideoOutput::DiscardFrames(bool KeyFrame, bool /*Flushed*/)
922 {
923  m_videoBuffers.DiscardFrames(KeyFrame);
924 }
925 
938 {
939  if (!m_display)
940  return;
941  if (!m_display->UsingVideoModes())
942  return;
943 
944  if (Size.isEmpty())
945  {
946  Size = m_window.GetVideoDispDim();
947  if (Size.isEmpty())
948  return;
949  }
950 
951  float rate = m_dbDisplayProfile ? m_dbDisplayProfile->GetOutput() : 0.0F;
952 
953  bool hide = m_display->NextModeIsLarger(Size);
954  MythMainWindow* window = GetMythMainWindow();
955  if (hide)
956  window->hide();
957 
958  if (m_display->SwitchToVideo(Size, static_cast<double>(rate)))
959  {
960  // Switching to custom display resolution succeeded
961  // Make a note of the new size
962  QString source;
963  double aspect = m_display->GetAspectRatio(source);
964  LOG(VB_PLAYBACK, LOG_INFO, LOC + QString("Aspect ratio: %1 (%2)")
965  .arg(aspect).arg(source));
966  m_window.SetDisplayAspect(static_cast<float>(aspect));
968 
969  bool fullscreen = !m_window.UsingGuiSize();
970 
971  // if width && height are zero users expect fullscreen playback
972  if (!fullscreen)
973  {
974  int gui_width = 0;
975  int gui_height = 0;
976  gCoreContext->GetResolutionSetting("Gui", gui_width, gui_height);
977  fullscreen |= (0 == gui_width && 0 == gui_height);
978  }
979 
980  if (fullscreen)
981  {
982  QSize sz = m_display->GetResolution();
983  QRect display_visible_rect = QRect(GetMythMainWindow()->geometry().topLeft(), sz);
984  if (HasMythMainWindow())
985  {
986  if (hide)
987  {
988  window->Show();
989  hide = false;
990  }
991  GetMythMainWindow()->MoveResize(display_visible_rect);
992  }
993  }
994  }
995  if (hide)
996  window->Show();
997 }
998 
1005 {
1006  if (!m_display)
1007  return;
1008 
1009  // Retrieve the display aspect ratio.
1010  // This will be, in priority order:-
1011  // - aspect ratio override when using resolution/mode switching (if not 'Default')
1012  // - aspect ratio override for setups where detection does not work/is broken (multiscreen, broken EDID etc)
1013  // - aspect ratio based on detected physical size (this should be the common/default value)
1014  // - aspect ratio fallback using screen resolution
1015  // - 16:9
1016  QString source;
1017  double displayaspect = m_display->GetAspectRatio(source);
1018  LOG(VB_PLAYBACK, LOG_INFO, LOC + QString("Display aspect ratio: %1 (%2)")
1019  .arg(displayaspect).arg(source));
1020 
1021  // Get the window and screen resolutions
1022  QSize window = m_window.GetWindowRect().size();
1023  QSize screen = m_display->GetResolution();
1024 
1025  // If not running fullscreen, adjust for window size and ignore any video
1026  // mode overrides as they do not apply when in a window
1027  if (!window.isEmpty() && !screen.isEmpty() && window != screen)
1028  {
1029  displayaspect = m_display->GetAspectRatio(source, true);
1030  double screenaspect = screen.width() / static_cast<double>(screen.height());
1031  double windowaspect = window.width() / static_cast<double>(window.height());
1032  displayaspect = displayaspect * (1.0 / screenaspect) * windowaspect;
1033  LOG(VB_PLAYBACK, LOG_INFO, LOC + QString("Window aspect ratio: %1").arg(displayaspect));
1034  }
1035 
1036  m_window.SetDisplayAspect(static_cast<float>(displayaspect));
1037 }
1038 
1040 int MythVideoOutput::CalcHueBase(const QString &AdaptorName)
1041 {
1042  int defaulthue = 50;
1043 
1044  QString lower = AdaptorName.toLower();
1045  // Hue base for different adaptors
1046  // This can probably now be removed as it is only relevant to VAAPI
1047  // which always uses 50
1048  if (lower.contains("radeon") ||
1049  lower.contains("g3d") ||
1050  lower.contains("xvba") /* VAAPI */ ||
1051  lower.startsWith("intel") ||
1052  lower.contains("splitted"))
1053  {
1054  defaulthue = 50;
1055  }
1056  else if (lower.startsWith("nv17")) /* nVidia */
1057  {
1058  defaulthue = 0;
1059  }
1060  else
1061  {
1062  LOG(VB_GENERAL, LOG_INFO, LOC +
1063  QString("CalcHueBase(%1): Unknown adaptor, hue may be wrong.")
1064  .arg(AdaptorName));
1065  }
1066 
1067  return defaulthue;
1068 }
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.
void SetInput(const QSize &Size, float Framerate=0, const QString &CodecName=QString(), const QStringList &DisallowedDecoders=QStringList())
QRect GetImageRect(const QRect &Rect, QRect *DisplayRect=nullptr)
translates caption/dvd button rectangle into 'screen' space
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:87
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.
QString get_decoder_name(MythCodecID codec_id)
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
static guint32 * tmp
Definition: goom_core.cpp:30
long long copy(QFile &dst, QFile &src, uint block_size)
Copies src file to dst file.
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:70
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)
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.
QString get_encoding_type(MythCodecID codecid)
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
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
Definition: mythlogging.h:23