From b102ed05c1c07ae2044120fb9da3407ca1ae33b3 Mon Sep 17 00:00:00 2001 From: Rodrigo Braz Monteiro Date: Tue, 18 Mar 2008 05:24:21 +0000 Subject: [PATCH] Fixed dummy video provider and possibly fixed dvd sub generation. Originally committed to SVN as r2079. --- aegilib/aegilib.vcproj | 16 ++- aegilib/include/aegilib/controller.h | 152 +++++++++++++-------------- aegisub/dialog_dummy_video.cpp | 31 +++--- aegisub/subtitle_format_dvd.cpp | 6 +- 4 files changed, 112 insertions(+), 93 deletions(-) diff --git a/aegilib/aegilib.vcproj b/aegilib/aegilib.vcproj index 82dd8e39f..8043c7fed 100644 --- a/aegilib/aegilib.vcproj +++ b/aegilib/aegilib.vcproj @@ -19,7 +19,7 @@ Name="Debug|Win32" OutputDirectory="$(SolutionDir)$(ConfigurationName)" IntermediateDirectory="$(ConfigurationName)" - ConfigurationType="4" + ConfigurationType="2" CharacterSet="1" > + @@ -79,6 +83,12 @@ + + @@ -108,6 +118,8 @@ /> ActionListPtr; - - // Controller class - class Controller { - private: - Model &model; - - public: - Controller (Model &model); - ActionListPtr CreateActionList(const String title,const String owner=L"",bool undoAble=true); - - void LoadFile(const String filename,const String encoding=L""); - void SaveFile(const String filename,const String encoding=L"UTF-8"); - - bool CanUndo(const String owner=L"") const; - bool CanRedo(const String owner=L"") const; - void Undo(const String owner=L""); - void Redo(const String owner=L""); - - DialoguePtr CreateDialogue() const; - StylePtr CreateStyle() const; - - DialogueConstPtr GetDialogue(size_t n) const; - DialogueConstPtr GetStyle(size_t n) const; - StyleConstPtr GetStyle(String name) const; - EntryConstPtr GetEntry(size_t n,String section) const; - - const FormatPtr GetFormat() const; - }; - -} +// 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/ATHENASUB +// +// Website: http://www.aegisub.net +// Contact: mailto:amz@aegisub.net +// + +#pragma once +#include "athenastring.h" +#include "tr1.h" +#include "format.h" + +namespace Athenasub { + + // Prototypes + class Model; + class ActionList; + typedef shared_ptr ActionListPtr; + + // Controller class + class Controller { + private: + Model &model; + + public: + Controller (Model &model); + ActionListPtr CreateActionList(const String title,const String owner=L"",bool undoAble=true); + + void LoadFile(const String filename,const String encoding=L""); + void SaveFile(const String filename,const String encoding=L"UTF-8"); + + bool CanUndo(const String owner=L"") const; + bool CanRedo(const String owner=L"") const; + void Undo(const String owner=L""); + void Redo(const String owner=L""); + + DialoguePtr CreateDialogue() const; + StylePtr CreateStyle() const; + + DialogueConstPtr GetDialogue(size_t n) const; + DialogueConstPtr GetStyle(size_t n) const; + StyleConstPtr GetStyle(String name) const; + EntryConstPtr GetEntry(size_t n,String section) const; + + const FormatPtr GetFormat() const; + }; + +} diff --git a/aegisub/dialog_dummy_video.cpp b/aegisub/dialog_dummy_video.cpp index af84bf1c6..dd9849f37 100644 --- a/aegisub/dialog_dummy_video.cpp +++ b/aegisub/dialog_dummy_video.cpp @@ -238,19 +238,26 @@ void DialogDummyVideo::OnLengthChange(wxCommandEvent &evt) void DialogDummyVideo::UpdateLengthDisplay() { double fpsval; - int lengthval = length->GetValue(); + int lengthval = 0; if (!length_display) return; - if ((fps->GetValue().ToDouble(&fpsval)) && fpsval > 0 && lengthval > 0) { - int tt = int(lengthval / fpsval * 1000); // frames / (frames/seconds) * 1000 = milliseconds - // 32 bit signed int can hold almost 600 positive hours when counting milliseconds, ASS allows at most just below 10 hours, so we're safe - int ms, s, m, h; - ms = tt % 1000; tt /= 1000; - s = tt % 60; tt /= 60; - m = tt % 60; tt /= 60; - h = tt; - length_display->SetLabel(wxString::Format(_("Resulting duration: %d:%02d:%02d.%03d"), h, m, s, ms)); - ok_button->Enable(); - } else { + bool valid = false; + if (fps->GetValue().ToDouble(&fpsval)) { + lengthval = length->GetValue(); + if (lengthval && fpsval > 0 && lengthval > 0) { + valid = true; + int tt = int(lengthval / fpsval * 1000); // frames / (frames/seconds) * 1000 = milliseconds + // 32 bit signed int can hold almost 600 positive hours when counting milliseconds, ASS allows at most just below 10 hours, so we're safe + int ms, s, m, h; + ms = tt % 1000; tt /= 1000; + s = tt % 60; tt /= 60; + m = tt % 60; tt /= 60; + h = tt; + length_display->SetLabel(wxString::Format(_("Resulting duration: %d:%02d:%02d.%03d"), h, m, s, ms)); + ok_button->Enable(); + } + } + + if (!valid) { length_display->SetLabel(_("Invalid fps or length value")); ok_button->Disable(); } diff --git a/aegisub/subtitle_format_dvd.cpp b/aegisub/subtitle_format_dvd.cpp index a1ab9579f..097165318 100644 --- a/aegisub/subtitle_format_dvd.cpp +++ b/aegisub/subtitle_format_dvd.cpp @@ -363,8 +363,8 @@ void DVDSubtitleFormat::WriteFile(wxString filename,wxString encoding) { unsigned char delay_b2 = delay & 0xFF; int sx = pics[i].x; int sy = pics[i].y; - int ex = pics[i].w + sx; - int ey = pics[i].h + sy; + int ex = pics[i].w + sx - 1; + int ey = pics[i].h + sy - 1; unsigned char dispx_b1 = (sx & 0xFF0) >> 4; unsigned char dispx_b2 = ((sx & 0x0F) << 4) | ((ex & 0xF00) >> 8); unsigned char dispx_b3 = (ex & 0xFF); @@ -376,11 +376,11 @@ void DVDSubtitleFormat::WriteFile(wxString filename,wxString encoding) { unsigned char control[] = { 0x00, 0x00, // Delay comm2_b1, comm2_b2, // Next command - 0x01, // Start display 0x03, 0x01, 0x23, // Set colours 0x04, 0x0F, 0xFF, // Alpha blend 0x05, dispx_b1, dispx_b2, dispx_b3, dispy_b1, dispy_b2, dispy_b3, // Display area 0x06, pix0_b1, pix0_b2, pix1_b1, pix1_b2, // Pixel pointers + 0x01, // Start display 0xFF, // End block 1 delay_b1, delay_b2, // Delay comm2_b1, comm2_b2, // This command