22#define LOC QString("VideoOutput: ")
111 float VideoAspect,
const QRect WindowRect,
MythCodecID CodecID)
122 bool mainSuccess =
InitBounds(VideoDim, VideoDispDim, VideoAspect, WindowRect);
151 LOG(VB_PLAYBACK, LOG_INFO,
LOC +
"Disabled all deinterlacing");
166 LOG(VB_PLAYBACK, LOG_INFO,
LOC +
"Overriding deinterlacers");
175 LOG(VB_GENERAL, LOG_INFO,
LOC + QString(
"SetDeinterlacing (Doublerate %1): Single %2 Double %3")
176 .arg(QString::number(DoubleRate),
189 bool& ,
int ReferenceFrames,
bool )
194 const AVCodec* codec = avcodec_find_decoder(avCodecId);
197 codecName = codec->name;
208 float& VisibleAspect,
210 float ThemeAspect)
const
224 float ThemeAspect)
const
227 float dispPixelAdj = 1.0F;
228 if (dvr.height() && dvr.width())
233 float vs = vr.height() ?
static_cast<float>(vr.width()) / vr.height() : 1.0F;
234 VisibleAspect = ThemeAspect * (ova > 0.0F ? vs / ova : 1.F) * dispPixelAdj;
237 return { QPoint(0,0), dvr.size() };
326 int image_height = video_size.height();
327 int image_width {720};
328 if (image_height > 720)
330 else if (image_height > 576)
332 qreal image_aspect =
static_cast<qreal
>(image_width) / image_height;
333 qreal pixel_aspect =
static_cast<qreal
>(video_size.width()) / video_size.height();
336 if (DisplayRect && DisplayRect->isValid())
339 m0.scale(
static_cast<qreal
>(image_width) / DisplayRect->width(),
340 static_cast<qreal
>(image_height) / DisplayRect->height());
341 rect1 = m0.mapRect(rect1);
342 rect1.translate(DisplayRect->left(), DisplayRect->top());
344 QRect result = rect1;
349 hscale = image_aspect / pixel_aspect;
350 if (hscale < 0.99 || hscale > 1.01)
352 vid_rec.setLeft(
static_cast<int>(lround(
static_cast<qreal
>(vid_rec.left()) * hscale)));
353 vid_rec.setWidth(
static_cast<int>(lround(
static_cast<qreal
>(vid_rec.width()) * hscale)));
356 qreal vscale =
static_cast<qreal
>(dvr_rec.width()) / image_width;
357 hscale =
static_cast<qreal
>(dvr_rec.height()) / image_height;
359 m1.translate(dvr_rec.left(), dvr_rec.top());
360 m1.scale(vscale, hscale);
362 vscale =
static_cast<qreal
>(image_width) / vid_rec.width();
363 hscale =
static_cast<qreal
>(image_height) / vid_rec.height();
365 m2.scale(vscale, hscale);
366 m2.translate(-vid_rec.left(), -vid_rec.top());
368 result = m2.mapRect(result);
369 result = m1.mapRect(result);
381 static constexpr float kSafeMargin = 0.05F;
384 int safex =
static_cast<int>(
static_cast<float>(result.width()) * kSafeMargin);
385 int safey =
static_cast<int>(
static_cast<float>(result.height()) * kSafeMargin);
386 return { result.left() + safex, result.top() + safey,
387 result.width() - (2 * safex), result.height() - (2 * safey) };
QRect GetEmbeddingRect(void) const
QRect GetDisplayVideoRect(void) const
bool IsEmbedding(void) const
virtual void EmbedPlayback(bool Embed, QRect Rect)
QSize GetVideoDispDim(void) const
float GetOverridenVideoAspect(void) const
QRect GetVideoRect(void) const
void SourceChanged(QSize VideoDim, QSize VideoDispDim, float Aspect)
Update for new source video dimensions and aspect ratio.
QRect GetDisplayVisibleRect(void) const
bool InitBounds(QSize VideoDim, QSize VideoDispDim, float Aspect, QRect WindowRect)
void VideoAspectRatioChanged(float Aspect)
Calls SetVideoAspectRatio(float aspect), then calls MoveResize() to apply changes.
float GetDisplayAspect(void) const
PictureAttributeSupported SupportedAttributes(void) const
static QString DeinterlacerPref(MythDeintType Deint)
static MythDeintType ParseDeinterlacer(const QString &Deinterlacer)
static void GetRenderOptions(RenderOptions &Options, MythRender *Render)
static void GetRenderOptions(RenderOptions &Options)
MythCodecID m_videoCodecID
bool EnoughFreeFrames()
Returns true iff enough frames are available to decode onto.
VideoErrorState m_errorState
bool EnoughDecodedFrames()
Returns true iff there are plenty of decoded frames ready for display.
virtual void ReleaseFrame(MythVideoFrame *Frame)
Releases a frame from the ready for decoding queue onto the queue of frames ready for display.
virtual void StartDisplayingFrame()
Tell GetLastShownFrame() to return the next frame from the head of the queue of frames to display.
virtual void GetOSDBounds(QRect &Total, QRect &Visible, float &VisibleAspect, float &FontScaling, float ThemeAspect) const
virtual int ValidVideoFrames() const
Returns number of frames that are fully decoded.
virtual void ClearAfterSeek()
Tells video output to toss decoded buffers due to a seek.
virtual MythVideoFrame * GetLastDecodedFrame()
void SetPrebuffering(bool Normal)
Sets whether to use a normal number of buffers or fewer buffers.
virtual void SetDeinterlacing(bool Enable, bool DoubleRate, MythDeintType Force=DEINT_NONE)
MythVideoColourSpace m_videoColourSpace
virtual bool Init(QSize VideoDim, QSize VideoDispDim, float VideoAspect, QRect WindowRect, MythCodecID CodecID)
QRect GetImageRect(QRect Rect, QRect *DisplayRect=nullptr)
translates caption/dvd button rectangle into 'screen' space
MythVideoProfilePtr m_videoProfile
virtual void SetVideoFrameRate(float VideoFrameRate)
PictureAttributeSupported GetSupportedPictureAttributes()
virtual long long GetFramesPlayed()
QRect GetSafeRect()
Returns a QRect describing an area of the screen on which it is 'safe' to render the On Screen Displa...
QString GetFrameStatus() const
Returns string with status of each frame for debugging.
MythDeintType m_forcedDeinterlacer
VideoErrorState GetError() const
virtual void DeLimboFrame(MythVideoFrame *Frame)
Releases a frame for reuse if it is in limbo.
VideoBuffers m_videoBuffers
virtual MythVideoFrame * GetLastShownFrame()
Returns frame from the head of the ready to be displayed queue, if StartDisplayingFrame has been call...
virtual MythVideoFrame * GetNextFreeFrame()
Blocks until it is possible to return a frame for decoding onto.
int FreeVideoFrames()
Returns number of frames available for decoding onto.
virtual void DiscardFrame(MythVideoFrame *Frame)
Releases frame from any queue onto the queue of frames ready for decoding onto.
virtual void SetFramesPlayed(long long FramesPlayed)
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...
static void GetRenderOptions(RenderOptions &Options, MythRender *Render)
virtual void DoneDisplayingFrame(MythVideoFrame *Frame)
Releases frame returned from GetLastShownFrame() onto the queue of frames ready for decoding onto.
virtual bool InputChanged(QSize VideoDim, QSize VideoDispDim, float VideoAspect, MythCodecID CodecID, bool &AspectChanged, int ReferenceFrames, bool ForceChange)
Tells video output to discard decoded frames and wait for new ones.
QRect GetVisibleOSDBounds(float &VisibleAspect, float &FontScaling, float ThemeAspect) const
Returns visible portions of total OSD bounds.
void SetPrebuffering(bool Normal)
Sets prebuffering state to normal, or small.
MythVideoFrame * GetNextFreeFrame(BufferType EnqueueTo=kVideoBuffer_limbo)
Gets a frame from available buffers list.
bool EnoughFreeFrames(void) const
QString GetStatus(uint Num=0) const
MythVideoFrame * GetLastShownFrame(void)
MythVideoFrame * GetLastDecodedFrame(void)
void SetDeinterlacing(MythDeintType Single, MythDeintType Double, MythCodecID CodecID)
uint ValidVideoFrames(void) const
bool EnoughDecodedFrames(void) const
void DoneDisplayingFrame(MythVideoFrame *Frame)
Removes frame from used queue and adds it to the available list.
void DiscardFrames(bool NextFrameIsKeyFrame)
Mark all used frames as ready to be reused, this is for seek.
void ReleaseFrame(MythVideoFrame *Frame)
Frame is ready to be for filtering or OSD application.
void ClearAfterSeek(void)
Clear used frames after seeking.
void DiscardFrame(MythVideoFrame *Frame)
Frame is ready to be reused by decoder.
uint FreeVideoFrames(void) const
void StartDisplayingFrame(void)
Sets rpos to index of videoframe at head of used queue.
void DeLimboFrame(MythVideoFrame *Frame)
If the frame is still in the limbo state it is added to the available queue.
AVCodecID myth2av_codecid(MythCodecID codec_id)
MythCoreContext * gCoreContext
This global variable contains the MythCoreContext instance for the app.
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
PictureAttributeSupported
@ kLetterBoxColour_Gray25