Skip to content

Commit

Permalink
MythPlayer: Pass the video aspect from the decoder on stream changes
Browse files Browse the repository at this point in the history
- avoids an extra unnecessary recalculation/reinitialisation when the
stream changes
  • Loading branch information
mark-kendall committed May 21, 2019
1 parent cb7fe54 commit 46d9414
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
10 changes: 5 additions & 5 deletions mythtv/libs/libmythtv/decoders/avformatdecoder.cpp
Expand Up @@ -1732,7 +1732,7 @@ void AvFormatDecoder::InitVideoCodec(AVStream *stream, AVCodecContext *enc,
QString codecName;
if (codec2)
codecName = codec2->name;
m_parent->SetVideoParams(width, height, m_fps, kScan_Detect, codecName);
m_parent->SetVideoParams(width, height, m_fps, m_current_aspect, kScan_Detect, codecName);
if (LCD *lcd = LCD::Get())
{
LCDVideoFormatSet video_format;
Expand Down Expand Up @@ -2729,12 +2729,12 @@ int AvFormatDecoder::ScanStreams(bool novideo)
tvformat == "pal-m" || tvformat == "atsc")
{
m_fps = 29.97;
m_parent->SetVideoParams(-1, -1, 29.97);
m_parent->SetVideoParams(-1, -1, 29.97, 1.0f);
}
else
{
m_fps = 25.0;
m_parent->SetVideoParams(-1, -1, 25.0);
m_parent->SetVideoParams(-1, -1, 25.0, 1.0f);
}
}

Expand Down Expand Up @@ -3414,7 +3414,7 @@ void AvFormatDecoder::MpegPreProcessPkt(AVStream *stream, AVPacket *pkt)
if (m_private_dec)
m_private_dec->Reset();

m_parent->SetVideoParams(width, height, seqFPS, kScan_Detect);
m_parent->SetVideoParams(width, height, seqFPS, m_current_aspect, kScan_Detect);

m_current_width = width;
m_current_height = height;
Expand Down Expand Up @@ -3524,7 +3524,7 @@ int AvFormatDecoder::H264PreProcessPkt(AVStream *stream, AVPacket *pkt)
if (m_private_dec)
m_private_dec->Reset();

m_parent->SetVideoParams(width, height, seqFPS, kScan_Detect);
m_parent->SetVideoParams(width, height, seqFPS, m_current_aspect, kScan_Detect);

m_current_width = width;
m_current_height = height;
Expand Down
4 changes: 2 additions & 2 deletions mythtv/libs/libmythtv/decoders/nuppeldecoder.cpp
Expand Up @@ -207,7 +207,7 @@ int NuppelDecoder::OpenFile(RingBuffer *rbuffer, bool novideo,

GetPlayer()->SetKeyframeDistance(m_fileheader.keyframedist);
GetPlayer()->SetVideoParams(m_fileheader.width, m_fileheader.height,
m_fileheader.fps);
m_fileheader.fps, m_current_aspect);

m_video_width = m_fileheader.width;
m_video_height = m_fileheader.height;
Expand Down Expand Up @@ -1338,7 +1338,7 @@ bool NuppelDecoder::GetFrame(DecodeType decodetype, bool&)

GetPlayer()->SetKeyframeDistance(m_fileheader.keyframedist);
GetPlayer()->SetVideoParams(m_fileheader.width, m_fileheader.height,
m_fileheader.fps);
m_fileheader.fps, m_current_aspect);
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions mythtv/libs/libmythtv/mythplayer.cpp
Expand Up @@ -765,7 +765,7 @@ void MythPlayer::SetScanType(FrameScanType scan)
m_scan = scan;
}

void MythPlayer::SetVideoParams(int width, int height, double fps,
void MythPlayer::SetVideoParams(int width, int height, double fps, float aspect,
FrameScanType scan, const QString& codecName)
{
bool paramsChanged = false;
Expand All @@ -775,7 +775,7 @@ void MythPlayer::SetVideoParams(int width, int height, double fps,
paramsChanged = true;
video_dim = QSize((width + 15) & ~0xf, (height + 15) & ~0xf);
video_disp_dim = QSize(width, height);
video_aspect = (float)width / height;
video_aspect = aspect > 0.0f ? aspect : static_cast<float>(width) / height;
}

if (!qIsNaN(fps) && fps > 0.0 && fps < 121.0)
Expand Down Expand Up @@ -846,7 +846,7 @@ void MythPlayer::OpenDummy(void)
if (!videoOutput)
{
SetKeyframeDistance(15);
SetVideoParams(720, 576, 25.00);
SetVideoParams(720, 576, 25.00, 1.25f);
}

player_ctx->LockPlayingInfo(__FILE__, __LINE__);
Expand Down
2 changes: 1 addition & 1 deletion mythtv/libs/libmythtv/mythplayer.h
Expand Up @@ -172,7 +172,7 @@ class MTV_PUBLIC MythPlayer
void SetWatchingRecording(bool mode);
void SetWatched(bool forceWatched = false);
void SetKeyframeDistance(int keyframedistance);
void SetVideoParams(int w, int h, double fps,
void SetVideoParams(int w, int h, double fps, float aspect,
FrameScanType scan = kScan_Ignore, const QString& codecName = QString());
void SetFileLength(int total, int frames);
void SetDuration(int duration);
Expand Down

0 comments on commit 46d9414

Please sign in to comment.