diff options
author | kinddragon <kinddragon@users.sourceforge.net> | 2010-05-28 05:23:17 +0400 |
---|---|---|
committer | kinddragon <kinddragon@users.sourceforge.net> | 2010-05-28 05:23:17 +0400 |
commit | b1389b5bf79340e1f348eb387c3ff6d2dd390644 (patch) | |
tree | 577a73bb919aaaff213334bda90eed4b31fb38f1 | |
parent | 169ce3df8f2db6eb61705d67e1588498cdea76d3 (diff) |
Minor code cleanup
Added SSE2 VD memcpy implementation
git-svn-id: https://mpc-hc.svn.sourceforge.net/svnroot/mpc-hc/trunk@1965 10f7b99b-c216-0410-bff0-8a66a9350fd8
-rw-r--r-- | src/apps/mplayerc/FGManager.cpp | 14 | ||||
-rw-r--r-- | src/apps/mplayerc/MainFrm.cpp | 49 | ||||
-rw-r--r-- | src/thirdparty/VirtualDub/system/source/a_memory.asm | 54 | ||||
-rw-r--r-- | src/thirdparty/VirtualDub/system/source/memory.cpp | 20 |
4 files changed, 108 insertions, 29 deletions
diff --git a/src/apps/mplayerc/FGManager.cpp b/src/apps/mplayerc/FGManager.cpp index 8e4d4ca58..a858ca3de 100644 --- a/src/apps/mplayerc/FGManager.cpp +++ b/src/apps/mplayerc/FGManager.cpp @@ -404,6 +404,7 @@ HRESULT CFGManager::AddSourceFilter(CFGFilter* pFGF, LPCWSTR lpcwstrFileName, LP pmt = &mt;
}
+ // sometimes looping with AviSynth
if(FAILED(hr = pFSF->Load(lpcwstrFileName, pmt)))
{
RemoveFilter(pBF);
@@ -412,10 +413,15 @@ HRESULT CFGManager::AddSourceFilter(CFGFilter* pFGF, LPCWSTR lpcwstrFileName, LP // doh :P
BeginEnumMediaTypes(GetFirstPin(pBF, PINDIR_OUTPUT), pEMT, pmt)
- {
- if(pmt->subtype == GUIDFromCString(_T("{640999A0-A946-11D0-A520-000000000000}"))
- || pmt->subtype == GUIDFromCString(_T("{640999A1-A946-11D0-A520-000000000000}"))
- || pmt->subtype == GUIDFromCString(_T("{D51BD5AE-7548-11CF-A520-0080C77EF58A}")))
+ {
+ static const GUID guid1 =
+ { 0x640999A0, 0xA946, 0x11D0, { 0xA5, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } };
+ static const GUID guid2 =
+ { 0x640999A1, 0xA946, 0x11D0, { 0xA5, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } };
+ static const GUID guid3 =
+ { 0xD51BD5AE, 0x7548, 0x11CF, { 0xA5, 0x20, 0x00, 0x80, 0xC7, 0x7E, 0xF5, 0x8A } };
+
+ if(pmt->subtype == guid1 || pmt->subtype == guid2 || pmt->subtype == guid3)
{
RemoveFilter(pBF);
pFGF = DNew CFGFilterRegistry(CLSID_NetShowSource);
diff --git a/src/apps/mplayerc/MainFrm.cpp b/src/apps/mplayerc/MainFrm.cpp index da8005587..3786e6908 100644 --- a/src/apps/mplayerc/MainFrm.cpp +++ b/src/apps/mplayerc/MainFrm.cpp @@ -10865,9 +10865,10 @@ bool CMainFrame::OpenMediaPrivate(CAutoPtr<OpenMediaData> pOMD) return(false);
}
- if(!dynamic_cast<OpenFileData*>(pOMD.m_p)
- && !dynamic_cast<OpenDVDData*>(pOMD.m_p)
- && !dynamic_cast<OpenDeviceData*>(pOMD.m_p))
+ OpenFileData *pFileData = dynamic_cast<OpenFileData *>(pOMD.m_p);
+ OpenDVDData* pDVDData = dynamic_cast<OpenDVDData*>(pOMD.m_p);
+ OpenDeviceData* pDeviceData = dynamic_cast<OpenDeviceData*>(pOMD.m_p);
+ if(!pFileData && !pDVDData && !pDeviceData)
{
ASSERT(0);
return(false);
@@ -10876,14 +10877,14 @@ bool CMainFrame::OpenMediaPrivate(CAutoPtr<OpenMediaData> pOMD) #ifdef _DEBUG
// Debug trace code - Begin
// Check for bad / buggy auto loading file code
- if ( OpenFileData *pOFD = dynamic_cast<OpenFileData *>(pOMD.m_p) )
+ if ( pFileData )
{
- POSITION pos = pOFD->fns.GetHeadPosition();
+ POSITION pos = pFileData->fns.GetHeadPosition();
UINT index = 0;
while ( pos != NULL )
{
- CString path = pOFD->fns.GetNext( pos );
- TRACE(_T("--> CMainFrame::OpenMediaPrivate - pOFD->fns[%d]:\n"), index);
+ CString path = pFileData->fns.GetNext( pos );
+ TRACE(_T("--> CMainFrame::OpenMediaPrivate - pFileData->fns[%d]:\n"), index);
TRACE(_T("\t%ws\n"), path.GetString()); // %ws - wide character string always
index++;
}
@@ -10891,12 +10892,12 @@ bool CMainFrame::OpenMediaPrivate(CAutoPtr<OpenMediaData> pOMD) // Debug trace code - End
#endif
- if(OpenFileData* pOFD = dynamic_cast<OpenFileData*>(pOMD.m_p))
+ if(pFileData)
{
- if(pOFD->fns.IsEmpty())
+ if(pFileData->fns.IsEmpty())
return(false);
- CString fn = pOFD->fns.GetHead();
+ CString fn = pFileData->fns.GetHead();
int i = fn.Find(_T(":\\"));
if(i > 0)
@@ -10953,14 +10954,14 @@ bool CMainFrame::OpenMediaPrivate(CAutoPtr<OpenMediaData> pOMD) if(m_fOpeningAborted) throw aborted;
- if(OpenFileData* p = dynamic_cast<OpenFileData*>(pOMD.m_p)) OpenFile(p);
- else if(OpenDVDData* p = dynamic_cast<OpenDVDData*>(pOMD.m_p)) OpenDVD(p);
- else if(OpenDeviceData* p = dynamic_cast<OpenDeviceData*>(pOMD.m_p))
+ if(pFileData) OpenFile(pFileData);
+ else if(pDVDData) OpenDVD(pDVDData);
+ else if(pDeviceData)
{
if (s.iDefaultCaptureDevice == 1)
OpenBDAGraph();
else
- OpenCapture(p);
+ OpenCapture(pDeviceData);
}
else throw _T("Can't open, invalid input parameters");
@@ -11057,21 +11058,21 @@ bool CMainFrame::OpenMediaPrivate(CAutoPtr<OpenMediaData> pOMD) AfxGetAppSettings().nCLSwitches &= ~CLSW_OPEN;
- if(OpenFileData* p = dynamic_cast<OpenFileData*>(pOMD.m_p))
+ if(pFileData)
{
- if(p->rtStart > 0)
- PostMessage(WM_RESUMEFROMSTATE, (WPARAM)PM_FILE, (LPARAM)(p->rtStart/10000)); // REFERENCE_TIME doesn't fit in LPARAM under a 32bit env.
+ if(pFileData->rtStart > 0)
+ PostMessage(WM_RESUMEFROMSTATE, (WPARAM)PM_FILE, (LPARAM)(pFileData->rtStart/10000)); // REFERENCE_TIME doesn't fit in LPARAM under a 32bit env.
}
- else if(OpenDVDData* p = dynamic_cast<OpenDVDData*>(pOMD.m_p))
+ else if(pDVDData)
{
- if(p->pDvdState)
- PostMessage(WM_RESUMEFROMSTATE, (WPARAM)PM_DVD, (LPARAM)(CComPtr<IDvdState>(p->pDvdState).Detach())); // must be released by the called message handler
+ if(pDVDData->pDvdState)
+ PostMessage(WM_RESUMEFROMSTATE, (WPARAM)PM_DVD, (LPARAM)(CComPtr<IDvdState>(pDVDData->pDvdState).Detach())); // must be released by the called message handler
}
- else if(OpenDeviceData* p = dynamic_cast<OpenDeviceData*>(pOMD.m_p))
+ else if(pDeviceData)
{
- m_wndCaptureBar.m_capdlg.SetVideoInput(p->vinput);
- m_wndCaptureBar.m_capdlg.SetVideoChannel(p->vchannel);
- m_wndCaptureBar.m_capdlg.SetAudioInput(p->ainput);
+ m_wndCaptureBar.m_capdlg.SetVideoInput(pDeviceData->vinput);
+ m_wndCaptureBar.m_capdlg.SetVideoChannel(pDeviceData->vchannel);
+ m_wndCaptureBar.m_capdlg.SetAudioInput(pDeviceData->ainput);
}
}
catch(LPCTSTR msg)
diff --git a/src/thirdparty/VirtualDub/system/source/a_memory.asm b/src/thirdparty/VirtualDub/system/source/a_memory.asm index e4b6cac8b..42a8ca998 100644 --- a/src/thirdparty/VirtualDub/system/source/a_memory.asm +++ b/src/thirdparty/VirtualDub/system/source/a_memory.asm @@ -130,6 +130,60 @@ _VDFastMemcpyPartialMMX2: pop ebp
ret
+ global _VDFastMemcpyPartialSSE2
+_VDFastMemcpyPartialSSE2:
+ push ebp
+ push edi
+ push esi
+ push ebx
+
+ mov edi, [esp+4+16]
+ mov esi, [esp+8+16]
+ mov ecx, [esp+12+16]
+ shr ecx, 7
+ cmp ecx, 0
+ jbe .skipblastloop
+.blastloop:
+ prefetchnta [esi+16*8]
+ movaps xmm0, [esi]
+ movaps xmm1, [esi+16*1]
+ movaps xmm2, [esi+16*2]
+ movaps xmm3, [esi+16*3]
+ movaps xmm4, [esi+16*4]
+ movaps xmm5, [esi+16*5]
+ movaps xmm6, [esi+16*6]
+ movaps xmm7, [esi+16*7]
+ movntps [edi], xmm0
+ movntps [edi+16*1], xmm1
+ movntps [edi+16*2], xmm2
+ movntps [edi+16*3], xmm3
+ movntps [edi+16*4], xmm4
+ movntps [edi+16*5], xmm5
+ movntps [edi+16*6], xmm6
+ movntps [edi+16*7], xmm7
+ add esi, 128
+ add edi, 128
+ dec ecx
+ jne .blastloop
+.skipblastloop:
+ mov ecx, [esp+12+16]
+ and ecx, 127
+ cmp ecx, 0
+ je .nooddballs
+.loop:
+ mov dl, [esi]
+ mov [edi], dl
+ inc esi
+ inc edi
+ dec ecx
+ jne .loop
+.nooddballs:
+ pop ebx
+ pop esi
+ pop edi
+ pop ebp
+ ret
+
end
diff --git a/src/thirdparty/VirtualDub/system/source/memory.cpp b/src/thirdparty/VirtualDub/system/source/memory.cpp index 3e03b5d34..6edce7873 100644 --- a/src/thirdparty/VirtualDub/system/source/memory.cpp +++ b/src/thirdparty/VirtualDub/system/source/memory.cpp @@ -365,6 +365,7 @@ void VDMemset32Rect(void *dst, ptrdiff_t pitch, uint32 value, size_t w, size_t h extern "C" void __cdecl VDFastMemcpyPartialScalarAligned8(void *dst, const void *src, size_t bytes);
extern "C" void __cdecl VDFastMemcpyPartialMMX(void *dst, const void *src, size_t bytes);
extern "C" void __cdecl VDFastMemcpyPartialMMX2(void *dst, const void *src, size_t bytes);
+ extern "C" void __cdecl VDFastMemcpyPartialSSE2(void *dst, const void *src, size_t bytes);
void VDFastMemcpyPartialScalar(void *dst, const void *src, size_t bytes) {
if (!(((int)dst | (int)src | bytes) & 7))
@@ -391,7 +392,13 @@ void VDMemset32Rect(void *dst, ptrdiff_t pitch, uint32 value, size_t w, size_t h void VDFastMemcpyAutodetect() {
long exts = CPUGetEnabledExtensions();
- if (exts & CPUF_SUPPORTS_SSE) {
+ // MPC custom code (begin)
+ if (exts & CPUF_SUPPORTS_SSE2) {
+ VDFastMemcpyPartial = VDFastMemcpyPartialSSE2;
+ VDFastMemcpyFinish = VDFastMemcpyFinishMMX2;
+ VDSwapMemory = VDSwapMemorySSE;
+ // MPC custom code (end)
+ } else if (exts & CPUF_SUPPORTS_SSE) {
VDFastMemcpyPartial = VDFastMemcpyPartialMMX2;
VDFastMemcpyFinish = VDFastMemcpyFinishMMX2;
VDSwapMemory = VDSwapMemorySSE;
@@ -426,6 +433,17 @@ void VDMemcpyRect(void *dst, ptrdiff_t dststride, const void *src, ptrdiff_t src if (w <= 0 || h <= 0)
return;
+ // MPC custom code (begin)
+#ifdef _DEBUG
+ if (CPUGetEnabledExtensions() & CPUF_SUPPORTS_SSE2) {
+ _ASSERT(!(((UINT_PTR)dst | (UINT_PTR)src) & 0xF));
+ if (h > 1) {
+ _ASSERT(!((dststride | srcstride) & 0xF));
+ }
+ }
+#endif
+ // MPC custom code (end)
+
if (w == srcstride && w == dststride)
VDFastMemcpyPartial(dst, src, w*h);
// MPC custom code (begin)
|