diff options
author | Hendrik Leppkes <h.leppkes@gmail.com> | 2012-12-15 16:27:33 +0400 |
---|---|---|
committer | Hendrik Leppkes <h.leppkes@gmail.com> | 2012-12-15 16:30:54 +0400 |
commit | 731e72e9f4b72da9d1dabfe118482f52e8b4e536 (patch) | |
tree | f09e718f440c5916b5a5c02af79dd3d24bf859d2 | |
parent | db95ed68e758a292e7d501b215365f5a83a9ac0d (diff) |
Make DVD Menu interaction between the video decoder and the subtitle decoder more direct.
-rw-r--r-- | decoder/LAVVideo/LAVVideo.cpp | 50 | ||||
-rw-r--r-- | decoder/LAVVideo/LAVVideo.h | 8 | ||||
-rw-r--r-- | decoder/LAVVideo/subtitles/LAVSubtitleConsumer.cpp | 34 | ||||
-rw-r--r-- | decoder/LAVVideo/subtitles/LAVSubtitleConsumer.h | 9 | ||||
-rw-r--r-- | decoder/LAVVideo/subtitles/LAVSubtitleProvider.cpp | 13 | ||||
-rw-r--r-- | decoder/LAVVideo/subtitles/LAVSubtitleProvider.h | 5 | ||||
-rw-r--r-- | decoder/LAVVideo/subtitles/LAVVideoSubtitleInputPin.cpp | 6 | ||||
-rw-r--r-- | decoder/LAVVideo/subtitles/LAVVideoSubtitleInputPin.h | 5 |
8 files changed, 78 insertions, 52 deletions
diff --git a/decoder/LAVVideo/LAVVideo.cpp b/decoder/LAVVideo/LAVVideo.cpp index 524b47cd..fccb0881 100644 --- a/decoder/LAVVideo/LAVVideo.cpp +++ b/decoder/LAVVideo/LAVVideo.cpp @@ -38,6 +38,19 @@ #include <evr.h> #include <d3d9.h> +class CLAVControlThread : public CAMThread +{ +public: + CLAVControlThread(CLAVVideo *m_pLAVVideo); + ~CLAVControlThread(); + +protected: + DWORD ThreadProc(); + +private: + CLAVVideo *m_pLAVVideo; +}; + #pragma warning(disable: 4355) CLAVVideo::CLAVVideo(LPUNKNOWN pUnk, HRESULT* phr) @@ -66,6 +79,7 @@ CLAVVideo::CLAVVideo(LPUNKNOWN pUnk, HRESULT* phr) , m_SubtitleConsumer(NULL) , m_pLastSequenceFrame(NULL) , m_bInDVDMenu(FALSE) + , m_ControlThread(NULL) { *phr = S_OK; m_pInput = new CVideoInputPin(TEXT("CVideoInputPin"), this, phr, L"Input"); @@ -84,6 +98,8 @@ CLAVVideo::CLAVVideo(LPUNKNOWN pUnk, HRESULT* phr) m_PixFmtConverter.SetSettings(this); + m_ControlThread = new CLAVControlThread(this); + #ifdef DEBUG DbgSetModuleLevel (LOG_TRACE, DWORD_MAX); DbgSetModuleLevel (LOG_ERROR, DWORD_MAX); @@ -96,6 +112,7 @@ CLAVVideo::CLAVVideo(LPUNKNOWN pUnk, HRESULT* phr) CLAVVideo::~CLAVVideo() { + SAFE_DELETE(m_ControlThread); CloseMTFilterThread(); ReleaseLastSequenceFrame(); @@ -1957,3 +1974,36 @@ STDMETHODIMP_(DWORD) CLAVVideo::GetHWAccelResolutionFlags() { return m_settings.HWAccelResFlags; } + + +CLAVControlThread::CLAVControlThread(CLAVVideo *pLAVVideo) + : CAMThread() + , m_pLAVVideo(pLAVVideo) +{ + Create(); +} + +CLAVControlThread::~CLAVControlThread() +{ + CallWorker(CLAVVideo::CNTRL_EXIT); + Close(); +} + +DWORD CLAVControlThread::ThreadProc() +{ + SetThreadName(-1, "LAV Control Thread"); + DWORD cmd; + while(1) { + cmd = GetRequest(); + switch(cmd) { + case CLAVVideo::CNTRL_EXIT: + Reply(S_OK); + return 0; + case CLAVVideo::CNTRL_REDRAW: + Reply(S_OK); + m_pLAVVideo->RedrawStillImage(); + break; + } + } + return 1; +} diff --git a/decoder/LAVVideo/LAVVideo.h b/decoder/LAVVideo/LAVVideo.h index cf3419c6..55c8f3b2 100644 --- a/decoder/LAVVideo/LAVVideo.h +++ b/decoder/LAVVideo/LAVVideo.h @@ -195,12 +195,20 @@ private: HRESULT RedrawStillImage(); HRESULT SetInDVDMenu(bool menu) { m_bInDVDMenu = menu; return S_OK; } + enum {CNTRL_EXIT, CNTRL_REDRAW}; + HRESULT ControlCmd(DWORD cmd) { + return m_ControlThread->CallWorker(cmd); + } + private: friend class CVideoOutputPin; friend class CDecodeThread; + friend class CLAVControlThread; + friend class CLAVSubtitleProvider; friend class CLAVSubtitleConsumer; CDecodeThread m_Decoder; + CAMThread *m_ControlThread; REFERENCE_TIME m_rtPrevStart; REFERENCE_TIME m_rtPrevStop; diff --git a/decoder/LAVVideo/subtitles/LAVSubtitleConsumer.cpp b/decoder/LAVVideo/subtitles/LAVSubtitleConsumer.cpp index 09603aac..15799c0a 100644 --- a/decoder/LAVVideo/subtitles/LAVSubtitleConsumer.cpp +++ b/decoder/LAVVideo/subtitles/LAVSubtitleConsumer.cpp @@ -48,15 +48,10 @@ CLAVSubtitleConsumer::CLAVSubtitleConsumer(CLAVVideo *pLAVVideo) context.name = TEXT(LAV_VIDEO); context.version = TEXT(LAV_VERSION_STR); m_evFrame.Reset(); - - CAMThread::Create(); } CLAVSubtitleConsumer::~CLAVSubtitleConsumer(void) { - CAMThread::CallWorker(CMD_EXIT); - CAMThread::Close(); - if (m_pProvider) { m_pProvider->Disconnect(); } @@ -407,32 +402,3 @@ STDMETHODIMP CLAVSubtitleConsumer::ProcessSubtitleBitmap(LAVPixelFormat pixFmt, return S_OK; } - -STDMETHODIMP CLAVSubtitleConsumer::OnSubOptionSet(LPCSTR field) -{ - if (strcmp(field, "redraw") == 0) { - CAMThread::CallWorker(CMD_REDRAW); - } else if (strcmp(field, "menu") == 0) { - m_pLAVVideo->SetInDVDMenu(context.menu); - } - - return S_OK; -} - -DWORD CLAVSubtitleConsumer::ThreadProc() -{ - DWORD cmd; - while(1) { - cmd = GetRequest(); - switch(cmd) { - case CMD_EXIT: - Reply(S_OK); - return 0; - case CMD_REDRAW: - Reply(S_OK); - m_pLAVVideo->RedrawStillImage(); - break; - } - } - return 1; -} diff --git a/decoder/LAVVideo/subtitles/LAVSubtitleConsumer.h b/decoder/LAVVideo/subtitles/LAVSubtitleConsumer.h index cc64b855..7c5982f1 100644 --- a/decoder/LAVVideo/subtitles/LAVSubtitleConsumer.h +++ b/decoder/LAVVideo/subtitles/LAVSubtitleConsumer.h @@ -43,7 +43,7 @@ typedef struct LAVSubtitleConsumerContext { class CLAVVideo; -class CLAVSubtitleConsumer : public ISubRenderConsumer, public CSubRenderOptionsImpl, public CUnknown, protected CAMThread +class CLAVSubtitleConsumer : public ISubRenderConsumer, public CSubRenderOptionsImpl, public CUnknown { public: CLAVSubtitleConsumer(CLAVVideo *pLAVVideo); @@ -57,9 +57,6 @@ public: STDMETHODIMP Disconnect(void); STDMETHODIMP DeliverFrame(REFERENCE_TIME start, REFERENCE_TIME stop, ISubRenderFrame *subtitleFrame); - // ISubRenderOptions - STDMETHODIMP OnSubOptionSet(LPCSTR field); - // LAV Internal methods STDMETHODIMP RequestFrame(REFERENCE_TIME rtStart, REFERENCE_TIME rtStop); STDMETHODIMP ProcessFrame(LAVFrame *pFrame); @@ -69,10 +66,6 @@ public: BOOL HasProvider() const { return m_pProvider != NULL; } void SetVideoSize(LONG w, LONG h) { context.originalVideoSize.cx = w; context.originalVideoSize.cy = h; } - -protected: - DWORD ThreadProc(); - enum {CMD_EXIT, CMD_REDRAW}; private: STDMETHODIMP ProcessSubtitleBitmap(LAVPixelFormat pixFmt, int bpp, RECT videoRect, BYTE *videoData[4], int videoStride[4], RECT subRect, POINT subPosition, SIZE subSize, const uint8_t *rgbData, int pitch); diff --git a/decoder/LAVVideo/subtitles/LAVSubtitleProvider.cpp b/decoder/LAVVideo/subtitles/LAVSubtitleProvider.cpp index 7edea57d..f7ae24e4 100644 --- a/decoder/LAVVideo/subtitles/LAVSubtitleProvider.cpp +++ b/decoder/LAVVideo/subtitles/LAVSubtitleProvider.cpp @@ -23,6 +23,8 @@ #include "moreuuids.h" #include "libavutil/colorspace.h" +#include "LAVVideo.h" + #define FAST_DIV255(x) ((((x) + 128) * 257) >> 16) #define OFFSET(x) offsetof(LAVSubtitleProviderContext, x) @@ -33,9 +35,10 @@ static const SubRenderOption options[] = { { 0 } }; -CLAVSubtitleProvider::CLAVSubtitleProvider(ISubRenderConsumer *pConsumer) +CLAVSubtitleProvider::CLAVSubtitleProvider(CLAVVideo *pLAVVideo, ISubRenderConsumer *pConsumer) : CSubRenderOptionsImpl(::options, &context) , CUnknown(L"CLAVSubtitleProvider", NULL) + , m_pLAVVideo(pLAVVideo) , m_pConsumer(pConsumer) , m_pAVCodec(NULL) , m_pAVCtx(NULL) @@ -196,8 +199,7 @@ STDMETHODIMP CLAVSubtitleProvider::Flush() ClearSubtitleRects(); SAFE_DELETE(m_pHLI); - if (m_pConsumer) - m_pConsumer->SetBool("menu", false); + m_pLAVVideo->SetInDVDMenu(false); return S_OK; } @@ -324,8 +326,7 @@ void CLAVSubtitleProvider::ProcessSubtitleRect(AVSubtitle *sub, REFERENCE_TIME r if (m_pAVCtx->codec_id == AV_CODEC_ID_DVD_SUBTITLE) { if (rtStart == AV_NOPTS_VALUE && sub->rects[0]->flags & AV_SUBTITLE_FLAG_FORCED) { ClearSubtitleRects(); - if (m_pConsumer) - m_pConsumer->SetBool("menu", true); + m_pLAVVideo->SetInDVDMenu(true); } if (rtStart != AV_NOPTS_VALUE) { CAutoLock lock(this); @@ -503,7 +504,7 @@ STDMETHODIMP CLAVSubtitleProvider::SetDVDHLI(struct _AM_PROPERTY_SPHLI *pHLI) } if (redraw) - m_pConsumer->SetBool("redraw", true); + m_pLAVVideo->ControlCmd(CLAVVideo::CNTRL_REDRAW); return S_OK; } diff --git a/decoder/LAVVideo/subtitles/LAVSubtitleProvider.h b/decoder/LAVVideo/subtitles/LAVSubtitleProvider.h index b6587e32..587096ea 100644 --- a/decoder/LAVVideo/subtitles/LAVSubtitleProvider.h +++ b/decoder/LAVVideo/subtitles/LAVSubtitleProvider.h @@ -22,6 +22,8 @@ #include "SubRenderOptionsImpl.h" #include "LAVSubtitleFrame.h" +class CLAVVideo; + typedef struct LAVSubtitleProviderContext { LPWSTR name; ///< name of the Provider LPWSTR version; ///< Version of the Provider @@ -35,7 +37,7 @@ struct _AM_PROPERTY_SPHLI; class CLAVSubtitleProvider : public ISubRenderProvider, public CSubRenderOptionsImpl, public CUnknown, private CCritSec { public: - CLAVSubtitleProvider(ISubRenderConsumer *pConsumer); + CLAVSubtitleProvider(CLAVVideo *pLAVVideo, ISubRenderConsumer *pConsumer); ~CLAVSubtitleProvider(void); DECLARE_IUNKNOWN; DECLARE_ISUBRENDEROPTIONS; @@ -67,6 +69,7 @@ private: private: LAVSubtitleProviderContext context; + CLAVVideo *m_pLAVVideo; ISubRenderConsumer *m_pConsumer; diff --git a/decoder/LAVVideo/subtitles/LAVVideoSubtitleInputPin.cpp b/decoder/LAVVideo/subtitles/LAVVideoSubtitleInputPin.cpp index 1aed4324..1b30704c 100644 --- a/decoder/LAVVideo/subtitles/LAVVideoSubtitleInputPin.cpp +++ b/decoder/LAVVideo/subtitles/LAVVideoSubtitleInputPin.cpp @@ -19,6 +19,7 @@ #include "stdafx.h" #include "LAVVideoSubtitleInputPin.h" +#include "LAVVideo.h" #include "moreuuids.h" @@ -35,8 +36,9 @@ static const LAV_TYPE_MAP lav_subtitle_codecs[] = { { &MEDIATYPE_Video, &MEDIASUBTYPE_DVD_SUBPICTURE, AV_CODEC_ID_DVD_SUBTITLE } }; -CLAVVideoSubtitleInputPin::CLAVVideoSubtitleInputPin(TCHAR* pObjectName, CBaseFilter* pFilter, CCritSec *pcsFilter, HRESULT* phr, LPWSTR pName) +CLAVVideoSubtitleInputPin::CLAVVideoSubtitleInputPin(TCHAR* pObjectName, CLAVVideo* pFilter, CCritSec *pcsFilter, HRESULT* phr, LPWSTR pName) : CBaseInputPin(pObjectName, pFilter, pcsFilter, phr, pName) + , m_pLAVVideo(pFilter) , CDeCSSPinHelper() , m_pProvider(NULL) { @@ -85,7 +87,7 @@ HRESULT CLAVVideoSubtitleInputPin::SetMediaType(const CMediaType *pmt) if (codecId == AV_CODEC_ID_NONE) return VFW_E_TYPE_NOT_ACCEPTED; - m_pProvider = new CLAVSubtitleProvider(m_pConsumer); + m_pProvider = new CLAVSubtitleProvider(m_pLAVVideo, m_pConsumer); m_pProvider->AddRef(); HRESULT hr = m_pProvider->InitDecoder(pmt, codecId); if (FAILED(hr)) { diff --git a/decoder/LAVVideo/subtitles/LAVVideoSubtitleInputPin.h b/decoder/LAVVideo/subtitles/LAVVideoSubtitleInputPin.h index d2346c16..1675b029 100644 --- a/decoder/LAVVideo/subtitles/LAVVideoSubtitleInputPin.h +++ b/decoder/LAVVideo/subtitles/LAVVideoSubtitleInputPin.h @@ -24,10 +24,12 @@ #include "LAVSubtitleProvider.h" +class CLAVVideo; + class CLAVVideoSubtitleInputPin : public CBaseInputPin, public CDeCSSPinHelper { public: - CLAVVideoSubtitleInputPin(TCHAR* pObjectName, CBaseFilter* pFilter, CCritSec *pcsFilter, HRESULT* phr, LPWSTR pName); + CLAVVideoSubtitleInputPin(TCHAR* pObjectName, CLAVVideo* pFilter, CCritSec *pcsFilter, HRESULT* phr, LPWSTR pName); ~CLAVVideoSubtitleInputPin(void); DECLARE_IUNKNOWN @@ -54,4 +56,5 @@ protected: ISubRenderConsumer *m_pConsumer; CLAVSubtitleProvider *m_pProvider; + CLAVVideo *m_pLAVVideo; }; |