Go to the documentation of this file.
23 #define LOC QString("VidOutGPU: ")
42 const QSize VideoDispDim,
float VideoAspect,
44 const QString& Codec,
int ReferenceFrames,
47 if (!(MainWindow && Render && Painter && Display))
49 LOG(VB_GENERAL, LOG_ERR,
LOC +
"Fatal error");
55 LOG(VB_GENERAL, LOG_ERR,
LOC +
"Cannot create null video output here");
59 QStringList renderers;
82 LOG(VB_PLAYBACK, LOG_INFO,
LOC + QString(
"Allowed renderers for %1 %2 (Decoder: %3): '%4'")
86 renderers.join(
",")));
88 LOG(VB_PLAYBACK, LOG_INFO,
LOC + QString(
"Allowed renderers (filt: %1): %2")
89 .arg(
Decoder, renderers.join(
",")));
93 auto videoprofile = std::make_shared<MythVideoProfile>();
95 if (!renderers.empty())
97 videoprofile->SetInput(VideoDispDim, FrameRate, Codec);
98 QString
tmp = videoprofile->GetVideoRenderer();
99 if (videoprofile->IsDecoderCompatible(
Decoder) && renderers.contains(
tmp))
102 LOG(VB_PLAYBACK, LOG_INFO,
LOC +
"Preferred renderer: " + renderer);
106 LOG(VB_PLAYBACK, LOG_INFO,
LOC + QString(
"No preferred renderer for decoder '%1' - profile renderer: '%2'")
111 if (renderer.isEmpty())
114 if (renderer.isEmpty())
125 LOG(VB_GENERAL, LOG_WARNING,
LOC +
"No renderer found. This should not happen!.");
126 LOG(VB_GENERAL, LOG_WARNING,
LOC + QString(
"Falling back to '%1'").arg(fallback));
130 while (!renderers.empty())
132 LOG(VB_PLAYBACK, LOG_INFO,
LOC + QString(
"Trying video renderer: '%1'").arg(renderer));
133 int index = renderers.indexOf(renderer);
135 renderers.removeAt(index);
149 if (!video && renderer.contains(
"opengl") && openglrender)
152 openglpainter, Display,
153 videoprofile, renderer);
160 vulkanpainter, Display,
161 videoprofile, renderer);
169 if (video->
Init(VideoDim, VideoDispDim, VideoAspect, MainWindow->
GetUIScreenRect(), CodecID))
181 LOG(VB_GENERAL, LOG_ERR,
LOC +
"Not compiled with any useable video output method.");
212 : m_mainWindow(MainWindow),
215 m_profile(std::move(Profile))
219 LOG(VB_GENERAL, LOG_ERR,
"Fatal error");
286 if (qFuzzyCompare(
m_videoProfile->GetOutput() + 1.0F, NewRate + 1.0F))
289 LOG(VB_PLAYBACK, LOG_INFO,
LOC + QString(
"Video frame rate changed: %1->%2")
290 .arg(
static_cast<double>(
m_videoProfile->GetOutput())).arg(
static_cast<double>(NewRate)));
296 float Aspect,
const QRect DisplayVisibleRect,
MythCodecID CodecId)
375 QVector<MythVideoFrame*> release;
381 if (!retain || (frame !=
Frame))
382 release.append(frame);
393 release.append(
Frame);
397 for (
auto * frame : release)
444 bool& AspectOnly,
int ReferenceFrames,
461 LOG(VB_PLAYBACK, LOG_INFO,
LOC + QString(
"Video changed: %1x%2 (%3x%4) '%5' (Aspect %6 Refs %13)"
462 "-> %7x%8 (%9x%10) '%11' (Aspect %12 Refs %14)")
463 .arg(currentvideodispdim.width()).arg(currentvideodispdim.height())
464 .arg(currentvideodim.width()).arg(currentvideodim.height())
465 .arg(
toString(currentcodec)).arg(
static_cast<double>(currentaspect))
466 .arg(VideoDispDim.width()).arg(VideoDispDim.height())
467 .arg(VideoDim.width()).arg(VideoDim.height())
468 .arg(
toString(CodecId)).arg(
static_cast<double>(VideoAspect))
471 bool cidchanged = (CodecId != currentcodec);
472 bool reschanged = (VideoDispDim != currentvideodispdim);
476 if (!(cidchanged || reschanged || refschanged || ForceChange))
522 const AVCodec* codec = avcodec_find_decoder(avCodecId);
525 codecName = codec->name;
535 if (wasembedding && ok)
574 LOG(VB_PLAYBACK, LOG_INFO,
LOC + QString(
"Display aspect ratio: %1 (%2)")
575 .arg(displayaspect).arg(source));
583 if (!window.isEmpty() && !screen.isEmpty() && window != screen)
586 double screenaspect = screen.width() /
static_cast<double>(screen.height());
587 double windowaspect = window.width() /
static_cast<double>(window.height());
588 displayaspect = displayaspect * (1.0 / screenaspect) * windowaspect;
589 LOG(VB_PLAYBACK, LOG_INFO,
LOC + QString(
"Window aspect ratio: %1").arg(displayaspect));
623 bool topfieldfirst =
false;
627 topfieldfirst =
Frame->m_interlacedReverse ? !
Frame->m_topFieldFirst :
Frame->m_topFieldFirst;
628 dummy =
Frame->m_dummy;
683 LOG(VB_PLAYBACK, LOG_WARNING,
LOC +
"Could not update pause frame");
742 LOG(VB_PLAYBACK, LOG_INFO,
LOC + QString(
"Aspect ratio: %1 (%2)")
743 .arg(aspect).arg(source));
755 fullscreen |= (0 == gui_width && 0 == gui_height);
761 QRect display_visible_rect = QRect(
m_mainWindow->geometry().topLeft(), size);
void InitPictureAttributes() override
void PictureAttributeChanged(PictureAttribute Attribute, int Value)
QString toString(const QDateTime &raw_dt, uint format)
Returns formatted string representing the time.
bool IsEmbedding(void) const
void DiscardFrames(bool KeyFrame, bool Flushed) override
Discard video frames.
void SetVideoFrameRate(float NewRate) override
virtual void RenderFrame(MythVideoFrame *Frame, bool TopFieldFirst, FrameScanType Scan, StereoscopicMode StereoOverride, bool DrawBorder=false)=0
MythVideoFrame * Head(BufferType Type)
virtual int DecrRef(void)
Decrements reference count and deletes on 0.
static bool codec_is_v4l2(MythCodecID id)
MythVideoFrame * Tail(BufferType Type)
void InitDisplayMeasurements()
Initialise display measurement.
virtual void EmbedPlayback(bool Embed, QRect Rect)
static bool codec_is_nvdec(MythCodecID id)
void Remove(BufferType Type, MythVideoFrame *Frame)
QRect GetDisplayVisibleRect(void) const
static bool codec_is_vaapi(MythCodecID id)
static bool codec_is_vtb(MythCodecID id)
void RefreshVideoBoundsState()
Send out latest state to listeners.
void PictureAttributesUpdated(const std::map< PictureAttribute, int > &Values)
bool DiscardAndRecreate(MythCodecID CodecID, QSize VideoDim, int References)
Discard all buffers and recreate.
static void GetRenderOptions(RenderOptions &Options)
Generate the list of available OpenGL profiles.
MythDeintType m_forcedDeinterlacer
MythVideoFrame * Dequeue(BufferType Type)
double GetAspectRatio(QString &Source, bool IgnoreModeOverride=false)
Returns current screen aspect ratio.
void SetSupportedAttributes(PictureAttributeSupported Supported)
Enable the given set of picture attributes.
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
static bool HardwareFormat(VideoFrameType Type)
void ClearAfterSeek() override
Tells video output to toss decoded buffers due to a seek.
bool UsingGuiSize(void) const
void Draw(MythPainter *Painter=nullptr)
std::chrono::milliseconds m_displayTimecode
static QString GetBestVideoRenderer(const QStringList &Renderers)
static QStringList GetAllowedRenderers(MythRenderOpenGL *Render, MythCodecID CodecId, QSize VideoDim)
Generate a list of supported OpenGL profiles.
void ResizeForVideo(QSize Size=QSize())
void SupportedAttributesChanged(PictureAttributeSupported Supported)
bool CreateBuffers(VideoFrameType Type, const VideoFrameTypes *RenderFormats, QSize Size, uint NeedFree, uint NeedprebufferNormal, uint NeedPrebufferSmall, int MaxReferenceFrames=16)
bool Init(QSize VideoDim, QSize VideoDispDim, float Aspect, QRect DisplayVisibleRect, MythCodecID CodecId) override
static void GetRenderOptions(RenderOptions &Options, MythRender *Render)
void DoneDisplayingFrame(MythVideoFrame *Frame) override
Release a video frame back into the decoder pool.
virtual void SetViewPort(const QRect, bool=false)
void SetDisplayAspect(float DisplayAspect)
virtual void ResetTextures()=0
MythMainWindow * m_mainWindow
virtual void PrepareFrame(MythVideoFrame *Frame, FrameScanType Scan=kScan_Progressive)=0
virtual bool Init(QSize VideoDim, QSize VideoDispDim, float VideoAspect, QRect WindowRect, MythCodecID CodecID)
void SetDisplay(MythDisplay *mDisplay)
bool Contains(BufferType Type, MythVideoFrame *Frame) const
void SourceChanged(QSize VideoDim, QSize VideoDispDim, float Aspect)
Update for new source video dimensions and aspect ratio.
virtual void ClearAfterSeek()
Tells video output to toss decoded buffers due to a seek.
void UpdatePauseFrame(std::chrono::milliseconds &DisplayTimecode, FrameScanType Scan=kScan_Progressive) override
bool m_alreadyDeinterlaced
std::vector< VideoFrameType > VideoFrameTypes
void PictureAttributeChanged(PictureAttribute Attribute, int Value)
MythVideoProfilePtr m_videoProfile
void Filter(MythVideoFrame *Frame, FrameScanType Scan, MythVideoProfile *Profile, bool Force=false)
Deinterlace Frame if needed.
void GetResolutionSetting(const QString &type, int &width, int &height, double &forced_aspect, double &refresh_rate, int index=-1)
bool SwitchToVideo(QSize Size, double Rate=0.0)
Switches to the resolution and refresh rate defined in the database for the specified video resolutio...
static MythVideoOutputGPU * Create(MythMainWindow *MainWindow, MythRender *Render, MythPainter *Painter, MythDisplay *Display, const QString &Decoder, MythCodecID CodecID, QSize VideoDim, QSize VideoDispDim, float VideoAspect, float FrameRate, uint PlayerFlags, const QString &Codec, int ReferenceFrames, const VideoFrameTypes *&RenderFormats)
QString get_encoding_type(MythCodecID codecid)
QWidget * GetPaintWindow()
QRect GetEmbeddingRect(void) const
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...
MythCodecID m_videoCodecID
void SetRotation(int Rotation)
Set the rotation in degrees.
MythCoreContext * gCoreContext
This global variable contains the MythCoreContext instance for the app.
virtual void FreeResources(void)
void SetReferenceFrames(int ReferenceFrames)
QSize GetVideoDispDim(void) const
virtual void EndFrame()=0
frame_queue_t::iterator BeginLock(BufferType Type)
Lock the video buffers.
static QStringList GetAllowedRenderers(MythCodecID CodecId)
void PrepareFrame(MythVideoFrame *Frame, FrameScanType Scan) override
MythDeinterlacer m_deinterlacer
static VideoFrameType FrameTypeForCodec(MythCodecID CodecId)
#define ALL_PICTURE_ATTRIBUTES
bool ProcessInputChange()
static void GetRenderOptions(RenderOptions &Options)
void SetViewControl(ViewControls Control)
void DiscardPauseFrames(void)
void ChangePictureAttribute(PictureAttribute Attribute, bool Direction, int Value)
const VideoFrameTypes * m_renderFormats
void PictureAttributesUpdated(const std::map< PictureAttribute, int > &Values)
AVCodecID myth2av_codecid(MythCodecID codec_id)
bool NextModeIsLarger(QSize Size)
Check whether the next mode is larger in size than the current mode.
void Enqueue(BufferType Type, MythVideoFrame *Frame)
int ChangePictureAttribute(PictureAttribute Attribute, bool Direction, int Value)
bool InputChanged(QSize VideoDim, QSize VideoDispDim, float VideoAspect, MythCodecID CodecId, bool &AspectOnly, int ReferenceFrames, bool ForceChange) override
Tells video output to discard decoded frames and wait for new ones.
MythVideoOutputGPU(MythMainWindow *MainWindow, MythRender *Render, MythPainterGPU *Painter, MythDisplay *Display, MythVideoProfilePtr VideoProfile, QString &Profile)
void RenderFrame(MythVideoFrame *Frame, FrameScanType Scan) override
static bool codec_is_mmal(MythCodecID id)
bool CreateBuffers(MythCodecID CodecID, QSize Size)
QString get_decoder_name(MythCodecID codec_id)
void DoneDisplayingFrame(MythVideoFrame *Frame)
void SetProfile(const QString &Profile)
void SetVideoScalingAllowed(bool Change)
Disable or enable underscan/overscan.
static bool codec_is_mediacodec(MythCodecID id)
Common code shared between GPU accelerated sub-classes (e.g. OpenGL)
static bool codec_is_drmprime(MythCodecID id)
void SupportedAttributesChanged(PictureAttributeSupported Supported)
RenderType Type(void) const
virtual void ResetFrameFormat()
static bool codec_is_vdpau(MythCodecID id)
virtual QRect GetDisplayVisibleRectAdj()
std::shared_ptr< MythVideoProfile > MythVideoProfilePtr
MythPainterGPU * m_painter
void MoveResize(QRect &Geometry)
QRect GetWindowRect(void) const
virtual bool UsingVideoModes()
virtual void SetDeinterlacing(bool Enable, bool DoubleRate, MythDeintType Force=DEINT_NONE)
QRect GetRawWindowRect(void) const
static bool codec_is_copyback(MythCodecID id)
~MythVideoOutputGPU() override
virtual int IncrRef(void)
Increments reference count.
bool is_interlaced(FrameScanType Scan)
void Init(uint NumDecode, uint NeedFree, uint NeedprebufferNormal, uint NeedPrebufferSmall)
Creates buffers and sets various buffer management parameters.
QString GetStatus(uint Num=0) const
QSize GetVideoDim(void) const
uint Size(BufferType Type) const
static uint GetNumBuffers(int PixelFormat, int MaxReferenceFrames=16, bool Decoder=false)
static HDRTracker Create(class MythDisplay *MDisplay)
Create a tracker instance that looks for changes in the required EOTF.
VideoBuffers m_videoBuffers
float GetVideoAspect(void) const
static QStringList GetFilteredRenderers(const QString &Decoder, const QStringList &Renderers)
MythVideoColourSpace m_videoColourSpace
void SetWindowSize(QSize Size)
StereoscopicMode GetStereoOverride() const
void WindowResized(QSize Size)