Skip to content

Commit 33daf2a

Browse files
committed
Support VapourSynth API R4 (since R55)
Formats YUY2 and RGB32 are no longer supported (due to them being dropped by VapourSynth)
1 parent d8b1ce8 commit 33daf2a

20 files changed

+187
-208
lines changed

avisynth_filter/avisynth_filter.vcxproj.filters

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
<ItemGroup>
44
<Filter Include="Source Files">
55
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
6-
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
6+
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
77
</Filter>
88
<Filter Include="Header Files">
99
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
10-
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
10+
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
1111
</Filter>
1212
<Filter Include="Resource Files">
1313
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
14-
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav</Extensions>
14+
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
1515
</Filter>
1616
</ItemGroup>
1717
<ItemGroup>

avisynth_filter/src/format.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
namespace SynthFilter {
1010

11-
// for each group of formats with the same format ID, they should appear with the most preferred -> list preferred order
11+
// for each group of formats with the same format ID, they should appear with the most preferred -> least preferred order
1212
const std::vector<Format::PixelFormat> Format::PIXEL_FORMATS {
1313
// 4:2:0
1414
{ .name = L"NV12", .mediaSubtype = MEDIASUBTYPE_NV12, .frameServerFormatId = VideoInfo::CS_YV12, .bitCount = 12, .componentsPerPixel = 1, .subsampleWidthRatio = 2, .subsampleHeightRatio = 2, .areUVPlanesInterleaved = true, .resourceId = IDC_INPUT_FORMAT_NV12 },

avisynth_filter/src/frame_handler.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,11 @@ auto FrameHandler::AddInputSample(IMediaSample *inputSample) -> HRESULT {
8181
const DWORD typeSpecificFlags = _filter.m_pInput->SampleProps()->dwTypeSpecificFlags;
8282
int rfpFieldBased;
8383
if (typeSpecificFlags & AM_VIDEO_FLAG_WEAVE) {
84-
rfpFieldBased = 0;
84+
rfpFieldBased = VSFieldBased::VSC_FIELD_PROGRESSIVE;
8585
} else if (typeSpecificFlags & AM_VIDEO_FLAG_FIELD1FIRST) {
86-
rfpFieldBased = 2;
86+
rfpFieldBased = VSFieldBased::VSC_FIELD_TOP;
8787
} else {
88-
rfpFieldBased = 1;
88+
rfpFieldBased = VSFieldBased::VSC_FIELD_BOTTOM;
8989
}
9090
AVSF_AVS_API->propSetInt(frameProps, FRAME_PROP_NAME_FIELD_BASED, rfpFieldBased, PROPAPPENDMODE_REPLACE);
9191
}

avisynth_filter/src/frameserver.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ MainFrameServer::~MainFrameServer() {
141141
}
142142

143143
auto MainFrameServer::ReloadScript(const AM_MEDIA_TYPE &mediaType, bool ignoreDisconnect) -> bool {
144-
Environment::GetInstance().Log(L"ReloadScript from main instance");
144+
Environment::GetInstance().Log(L"ReloadScript from main frameserver");
145145

146146
if (__super::ReloadScript(mediaType, ignoreDisconnect)) {
147147
const VideoInfo &sourceVideoInfo = FrameServerCommon::GetInstance()._sourceVideoInfo;
@@ -160,7 +160,7 @@ auto MainFrameServer::GetFrame(int frameNb) const -> PVideoFrame {
160160
}
161161

162162
auto AuxFrameServer::ReloadScript(const AM_MEDIA_TYPE &mediaType, bool ignoreDisconnect) -> bool {
163-
Environment::GetInstance().Log(L"ReloadScript from checking instance");
163+
Environment::GetInstance().Log(L"ReloadScript from auxiliary frameserver");
164164

165165
if (__super::ReloadScript(mediaType, ignoreDisconnect)) {
166166
StopScript();

baseclasses/baseclasses.vcxproj.filters

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
<ItemGroup>
44
<Filter Include="Source Files">
55
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
6-
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
6+
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
77
</Filter>
88
<Filter Include="Header Files">
99
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
10-
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
10+
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
1111
</Filter>
1212
</ItemGroup>
1313
<ItemGroup>
@@ -218,4 +218,4 @@
218218
<Filter>Source Files</Filter>
219219
</ClCompile>
220220
</ItemGroup>
221-
</Project>
221+
</Project>

common.props

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@
2525
<TargetName>$(ProjectName)_$(PlatformArchitecture)</TargetName>
2626
</PropertyGroup>
2727
<PropertyGroup Label="Globals">
28-
<Keyword>Win32Proj</Keyword>
2928
<VCProjectVersion>16.0</VCProjectVersion>
29+
<Keyword>Win32Proj</Keyword>
3030
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
3131
</PropertyGroup>
3232
<PropertyGroup Label="Configuration">
33-
<CharacterSet>Unicode</CharacterSet>
3433
<PlatformToolset>v142</PlatformToolset>
3534
<UseDebugLibraries Condition="'$(Configuration)' == 'Debug'">true</UseDebugLibraries>
35+
<CharacterSet>Unicode</CharacterSet>
3636
<WholeProgramOptimization Condition="'$(Configuration)' == 'Release'">true</WholeProgramOptimization>
3737
</PropertyGroup>
3838
<ImportGroup Label="ExtensionSettings">

filter_common/src/format.h

+9-9
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ class FrameServerBase;
1111

1212
class Format {
1313
#ifdef AVSF_AVISYNTH
14-
using FrameServerInstance = void *;
14+
using FrameServerCore = void *;
1515
using FrameType = PVideoFrame;
1616
using ConstFrameType = const PVideoFrame &;
1717
using VideoInfoType = VideoInfo;
1818
#else
19-
using FrameServerInstance = VSCore *;
20-
using FrameType = VSFrameRef *;
21-
using ConstFrameType = const VSFrameRef *;
19+
using FrameServerCore = VSCore *;
20+
using FrameType = VSFrame *;
21+
using ConstFrameType = const VSFrame *;
2222
using VideoInfoType = VSVideoInfo;
2323
#endif
2424

@@ -46,9 +46,9 @@ class Format {
4646
struct VideoFormat {
4747
struct ColorSpaceInfo {
4848
std::optional<int> colorRange;
49-
int primaries = 2;
50-
int matrix = 2;
51-
int transfer = 2;
49+
int primaries = VSColorPrimaries::VSC_PRIMARIES_UNSPECIFIED;
50+
int matrix = VSMatrixCoefficients::VSC_MATRIX_UNSPECIFIED;
51+
int transfer = VSTransferCharacteristics::VSC_TRANSFER_UNSPECIFIED;
5252

5353
auto Update(const DXVA_ExtendedFormat &dxvaExtFormat) -> void;
5454
};
@@ -61,7 +61,7 @@ class Format {
6161
int hdrType;
6262
int hdrLuminance;
6363
BITMAPINFOHEADER bmi;
64-
FrameServerInstance frameServer;
64+
FrameServerCore frameServerCore;
6565

6666
auto GetCodecFourCC() const -> DWORD {
6767
return FOURCCMap(&pixelFormat->mediaSubtype).GetFOURCC();
@@ -70,7 +70,7 @@ class Format {
7070

7171
static auto Initialize() -> void;
7272
static auto LookupMediaSubtype(const CLSID &mediaSubtype) -> const PixelFormat *;
73-
static constexpr auto LookupFrameServerFormatId(int frameServerFormatId) {
73+
static auto LookupFrameServerFormatId(int frameServerFormatId) {
7474
return PIXEL_FORMATS | std::views::filter([frameServerFormatId](const PixelFormat &pixelFormat) -> bool {
7575
return frameServerFormatId == pixelFormat.frameServerFormatId;
7676
});

filter_common/src/format_common.cpp

+16-16
Original file line numberDiff line numberDiff line change
@@ -10,62 +10,62 @@ namespace SynthFilter {
1010
auto Format::VideoFormat::ColorSpaceInfo::Update(const DXVA_ExtendedFormat &dxvaExtFormat) -> void {
1111
switch (dxvaExtFormat.NominalRange) {
1212
case DXVA_NominalRange_Normal:
13-
colorRange = 0;
13+
colorRange = VSColorRange::VSC_RANGE_FULL;
1414
break;
1515
case DXVA_NominalRange_Wide:
16-
colorRange = 1;
16+
colorRange = VSColorRange::VSC_RANGE_LIMITED;
1717
break;
1818
}
1919

2020
switch (dxvaExtFormat.VideoPrimaries) {
2121
case DXVA_VideoPrimaries_BT709:
22-
primaries = 1;
22+
primaries = VSColorPrimaries::VSC_PRIMARIES_BT709;
2323
break;
2424
case DXVA_VideoPrimaries_BT470_2_SysM:
25-
primaries = 4;
25+
primaries = VSColorPrimaries::VSC_PRIMARIES_BT470_M;
2626
break;
2727
case DXVA_VideoPrimaries_BT470_2_SysBG:
28-
primaries = 5;
28+
primaries = VSColorPrimaries::VSC_PRIMARIES_BT470_BG;
2929
break;
3030
case DXVA_VideoPrimaries_SMPTE170M:
3131
case DXVA_VideoPrimaries_SMPTE_C:
32-
primaries = 6;
32+
primaries = VSColorPrimaries::VSC_PRIMARIES_ST170_M;
3333
break;
3434
case DXVA_VideoPrimaries_SMPTE240M:
35-
primaries = 7;
35+
primaries = VSColorPrimaries::VSC_PRIMARIES_ST240_M;
3636
break;
3737
case DXVA_VideoPrimaries_EBU3213:
38-
primaries = 22;
38+
primaries = VSColorPrimaries::VSC_PRIMARIES_EBU3213_E;
3939
break;
4040
}
4141

4242
switch (dxvaExtFormat.VideoTransferMatrix) {
4343
case DXVA_VideoTransferMatrix_BT709:
44-
matrix = 1;
44+
matrix = VSMatrixCoefficients::VSC_MATRIX_BT709;
4545
break;
4646
case DXVA_VideoTransferMatrix_BT601:
47-
matrix = 5;
47+
matrix = VSMatrixCoefficients::VSC_MATRIX_BT470_BG;
4848
break;
4949
case DXVA_VideoTransferMatrix_SMPTE240M:
50-
matrix = 7;
50+
matrix = VSMatrixCoefficients::VSC_MATRIX_ST240_M;
5151
break;
5252
}
5353

5454
switch (dxvaExtFormat.VideoTransferFunction) {
5555
case DXVA_VideoTransFunc_10:
56-
transfer = 8;
56+
transfer = VSTransferCharacteristics::VSC_TRANSFER_LINEAR;
5757
break;
5858
case DXVA_VideoTransFunc_22:
59-
transfer = 4;
59+
transfer = VSTransferCharacteristics::VSC_TRANSFER_BT470_M;
6060
break;
6161
case DXVA_VideoTransFunc_22_709:
62-
transfer = 1;
62+
transfer = VSTransferCharacteristics::VSC_TRANSFER_BT709;
6363
break;
6464
case DXVA_VideoTransFunc_22_240M:
65-
transfer = 7;
65+
transfer = VSTransferCharacteristics::VSC_TRANSFER_ST240_M;
6666
break;
6767
case DXVA_VideoTransFunc_28:
68-
transfer = 5;
68+
transfer = VSTransferCharacteristics::VSC_TRANSFER_BT470_BG;
6969
break;
7070
}
7171
}

filter_common/src/hdr.h

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
#pragma once
44

5-
#include "pch.h"
65
#include "side_data.h"
76

87

filter_common/src/main.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#ifdef AVSF_AVISYNTH
1515
#pragma comment(lib, "AviSynth")
1616
#else
17+
#pragma comment(lib, "VapourSynth")
1718
#pragma comment(lib, "VSScript")
1819
#endif
1920

filter_common/src/pch.h

+4-3
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,11 @@
4646
#ifdef AVSF_AVISYNTH
4747
#include <avisynth.h>
4848
#else
49-
#include <VapourSynth.h>
50-
#include <VSScript.h>
51-
#include <VSHelper.h>
49+
#include <VapourSynth4.h>
50+
#include <VSScript4.h>
51+
#include <VSHelper4.h>
5252
#endif
53+
#include <VSConstants4.h>
5354

5455
#include <SimpleIni.h>
5556

filter_common/src/prop_settings.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,9 @@ auto CSynthFilterPropSettings::OnActivate() -> HRESULT {
4646
});
4747

4848
#ifdef AVSF_VAPOURSYNTH
49+
EnableWindow(GetDlgItem(m_Dlg, IDC_INPUT_FORMAT_YUY2), FALSE);
4950
EnableWindow(GetDlgItem(m_Dlg, IDC_INPUT_FORMAT_RGB24), FALSE);
51+
EnableWindow(GetDlgItem(m_Dlg, IDC_INPUT_FORMAT_RGB32), FALSE);
5052
#endif
5153

5254
const std::string title = std::format("<a>{} v{}</a>\nwith {}", FILTER_NAME_BASE, FILTER_VERSION_STRING, FrameServerCommon::GetInstance().GetVersionString());

install.bat install.cmd

File renamed without changes.

uninstall.bat uninstall.cmd

File renamed without changes.

0 commit comments

Comments
 (0)