From 0b59b35efe79ff29974b57b64011844c5a1836ef Mon Sep 17 00:00:00 2001 From: Anton Fedchin Date: Thu, 7 Apr 2016 17:28:50 +0300 Subject: [PATCH] [VideoPlayer] Disable reading extension stream from input stream if decoder doesn't support it. --- .../DVDCodecs/Video/DVDVideoCodec.h | 5 +++++ .../VideoPlayer/DVDDemuxers/DVDDemuxFFmpeg.cpp | 18 +++++++++--------- .../DVDDemuxers/DemuxStreamSSIF.cpp | 4 +++- .../VideoPlayer/DVDDemuxers/DemuxStreamSSIF.h | 6 +++--- .../DVDInputStreams/DVDInputStream.h | 11 +++++++++++ .../DVDInputStreams/DVDInputStreamBluray.cpp | 9 ++++++++- .../DVDInputStreams/DVDInputStreamBluray.h | 9 ++++++--- xbmc/cores/VideoPlayer/IVideoPlayer.h | 1 + xbmc/cores/VideoPlayer/VideoPlayer.cpp | 4 ++++ xbmc/cores/VideoPlayer/VideoPlayerVideo.h | 1 + 10 files changed, 51 insertions(+), 17 deletions(-) diff --git a/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodec.h b/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodec.h index a2da9de437593..8101b6eeff034 100644 --- a/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodec.h +++ b/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodec.h @@ -311,6 +311,11 @@ class CDVDVideoCodec */ virtual void Reopen() {}; + /** + * Indicates that the decoder supports extention streams. + */ + virtual bool SupportsExtention() { return false; } + protected: CProcessInfo &m_processInfo; }; diff --git a/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxFFmpeg.cpp b/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxFFmpeg.cpp index 616e790714741..7503bc6b47bf3 100644 --- a/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxFFmpeg.cpp +++ b/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxFFmpeg.cpp @@ -504,14 +504,14 @@ bool CDVDDemuxFFmpeg::Open(CDVDInputStream* pInput, bool streaminfo, bool filein UpdateCurrentPTS(); - if (!fileinfo && m_pInput->IsStreamType(DVDSTREAM_TYPE_BLURAY)) + if (!fileinfo) { - CDVDInputStreamBluray *bluRay = static_cast(m_pInput); - if (bluRay->HasMVC()) + CDVDInputStream::IExtentionStream* pExt = dynamic_cast(m_pInput); + if (pExt && pExt->HasExtention()) { SAFE_DELETE(m_pSSIF); m_pSSIF = new CDemuxStreamSSIF(); - m_pSSIF->SetBluRay(bluRay); + m_pSSIF->SetBluRay(pExt); } } // in case of mpegts and we have not seen pat/pmt, defer creation of streams @@ -1475,13 +1475,13 @@ CDemuxStream* CDVDDemuxFFmpeg::AddStream(int streamIdx) pStream->codec->codec_tag = MKTAG('A', 'M', 'V', 'C'); AVStream* mvcStream = nullptr; - if (m_pInput->IsStreamType(DVDSTREAM_TYPE_BLURAY)) + CDVDInputStream::IExtentionStream* pExt = dynamic_cast(m_pInput); + if (pExt) { - CDVDInputStreamBluray *bluRay = static_cast(m_pInput); - if (bluRay->HasMVC()) + if (pExt->HasExtention()) { - st->stereo_mode = bluRay->AreEyesFlipped() ? "block_rl" : "block_lr"; - mvcStream = static_cast(bluRay->GetDemuxMVC())->GetAVStream(); + st->stereo_mode = pExt->AreEyesFlipped() ? "block_rl" : "block_lr"; + mvcStream = static_cast(pExt->GetExtentionDemux())->GetAVStream(); } } else diff --git a/xbmc/cores/VideoPlayer/DVDDemuxers/DemuxStreamSSIF.cpp b/xbmc/cores/VideoPlayer/DVDDemuxers/DemuxStreamSSIF.cpp index 2c7e66f7ee568..7c8719ce40e72 100644 --- a/xbmc/cores/VideoPlayer/DVDDemuxers/DemuxStreamSSIF.cpp +++ b/xbmc/cores/VideoPlayer/DVDDemuxers/DemuxStreamSSIF.cpp @@ -35,6 +35,8 @@ DemuxPacket* CDemuxStreamSSIF::AddPacket(DemuxPacket* &srcPkt) if (srcPkt->iStreamId == m_h264StreamId) { + if (m_bluRay && !m_bluRay->HasExtention()) + return srcPkt; m_H264queue.push(srcPkt); } else if (srcPkt->iStreamId == m_mvcStreamId) @@ -170,7 +172,7 @@ bool CDemuxStreamSSIF::FillMVCQueue(double dtsBase) if (!m_bluRay) return false; - CDVDDemux* demux = m_bluRay->GetDemuxMVC(); + CDVDDemux* demux = m_bluRay->GetExtentionDemux(); DemuxPacket* mvc; while ((m_MVCqueue.size() < MVC_QUEUE_SIZE) && (mvc = demux->Read())) { diff --git a/xbmc/cores/VideoPlayer/DVDDemuxers/DemuxStreamSSIF.h b/xbmc/cores/VideoPlayer/DVDDemuxers/DemuxStreamSSIF.h index 508e9debd3e66..26cd97dddcae2 100644 --- a/xbmc/cores/VideoPlayer/DVDDemuxers/DemuxStreamSSIF.h +++ b/xbmc/cores/VideoPlayer/DVDDemuxers/DemuxStreamSSIF.h @@ -21,7 +21,7 @@ */ #include "DVDDemuxPacket.h" -#include "DVDInputStreams/DVDInputStreamBluray.h" +#include "DVDInputStreams/DVDInputStream.h" #include extern "C" { @@ -41,7 +41,7 @@ class CDemuxStreamSSIF int GetH264StreamId() { return m_h264StreamId; }; int GetMVCStreamId() { return m_mvcStreamId; }; void AddMVCExtPacket(DemuxPacket* &scrPkt); - void SetBluRay(CDVDInputStreamBluray* &bluRay) { m_bluRay = bluRay; }; + void SetBluRay(CDVDInputStream::IExtentionStream* &bluRay) { m_bluRay = bluRay; }; bool IsBluRay() { return m_bluRay != nullptr; }; private: @@ -49,7 +49,7 @@ class CDemuxStreamSSIF DemuxPacket* MergePacket(DemuxPacket* &srcPkt, DemuxPacket* &appendPkt); bool FillMVCQueue(double dtsBase); - CDVDInputStreamBluray* m_bluRay = nullptr; + CDVDInputStream::IExtentionStream* m_bluRay = nullptr; std::queue m_H264queue; std::queue m_MVCqueue; int m_h264StreamId = -1; diff --git a/xbmc/cores/VideoPlayer/DVDInputStreams/DVDInputStream.h b/xbmc/cores/VideoPlayer/DVDInputStreams/DVDInputStream.h index aa204ddd6941b..c79435e405bba 100644 --- a/xbmc/cores/VideoPlayer/DVDInputStreams/DVDInputStream.h +++ b/xbmc/cores/VideoPlayer/DVDInputStreams/DVDInputStream.h @@ -57,6 +57,7 @@ namespace XFILE struct DemuxPacket; class CDemuxStream; +class CDVDDemux; class CDVDInputStream { @@ -131,6 +132,16 @@ class CDVDInputStream virtual void SetVideoResolution(int width, int height) {}; }; + class IExtentionStream + { + public: + virtual ~IExtentionStream() {} + virtual bool HasExtention() = 0; + virtual bool AreEyesFlipped() = 0; + virtual CDVDDemux* GetExtentionDemux() = 0; + virtual void DisableExtention() = 0; + }; + enum ENextStream { NEXTSTREAM_NONE, diff --git a/xbmc/cores/VideoPlayer/DVDInputStreams/DVDInputStreamBluray.cpp b/xbmc/cores/VideoPlayer/DVDInputStreams/DVDInputStreamBluray.cpp index ad2c65ba5b80c..74e8e1fc2da66 100644 --- a/xbmc/cores/VideoPlayer/DVDInputStreams/DVDInputStreamBluray.cpp +++ b/xbmc/cores/VideoPlayer/DVDInputStreams/DVDInputStreamBluray.cpp @@ -617,6 +617,13 @@ void CDVDInputStreamBluray::ProcessEvent() { } } +void CDVDInputStreamBluray::DisableExtention() +{ + CloseMVCDemux(); + m_bMVCDisabled = true; + m_bMVCPlayback = false; +} + int CDVDInputStreamBluray::Read(uint8_t* buf, int buf_size) { int result = 0; @@ -1165,7 +1172,7 @@ bool CDVDInputStreamBluray::ProcessItem(int playitem) m_title = m_dll->bd_get_playlist_info(m_bd, playitem, m_angle); - if (CSettings::GetInstance().GetBool("videoplayer.supportmvc")) + if (CSettings::GetInstance().GetBool("videoplayer.supportmvc") && !m_bMVCDisabled) { MPLS_PL * mpls = m_dll->bd_get_title_mpls(m_bd); if (mpls) diff --git a/xbmc/cores/VideoPlayer/DVDInputStreams/DVDInputStreamBluray.h b/xbmc/cores/VideoPlayer/DVDInputStreams/DVDInputStreamBluray.h index 561fb5cd4f971..f70657c9e31fb 100644 --- a/xbmc/cores/VideoPlayer/DVDInputStreams/DVDInputStreamBluray.h +++ b/xbmc/cores/VideoPlayer/DVDInputStreams/DVDInputStreamBluray.h @@ -46,6 +46,7 @@ class CDVDInputStreamBluray , public CDVDInputStream::IChapter , public CDVDInputStream::IPosTime , public CDVDInputStream::IMenus + , public CDVDInputStream::IExtentionStream { public: CDVDInputStreamBluray(IVideoPlayer* player, const CFileItem& fileitem); @@ -120,9 +121,10 @@ class CDVDInputStreamBluray BLURAY_TITLE_INFO* GetTitleFile(const std::string& name); void ProcessEvent(); - CDVDDemux* GetDemuxMVC() { return m_pMVCDemux; }; - bool HasMVC() { return m_bMVCPlayback; } - bool AreEyesFlipped() { return m_bFlipEyes; } + CDVDDemux* GetExtentionDemux() override { return m_pMVCDemux; }; + bool HasExtention() override { return m_bMVCPlayback; } + bool AreEyesFlipped() override { return m_bFlipEyes; } + void DisableExtention() override; protected: struct SPlane; @@ -157,6 +159,7 @@ class CDVDInputStreamBluray int m_nMVCSubPathIndex = 0; int m_nMVCClip = -1; bool m_bFlipEyes = false; + bool m_bMVCDisabled = false; uint64_t m_clipStartTime = 0; typedef std::shared_ptr SOverlay; diff --git a/xbmc/cores/VideoPlayer/IVideoPlayer.h b/xbmc/cores/VideoPlayer/IVideoPlayer.h index 0b676c9b611fe..6762e733848d1 100644 --- a/xbmc/cores/VideoPlayer/IVideoPlayer.h +++ b/xbmc/cores/VideoPlayer/IVideoPlayer.h @@ -111,6 +111,7 @@ class IDVDStreamPlayerVideo : public IDVDStreamPlayer virtual int GetDecoderBufferSize() { return 0; } virtual int GetDecoderFreeSpace() = 0; virtual bool IsEOS() { return false; }; + virtual bool SupportsExtention() const = 0; }; class CDVDAudioCodec; diff --git a/xbmc/cores/VideoPlayer/VideoPlayer.cpp b/xbmc/cores/VideoPlayer/VideoPlayer.cpp index 71221f9dd3f67..5b8037038bdd1 100644 --- a/xbmc/cores/VideoPlayer/VideoPlayer.cpp +++ b/xbmc/cores/VideoPlayer/VideoPlayer.cpp @@ -3891,6 +3891,10 @@ bool CVideoPlayer::OpenVideoStream(CDVDStreamInfo& hint, bool reset) if (!player->OpenStream(hint)) return false; + CDVDInputStream::IExtentionStream* pExt = dynamic_cast(m_pInputStream); + if (pExt && !static_cast(player)->SupportsExtention()) + pExt->DisableExtention(); + s.stereo_mode = static_cast(player)->GetStereoMode(); if (s.stereo_mode == "mono") s.stereo_mode = ""; diff --git a/xbmc/cores/VideoPlayer/VideoPlayerVideo.h b/xbmc/cores/VideoPlayer/VideoPlayerVideo.h index 0d4100e58e9db..69570153f0810 100644 --- a/xbmc/cores/VideoPlayer/VideoPlayerVideo.h +++ b/xbmc/cores/VideoPlayer/VideoPlayerVideo.h @@ -91,6 +91,7 @@ class CVideoPlayerVideo : public CThread, public IDVDStreamPlayerVideo int GetVideoBitrate(); std::string GetStereoMode(); void SetSpeed(int iSpeed); + bool SupportsExtention() const override { return m_pVideoCodec && m_pVideoCodec->SupportsExtention(); } // classes CDVDOverlayContainer* m_pOverlayContainer;