mirror of https://github.com/odrling/Aegisub
Added some initial code for DVD .sup generation (get lines from renderer and output them as 4-colour PNG files). This is currently only available on debug builds.
Originally committed to SVN as r1802.
This commit is contained in:
parent
b33e9c9bff
commit
849921c7c5
|
@ -196,6 +196,7 @@ aegisub_SOURCES = \
|
|||
subs_preview.cpp \
|
||||
subtitle_format.cpp \
|
||||
subtitle_format_ass.cpp \
|
||||
subtitle_format_dvd.cpp \
|
||||
subtitle_format_encore.cpp \
|
||||
subtitle_format_microdvd.cpp \
|
||||
subtitle_format_mkv.cpp \
|
||||
|
|
|
@ -46,6 +46,7 @@
|
|||
#include "subtitle_format_mkv.h"
|
||||
#include "subtitle_format_microdvd.h"
|
||||
#include "subtitle_format_encore.h"
|
||||
#include "subtitle_format_dvd.h"
|
||||
#include "ass_file.h"
|
||||
#include "vfr.h"
|
||||
|
||||
|
@ -133,6 +134,9 @@ void SubtitleFormat::LoadFormats () {
|
|||
new MicroDVDSubtitleFormat();
|
||||
new MKVSubtitleFormat();
|
||||
new EncoreSubtitleFormat();
|
||||
#ifdef __WXDEBUG__
|
||||
new DVDSubtitleFormat();
|
||||
#endif
|
||||
}
|
||||
loaded = true;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,184 @@
|
|||
// Copyright (c) 2008, Rodrigo Braz Monteiro
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
// * Neither the name of the Aegisub Group nor the names of its contributors
|
||||
// may be used to endorse or promote products derived from this software
|
||||
// without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
// POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// -----------------------------------------------------------------------------
|
||||
//
|
||||
// AEGISUB
|
||||
//
|
||||
// Website: http://aegisub.cellosoft.com
|
||||
// Contact: mailto:zeratul@cellosoft.com
|
||||
//
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
///////////
|
||||
// Headers
|
||||
#include "subtitle_format_dvd.h"
|
||||
#include "video_provider_dummy.h"
|
||||
#include "subtitles_provider.h"
|
||||
#include "ass_dialogue.h"
|
||||
#include "ass_file.h"
|
||||
|
||||
|
||||
///////////////
|
||||
// Format name
|
||||
wxString DVDSubtitleFormat::GetName() {
|
||||
return _T("DVD Subpictures");
|
||||
}
|
||||
|
||||
|
||||
//////////////
|
||||
// Extensions
|
||||
wxArrayString DVDSubtitleFormat::GetWriteWildcards() {
|
||||
wxArrayString results;
|
||||
results.Add(_T("sup"));
|
||||
return results;
|
||||
}
|
||||
|
||||
|
||||
/////////////
|
||||
// Can write
|
||||
bool DVDSubtitleFormat::CanWriteFile(wxString filename) {
|
||||
return (filename.Lower().EndsWith(_T(".sup")));
|
||||
}
|
||||
|
||||
|
||||
///////////////////////
|
||||
// Actually write them
|
||||
void DVDSubtitleFormat::WriteFile(wxString filename,wxString encoding) {
|
||||
// Create video frame
|
||||
int w = 720;
|
||||
int h = 480;
|
||||
VideoProvider *video = new DummyVideoProvider(10,1,w,h,wxColour(255,0,0),false);
|
||||
AegiVideoFrame srcFrame;
|
||||
srcFrame.CopyFrom(video->GetFrame(0));
|
||||
delete video;
|
||||
|
||||
// Subtitles
|
||||
SubtitlesProvider *provider = SubtitlesProviderFactory::GetProvider();
|
||||
|
||||
// Prepare subtitles
|
||||
CreateCopy();
|
||||
SortLines();
|
||||
//Merge(true,true,true);
|
||||
provider->LoadSubtitles(GetAssFile());
|
||||
|
||||
// Write lines
|
||||
using std::list;
|
||||
int i = 0;
|
||||
for (list<AssEntry*>::iterator cur=Line->begin();cur!=Line->end();cur++) {
|
||||
AssDialogue *current = AssEntry::GetAsDialogue(*cur);
|
||||
if (current) {
|
||||
// Get the image
|
||||
AegiVideoFrame dst;
|
||||
dst.CopyFrom(srcFrame);
|
||||
provider->DrawSubtitles(dst,current->Start.GetMS()/1000.0);
|
||||
wxImage img = dst.GetImage();
|
||||
dst.Clear();
|
||||
|
||||
// Perform colour reduction on image
|
||||
unsigned char r,g,b;
|
||||
unsigned char *data = img.GetData();
|
||||
const unsigned char *dataRead = data;
|
||||
unsigned char *dataWrite = data;
|
||||
int startY = 0;
|
||||
int endY;
|
||||
int startX = w;
|
||||
int endX = 0;
|
||||
|
||||
// For each line
|
||||
for (int y=h;--y>=0;) {
|
||||
bool hasData = false;
|
||||
int lineStartX = 0;
|
||||
int lineEndX;
|
||||
|
||||
// Scan line
|
||||
for (int x=w;--x>=0;) {
|
||||
// Read
|
||||
r = *(dataRead++);
|
||||
g = *(dataRead++);
|
||||
b = *(dataRead++);
|
||||
|
||||
// Background
|
||||
if (r > 127 && g < 20) {
|
||||
r = 255;
|
||||
g = 0;
|
||||
b = 0;
|
||||
}
|
||||
|
||||
// Text
|
||||
else {
|
||||
// Mark coordinates
|
||||
hasData = true;
|
||||
if (lineStartX == 0) lineStartX = w-x-1;
|
||||
lineEndX = w-x-1;
|
||||
|
||||
// Set colour
|
||||
if (r > 170 && g > 170) {
|
||||
r = 255;
|
||||
g = 255;
|
||||
b = 255;
|
||||
}
|
||||
else if (r > 85 && g > 85) {
|
||||
r = 127;
|
||||
g = 127;
|
||||
b = 127;
|
||||
}
|
||||
else {
|
||||
r = 0;
|
||||
g = 0;
|
||||
b = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Write
|
||||
*(dataWrite++) = r;
|
||||
*(dataWrite++) = g;
|
||||
*(dataWrite++) = b;
|
||||
}
|
||||
|
||||
// Mark as last found so far
|
||||
if (hasData) {
|
||||
if (startY == 0) startY = h-y-1;
|
||||
endY = h-y-1;
|
||||
if (lineStartX < startX) startX = lineStartX;
|
||||
if (lineEndX > endX) endX = lineEndX;
|
||||
}
|
||||
}
|
||||
|
||||
// Save image
|
||||
img.GetSubImage(wxRect(startX,startY,endX-startX+1,endY-startY+1)).SaveFile(filename + wxString::Format(_T("%03i.png"),i));
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
// Clean up
|
||||
delete provider;
|
||||
srcFrame.Clear();
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
// Copyright (c) 2008, Rodrigo Braz Monteiro
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
// * Neither the name of the Aegisub Group nor the names of its contributors
|
||||
// may be used to endorse or promote products derived from this software
|
||||
// without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
// POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// -----------------------------------------------------------------------------
|
||||
//
|
||||
// AEGISUB
|
||||
//
|
||||
// Website: http://aegisub.cellosoft.com
|
||||
// Contact: mailto:zeratul@cellosoft.com
|
||||
//
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
///////////
|
||||
// Headers
|
||||
#include "subtitle_format.h"
|
||||
|
||||
|
||||
//////////////////////////
|
||||
// DVD subpictures writer
|
||||
class DVDSubtitleFormat : public SubtitleFormat {
|
||||
public:
|
||||
wxString GetName();
|
||||
wxArrayString GetWriteWildcards();
|
||||
bool CanWriteFile(wxString filename);
|
||||
void WriteFile(wxString filename,wxString encoding);
|
||||
};
|
|
@ -104,92 +104,6 @@
|
|||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
||||
IntermediateDirectory="$(ConfigurationName)"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="1"
|
||||
WholeProgramOptimization="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
CommandLine="if not exist "..\..\aegisub\win32\config.h" (copy "..\..\aegisub\win32\config0.h" "..\..\aegisub\win32\config.h")
SubWCRev.exe "..\..\aegisub" "..\svn-revision-base.h" "..\svn-revision.h"
"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories="../../aegisub/win32;../../hunspell/src"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS"
|
||||
RuntimeLibrary="2"
|
||||
OpenMP="true"
|
||||
UsePrecompiledHeader="2"
|
||||
PrecompiledHeaderThrough="stdwx.h"
|
||||
WarningLevel="3"
|
||||
WarnAsError="true"
|
||||
Detect64BitPortabilityProblems="true"
|
||||
DebugInformationFormat="3"
|
||||
DisableSpecificWarnings="4267"
|
||||
ForcedIncludeFiles="stdwx.h;config.h"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
OutputFile="../../bin/aegisub.exe"
|
||||
LinkIncremental="1"
|
||||
AdditionalLibraryDirectories="../../lib"
|
||||
GenerateManifest="true"
|
||||
DelayLoadDLLs="perl510.dll"
|
||||
GenerateDebugInformation="true"
|
||||
SubSystem="2"
|
||||
OptimizeReferences="2"
|
||||
EnableCOMDATFolding="2"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Debug|x64"
|
||||
OutputDirectory="$(SolutionDir)$(PlatformName)\$(ConfigurationName)"
|
||||
|
@ -277,6 +191,92 @@
|
|||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
||||
IntermediateDirectory="$(ConfigurationName)"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="1"
|
||||
WholeProgramOptimization="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
CommandLine="if not exist "..\..\aegisub\win32\config.h" (copy "..\..\aegisub\win32\config0.h" "..\..\aegisub\win32\config.h")
SubWCRev.exe "..\..\aegisub" "..\svn-revision-base.h" "..\svn-revision.h"
"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories="../../aegisub/win32;../../hunspell/src"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS"
|
||||
RuntimeLibrary="2"
|
||||
OpenMP="true"
|
||||
UsePrecompiledHeader="2"
|
||||
PrecompiledHeaderThrough="stdwx.h"
|
||||
WarningLevel="3"
|
||||
WarnAsError="true"
|
||||
Detect64BitPortabilityProblems="true"
|
||||
DebugInformationFormat="3"
|
||||
DisableSpecificWarnings="4267"
|
||||
ForcedIncludeFiles="stdwx.h;config.h"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
OutputFile="../../bin/aegisub.exe"
|
||||
LinkIncremental="1"
|
||||
AdditionalLibraryDirectories="../../lib"
|
||||
GenerateManifest="true"
|
||||
DelayLoadDLLs="perl510.dll"
|
||||
GenerateDebugInformation="true"
|
||||
SubSystem="2"
|
||||
OptimizeReferences="2"
|
||||
EnableCOMDATFolding="2"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|x64"
|
||||
OutputDirectory="$(SolutionDir)$(PlatformName)\$(ConfigurationName)"
|
||||
|
@ -943,7 +943,7 @@
|
|||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
Name="Debug|x64"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
|
@ -951,7 +951,7 @@
|
|||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Debug|x64"
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
|
@ -983,7 +983,7 @@
|
|||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
Name="Debug|x64"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
|
@ -991,7 +991,7 @@
|
|||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Debug|x64"
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
|
@ -1431,7 +1431,7 @@
|
|||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
Name="Debug|x64"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
|
@ -1439,7 +1439,7 @@
|
|||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Debug|x64"
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
|
@ -1643,6 +1643,14 @@
|
|||
RelativePath="..\..\aegisub\subtitle_format_ass.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\aegisub\subtitle_format_dvd.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\aegisub\subtitle_format_dvd.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\aegisub\subtitle_format_encore.cpp"
|
||||
>
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
;
|
||||
|
||||
#define MyAppName "Aegisub"
|
||||
#define MyAppRevision "r1787"
|
||||
#define MyAppRevision "r1800"
|
||||
#define MyAppVerName "Aegisub 2.00 alpha"
|
||||
#define MyAppPublisher "Aegisub Team"
|
||||
#define MyAppURL "http://aegisub.net/"
|
||||
|
|
Loading…
Reference in New Issue