diff options
author | Hendrik Leppkes <h.leppkes@gmail.com> | 2012-10-13 10:49:56 +0400 |
---|---|---|
committer | Hendrik Leppkes <h.leppkes@gmail.com> | 2012-10-13 10:51:18 +0400 |
commit | 6db5e779adce122f31793b737620a1c99613213b (patch) | |
tree | bf3b7041ca3e7607be6cc6b33cdc3586385160aa /decoder/LAVVideo | |
parent | 264e0ba8a66e25cce2a6387afb626f7a4636d0c9 (diff) |
Factor individual setting getters into a central flag function
Diffstat (limited to 'decoder/LAVVideo')
-rw-r--r-- | decoder/LAVVideo/DecodeThread.cpp | 4 | ||||
-rw-r--r-- | decoder/LAVVideo/DecodeThread.h | 4 | ||||
-rw-r--r-- | decoder/LAVVideo/LAVVideo.cpp | 43 | ||||
-rw-r--r-- | decoder/LAVVideo/LAVVideo.h | 10 | ||||
-rw-r--r-- | decoder/LAVVideo/decoders/ILAVDecoder.h | 25 | ||||
-rw-r--r-- | decoder/LAVVideo/decoders/avcodec.cpp | 11 | ||||
-rw-r--r-- | decoder/LAVVideo/decoders/cuvid.cpp | 4 | ||||
-rw-r--r-- | decoder/LAVVideo/decoders/quicksync.cpp | 6 | ||||
-rw-r--r-- | decoder/LAVVideo/decoders/wmv9.cpp | 2 |
9 files changed, 49 insertions, 60 deletions
diff --git a/decoder/LAVVideo/DecodeThread.cpp b/decoder/LAVVideo/DecodeThread.cpp index 17dc8a89..865af558 100644 --- a/decoder/LAVVideo/DecodeThread.cpp +++ b/decoder/LAVVideo/DecodeThread.cpp @@ -496,9 +496,7 @@ STDMETHODIMP CDecodeThread::AllocateFrame(LAVFrame **ppFrame) { return m_pLAVVid STDMETHODIMP CDecodeThread::ReleaseFrame(LAVFrame **ppFrame) { return m_pLAVVideo->ReleaseFrame(ppFrame); } STDMETHODIMP_(LPWSTR) CDecodeThread::GetFileExtension() { return m_pLAVVideo->GetFileExtension(); } STDMETHODIMP_(BOOL) CDecodeThread::FilterInGraph(PIN_DIRECTION dir, const GUID &clsid) { return m_pLAVVideo->FilterInGraph(dir, clsid); } -STDMETHODIMP_(BOOL) CDecodeThread::VC1IsDTS() { return m_pLAVVideo->VC1IsDTS(); } -STDMETHODIMP_(BOOL) CDecodeThread::H264IsAVI() { return m_pLAVVideo->H264IsAVI(); } -STDMETHODIMP_(BOOL) CDecodeThread::IsLAVSplitter() { return m_pLAVVideo->IsLAVSplitter(); } +STDMETHODIMP_(DWORD) CDecodeThread::GetDecodeFlags() { return m_pLAVVideo->GetDecodeFlags(); } STDMETHODIMP_(BOOL) CDecodeThread::IsVistaOrNewer() { return m_pLAVVideo->IsVistaOrNewer(); } STDMETHODIMP_(CMediaType&) CDecodeThread::GetInputMediaType() { return m_pLAVVideo->GetInputMediaType(); } STDMETHODIMP CDecodeThread::GetLAVPinInfo(LAVPinInfo &info) { return m_pLAVVideo->GetLAVPinInfo(info); } diff --git a/decoder/LAVVideo/DecodeThread.h b/decoder/LAVVideo/DecodeThread.h index 38f0df2b..b7071752 100644 --- a/decoder/LAVVideo/DecodeThread.h +++ b/decoder/LAVVideo/DecodeThread.h @@ -57,9 +57,7 @@ public: STDMETHODIMP Deliver(LAVFrame *pFrame); STDMETHODIMP_(LPWSTR) GetFileExtension(); STDMETHODIMP_(BOOL) FilterInGraph(PIN_DIRECTION dir, const GUID &clsid); - STDMETHODIMP_(BOOL) VC1IsDTS(); - STDMETHODIMP_(BOOL) H264IsAVI(); - STDMETHODIMP_(BOOL) IsLAVSplitter(); + STDMETHODIMP_(DWORD) GetDecodeFlags(); STDMETHODIMP_(BOOL) IsVistaOrNewer(); STDMETHODIMP_(CMediaType&) GetInputMediaType(); STDMETHODIMP GetLAVPinInfo(LAVPinInfo &info); diff --git a/decoder/LAVVideo/LAVVideo.cpp b/decoder/LAVVideo/LAVVideo.cpp index a40f6bc7..a2a92fe5 100644 --- a/decoder/LAVVideo/LAVVideo.cpp +++ b/decoder/LAVVideo/LAVVideo.cpp @@ -45,7 +45,7 @@ CLAVVideo::CLAVVideo(LPUNKNOWN pUnk, HRESULT* phr) , m_bForceInputAR(FALSE) , m_bSendMediaType(FALSE) , m_bDXVAExtFormatSupport(-1) - , m_bVC1IsDTS(FALSE), m_bH264IsAVI(FALSE), m_bLAVSplitter(FALSE) + , m_dwDecodeFlags(0) , m_pFilterGraph(NULL) , m_pFilterBufferSrc(NULL) , m_pFilterBufferSink(NULL) @@ -57,11 +57,9 @@ CLAVVideo::CLAVVideo(LPUNKNOWN pUnk, HRESULT* phr) , m_bMTFiltering(FALSE) , m_bFlushing(FALSE) , m_evFilterInput(TRUE) - , m_bStreamARBlacklisted(FALSE) , m_pSubtitleInput(NULL) , m_SubtitleConsumer(NULL) , m_pLastSequenceFrame(NULL) - , m_bDVDPlayback(NULL) { *phr = S_OK; m_pInput = new CDeCSSTransformInputPin(TEXT("CDeCSSTransformInputPin"), this, phr, L"Input"); @@ -555,7 +553,7 @@ HRESULT CLAVVideo::CreateDecoder(const CMediaType *pmt) m_LAVPinInfoValid = FALSE; } - m_bStreamARBlacklisted = FALSE; + m_dwDecodeFlags = 0; LPWSTR pszExtension = GetFileExtension(); if (pszExtension) { @@ -563,29 +561,38 @@ HRESULT CLAVVideo::CreateDecoder(const CMediaType *pmt) for (int i = 0; i < countof(stream_ar_blacklist); i++) { if (_wcsicmp(stream_ar_blacklist[i], pszExtension) == 0) { - m_bStreamARBlacklisted = TRUE; + m_dwDecodeFlags |= LAV_VIDEO_DEC_FLAG_STREAMAR_BLACKLIST; break; } } - if (m_bStreamARBlacklisted) { + if (m_dwDecodeFlags & LAV_VIDEO_DEC_FLAG_STREAMAR_BLACKLIST) { // MPC-HC MP4 Splitter fails at Container AR if (FilterInGraph(PINDIR_INPUT, CLSID_MPCHCMP4Splitter) || FilterInGraph(PINDIR_INPUT, CLSID_MPCHCMP4SplitterSource)) { - m_bStreamARBlacklisted = FALSE; + m_dwDecodeFlags &= ~LAV_VIDEO_DEC_FLAG_STREAMAR_BLACKLIST; } } } // Certain filters send VC-1 in PTS instead of DTS, so list them here // Usually, these are MPEG systems. - m_bVC1IsDTS = (codec == AV_CODEC_ID_VC1) && - !(FilterInGraph(PINDIR_INPUT, CLSID_MPCHCMPEGSplitter) - || FilterInGraph(PINDIR_INPUT, CLSID_MPCHCMPEGSplitterSource) - || FilterInGraph(PINDIR_INPUT, CLSID_MPBDReader) - || FilterInGraph(PINDIR_INPUT, CLSID_SageTVMpegDeMux)); - - m_bH264IsAVI = (codec == AV_CODEC_ID_H264 && ((m_LAVPinInfoValid && (m_LAVPinInfo.flags & LAV_STREAM_FLAG_H264_DTS)) || (!m_LAVPinInfoValid && pszExtension && _wcsicmp(pszExtension, L".avi") == 0))); - m_bLAVSplitter = FilterInGraph(PINDIR_INPUT, CLSID_LAVSplitterSource) || FilterInGraph(PINDIR_INPUT, CLSID_LAVSplitter); - m_bDVDPlayback = (pmt->majortype == MEDIATYPE_DVD_ENCRYPTED_PACK || pmt->majortype == MEDIATYPE_MPEG2_PACK || pmt->majortype == MEDIATYPE_MPEG2_PES); + BOOL bVC1DTS = (codec == AV_CODEC_ID_VC1) && + !(FilterInGraph(PINDIR_INPUT, CLSID_MPCHCMPEGSplitter) + || FilterInGraph(PINDIR_INPUT, CLSID_MPCHCMPEGSplitterSource) + || FilterInGraph(PINDIR_INPUT, CLSID_MPBDReader) + || FilterInGraph(PINDIR_INPUT, CLSID_SageTVMpegDeMux)); + + BOOL bH264IsAVI = (codec == AV_CODEC_ID_H264 && ((m_LAVPinInfoValid && (m_LAVPinInfo.flags & LAV_STREAM_FLAG_H264_DTS)) || (!m_LAVPinInfoValid && pszExtension && _wcsicmp(pszExtension, L".avi") == 0))); + BOOL bLAVSplitter = FilterInGraph(PINDIR_INPUT, CLSID_LAVSplitterSource) || FilterInGraph(PINDIR_INPUT, CLSID_LAVSplitter); + BOOL bDVDPlayback = (pmt->majortype == MEDIATYPE_DVD_ENCRYPTED_PACK || pmt->majortype == MEDIATYPE_MPEG2_PACK || pmt->majortype == MEDIATYPE_MPEG2_PES); + + if (bVC1DTS) + m_dwDecodeFlags |= LAV_VIDEO_DEC_FLAG_VC1_DTS; + if (bH264IsAVI) + m_dwDecodeFlags |= LAV_VIDEO_DEC_FLAG_H264_AVI; + if (bLAVSplitter) + m_dwDecodeFlags |= LAV_VIDEO_DEC_FLAG_LAVSPLITTER; + if (bDVDPlayback) + m_dwDecodeFlags |= LAV_VIDEO_DEC_FLAG_DVD; SAFE_CO_FREE(pszExtension); @@ -654,7 +661,7 @@ HRESULT CLAVVideo::EndFlush() CAutoLock cAutoLock(&m_csReceive); ReleaseFrame(&m_pLastSequenceFrame); - if (m_bDVDPlayback) { + if (m_dwDecodeFlags & LAV_VIDEO_DEC_FLAG_DVD) { PerformFlush(); } @@ -836,7 +843,7 @@ HRESULT CLAVVideo::ReconnectOutput(int width, int height, AVRational ar, DXVA2_E videoFormatTypeHandler(m_pInput->CurrentMediaType().Format(), m_pInput->CurrentMediaType().FormatType(), NULL, NULL, &dwARX, &dwARY); int num = ar.num, den = ar.den; - BOOL bStreamAR = (m_settings.StreamAR == 1) || (m_settings.StreamAR == 2 && (!m_bStreamARBlacklisted || !(dwARX && dwARY))); + BOOL bStreamAR = (m_settings.StreamAR == 1) || (m_settings.StreamAR == 2 && (!(m_dwDecodeFlags & LAV_VIDEO_DEC_FLAG_STREAMAR_BLACKLIST) || !(dwARX && dwARY))); if (!bStreamAR || num == 0 || den == 0) { if (m_bForceInputAR && dwARX && dwARY) { num = dwARX; diff --git a/decoder/LAVVideo/LAVVideo.h b/decoder/LAVVideo/LAVVideo.h index 962f6186..032b38e1 100644 --- a/decoder/LAVVideo/LAVVideo.h +++ b/decoder/LAVVideo/LAVVideo.h @@ -139,9 +139,7 @@ public: STDMETHODIMP Deliver(LAVFrame *pFrame); STDMETHODIMP_(LPWSTR) GetFileExtension(); STDMETHODIMP_(BOOL) FilterInGraph(PIN_DIRECTION dir, const GUID &clsid) { if (dir == PINDIR_INPUT) return FilterInGraphSafe(m_pInput, clsid); else return FilterInGraphSafe(m_pOutput, clsid); } - STDMETHODIMP_(BOOL) VC1IsDTS() { return m_bVC1IsDTS; } - STDMETHODIMP_(BOOL) H264IsAVI() { return m_bH264IsAVI; } - STDMETHODIMP_(BOOL) IsLAVSplitter() { return m_bLAVSplitter; } + STDMETHODIMP_(DWORD) GetDecodeFlags() { return m_dwDecodeFlags; } STDMETHODIMP_(BOOL) IsVistaOrNewer(); STDMETHODIMP_(CMediaType&) GetInputMediaType() { return m_pInput->CurrentMediaType(); } STDMETHODIMP GetLAVPinInfo(LAVPinInfo &info) { if (m_LAVPinInfoValid) { info = m_LAVPinInfo; return S_OK; } return E_FAIL; } @@ -206,11 +204,7 @@ private: DWORD m_bDXVAExtFormatSupport; DWORD m_bMadVR; - BOOL m_bVC1IsDTS; - BOOL m_bH264IsAVI; - BOOL m_bLAVSplitter; - BOOL m_bStreamARBlacklisted; - BOOL m_bDVDPlayback; + DWORD m_dwDecodeFlags; AVFilterGraph *m_pFilterGraph; AVFilterContext *m_pFilterBufferSrc; diff --git a/decoder/LAVVideo/decoders/ILAVDecoder.h b/decoder/LAVVideo/decoders/ILAVDecoder.h index 4286d3a1..21af5b54 100644 --- a/decoder/LAVVideo/decoders/ILAVDecoder.h +++ b/decoder/LAVVideo/decoders/ILAVDecoder.h @@ -205,25 +205,16 @@ interface ILAVVideoCallback STDMETHOD_(BOOL, FilterInGraph)(PIN_DIRECTION dir, const GUID &clsid) PURE; /** - * Check wether VC-1 timestamps are DTS instead of PTS + * Get Decode Flags * - * @result TRUE if DTS, FALSE if PTS + * @return flags */ - STDMETHOD_(BOOL, VC1IsDTS)() PURE; - - /** - * Check wether H264 is from a AVI file (or similar) - * - * @result TRUE/FALSE - */ - STDMETHOD_(BOOL,H264IsAVI)() PURE; - - /** - * Check wether LAV Splitter is the source filter - * - * @return TRUE/FALSE - */ - STDMETHOD_(BOOL, IsLAVSplitter)() PURE; + STDMETHOD_(DWORD, GetDecodeFlags)() PURE; +#define LAV_VIDEO_DEC_FLAG_STREAMAR_BLACKLIST 0x00000001 +#define LAV_VIDEO_DEC_FLAG_VC1_DTS 0x00000002 +#define LAV_VIDEO_DEC_FLAG_H264_AVI 0x00000004 +#define LAV_VIDEO_DEC_FLAG_LAVSPLITTER 0x00000008 +#define LAV_VIDEO_DEC_FLAG_DVD 0x00000010 /** * Check wether we're running on Vista or newer diff --git a/decoder/LAVVideo/decoders/avcodec.cpp b/decoder/LAVVideo/decoders/avcodec.cpp index a79b41f2..c83d8627 100644 --- a/decoder/LAVVideo/decoders/avcodec.cpp +++ b/decoder/LAVVideo/decoders/avcodec.cpp @@ -475,15 +475,16 @@ STDMETHODIMP CDecAvcodec::InitDecoder(AVCodecID codec, const CMediaType *pmt) LAVPinInfo lavPinInfo = {0}; BOOL bLAVInfoValid = SUCCEEDED(m_pCallback->GetLAVPinInfo(lavPinInfo)); - m_bInputPadded = m_pCallback->IsLAVSplitter(); + DWORD dwDecFlags = m_pCallback->GetDecodeFlags(); + m_bInputPadded = dwDecFlags & LAV_VIDEO_DEC_FLAG_LAVSPLITTER; // Setup codec-specific timing logic - BOOL bVC1IsPTS = (codec == AV_CODEC_ID_VC1 && !m_pCallback->VC1IsDTS()); + BOOL bVC1IsPTS = (codec == AV_CODEC_ID_VC1 && !(dwDecFlags & LAV_VIDEO_DEC_FLAG_VC1_DTS)); // Use ffmpegs logic to reorder timestamps // This is required for H264 content (except AVI), and generally all codecs that use frame threading // VC-1 is also a special case. Its required for splitters that deliver PTS timestamps (see bVC1IsPTS above) - m_bFFReordering = ( codec == AV_CODEC_ID_H264 && !m_pCallback->H264IsAVI()) + m_bFFReordering = ( codec == AV_CODEC_ID_H264 && !(dwDecFlags & LAV_VIDEO_DEC_FLAG_H264_AVI)) || codec == AV_CODEC_ID_VP8 || codec == AV_CODEC_ID_VP3 || codec == AV_CODEC_ID_THEORA @@ -502,7 +503,7 @@ STDMETHODIMP CDecAvcodec::InitDecoder(AVCodecID codec, const CMediaType *pmt) // Real Video content has some odd timestamps // LAV Splitter does them allright with RV30/RV40, everything else screws them up - m_bRVDropBFrameTimings = (codec == AV_CODEC_ID_RV10 || codec == AV_CODEC_ID_RV20 || ((codec == AV_CODEC_ID_RV30 || codec == AV_CODEC_ID_RV40) && (!m_pCallback->IsLAVSplitter() || (bLAVInfoValid && (lavPinInfo.flags & LAV_STREAM_FLAG_RV34_MKV))))); + m_bRVDropBFrameTimings = (codec == AV_CODEC_ID_RV10 || codec == AV_CODEC_ID_RV20 || ((codec == AV_CODEC_ID_RV30 || codec == AV_CODEC_ID_RV40) && (!(dwDecFlags & LAV_VIDEO_DEC_FLAG_LAVSPLITTER) || (bLAVInfoValid && (lavPinInfo.flags & LAV_STREAM_FLAG_RV34_MKV))))); // Enable B-Frame delay handling m_bBFrameDelay = !m_bFFReordering && !m_bRVDropBFrameTimings; @@ -519,7 +520,7 @@ STDMETHODIMP CDecAvcodec::InitDecoder(AVCodecID codec, const CMediaType *pmt) m_bNoBufferConsumption = codec == AV_CODEC_ID_MJPEGB || codec == AV_CODEC_ID_LOCO; - m_bHasPalette = m_pAVCtx->bits_per_coded_sample <= 8 && m_pAVCtx->extradata_size && !m_pCallback->IsLAVSplitter() + m_bHasPalette = m_pAVCtx->bits_per_coded_sample <= 8 && m_pAVCtx->extradata_size && !(dwDecFlags & LAV_VIDEO_DEC_FLAG_LAVSPLITTER) && (codec == AV_CODEC_ID_MSVIDEO1 || codec == AV_CODEC_ID_MSRLE || codec == AV_CODEC_ID_CINEPAK diff --git a/decoder/LAVVideo/decoders/cuvid.cpp b/decoder/LAVVideo/decoders/cuvid.cpp index 4b2b9064..0fdde0dd 100644 --- a/decoder/LAVVideo/decoders/cuvid.cpp +++ b/decoder/LAVVideo/decoders/cuvid.cpp @@ -582,9 +582,9 @@ STDMETHODIMP CDecCuvid::InitDecoder(AVCodecID codec, const CMediaType *pmt) return E_FAIL; } - m_bUseTimestampQueue = (cudaCodec == cudaVideoCodec_H264 && m_pCallback->H264IsAVI()) + m_bUseTimestampQueue = (cudaCodec == cudaVideoCodec_H264 && m_pCallback->GetDecodeFlags() & LAV_VIDEO_DEC_FLAG_H264_AVI) || (cudaCodec == cudaVideoCodec_MPEG4 && pmt->formattype != FORMAT_MPEG2Video) - || (cudaCodec == cudaVideoCodec_VC1 && m_pCallback->VC1IsDTS()); + || (cudaCodec == cudaVideoCodec_VC1 && m_pCallback->GetDecodeFlags() & LAV_VIDEO_DEC_FLAG_VC1_DTS); m_bWaitForKeyframe = m_bUseTimestampQueue; m_bInterlaced = TRUE; m_bFormatIncompatible = FALSE; diff --git a/decoder/LAVVideo/decoders/quicksync.cpp b/decoder/LAVVideo/decoders/quicksync.cpp index 04261931..549f625c 100644 --- a/decoder/LAVVideo/decoders/quicksync.cpp +++ b/decoder/LAVVideo/decoders/quicksync.cpp @@ -272,8 +272,8 @@ STDMETHODIMP CDecQuickSync::InitDecoder(AVCodecID codec, const CMediaType *pmt) m_bNeedSequenceCheck = FALSE; m_bInterlaced = TRUE; - m_bUseTimestampQueue = (codec == AV_CODEC_ID_H264 && m_pCallback->H264IsAVI()) - || (codec == AV_CODEC_ID_VC1 && m_pCallback->VC1IsDTS()); + m_bUseTimestampQueue = (codec == AV_CODEC_ID_H264 && m_pCallback->GetDecodeFlags() & LAV_VIDEO_DEC_FLAG_H264_AVI) + || (codec == AV_CODEC_ID_VC1 && m_pCallback->GetDecodeFlags() & LAV_VIDEO_DEC_FLAG_VC1_DTS); int ref_frames = 0; @@ -309,7 +309,7 @@ STDMETHODIMP CDecQuickSync::InitDecoder(AVCodecID codec, const CMediaType *pmt) // Timestamp correction is only used for VC-1 codecs which send PTS // because this is not handled properly by the API (it expects DTS) - qsConfig.bTimeStampCorrection = (codec == AV_CODEC_ID_VC1 && !m_pCallback->VC1IsDTS()); + qsConfig.bTimeStampCorrection = (codec == AV_CODEC_ID_VC1 && !(m_pCallback->GetDecodeFlags() & LAV_VIDEO_DEC_FLAG_VC1_DTS)); // Configure number of buffers (dependant on ref_frames) // MPEG2 and VC1 always use "low latency" mode diff --git a/decoder/LAVVideo/decoders/wmv9.cpp b/decoder/LAVVideo/decoders/wmv9.cpp index 9e368021..1150393f 100644 --- a/decoder/LAVVideo/decoders/wmv9.cpp +++ b/decoder/LAVVideo/decoders/wmv9.cpp @@ -377,7 +377,7 @@ STDMETHODIMP CDecWMV9::InitDecoder(AVCodecID codec, const CMediaType *pmt) } } - m_bManualReorder = (codec == AV_CODEC_ID_VC1) && !m_pCallback->VC1IsDTS(); + m_bManualReorder = (codec == AV_CODEC_ID_VC1) && !(m_pCallback->GetDecodeFlags() & LAV_VIDEO_DEC_FLAG_VC1_DTS); return S_OK; } |