Skip to content

Commit

Permalink
Merge pull request #39 from TheOneric/pinterf_layoutres
Browse files Browse the repository at this point in the history
ASS Format: Introduce LayoutRes{X,Y} script headers
  • Loading branch information
pinterf authored Jan 18, 2023
2 parents 494391e + 06571e8 commit 15390e5
Show file tree
Hide file tree
Showing 7 changed files with 151 additions and 11 deletions.
91 changes: 91 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
name: Build VSFilter

on:
push:
branches: [ci, xy_sub_filter_rc*, vsfilter_rc*, master]

jobs:
build:
runs-on: windows-2019
strategy:
fail-fast: false
matrix:
include:
- msarch: x64
vsfplat: x64
namesuf: x86-64
- arch: x86
vsfplat: Win32
namesuf: x86-32
defaults:
run:
shell: 'bash'

steps:
- name: Determine configuration
id: config
run: |
# base name of GHA artifact
name="VSFilter+SubFilter"
# space delimited list of filename stems to delete from artifact
delete=""
# If it runs for one of the main XySubFilter or xy-VSFilter dev branches,
# only publish compatible binaries. If it's some other branch, it's probably
# a transient testing build, so keep everything.
# ref.: https://github.com/Cyberbeing/xy-VSFilter/pull/18#issuecomment-1302638201
REF="${{ github.ref }}"
REF="${REF#refs/heads/}"
if [ "$REF" = "master" ] || [ "$REF" = "vsfilter_rc" ] ; then
name="VSFilter"
delete="XySubFilter"
# xy-VSFilter specific changes weren't merged back into the
# XySubFilter branch, so it normally shouldn't be used to build
# xy-VSFilter. But in pinterf/xy-VSFilter there’s only one branch.
#elif echo "$REF" | grep -qE '^xy_sub_filter_rc' ; then
# name="SubFilter"
# delete="VSFilter"
fi
echo "name=$name" >> $GITHUB_OUTPUT
echo "delete=$delete" >> $GITHUB_OUTPUT
- name: checkout code
uses: actions/checkout@v3
with:
# We need full history to allow finding the tag in build prep
fetch-depth: 0

- name: install yasm
shell: cmd
run: |
git clone --depth=1 https://github.com/ShiftMediaProject/VSYASM.git
.\VSYASM\install_script.bat
# VS2019 is 16.x; VS2022 17.x
- name: Setup VS2019
uses: microsoft/setup-msbuild@v1.1
with:
msbuild-architecture: matrix.msarch
# vs-version: '[16.01,16.11]'

- name: Build xy-VSFilter and/or XySubFilter
run: |
export VS160COMNTOOLS="C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/Common7/Tools/"
bash ./build_vsfilter.sh -platform "${{ matrix.vsfplat }}" -compiler VS2019
- name: Prune incompatible files
if: steps.config.outputs.delete != ''
run: |
for dir in bin/lib*/*/Release ; do
for bn in ${{ steps.config.outputs.delete }} ; do
rm -f "$dir"/"$bn".*
done
done
- name: Publish output
uses: actions/upload-artifact@v3
with:
name: xy-${{ steps.config.outputs.name }}_nightly_${{ matrix.namesuf }}
path: |
bin/lib*/*/Release
21 changes: 14 additions & 7 deletions src/subtitles/RTS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1854,22 +1854,23 @@ void CRenderedTextSubtitle::OnChanged()


bool CRenderedTextSubtitle::Init( const CRectCoor2& video_rect, const CRectCoor2& subtitle_target_rect,
const SIZE& original_video_size )
const SIZE& layout_size )
{
XY_LOG_INFO(_T(""));
Deinit();

m_video_rect = CRect(video_rect.left*MAX_SUB_PIXEL,
video_rect.top*MAX_SUB_PIXEL,
video_rect.right*MAX_SUB_PIXEL,
video_rect.bottom*MAX_SUB_PIXEL);
m_subtitle_target_rect = CRect(subtitle_target_rect.left*MAX_SUB_PIXEL, subtitle_target_rect.top*MAX_SUB_PIXEL,
subtitle_target_rect.right*MAX_SUB_PIXEL, subtitle_target_rect.bottom*MAX_SUB_PIXEL);
m_size = CSize(original_video_size.cx*MAX_SUB_PIXEL, original_video_size.cy*MAX_SUB_PIXEL);
m_size = CSize(layout_size.cx*MAX_SUB_PIXEL, layout_size.cy*MAX_SUB_PIXEL);

ASSERT(original_video_size.cx!=0 && original_video_size.cy!=0);
ASSERT(layout_size.cx!=0 && layout_size.cy!=0);

m_target_scale_x = video_rect.Width() * 1.0 / original_video_size.cx;
m_target_scale_y = video_rect.Height() * 1.0 / original_video_size.cy;
m_target_scale_x = video_rect.Width() * 1.0 / layout_size.cx;
m_target_scale_y = video_rect.Height() * 1.0 / layout_size.cy;

return(true);
}
Expand Down Expand Up @@ -3360,6 +3361,12 @@ STDMETHODIMP CRenderedTextSubtitle::RenderEx( IXySubRenderFrame**subRenderFrame,
cvideo_rect.MoveToXY(0,0);
}

SIZE layout_size = original_video_size;
if (m_layout_size.cx > 0 && m_layout_size.cy > 0) {
layout_size.cx = m_layout_size.cx;
layout_size.cy = m_layout_size.cy;
}

XyColorSpace color_space = XY_CS_ARGB;
switch(spd_type)
{
Expand Down Expand Up @@ -3391,9 +3398,9 @@ STDMETHODIMP CRenderedTextSubtitle::RenderEx( IXySubRenderFrame**subRenderFrame,
subtitle_target_rect.top*MAX_SUB_PIXEL,
subtitle_target_rect.right*MAX_SUB_PIXEL,
subtitle_target_rect.bottom*MAX_SUB_PIXEL)
|| m_size != CSize(original_video_size.cx*MAX_SUB_PIXEL, original_video_size.cy*MAX_SUB_PIXEL) )
|| m_size != CSize(layout_size.cx*MAX_SUB_PIXEL, layout_size.cy*MAX_SUB_PIXEL) )
{
if (!Init(cvideo_rect, subtitle_target_rect, original_video_size))
if (!Init(cvideo_rect, subtitle_target_rect, layout_size))
{
XY_LOG_FATAL("Failed to Init.");
return E_FAIL;
Expand Down
11 changes: 9 additions & 2 deletions src/subtitles/RTS.h
Original file line number Diff line number Diff line change
Expand Up @@ -457,9 +457,16 @@ class CRenderedTextSubtitle : public CSubPicProviderImpl, public ISubStream, pub
virtual void Copy(CSimpleTextSubtitle& sts);
virtual void Empty();

public:
private:
/*
* The layout_size parameter is either derived from
* valid LayoutRes{X,Y} script headers (both must be valid!)
* or if those do not exist, equal to the video's storage resolution.
* Will call Deinit()
*/
bool Init(const CRectCoor2& video_rect, const CRectCoor2& subtitle_target_rect,
const SIZE& original_video_size); // will call Deinit()
const SIZE& layout_size);
public:
void Deinit();

DECLARE_IUNKNOWN
Expand Down
10 changes: 10 additions & 0 deletions src/subtitles/STS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2060,6 +2060,16 @@ if(sver <= 4) style->scrAlignment = (style->scrAlignment&4) ? ((style->scrAlig
: ret.m_dstScreenSize.cy * 4 / 3;
}
}
else if(entry == L"layoutresx")
{
try {ret.m_layout_size.cx = GetInt(buff);}
catch(...) {ret.m_layout_size = CSize(0, 0); return(false);}
}
else if(entry == L"layoutresy")
{
try {ret.m_layout_size.cy = GetInt(buff);}
catch(...) {ret.m_layout_size = CSize(0, 0); return(false);}
}
else if(entry == L"wrapstyle")
{
try {ret.m_defaultWrapStyle = GetInt(buff);}
Expand Down
1 change: 1 addition & 0 deletions src/subtitles/STS.h
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ class CSimpleTextSubtitle
int m_defaultWrapStyle;
int m_collisions;
bool m_fScaledBAS;
CSize m_layout_size;

CSTSStyleMap m_styles;

Expand Down
14 changes: 13 additions & 1 deletion src/thirdparty/VirtualDub/Kasumi/Kasumi.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,18 @@
<Import Project="..\..\..\common.props" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ExecutablePath>$(VCInstallDir);$(VC_ExecutablePath_x86);$(CommonExecutablePath)</ExecutablePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ExecutablePath>$(VCInstallDir);$(VC_ExecutablePath_x86);$(CommonExecutablePath)</ExecutablePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ExecutablePath>$(VCInstallDir);$(VC_ExecutablePath_x64);$(CommonExecutablePath)</ExecutablePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ExecutablePath>$(VCInstallDir);$(VC_ExecutablePath_x64);$(CommonExecutablePath)</ExecutablePath>
</PropertyGroup>
<ItemDefinitionGroup>
<ClCompile>
<AdditionalIncludeDirectories>h;..\h;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
Expand Down Expand Up @@ -200,4 +212,4 @@
<ImportGroup Label="ExtensionTargets">
<Import Project="..\..\..\YASM.targets" />
</ImportGroup>
</Project>
</Project>
14 changes: 13 additions & 1 deletion src/thirdparty/VirtualDub/system/system.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,18 @@
<Import Project="..\..\..\common.props" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ExecutablePath>$(VCInstallDir);$(VC_ExecutablePath_x86);$(CommonExecutablePath)</ExecutablePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ExecutablePath>$(VCInstallDir);$(VC_ExecutablePath_x86);$(CommonExecutablePath)</ExecutablePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ExecutablePath>$(VCInstallDir);$(VC_ExecutablePath_x64);$(CommonExecutablePath)</ExecutablePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ExecutablePath>$(VCInstallDir);$(VC_ExecutablePath_x64);$(CommonExecutablePath)</ExecutablePath>
</PropertyGroup>
<ItemDefinitionGroup>
<ClCompile>
<AdditionalIncludeDirectories>..\h;h;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
Expand Down Expand Up @@ -192,4 +204,4 @@
<ImportGroup Label="ExtensionTargets">
<Import Project="..\..\..\YASM.targets" />
</ImportGroup>
</Project>
</Project>

0 comments on commit 15390e5

Please sign in to comment.