Added support for adobe encore export (both PAL and NTSC)

Originally committed to SVN as r1262.
This commit is contained in:
Rodrigo Braz Monteiro 2007-06-19 05:04:15 +00:00
parent e1df257ff4
commit fd9f14573d
10 changed files with 203 additions and 14 deletions

View File

@ -185,6 +185,7 @@ aegisub_SOURCES = \
subs_preview.cpp \
subtitle_format.cpp \
subtitle_format_ass.cpp \
subtitle_format_encore.cpp \
subtitle_format_microdvd.cpp \
subtitle_format_mkv.cpp \
subtitle_format_srt.cpp \

View File

@ -278,3 +278,12 @@ bool operator != (AssTime &t1, AssTime &t2) {
/////////////////
// Static option
bool AssTime::UseMSPrecision = false;
///////
// Get
int AssTime::GetTimeHours() { return time / 3600000; }
int AssTime::GetTimeMinutes() { return (time % 3600000)/60000; }
int AssTime::GetTimeSeconds() { return (time % 60000)/1000; }
int AssTime::GetTimeMiliseconds() { return (time % 1000); }
int AssTime::GetTimeCentiseconds() { return (time % 1000)/10; }

View File

@ -53,6 +53,12 @@ public:
AssTime();
int GetTimeHours();
int GetTimeMinutes();
int GetTimeSeconds();
int GetTimeMiliseconds();
int GetTimeCentiseconds();
int GetMS(); // Returns miliseconds
void SetMS(int ms); // Sets values to miliseconds
void ParseASS(const wxString text); // Sets value to text-form time, in ASS format

View File

@ -43,6 +43,7 @@
#include "subtitle_format_ttxt.h"
#include "subtitle_format_mkv.h"
#include "subtitle_format_microdvd.h"
#include "subtitle_format_encore.h"
#include "ass_file.h"
#include "vfr.h"
@ -129,6 +130,7 @@ void SubtitleFormat::LoadFormats () {
new TTXTSubtitleFormat();
new MicroDVDSubtitleFormat();
new MKVSubtitleFormat();
new EncoreSubtitleFormat();
}
loaded = true;
}
@ -267,11 +269,11 @@ wxString SubtitleFormat::GetWildcards(int mode) {
/////////////////////////////////
// Ask the user to enter the FPS
double SubtitleFormat::AskForFPS() {
double SubtitleFormat::AskForFPS(bool palNtscOnly) {
wxArrayString choices;
// Video FPS
bool vidLoaded = VFR_Output.IsLoaded();
bool vidLoaded = !palNtscOnly && VFR_Output.IsLoaded();
if (vidLoaded) {
wxString vidFPS;
if (VFR_Output.GetFrameRateType() == VFR) vidFPS = _T("VFR");
@ -280,21 +282,31 @@ double SubtitleFormat::AskForFPS() {
}
// Standard FPS values
choices.Add(_("15.000 FPS"));
choices.Add(_("23.976 FPS (Decimated NTSC)"));
choices.Add(_("24.000 FPS (FILM)"));
if (!palNtscOnly) {
choices.Add(_("15.000 FPS"));
choices.Add(_("23.976 FPS (Decimated NTSC)"));
choices.Add(_("24.000 FPS (FILM)"));
}
choices.Add(_("25.000 FPS (PAL)"));
choices.Add(_("29.970 FPS (NTSC)"));
choices.Add(_("30.000 FPS"));
choices.Add(_("59.940 FPS (NTSC x2)"));
choices.Add(_("60.000 FPS"));
choices.Add(_("119.880 FPS (NTSC x4)"));
choices.Add(_("120.000 FPS"));
if (!palNtscOnly) {
choices.Add(_("30.000 FPS"));
choices.Add(_("59.940 FPS (NTSC x2)"));
choices.Add(_("60.000 FPS"));
choices.Add(_("119.880 FPS (NTSC x4)"));
choices.Add(_("120.000 FPS"));
}
// Ask
int choice = wxGetSingleChoiceIndex(_("Please choose the appropriate FPS for the subtitles:"),_("FPS"),choices);
if (choice == -1) return 0.0;
// PAL/NTSC choice
if (palNtscOnly) {
if (choice == 0) return 25.0;
else return 30.0 / 1.001;
}
// Get FPS from choice
if (vidLoaded) choice--;
switch (choice) {

View File

@ -75,7 +75,7 @@ protected:
void LoadDefault(bool defline=true);
AssFile *GetAssFile() { return assFile; }
int AddLine(wxString data,wxString group,int lasttime,int &version,wxString *outgroup=NULL);
double AskForFPS();
double AskForFPS(bool palNtscOnly=false);
virtual wxString GetName()=0;
virtual wxArrayString GetReadWildcards();

View File

@ -0,0 +1,108 @@
// Copyright (c) 2007, 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
//
///////////
// Headers
#include "ass_dialogue.h"
#include "subtitle_format_encore.h"
#include "text_file_writer.h"
////////
// Name
wxString EncoreSubtitleFormat::GetName() {
return _T("Adobe Encore");
}
/////////////
// Wildcards
wxArrayString EncoreSubtitleFormat::GetWriteWildcards() {
wxArrayString formats;
formats.Add(_T("encore.txt"));
return formats;
}
///////////////////
// Can write file?
bool EncoreSubtitleFormat::CanWriteFile(wxString filename) {
return (filename.Right(11).Lower() == _T(".encore.txt"));
}
//////////////
// Write file
void EncoreSubtitleFormat::WriteFile(wxString _filename,wxString encoding) {
// Get FPS
double fps = AskForFPS(true);
if (fps <= 0.0) return;
// Open file
TextFileWriter file(_filename,encoding);
// Convert to encore
CreateCopy();
SortLines();
Merge(true,true,true);
ConvertTags(1,_T("\r\n"));
// 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 && !current->Comment) {
// Time stamps
i++;
AssTime time = current->Start;
int f = int(time.GetTimeMiliseconds() * fps / 1000.0 + 0.5);
wxString timeStamps = wxString::Format(_T("%i %02i:%02i:%02i:%02i "),i,time.GetTimeHours(),time.GetTimeMinutes(),time.GetTimeSeconds(),f);
time = current->End;
f = int(time.GetTimeMiliseconds() * fps / 1000.0 + 0.5);
timeStamps += wxString::Format(_T("%02i:%02i:%02i:%02i "),time.GetTimeHours(),time.GetTimeMinutes(),time.GetTimeSeconds(),f);
// Convert : to ; if it's NTSC
if (fps > 26.0) timeStamps.Replace(_T(":"),_T(";"));
// Write
file.WriteLineToFile(timeStamps + current->Text);
}
}
// Clean up
ClearCopy();
}

View File

@ -0,0 +1,53 @@
// Copyright (c) 2007, 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"
///////////////////////
// Adobe Encore writer
class EncoreSubtitleFormat : public SubtitleFormat {
public:
wxString GetName();
wxArrayString GetWriteWildcards();
bool CanWriteFile(wxString filename);
void WriteFile(wxString filename,wxString encoding);
};

View File

@ -1,4 +1,4 @@
// Copyright (c) 2006, Rodrigo Braz Monteiro
// Copyright (c) 2007, Rodrigo Braz Monteiro
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without

View File

@ -1,4 +1,4 @@
// Copyright (c) 2006, Rodrigo Braz Monteiro
// Copyright (c) 2007, Rodrigo Braz Monteiro
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without

View File

@ -54,7 +54,7 @@ bool TXTSubtitleFormat::CanReadFile(wxString filename) {
//////////////
// Can write?
bool TXTSubtitleFormat::CanWriteFile(wxString filename) {
return (filename.Right(4).Lower() == _T(".txt"));
return (filename.Right(4).Lower() == _T(".txt") && filename.Right(11).Lower() != _T(".encore.txt"));
}