-
Notifications
You must be signed in to change notification settings - Fork 141
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Anime4KCPP for DirectShow
- Loading branch information
Showing
13 changed files
with
1,090 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,4 +13,5 @@ _deps | |
Build | ||
ThirdParty | ||
settings.ini | ||
*.rc | ||
logo.rc | ||
*.aps |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
project(Anime4KCPPDS LANGUAGES CXX) | ||
|
||
if(Build_DS_Filter) | ||
|
||
aux_source_directory(src SOURCE) | ||
aux_source_directory(${TOP_DIR}/Anime4KCore/src Anime4KCPPCoreSource) | ||
|
||
include_directories(${TOP_DIR}/Anime4KCore/include include) | ||
file(GLOB INCLUDE include/*.h) | ||
enable_language(RC) | ||
list(APPEND SOURCE src/Anime4KCPPDS.rc src/Anime4KCPPDS.def) | ||
|
||
add_compile_definitions(BUILT_IN_KERNEL UNICODE) | ||
|
||
add_library(${PROJECT_NAME} SHARED ${INCLUDE} ${SOURCE} ${Anime4KCPPCoreSource}) | ||
|
||
include(${TOP_DIR}/cmake/ThirdPartyForDS.cmake) | ||
|
||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
#pragma once | ||
|
||
#include <string> | ||
#include <streams.h> | ||
#include <strsafe.h> | ||
|
||
#include "resource.h" | ||
|
||
extern "C" | ||
{ | ||
// {82F56FD7-717C-46CA-94C4-C1DBD380BCA4} | ||
DEFINE_GUID(IID_IAC, | ||
0x82f56fd7, 0x717c, 0x46ca, 0x94, 0xc4, 0xc1, 0xdb, 0xd3, 0x80, 0xbc, 0xa4); | ||
|
||
DECLARE_INTERFACE_(IAC, IUnknown) | ||
{ | ||
STDMETHOD(GetParameters) (THIS_ | ||
bool* HDN, | ||
bool* CNN, | ||
unsigned int* pID, | ||
unsigned int* dID, | ||
float* zoomFactor | ||
) PURE; | ||
|
||
STDMETHOD(SetParameters) (THIS_ | ||
bool HDN, | ||
bool CNN, | ||
unsigned int pID, | ||
unsigned int dID, | ||
float zoomFactor | ||
) PURE; | ||
|
||
STDMETHOD(GetGPUInfo) (THIS_ | ||
std::string & info | ||
) PURE; | ||
}; | ||
} | ||
|
||
class ACProp : | ||
public CBasePropertyPage | ||
{ | ||
public: | ||
static CUnknown* WINAPI CreateInstance(LPUNKNOWN lpunk, HRESULT* phr); | ||
private: | ||
virtual INT_PTR OnReceiveMessage(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam); | ||
virtual HRESULT OnConnect(IUnknown* pUnk); | ||
virtual HRESULT OnDisconnect(); | ||
virtual HRESULT OnActivate(); | ||
virtual HRESULT OnDeactivate(); | ||
virtual HRESULT OnApplyChanges(); | ||
|
||
void GetValues(); | ||
|
||
private: | ||
ACProp(LPUNKNOWN lpunk, HRESULT* phr); | ||
private: | ||
bool HDN, CNN; | ||
unsigned int pID, dID; | ||
float zoomFactor; | ||
std::string GPUInfo; | ||
|
||
IAC* pIAC; | ||
BOOL bInit; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#pragma once | ||
|
||
#include <initguid.h> | ||
|
||
//Anime4KCPP DirectShow Filter | ||
//{731ae2e9-eeed-4e29-b81b-5dc8a0d6a307} | ||
DEFINE_GUID(CLSID_Anime4KCPPDS, | ||
0x731ae2e9, 0xeeed, 0x4e29, 0xb8, 0x1b, 0x5d, 0xc8, 0xa0, 0xd6, 0xa3, 0x07); | ||
|
||
//Anime4KCPP DirectShow Filter Property Page | ||
// {2548FD44-5370-40F6-9966-485D7BAC713C} | ||
DEFINE_GUID(CLSID_ACProp, | ||
0x2548fd44, 0x5370, 0x40f6, 0x99, 0x66, 0x48, 0x5d, 0x7b, 0xac, 0x71, 0x3c); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#pragma once | ||
|
||
#include<streams.h> | ||
#include<Dvdmedia.h> | ||
|
||
#include"ACuids.h" | ||
#include "ACProp.h" | ||
#include"Anime4KCPP.h" | ||
|
||
enum class ColorFormat | ||
{ | ||
YV12, IYUV, NV12, RGB24, RGB32 | ||
}; | ||
|
||
class Anime4KCPPDS : | ||
public CTransformFilter, ISpecifyPropertyPages, IAC | ||
{ | ||
public: | ||
DECLARE_IUNKNOWN; | ||
static CUnknown* WINAPI CreateInstance(LPUNKNOWN punk, HRESULT* phr); | ||
STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv); | ||
|
||
virtual HRESULT CheckInputType(const CMediaType* mtIn); | ||
virtual HRESULT CheckTransform(const CMediaType* mtIn, const CMediaType* mtOut); | ||
virtual HRESULT DecideBufferSize(IMemAllocator* pAlloc, ALLOCATOR_PROPERTIES* pProperties); | ||
virtual HRESULT GetMediaType(int iPosition, CMediaType* pMediaType); | ||
virtual HRESULT Transform(IMediaSample* pIn, IMediaSample* pOut); | ||
|
||
STDMETHODIMP GetParameters(bool* HDN, bool* CNN, unsigned int* pID, unsigned int* dID, float* zoomFactor); | ||
STDMETHODIMP SetParameters(bool HDN, bool CNN, unsigned int pID, unsigned int dID, float zoomFactor); | ||
STDMETHODIMP GetGPUInfo(std::string& info); | ||
|
||
STDMETHODIMP GetPages(CAUUID* pPages); | ||
|
||
private: | ||
Anime4KCPPDS(TCHAR* tszName, LPUNKNOWN punk, HRESULT* phr); | ||
BOOL IsRGB24(const CMediaType* pMediaType) const; | ||
BOOL IsRGB32(const CMediaType* pMediaType) const; | ||
BOOL IsIYUV(const CMediaType* pMediaType) const; | ||
BOOL IsYV12(const CMediaType* pMediaType) const; | ||
BOOL IsNV12(const CMediaType* pMediaType) const; | ||
private: | ||
Anime4KCPP::Anime4KCreator acCreator; | ||
Anime4KCPP::Parameters parameters; | ||
unsigned int pID, dID; | ||
float zf; | ||
bool CNN; | ||
|
||
LONG srcH, srcW, dstH, dstW; | ||
LONG dstDataLength; | ||
ColorFormat colorFormat; | ||
TCHAR lpPath[MAX_PATH]; | ||
CCritSec lock; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
//{{NO_DEPENDENCIES}} | ||
// Created by Microsoft Visual C++ | ||
// For Anime4KCPPDS.rc | ||
// | ||
#define IDD_ACPROP 104 | ||
#define IDS_TITLE 107 | ||
#define IDC_CHECK_HDN 1001 | ||
#define IDC_CHECK_CNN 1003 | ||
#define IDC_EDIT_ZF 1004 | ||
#define IDC_EDIT_DID 1005 | ||
#define IDC_EDIT_PID 1006 | ||
#define IDC_STATIC_ZF 1008 | ||
#define IDC_STATIC_PID 1009 | ||
#define IDC_STATIC_DID 1010 | ||
#define IDC_EDIT_GPUINFO 1011 | ||
#define IDC_STATIC_EXPLAIN 1012 | ||
#define IDC_STATIC_GPUs 1013 | ||
|
||
// Next default values for new objects | ||
// | ||
#ifdef APSTUDIO_INVOKED | ||
#ifndef APSTUDIO_READONLY_SYMBOLS | ||
#define _APS_NEXT_RESOURCE_VALUE 108 | ||
#define _APS_NEXT_COMMAND_VALUE 40001 | ||
#define _APS_NEXT_CONTROL_VALUE 1012 | ||
#define _APS_NEXT_SYMED_VALUE 101 | ||
#endif | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
#include "ACProp.h" | ||
|
||
CUnknown* ACProp::CreateInstance(LPUNKNOWN lpunk, HRESULT* phr) | ||
{ | ||
CUnknown* punk = new ACProp(lpunk, phr); | ||
|
||
if (punk == NULL) | ||
{ | ||
if (phr) | ||
*phr = E_OUTOFMEMORY; | ||
} | ||
|
||
return punk; | ||
} | ||
|
||
INT_PTR ACProp::OnReceiveMessage(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) | ||
{ | ||
switch (uMsg) | ||
{ | ||
case WM_COMMAND: | ||
{ | ||
if (bInit) | ||
{ | ||
m_bDirty = TRUE; | ||
if (m_pPageSite) | ||
m_pPageSite->OnStatusChange(PROPPAGESTATUS_DIRTY); | ||
} | ||
return (LRESULT)1; | ||
} | ||
} | ||
|
||
return CBasePropertyPage::OnReceiveMessage(hwnd, uMsg, wParam, lParam); | ||
} | ||
|
||
HRESULT ACProp::OnConnect(IUnknown* pUnk) | ||
{ | ||
CheckPointer(pUnk, E_POINTER); | ||
|
||
HRESULT hr = pUnk->QueryInterface(IID_IAC, (void**)&pIAC); | ||
if (FAILED(hr)) | ||
return E_NOINTERFACE; | ||
|
||
CheckPointer(pIAC, E_FAIL); | ||
pIAC->GetParameters(&HDN, &CNN, &pID, &dID, &zoomFactor); | ||
|
||
pIAC->GetGPUInfo(GPUInfo); | ||
|
||
bInit = FALSE; | ||
|
||
return NOERROR; | ||
} | ||
|
||
HRESULT ACProp::OnDisconnect() | ||
{ | ||
if (pIAC) | ||
{ | ||
pIAC->Release(); | ||
pIAC = NULL; | ||
} | ||
|
||
return NOERROR; | ||
} | ||
|
||
HRESULT ACProp::OnActivate() | ||
{ | ||
Button_SetCheck(GetDlgItem(m_Dlg, IDC_CHECK_HDN), HDN); | ||
Button_SetCheck(GetDlgItem(m_Dlg, IDC_CHECK_CNN), CNN); | ||
|
||
TCHAR sz[STR_MAX_LENGTH]; | ||
(void)StringCchPrintf(sz, NUMELMS(sz), TEXT("%f\0"), zoomFactor); | ||
Edit_SetText(GetDlgItem(m_Dlg, IDC_EDIT_ZF), sz); | ||
|
||
(void)StringCchPrintf(sz, NUMELMS(sz), TEXT("%d\0"), pID); | ||
Edit_SetText(GetDlgItem(m_Dlg, IDC_EDIT_PID), sz); | ||
|
||
(void)StringCchPrintf(sz, NUMELMS(sz), TEXT("%d\0"), dID); | ||
Edit_SetText(GetDlgItem(m_Dlg, IDC_EDIT_DID), sz); | ||
|
||
MultiByteToWideChar(CP_ACP, 0, GPUInfo.c_str(), -1, sz, STR_MAX_LENGTH); | ||
Edit_SetText(GetDlgItem(m_Dlg, IDC_EDIT_GPUINFO), sz); | ||
|
||
bInit = TRUE; | ||
|
||
return NOERROR; | ||
} | ||
|
||
HRESULT ACProp::OnDeactivate() | ||
{ | ||
bInit = FALSE; | ||
GetValues(); | ||
|
||
return NOERROR; | ||
} | ||
|
||
HRESULT ACProp::OnApplyChanges() | ||
{ | ||
GetValues(); | ||
CheckPointer(pIAC, E_POINTER); | ||
pIAC->SetParameters(HDN, CNN, pID, dID, zoomFactor); | ||
|
||
return NOERROR; | ||
} | ||
|
||
void ACProp::GetValues() | ||
{ | ||
HDN = Button_GetCheck(GetDlgItem(m_Dlg, IDC_CHECK_HDN)) == BST_CHECKED; | ||
|
||
CNN = Button_GetCheck(GetDlgItem(m_Dlg, IDC_CHECK_CNN)) == BST_CHECKED; | ||
|
||
TCHAR sz[STR_MAX_LENGTH]; | ||
Edit_GetText(GetDlgItem(m_Dlg, IDC_EDIT_ZF), sz, STR_MAX_LENGTH); | ||
zoomFactor = _wtof(sz); | ||
zoomFactor = zoomFactor >= 1.0F ? zoomFactor : 1.0F; | ||
|
||
Edit_GetText(GetDlgItem(m_Dlg, IDC_EDIT_PID), sz, STR_MAX_LENGTH); | ||
pID = _wtoi(sz); | ||
pID = pID < 0 ? 0 : pID; | ||
|
||
Edit_GetText(GetDlgItem(m_Dlg, IDC_EDIT_DID), sz, STR_MAX_LENGTH); | ||
dID = _wtoi(sz); | ||
dID = dID < 0 ? 0 : dID; | ||
} | ||
|
||
ACProp::ACProp(LPUNKNOWN lpunk, HRESULT* phr) : | ||
CBasePropertyPage(NAME("Anime4KCPP for DirectShow Property Page"), lpunk, | ||
IDD_ACPROP, IDS_TITLE), | ||
HDN(false), CNN(false), pID(0), dID(0), zoomFactor(2.0), | ||
pIAC(NULL), bInit(FALSE) {} |
Oops, something went wrong.