Skip to content

Commit

Permalink
Merge branch '2019-render' into branch 'render-tidy'.
Browse files Browse the repository at this point in the history
  • Loading branch information
linuxdude42 committed Dec 1, 2019
2 parents dec0996 + 1894599 commit 2181ec6
Show file tree
Hide file tree
Showing 36 changed files with 1,174 additions and 1,004 deletions.
4 changes: 2 additions & 2 deletions mythtv/external/FFmpeg/libavcodec/v4l2_context.c
Expand Up @@ -748,8 +748,8 @@ int ff_v4l2_context_init(V4L2Context* ctx)
ctx->num_buffers = req.count;
ctx->buffers = av_mallocz(ctx->num_buffers * sizeof(V4L2Buffer));
if (!ctx->buffers) {
av_log(logger(ctx), AV_LOG_ERROR, "%s malloc enomem\n", ctx->name);
return AVERROR(ENOMEM);
av_log(logger(ctx), AV_LOG_ERROR, "%s malloc enomem\n", ctx->name);
return AVERROR(ENOMEM);
}

for (i = 0; i < req.count; i++) {
Expand Down
3 changes: 2 additions & 1 deletion mythtv/external/FFmpeg/libavcodec/v4l2_m2m_dec.c
Expand Up @@ -227,6 +227,8 @@ static av_cold int v4l2_decode_init(AVCodecContext *avctx)
ret = AVERROR(ENOMEM);
return ret;
}

s->avctx = avctx;
ret = av_hwdevice_ctx_init(s->device_ref);
if (ret < 0)
return ret;
Expand All @@ -239,7 +241,6 @@ static av_cold int v4l2_decode_init(AVCodecContext *avctx)

return ret;
}
s->avctx = avctx;

return v4l2_prepare_decoder(s);
}
Expand Down
3 changes: 1 addition & 2 deletions mythtv/libs/libmyth/mythcontext.cpp
Expand Up @@ -29,10 +29,9 @@ using namespace std;
#include "dbsettings.h"
#include "langsettings.h"
#include "mythtranslation.h"
#include "mythxdisplay.h"
#include "platforms/mythxdisplay.h"
#include "mythevent.h"
#include "dbutil.h"
#include "DisplayRes.h"
#include "mythmediamonitor.h"

#include "mythdb.h"
Expand Down
2 changes: 1 addition & 1 deletion mythtv/libs/libmythtv/decoders/mythvdpauhelper.cpp
Expand Up @@ -2,7 +2,7 @@
#include "mythlogging.h"
#include "videocolourspace.h"
#include "mythvdpauhelper.h"
#include "mythxdisplay.h" // always last
#include "platforms/mythxdisplay.h" // always last

// Std
#include <cmath>
Expand Down
14 changes: 6 additions & 8 deletions mythtv/libs/libmythtv/mythplayer.cpp
Expand Up @@ -168,10 +168,6 @@ MythPlayer::MythPlayer(PlayerFlags flags)
detect_letter_box = new DetectLetterbox(this);

vbimode = VBIMode::Parse(gCoreContext->GetSetting("VbiFormat"));

defaultDisplayAspect =
gCoreContext->GetFloatSettingOnHost("XineramaMonitorAspectRatio",
gCoreContext->GetHostName(), 1.7777);
captionsEnabledbyDefault = gCoreContext->GetBoolSetting("DefaultCCMode");
decode_extra_audio = gCoreContext->GetBoolSetting("DecodeExtraAudio", false);
itvEnabled = gCoreContext->GetBoolSetting("EnableMHEG", false);
Expand Down Expand Up @@ -242,6 +238,8 @@ MythPlayer::~MythPlayer(void)
delete detect_letter_box;
detect_letter_box = nullptr;
}

MythDisplay::AcquireRelease(false);
}

void MythPlayer::SetWatchingRecording(bool mode)
Expand Down Expand Up @@ -499,7 +497,7 @@ void MythPlayer::ReinitVideo(bool ForceUpdate)
// the display refresh rate may have been changed by VideoOutput
if (videosync)
{
int ri = MythDisplay::GetDisplayInfo(frame_interval).Rate();
int ri = m_display->GetDisplayInfo(frame_interval).Rate();
if (ri != videosync->getRefreshInterval())
{
LOG(VB_PLAYBACK, LOG_INFO, LOC +
Expand Down Expand Up @@ -1565,7 +1563,7 @@ void MythPlayer::InitAVSync(void)

repeat_delay = 0;

refreshrate = MythDisplay::GetDisplayInfo(frame_interval).Rate();
refreshrate = m_display->GetDisplayInfo(frame_interval).Rate();

// Number of frames over which to average time divergence
avsync_averaging=4;
Expand Down Expand Up @@ -2420,7 +2418,7 @@ bool MythPlayer::CanSupportDoubleRate(void)
else
{
// used by the decoder before videosync is created
refreshinterval = MythDisplay::GetDisplayInfo(frame_interval).Rate();
refreshinterval = m_display->GetDisplayInfo(frame_interval).Rate();
}

// At this point we may not have the correct frame rate.
Expand Down Expand Up @@ -2512,7 +2510,7 @@ void MythPlayer::VideoStart(void)

float temp_speed = (play_speed == 0.0F) ? audio.GetStretchFactor() : play_speed;
int fr_int = (1000000.0 / video_frame_rate / static_cast<double>(temp_speed));
int rf_int = MythDisplay::GetDisplayInfo(fr_int).Rate();
int rf_int = m_display->GetDisplayInfo(fr_int).Rate();

// Default to interlaced playback but set the tracker to progressive
// Enable autodetection of interlaced/progressive from video stream
Expand Down
2 changes: 1 addition & 1 deletion mythtv/libs/libmythtv/mythplayer.h
Expand Up @@ -647,10 +647,10 @@ class MTV_PUBLIC MythPlayer
#endif

// Window stuff
MythDisplay* m_display { MythDisplay::AcquireRelease() };
QWidget *parentWidget {nullptr};
bool embedding {false};
QRect embedRect {0,0,0,0};
float defaultDisplayAspect {1.7777F};

// State
QWaitCondition decoderThreadPause;
Expand Down
28 changes: 13 additions & 15 deletions mythtv/libs/libmythtv/mythvideoout.cpp
Expand Up @@ -7,7 +7,6 @@
#include "mythlogging.h"
#include "mythmainwindow.h"
#include "mythuihelper.h"
#include "mythxdisplay.h"
#include "mythavutil.h"
#include "mthreadpool.h"
#include "mythcodeccontext.h"
Expand Down Expand Up @@ -254,6 +253,7 @@ MythVideoOutput *MythVideoOutput::Create(const QString &Decoder, MythCodecID
* Init(int,int,float,WId,int,int,int,int,WId) call.
*/
MythVideoOutput::MythVideoOutput()
: m_display(MythDisplay::AcquireRelease())
{
m_dbDisplayDimensionsMM = QSize(gCoreContext->GetNumSetting("DisplaySizeWidth", 0),
gCoreContext->GetNumSetting("DisplaySizeHeight", 0));
Expand All @@ -270,8 +270,7 @@ MythVideoOutput::~MythVideoOutput()
{
delete m_dbDisplayProfile;
ResizeForGui();
if (m_displayRes)
DisplayRes::AcquireRelease(false);
MythDisplay::AcquireRelease(false);
}

/**
Expand Down Expand Up @@ -915,8 +914,8 @@ void MythVideoOutput::DiscardFrames(bool KeyFrame, bool /*unused*/)
*/
void MythVideoOutput::ResizeForGui(void)
{
if (m_displayRes)
m_displayRes->SwitchToGUI();
if (m_display->UsingVideoModes())
m_display->SwitchToGUI();
}

/**
Expand All @@ -932,7 +931,7 @@ void MythVideoOutput::ResizeForGui(void)
*/
void MythVideoOutput::ResizeForVideo(int Width, int Height)
{
if (!m_displayRes)
if (!m_display->UsingVideoModes())
return;

if (!Width || !Height)
Expand All @@ -944,14 +943,13 @@ void MythVideoOutput::ResizeForVideo(int Width, int Height)
}

float rate = m_dbDisplayProfile ? m_dbDisplayProfile->GetOutput() : 0.0F;
if (m_displayRes && m_displayRes->SwitchToVideo(Width, Height, static_cast<double>(rate)))
if (m_display->SwitchToVideo(Width, Height, static_cast<double>(rate)))
{
// Switching to custom display resolution succeeded
// Make a note of the new size
m_window.SetDisplayProperties(QSize(m_displayRes->GetPhysicalWidth(),
m_displayRes->GetPhysicalHeight()),
static_cast<float>(m_displayRes->GetAspectRatio()));
m_window.SetWindowSize(QSize(m_displayRes->GetWidth(), m_displayRes->GetHeight()));
m_window.SetDisplayProperties(m_display->GetPhysicalSize(),
static_cast<float>(m_display->GetAspectRatio()));
m_window.SetWindowSize(m_display->GetResolution());

bool fullscreen = !m_window.UsingGuiSize();

Expand All @@ -965,7 +963,7 @@ void MythVideoOutput::ResizeForVideo(int Width, int Height)

if (fullscreen)
{
QSize sz(m_displayRes->GetWidth(), m_displayRes->GetHeight());
QSize sz = m_display->GetResolution();
QRect display_visible_rect = QRect(GetMythMainWindow()->geometry().topLeft(), sz);
if (HasMythMainWindow())
GetMythMainWindow()->MoveResize(display_visible_rect);
Expand All @@ -979,7 +977,7 @@ void MythVideoOutput::ResizeForVideo(int Width, int Height)
*/
void MythVideoOutput::InitDisplayMeasurements(void)
{
DisplayInfo disp = MythDisplay::GetDisplayInfo();
DisplayInfo disp = m_display->GetDisplayInfo();
QString source = "Actual";

// get the physical dimensions (in mm) of the display. If using
Expand Down Expand Up @@ -1054,8 +1052,8 @@ void MythVideoOutput::InitDisplayMeasurements(void)
disp_aspect = static_cast<float>(disp_dim.width()) / disp_dim.height();

// If we are using XRandR, use the aspect ratio from it
if (m_displayRes)
disp_aspect = static_cast<float>(m_displayRes->GetAspectRatio());
if (m_display->UsingVideoModes())
disp_aspect = static_cast<float>(m_display->GetAspectRatio());

m_window.SetDisplayProperties(disp_dim, disp_aspect);
}
Expand Down
3 changes: 1 addition & 2 deletions mythtv/libs/libmythtv/mythvideoout.h
Expand Up @@ -16,7 +16,6 @@
#include "videoouttypes.h"
#include "videooutwindow.h"
#include "mythdisplay.h"
#include "DisplayRes.h"
#include "videodisplayprofile.h"
#include "videocolourspace.h"
#include "visualisations/videovisual.h"
Expand Down Expand Up @@ -158,6 +157,7 @@ class MythVideoOutput

static void CopyFrame(VideoFrame* To, const VideoFrame* From);

MythDisplay* m_display {nullptr};
VideoOutWindow m_window;
QSize m_dbDisplayDimensionsMM {0,0};
VideoColourSpace m_videoColourSpace;
Expand All @@ -170,7 +170,6 @@ class MythVideoOutput
VideoBuffers m_videoBuffers;
VideoErrorState m_errorState {kError_None};
long long m_framesPlayed {0};
DisplayRes *m_displayRes {nullptr};
QSize m_monitorSize {640,480};
QSize m_monitorDimensions {400,300};
VideoVisual *m_visual {nullptr};
Expand Down
6 changes: 1 addition & 5 deletions mythtv/libs/libmythtv/opengl/mythvideooutopengl.cpp
Expand Up @@ -99,10 +99,6 @@ void MythVideoOutputOpenGL::GetRenderOptions(RenderOptions &Options)
MythVideoOutputOpenGL::MythVideoOutputOpenGL(QString Profile)
: m_videoProfile(std::move(Profile))
{
// Setup display switching
if (gCoreContext->GetBoolSetting("UseVideoModes", false))
m_displayRes = DisplayRes::AcquireRelease();

// Retrieve render context
m_render = MythRenderOpenGL::GetOpenGLRender();
if (!m_render)
Expand Down Expand Up @@ -225,7 +221,7 @@ bool MythVideoOutputOpenGL::Init(const QSize &VideoDim, const QSize &VideoDispDi
QSize size = m_window.GetVideoDim();

// Set the display mode if required
if (m_displayRes && !m_window.IsEmbedding())
if (m_display->UsingVideoModes() && !m_window.IsEmbedding())
ResizeForVideo(size.width(), size.height());
InitDisplayMeasurements();

Expand Down
1 change: 0 additions & 1 deletion mythtv/libs/libmythtv/tv_play.cpp
Expand Up @@ -48,7 +48,6 @@ using namespace std;
#include "mythmainwindow.h"
#include "mythscreenstack.h"
#include "mythscreentype.h"
#include "DisplayRes.h"
#include "mythuiactions.h" // for ACTION_LEFT, ACTION_RIGHT, etc

// libmythtv
Expand Down
15 changes: 14 additions & 1 deletion mythtv/libs/libmythtv/videooutwindow.cpp
Expand Up @@ -49,6 +49,7 @@ const float VideoOutWindow::kManualZoomMinVerticalZoom = 0.25F;
const int VideoOutWindow::kManualZoomMaxMove = 50;

VideoOutWindow::VideoOutWindow()
: m_display(MythDisplay::AcquireRelease())
{
m_dbPipSize = gCoreContext->GetNumSetting("PIPSize", 26);

Expand All @@ -57,6 +58,18 @@ VideoOutWindow::VideoOutWindow()
m_dbUseGUISize = gCoreContext->GetBoolSetting("GuiSizeForTV", false);

PopulateGeometry();
connect(m_display, &MythDisplay::CurrentScreenChanged, this, &VideoOutWindow::ScreenChanged);
}

VideoOutWindow::~VideoOutWindow()
{
MythDisplay::AcquireRelease(false);
}

void VideoOutWindow::ScreenChanged(QScreen*)
{
PopulateGeometry();
MoveResize();
}

void VideoOutWindow::PopulateGeometry(void)
Expand All @@ -65,7 +78,7 @@ void VideoOutWindow::PopulateGeometry(void)
if (not qobject_cast<QApplication*>(qApp))
return;

QScreen *screen = MythDisplay::GetScreen();
QScreen *screen = m_display->GetCurrentScreen();
if (MythDisplay::SpanAllScreens())
{
m_usingXinerama = true;
Expand Down
6 changes: 6 additions & 0 deletions mythtv/libs/libmythtv/videooutwindow.h
Expand Up @@ -18,6 +18,8 @@
// MythTV headers
#include "videoouttypes.h"

class QScreen;
class MythDisplay;
class MythPlayer;

class VideoOutWindow : public QObject
Expand All @@ -26,6 +28,7 @@ class VideoOutWindow : public QObject

public:
VideoOutWindow();
~VideoOutWindow() override;

bool Init(const QSize &VideoDim, const QSize &VideoDispDim,
float Aspect, const QRect &WindowRect,
Expand All @@ -40,6 +43,8 @@ class VideoOutWindow : public QObject
void WindowRectChanged (const QRect &WindowRect);

public slots:
void ScreenChanged (QScreen*);

// Sets
void InputChanged (const QSize &VideoDim, const QSize &VideoDispDim, float Aspect);
void VideoAspectRatioChanged(float Aspect);
Expand Down Expand Up @@ -103,6 +108,7 @@ class VideoOutWindow : public QObject
void Rotate (void);

private:
MythDisplay* m_display {nullptr};
QPoint m_dbMove {0,0}; ///< Percentage move from database
float m_dbHorizScale {0.0F}; ///< Horizontal Overscan/Underscan percentage
float m_dbVertScale {0.0F}; ///< Vertical Overscan/Underscan percentage
Expand Down

0 comments on commit 2181ec6

Please sign in to comment.