Skip to content

Commit

Permalink
Video Playback: Extend playback profiles to allow preferences based o…
Browse files Browse the repository at this point in the history
…n more criteria

Video playback allows selection of different settings based on video
size. This change extends it to also allow selection based on video format
and frame rate. These are optional and if left blank the existing rules
continue to apply.

Fixes #13061
  • Loading branch information
bennettpeter committed Jul 30, 2017
1 parent f7fe2d5 commit 538f99e
Show file tree
Hide file tree
Showing 13 changed files with 340 additions and 81 deletions.
4 changes: 2 additions & 2 deletions mythtv/libs/libmyth/standardsettings.h
Expand Up @@ -253,8 +253,8 @@ class MPUBLIC GlobalComboBoxSetting: public MythUIComboBoxSetting
class MPUBLIC TransMythUIComboBoxSetting: public MythUIComboBoxSetting
{
public:
TransMythUIComboBoxSetting() :
MythUIComboBoxSetting() { }
TransMythUIComboBoxSetting(bool rw = false) :
MythUIComboBoxSetting(NULL, rw) { }
};

class MPUBLIC HostTimeBoxSetting : public HostComboBoxSetting
Expand Down
17 changes: 14 additions & 3 deletions mythtv/libs/libmythtv/avformatdecoder.cpp
Expand Up @@ -1636,7 +1636,11 @@ void AvFormatDecoder::InitVideoCodec(AVStream *stream, AVCodecContext *enc,
}

m_parent->SetKeyframeDistance(keyframedist);
m_parent->SetVideoParams(width, height, fps, kScan_Detect);
AVCodec *codec = avcodec_find_decoder(enc->codec_id);
QString codecName;
if (codec)
codecName = codec->name;
m_parent->SetVideoParams(width, height, fps, kScan_Detect, codecName);
if (LCD *lcd = LCD::Get())
{
LCDVideoFormatSet video_format;
Expand Down Expand Up @@ -2335,11 +2339,18 @@ int AvFormatDecoder::ScanStreams(bool novideo)
uint height = max(dim.height(), 16);
QString dec = "ffmpeg";
uint thread_count = 1;

AVCodec *codec1 = avcodec_find_decoder(enc->codec_id);
QString codecName;
if (codec1)
codecName = codec1->name;
if (enc->framerate.den && enc->framerate.num)
fps = float(enc->framerate.num) / float(enc->framerate.den);
else
fps = 0;
if (!is_db_ignored)
{
VideoDisplayProfile vdp;
vdp.SetInput(QSize(width, height));
vdp.SetInput(QSize(width, height),fps,codecName);
dec = vdp.GetDecoder();
thread_count = vdp.GetMaxCPUs();
bool skip_loop_filter = vdp.IsSkipLoopEnabled();
Expand Down
17 changes: 8 additions & 9 deletions mythtv/libs/libmythtv/mythplayer.cpp
Expand Up @@ -497,7 +497,7 @@ bool MythPlayer::InitVideo(void)
decoder->GetVideoCodecPrivate(),
pipState, video_dim, video_disp_dim, video_aspect,
parentWidget, embedRect,
video_frame_rate, (uint)playerFlags);
video_frame_rate, (uint)playerFlags, m_codecName);

if (!videoOutput)
{
Expand Down Expand Up @@ -588,13 +588,6 @@ void MythPlayer::ReinitOSD(void)

void MythPlayer::ReinitVideo(void)
{
if (!videoOutput->IsPreferredRenderer(video_disp_dim))
{
LOG(VB_PLAYBACK, LOG_INFO, LOC + "Need to switch video renderer.");
SetErrored(tr("Need to switch video renderer"));
errorType |= kError_Switch_Renderer;
return;
}

bool aspect_only = false;
{
Expand Down Expand Up @@ -824,7 +817,7 @@ void MythPlayer::SetScanType(FrameScanType scan)
}

void MythPlayer::SetVideoParams(int width, int height, double fps,
FrameScanType scan)
FrameScanType scan, QString codecName)
{
bool paramsChanged = false;

Expand Down Expand Up @@ -854,6 +847,12 @@ void MythPlayer::SetVideoParams(int width, int height, double fps,
}
}

if (!codecName.isEmpty())
{
m_codecName = codecName;
paramsChanged = true;
}

if (!paramsChanged)
return;

Expand Down
4 changes: 3 additions & 1 deletion mythtv/libs/libmythtv/mythplayer.h
Expand Up @@ -160,7 +160,7 @@ class MTV_PUBLIC MythPlayer
void SetWatched(bool forceWatched = false);
void SetKeyframeDistance(int keyframedistance);
void SetVideoParams(int w, int h, double fps,
FrameScanType scan = kScan_Ignore);
FrameScanType scan = kScan_Ignore, QString codecName = QString());
void SetFileLength(int total, int frames);
void SetDuration(int duration);
void SetVideoResize(const QRect &videoRect);
Expand Down Expand Up @@ -725,6 +725,8 @@ class MTV_PUBLIC MythPlayer
bool m_scan_initialized;
/// Video (input) Number of frames between key frames (often inaccurate)
uint keyframedist;
/// Codec Name - used by playback profile
QString m_codecName;

// Buffering
bool buffering;
Expand Down

0 comments on commit 538f99e

Please sign in to comment.