Overload operator int() on AssTime and remove GetMS/SetMS
Originally committed to SVN as r6123.
This commit is contained in:
parent
de9583004d
commit
71345af81a
37 changed files with 156 additions and 236 deletions
|
@ -418,11 +418,7 @@ void AssDialogue::ProcessParameters(AssDialogueBlockOverride::ProcessParametersC
|
|||
|
||||
bool AssDialogue::CollidesWith(AssDialogue *target) {
|
||||
if (!target) return false;
|
||||
int a = Start.GetMS();
|
||||
int b = End.GetMS();
|
||||
int c = target->Start.GetMS();
|
||||
int d = target->End.GetMS();
|
||||
return ((a < c) ? (c < b) : (a < d));
|
||||
return ((Start < target->Start) ? (target->Start < End) : (Start < target->End));
|
||||
}
|
||||
|
||||
wxString AssDialogue::GetStrippedText() const {
|
||||
|
|
|
@ -282,7 +282,7 @@ bool AssFile::CanSave() {
|
|||
curdiag = dynamic_cast<AssDialogue*>(*cur);
|
||||
if (curdiag) {
|
||||
// Timed?
|
||||
if (curdiag->Start.GetMS() != 0 || curdiag->End.GetMS() != 0) return false;
|
||||
if (curdiag->Start != 0 || curdiag->End != 0) return false;
|
||||
|
||||
// Overrides?
|
||||
curdiag->ParseASSTags();
|
||||
|
|
|
@ -65,7 +65,7 @@ void AssKaraoke::SetLine(AssDialogue *line, bool auto_split) {
|
|||
|
||||
syls.clear();
|
||||
Syllable syl;
|
||||
syl.start_time = line->Start.GetMS();
|
||||
syl.start_time = line->Start;
|
||||
syl.duration = 0;
|
||||
syl.tag_type = "\\k";
|
||||
|
||||
|
@ -133,7 +133,7 @@ void AssKaraoke::SetLine(AssDialogue *line, bool auto_split) {
|
|||
line->ClearBlocks();
|
||||
|
||||
// Normalize the syllables so that the total duration is equal to the line length
|
||||
int end_time = active_line->End.GetMS();
|
||||
int end_time = active_line->End;
|
||||
int last_end = syl.start_time + syl.duration;
|
||||
|
||||
// Total duration is shorter than the line length so just extend the last
|
||||
|
@ -142,7 +142,7 @@ void AssKaraoke::SetLine(AssDialogue *line, bool auto_split) {
|
|||
syls.back().duration += end_time - last_end;
|
||||
else if (last_end > end_time) {
|
||||
// Shrink each syllable proportionately
|
||||
int start_time = active_line->Start.GetMS();
|
||||
int start_time = active_line->Start;
|
||||
double scale_factor = double(end_time - start_time) / (last_end - start_time);
|
||||
|
||||
for (size_t i = 0; i < size(); ++i) {
|
||||
|
@ -285,8 +285,8 @@ void AssKaraoke::SplitLines(std::set<AssDialogue*> const& lines, agi::Context *c
|
|||
for (iterator kit = kara.begin(); kit != kara.end(); ++kit) {
|
||||
AssDialogue *new_line = new AssDialogue(*diag);
|
||||
|
||||
new_line->Start.SetMS(kit->start_time);
|
||||
new_line->End.SetMS(kit->start_time + kit->duration);
|
||||
new_line->Start = kit->start_time;
|
||||
new_line->End = kit->start_time + kit->duration;
|
||||
new_line->Text = kit->GetText(false);
|
||||
|
||||
c->ass->Line.insert(it, new_line);
|
||||
|
|
|
@ -45,7 +45,7 @@
|
|||
|
||||
#include "utils.h"
|
||||
|
||||
AssTime::AssTime(int time) { SetMS(time); }
|
||||
AssTime::AssTime(int time) : time(mid(0, time, 10 * 60 * 60 * 1000 - 1)) { }
|
||||
|
||||
void AssTime::ParseASS(wxString const& text) {
|
||||
int ms = 0;
|
||||
|
@ -72,15 +72,7 @@ void AssTime::ParseASS(wxString const& text) {
|
|||
// Milliseconds (includes seconds)
|
||||
ms += AegiStringToFix(text, 3, end, text.size());
|
||||
|
||||
SetMS(ms);
|
||||
}
|
||||
|
||||
int AssTime::GetMS() const {
|
||||
return time / 10 * 10;
|
||||
}
|
||||
|
||||
void AssTime::SetMS(int ms) {
|
||||
time = mid(0, ms, 10 * 60 * 60 * 1000 - 1);
|
||||
*this = AssTime(ms);
|
||||
}
|
||||
|
||||
wxString AssTime::GetASSFormated (bool msPrecision) const {
|
||||
|
@ -90,38 +82,6 @@ wxString AssTime::GetASSFormated (bool msPrecision) const {
|
|||
return wxString::Format("%d:%02d:%02d.%02d", GetTimeHours(), GetTimeMinutes(), GetTimeSeconds(), GetTimeCentiseconds());
|
||||
}
|
||||
|
||||
bool operator < (AssTime t1, AssTime t2) {
|
||||
return t1.GetMS() < t2.GetMS();
|
||||
}
|
||||
|
||||
bool operator > (AssTime t1, AssTime t2) {
|
||||
return t1.GetMS() > t2.GetMS();
|
||||
}
|
||||
|
||||
bool operator <= (AssTime t1, AssTime t2) {
|
||||
return t1.GetMS() <= t2.GetMS();
|
||||
}
|
||||
|
||||
bool operator >= (AssTime t1, AssTime t2) {
|
||||
return t1.GetMS() >= t2.GetMS();
|
||||
}
|
||||
|
||||
bool operator == (AssTime t1, AssTime t2) {
|
||||
return t1.GetMS() == t2.GetMS();
|
||||
}
|
||||
|
||||
bool operator != (AssTime t1, AssTime t2) {
|
||||
return t1.GetMS() != t2.GetMS();
|
||||
}
|
||||
|
||||
AssTime operator + (AssTime t1, AssTime t2) {
|
||||
return AssTime(t1.GetMS() + t2.GetMS());
|
||||
}
|
||||
|
||||
AssTime operator - (AssTime t1, AssTime t2) {
|
||||
return AssTime(t1.GetMS() - t2.GetMS());
|
||||
}
|
||||
|
||||
int AssTime::GetTimeHours() const { return time / 3600000; }
|
||||
int AssTime::GetTimeMinutes() const { return (time % 3600000) / 60000; }
|
||||
int AssTime::GetTimeSeconds() const { return (time % 60000) / 1000; }
|
||||
|
@ -134,16 +94,12 @@ FractionalTime::FractionalTime(agi::vfr::Framerate fps, bool dropframe)
|
|||
{
|
||||
}
|
||||
|
||||
wxString FractionalTime::FromAssTime(AssTime time, char sep) {
|
||||
return FromMillisecs(time.GetMS(), sep);
|
||||
}
|
||||
|
||||
wxString FractionalTime::FromMillisecs(int64_t msec, char sep) {
|
||||
wxString FractionalTime::ToSMPTE(AssTime time, char sep) {
|
||||
int h=0, m=0, s=0, f=0; // hours, minutes, seconds, fractions
|
||||
int fn = fps.FrameAtTime(msec);
|
||||
int fn = fps.FrameAtTime(time);
|
||||
|
||||
// return 00:00:00:00
|
||||
if (msec <= 0) {
|
||||
if (time <= 0) {
|
||||
}
|
||||
// dropframe?
|
||||
else if (drop) {
|
||||
|
|
|
@ -54,16 +54,15 @@ class AssTime {
|
|||
public:
|
||||
AssTime(int ms = 0);
|
||||
|
||||
/// Get millisecond, rounded to centisecond precision
|
||||
operator int() const { return time / 10 * 10; }
|
||||
|
||||
int GetTimeHours() const; ///< Get the hours portion of this time
|
||||
int GetTimeMinutes() const; ///< Get the minutes portion of this time
|
||||
int GetTimeSeconds() const; ///< Get the seconds portion of this time
|
||||
int GetTimeMiliseconds() const; ///< Get the miliseconds portion of this time
|
||||
int GetTimeCentiseconds() const; ///< Get the centiseconds portion of this time
|
||||
|
||||
/// Get millisecond, rounded to centisecond precision
|
||||
int GetMS() const;
|
||||
/// Sets values to milliseconds with bounds-checking
|
||||
void SetMS(int ms);
|
||||
/// Parse an ASS time string, leaving the time unchanged if the string is malformed
|
||||
void ParseASS(wxString const& text);
|
||||
/// Return the time as a string
|
||||
|
@ -71,17 +70,6 @@ public:
|
|||
wxString GetASSFormated(bool ms=false) const;
|
||||
};
|
||||
|
||||
// Comparison operators
|
||||
bool operator == (AssTime t1, AssTime t2);
|
||||
bool operator != (AssTime t1, AssTime t2);
|
||||
bool operator < (AssTime t1, AssTime t2);
|
||||
bool operator > (AssTime t1, AssTime t2);
|
||||
bool operator <= (AssTime t1, AssTime t2);
|
||||
bool operator >= (AssTime t1, AssTime t2);
|
||||
// Arithmetic operators
|
||||
AssTime operator + (AssTime t1, AssTime t2);
|
||||
AssTime operator - (AssTime t1, AssTime t2);
|
||||
|
||||
/// DOCME
|
||||
/// @class FractionalTime
|
||||
/// @brief DOCME
|
||||
|
@ -101,7 +89,5 @@ public:
|
|||
agi::vfr::Framerate const& FPS() const { return fps; }
|
||||
|
||||
/// Convert an AssTime to a SMPTE timecode
|
||||
wxString FromAssTime(AssTime time, char sep=':');
|
||||
/// Convert milliseconds to a SMPTE timecode
|
||||
wxString FromMillisecs(int64_t msec, char sep=':');
|
||||
wxString ToSMPTE(AssTime time, char sep=':');
|
||||
};
|
||||
|
|
|
@ -1058,8 +1058,7 @@ void AudioDisplay::SetTrackCursor(int new_pos, bool show_time)
|
|||
|
||||
if (show_time)
|
||||
{
|
||||
AssTime new_label_time;
|
||||
new_label_time.SetMS(controller->MillisecondsFromSamples(SamplesFromAbsoluteX(track_cursor_pos)));
|
||||
AssTime new_label_time = controller->MillisecondsFromSamples(SamplesFromAbsoluteX(track_cursor_pos));
|
||||
track_cursor_label = new_label_time.GetASSFormated();
|
||||
track_cursor_label_rect.x += new_pos - old_pos;
|
||||
RefreshRect(track_cursor_label_rect, false);
|
||||
|
|
|
@ -427,8 +427,8 @@ void AudioTimingControllerDialogue::Commit()
|
|||
context->selectionController->GetSelectedSet(sel);
|
||||
for (Selection::iterator sub = sel.begin(); sub != sel.end(); ++sub)
|
||||
{
|
||||
(*sub)->Start.SetMS(new_start_ms);
|
||||
(*sub)->End.SetMS(new_end_ms);
|
||||
(*sub)->Start = new_start_ms;
|
||||
(*sub)->End = new_end_ms;
|
||||
}
|
||||
|
||||
commit_connection.Block();
|
||||
|
@ -450,7 +450,7 @@ void AudioTimingControllerDialogue::Commit()
|
|||
/// like the edit box, so maybe add a way to do that which both
|
||||
/// this and the edit box can use
|
||||
Next();
|
||||
if (context->selectionController->GetActiveLine()->End.GetMS() == 0) {
|
||||
if (context->selectionController->GetActiveLine()->End == 0) {
|
||||
const int default_duration = OPT_GET("Timing/Default Duration")->GetInt();
|
||||
active_markers[0].SetPosition(context->audioController->SamplesFromMilliseconds(new_end_ms));
|
||||
active_markers[1].SetPosition(context->audioController->SamplesFromMilliseconds(new_end_ms + default_duration));
|
||||
|
@ -467,10 +467,10 @@ void AudioTimingControllerDialogue::Revert()
|
|||
AssTime new_start = line->Start;
|
||||
AssTime new_end = line->End;
|
||||
|
||||
if (new_start.GetMS() != 0 || new_end.GetMS() != 0)
|
||||
if (new_start != 0 || new_end != 0)
|
||||
{
|
||||
active_markers[0].SetPosition(context->audioController->SamplesFromMilliseconds(new_start.GetMS()));
|
||||
active_markers[1].SetPosition(context->audioController->SamplesFromMilliseconds(new_end.GetMS()));
|
||||
active_markers[0].SetPosition(context->audioController->SamplesFromMilliseconds(new_start));
|
||||
active_markers[1].SetPosition(context->audioController->SamplesFromMilliseconds(new_end));
|
||||
timing_modified = false;
|
||||
UpdateSelection();
|
||||
}
|
||||
|
@ -558,9 +558,9 @@ void AudioTimingControllerDialogue::RegenerateInactiveLines()
|
|||
if (AssDialogue *prev = dynamic_cast<AssDialogue*>(*it))
|
||||
{
|
||||
inactive_markers.push_back(InactiveLineMarker(
|
||||
context->audioController->SamplesFromMilliseconds(prev->Start.GetMS()), true));
|
||||
context->audioController->SamplesFromMilliseconds(prev->Start), true));
|
||||
inactive_markers.push_back(InactiveLineMarker(
|
||||
context->audioController->SamplesFromMilliseconds(prev->End.GetMS()), false));
|
||||
context->audioController->SamplesFromMilliseconds(prev->End), false));
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -574,9 +574,9 @@ void AudioTimingControllerDialogue::RegenerateInactiveLines()
|
|||
if (line && line != active_line)
|
||||
{
|
||||
inactive_markers.push_back(InactiveLineMarker(
|
||||
context->audioController->SamplesFromMilliseconds(line->Start.GetMS()), true));
|
||||
context->audioController->SamplesFromMilliseconds(line->Start), true));
|
||||
inactive_markers.push_back(InactiveLineMarker(
|
||||
context->audioController->SamplesFromMilliseconds(line->End.GetMS()), false));
|
||||
context->audioController->SamplesFromMilliseconds(line->End), false));
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -151,8 +151,8 @@ AudioTimingControllerKaraoke::AudioTimingControllerKaraoke(agi::Context *c, AssK
|
|||
, separator_pen("Colour/Audio Display/Syllable Boundaries", "Audio/Line Boundaries Thickness", wxPENSTYLE_DOT)
|
||||
, start_pen("Colour/Audio Display/Line boundary Start", "Audio/Line Boundaries Thickness")
|
||||
, end_pen("Colour/Audio Display/Line boundary End", "Audio/Line Boundaries Thickness")
|
||||
, start_marker(ToSamples(active_line->Start.GetMS()), &start_pen, AudioMarker::Feet_Right)
|
||||
, end_marker(ToSamples(active_line->End.GetMS()), &end_pen, AudioMarker::Feet_Left)
|
||||
, start_marker(ToSamples(active_line->Start), &start_pen, AudioMarker::Feet_Right)
|
||||
, end_marker(ToSamples(active_line->End), &end_pen, AudioMarker::Feet_Left)
|
||||
, keyframes_provider(c, "Audio/Display/Draw/Keyframes in Karaoke Mode")
|
||||
, auto_commit(OPT_GET("Audio/Auto/Commit")->GetBool())
|
||||
, auto_next(OPT_GET("Audio/Next Line on Commit")->GetBool())
|
||||
|
@ -253,8 +253,8 @@ void AudioTimingControllerKaraoke::Revert() {
|
|||
cur_syl = 0;
|
||||
commit_id = -1;
|
||||
|
||||
start_marker.Move(ToSamples(active_line->Start.GetMS()));
|
||||
end_marker.Move(ToSamples(active_line->End.GetMS()));
|
||||
start_marker.Move(ToSamples(active_line->Start));
|
||||
end_marker.Move(ToSamples(active_line->End));
|
||||
|
||||
markers.clear();
|
||||
labels.clear();
|
||||
|
|
|
@ -219,8 +219,8 @@ namespace Automation4 {
|
|||
|
||||
set_field(L, "layer", dia->Layer);
|
||||
|
||||
set_field(L, "start_time", dia->Start.GetMS());
|
||||
set_field(L, "end_time", dia->End.GetMS());
|
||||
set_field(L, "start_time", dia->Start);
|
||||
set_field(L, "end_time", dia->End);
|
||||
|
||||
set_field(L, "style", dia->Style);
|
||||
set_field(L, "actor", dia->Actor);
|
||||
|
@ -351,8 +351,8 @@ namespace Automation4 {
|
|||
|
||||
dia->Comment = get_bool_field(L, "comment", "dialogue");
|
||||
dia->Layer = get_int_field(L, "layer", "dialogue");
|
||||
dia->Start.SetMS(get_int_field(L, "start_time", "dialogue"));
|
||||
dia->End.SetMS(get_int_field(L, "end_time", "dialogue"));
|
||||
dia->Start = get_int_field(L, "start_time", "dialogue");
|
||||
dia->End = get_int_field(L, "end_time", "dialogue");
|
||||
dia->Style = get_string_field(L, "style", "dialogue");
|
||||
dia->Actor = get_string_field(L, "actor", "dialogue");
|
||||
dia->Margin[0] = get_int_field(L, "margin_l", "dialogue");
|
||||
|
|
|
@ -604,8 +604,8 @@ void BaseGrid::GetRowStrings(int row, AssDialogue *line, bool *paint_columns, wx
|
|||
if (paint_columns[0]) strings[0] = wxString::Format("%d", row + 1);
|
||||
if (paint_columns[1]) strings[1] = wxString::Format("%d", line->Layer);
|
||||
if (byFrame) {
|
||||
if (paint_columns[2]) strings[2] = wxString::Format("%d", context->videoController->FrameAtTime(line->Start.GetMS(), agi::vfr::START));
|
||||
if (paint_columns[3]) strings[3] = wxString::Format("%d", context->videoController->FrameAtTime(line->End.GetMS(), agi::vfr::END));
|
||||
if (paint_columns[2]) strings[2] = wxString::Format("%d", context->videoController->FrameAtTime(line->Start, agi::vfr::START));
|
||||
if (paint_columns[3]) strings[3] = wxString::Format("%d", context->videoController->FrameAtTime(line->End, agi::vfr::END));
|
||||
}
|
||||
else {
|
||||
if (paint_columns[2]) strings[2] = line->Start.GetASSFormated();
|
||||
|
@ -737,7 +737,7 @@ void BaseGrid::OnMouseEvent(wxMouseEvent &event) {
|
|||
// Normal click
|
||||
if ((click || dclick) && !shift && !ctrl && !alt) {
|
||||
SetActiveLine(dlg);
|
||||
if (dclick) context->videoController->JumpToTime(dlg->Start.GetMS());
|
||||
if (dclick) context->videoController->JumpToTime(dlg->Start);
|
||||
SelectRow(row,false);
|
||||
lastRow = row;
|
||||
return;
|
||||
|
@ -887,8 +887,8 @@ void BaseGrid::SetColumnWidths() {
|
|||
|
||||
// Times
|
||||
if (byFrame) {
|
||||
maxStart = std::max(maxStart, context->videoController->FrameAtTime(curDiag->Start.GetMS(), agi::vfr::START));
|
||||
maxEnd = std::max(maxEnd, context->videoController->FrameAtTime(curDiag->End.GetMS(), agi::vfr::END));
|
||||
maxStart = std::max(maxStart, context->videoController->FrameAtTime(curDiag->Start, agi::vfr::START));
|
||||
maxEnd = std::max(maxEnd, context->videoController->FrameAtTime(curDiag->End, agi::vfr::END));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -970,8 +970,8 @@ bool BaseGrid::IsDisplayed(const AssDialogue *line) const {
|
|||
if (!context->videoController->IsLoaded()) return false;
|
||||
int frame = context->videoController->GetFrameN();
|
||||
return
|
||||
context->videoController->FrameAtTime(line->Start.GetMS(),agi::vfr::START) <= frame &&
|
||||
context->videoController->FrameAtTime(line->End.GetMS(),agi::vfr::END) >= frame;
|
||||
context->videoController->FrameAtTime(line->Start,agi::vfr::START) <= frame &&
|
||||
context->videoController->FrameAtTime(line->End,agi::vfr::END) >= frame;
|
||||
}
|
||||
|
||||
void BaseGrid::OnKeyDown(wxKeyEvent &event) {
|
||||
|
|
|
@ -212,8 +212,8 @@ struct audio_save_clip : public Command {
|
|||
for (Selection::iterator it = sel.begin(); it != sel.end(); ++it) {
|
||||
c->audioController->SaveClip(
|
||||
wxFileSelector(_("Save audio clip"), "", "", "wav", "", wxFD_SAVE|wxFD_OVERWRITE_PROMPT, c->parent),
|
||||
SampleRange(c->audioController->SamplesFromMilliseconds((*it)->Start.GetMS()),
|
||||
c->audioController->SamplesFromMilliseconds((*it)->End.GetMS())));
|
||||
SampleRange(c->audioController->SamplesFromMilliseconds((*it)->Start),
|
||||
c->audioController->SamplesFromMilliseconds((*it)->End)));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -185,7 +185,7 @@ static void combine_lines(agi::Context *c, void (*combiner)(AssDialogue *, AssDi
|
|||
|
||||
combiner(first, diag);
|
||||
|
||||
first->End.SetMS(diag->End.GetMS());
|
||||
first->End = diag->End;
|
||||
delete diag;
|
||||
}
|
||||
|
||||
|
@ -198,7 +198,7 @@ static void combine_lines(agi::Context *c, void (*combiner)(AssDialogue *, AssDi
|
|||
}
|
||||
|
||||
static void combine_karaoke(AssDialogue *first, AssDialogue *second) {
|
||||
first->Text += wxString::Format("{\\k%d}%s", (second->Start.GetMS() - first->End.GetMS()) / 10, second->Text);
|
||||
first->Text += wxString::Format("{\\k%d}%s", (second->Start - first->End) / 10, second->Text);
|
||||
}
|
||||
|
||||
static void combine_concat(AssDialogue *first, AssDialogue *second) {
|
||||
|
|
|
@ -128,8 +128,8 @@ static void insert_subtitle_at_video(agi::Context *c, bool after) {
|
|||
// Create line to add
|
||||
AssDialogue *def = new AssDialogue;
|
||||
int video_ms = c->videoController->TimeAtFrame(c->videoController->GetFrameN(), agi::vfr::START);
|
||||
def->Start.SetMS(video_ms);
|
||||
def->End.SetMS(video_ms + OPT_GET("Timing/Default Duration")->GetInt());
|
||||
def->Start = video_ms;
|
||||
def->End = video_ms + OPT_GET("Timing/Default Duration")->GetInt();
|
||||
def->Style = c->subsGrid->GetDialogue(n)->Style;
|
||||
|
||||
// Insert it
|
||||
|
@ -156,13 +156,13 @@ struct subtitle_insert_after : public validate_nonempty_selection {
|
|||
if (n == nrows-1) {
|
||||
def->Start = c->subsGrid->GetDialogue(n)->End;
|
||||
def->End = c->subsGrid->GetDialogue(n)->End;
|
||||
def->End.SetMS(def->End.GetMS()+OPT_GET("Timing/Default Duration")->GetInt());
|
||||
def->End = def->End + OPT_GET("Timing/Default Duration")->GetInt();
|
||||
}
|
||||
else {
|
||||
def->Start = c->subsGrid->GetDialogue(n)->End;
|
||||
def->End = c->subsGrid->GetDialogue(n+1)->Start;
|
||||
}
|
||||
if (def->End.GetMS() < def->Start.GetMS()) def->End.SetMS(def->Start.GetMS()+OPT_GET("Timing/Default Duration")->GetInt());
|
||||
if (def->End < def->Start) def->End = def->Start + OPT_GET("Timing/Default Duration")->GetInt();
|
||||
def->Style = c->subsGrid->GetDialogue(n)->Style;
|
||||
|
||||
// Insert it
|
||||
|
@ -200,18 +200,18 @@ struct subtitle_insert_before : public validate_nonempty_selection {
|
|||
// Create line to add
|
||||
AssDialogue *def = new AssDialogue;
|
||||
if (n == 0) {
|
||||
def->Start.SetMS(0);
|
||||
def->Start = 0;
|
||||
def->End = c->subsGrid->GetDialogue(n)->Start;
|
||||
}
|
||||
else if (c->subsGrid->GetDialogue(n-1)->End.GetMS() > c->subsGrid->GetDialogue(n)->Start.GetMS()) {
|
||||
def->Start.SetMS(c->subsGrid->GetDialogue(n)->Start.GetMS()-OPT_GET("Timing/Default Duration")->GetInt());
|
||||
else if (c->subsGrid->GetDialogue(n-1)->End > c->subsGrid->GetDialogue(n)->Start) {
|
||||
def->Start = c->subsGrid->GetDialogue(n)->Start-OPT_GET("Timing/Default Duration")->GetInt();
|
||||
def->End = c->subsGrid->GetDialogue(n)->Start;
|
||||
}
|
||||
else {
|
||||
def->Start = c->subsGrid->GetDialogue(n-1)->End;
|
||||
def->End = c->subsGrid->GetDialogue(n)->Start;
|
||||
}
|
||||
if (def->End.GetMS() < def->Start.GetMS()) def->End.SetMS(def->Start.GetMS()+OPT_GET("Timing/Default Duration")->GetInt());
|
||||
if (def->End < def->Start) def->End = def->Start+OPT_GET("Timing/Default Duration")->GetInt();
|
||||
def->Style = c->subsGrid->GetDialogue(n)->Style;
|
||||
|
||||
// Insert it
|
||||
|
@ -408,8 +408,8 @@ struct subtitle_select_visible : public Command {
|
|||
for (entryIter it = c->ass->Line.begin(); it != c->ass->Line.end(); ++it) {
|
||||
AssDialogue *diag = dynamic_cast<AssDialogue*>(*it);
|
||||
if (diag &&
|
||||
c->videoController->FrameAtTime(diag->Start.GetMS(), agi::vfr::START) <= frame &&
|
||||
c->videoController->FrameAtTime(diag->End.GetMS(), agi::vfr::END) >= frame)
|
||||
c->videoController->FrameAtTime(diag->Start, agi::vfr::START) <= frame &&
|
||||
c->videoController->FrameAtTime(diag->End, agi::vfr::END) >= frame)
|
||||
{
|
||||
if (new_selection.empty())
|
||||
c->selectionController->SetActiveLine(diag);
|
||||
|
|
|
@ -135,11 +135,11 @@ struct time_frame_current : public validate_video_loaded {
|
|||
|
||||
if (sel.empty() || !active_line) return;
|
||||
|
||||
int shift_by = c->videoController->TimeAtFrame(c->videoController->GetFrameN(), agi::vfr::START) - active_line->Start.GetMS();
|
||||
int shift_by = c->videoController->TimeAtFrame(c->videoController->GetFrameN(), agi::vfr::START) - active_line->Start;
|
||||
|
||||
for (std::set<AssDialogue*>::iterator it = sel.begin(); it != sel.end(); ++it) {
|
||||
(*it)->Start.SetMS((*it)->Start.GetMS() + shift_by);
|
||||
(*it)->End.SetMS((*it)->End.GetMS() + shift_by);
|
||||
(*it)->Start = (*it)->Start + shift_by;
|
||||
(*it)->End = (*it)->End + shift_by;
|
||||
}
|
||||
|
||||
c->ass->Commit(_("shift to frame"), AssFile::COMMIT_DIAG_TIME);
|
||||
|
@ -169,10 +169,10 @@ static void snap_subs_video(agi::Context *c, bool set_start) {
|
|||
int end = c->videoController->TimeAtFrame(c->videoController->GetFrameN(), agi::vfr::END);
|
||||
|
||||
for (std::set<AssDialogue*>::iterator it = sel.begin(); it != sel.end(); ++it) {
|
||||
if (set_start || (*it)->Start.GetMS() > start)
|
||||
(*it)->Start.SetMS(start);
|
||||
if (!set_start || (*it)->End.GetMS() < end)
|
||||
(*it)->End.SetMS(end);
|
||||
if (set_start || (*it)->Start > start)
|
||||
(*it)->Start = start;
|
||||
if (!set_start || (*it)->End < end)
|
||||
(*it)->End = end;
|
||||
}
|
||||
|
||||
c->ass->Commit(_("timing"), AssFile::COMMIT_DIAG_TIME);
|
||||
|
@ -235,8 +235,8 @@ struct time_snap_scene : public validate_video_loaded {
|
|||
// Update rows
|
||||
for (size_t i=0;i<sel.Count();i++) {
|
||||
cur = c->subsGrid->GetDialogue(sel[i]);
|
||||
cur->Start.SetMS(start_ms);
|
||||
cur->End.SetMS(end_ms);
|
||||
cur->Start = start_ms;
|
||||
cur->End = end_ms;
|
||||
}
|
||||
|
||||
// Commit
|
||||
|
@ -251,7 +251,7 @@ struct time_add_lead_in : public Command {
|
|||
STR_HELP("Add lead in")
|
||||
void operator()(agi::Context *c) {
|
||||
if (AssDialogue *line = c->selectionController->GetActiveLine()) {
|
||||
line->Start.SetMS(line->Start.GetMS() - OPT_GET("Audio/Lead/IN")->GetInt());
|
||||
line->Start = line->Start - OPT_GET("Audio/Lead/IN")->GetInt();
|
||||
c->ass->Commit(_("add lead in"), AssFile::COMMIT_DIAG_TIME);
|
||||
}
|
||||
}
|
||||
|
@ -264,7 +264,7 @@ struct time_add_lead_out : public Command {
|
|||
STR_HELP("Add lead out")
|
||||
void operator()(agi::Context *c) {
|
||||
if (AssDialogue *line = c->selectionController->GetActiveLine()) {
|
||||
line->End.SetMS(line->End.GetMS() + OPT_GET("Audio/Lead/OUT")->GetInt());
|
||||
line->End = line->End + OPT_GET("Audio/Lead/OUT")->GetInt();
|
||||
c->ass->Commit(_("add lead out"), AssFile::COMMIT_DIAG_TIME);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -353,13 +353,13 @@ struct video_frame_next_boundary : public validator_video_loaded {
|
|||
AssDialogue *active_line = c->selectionController->GetActiveLine();
|
||||
if (!active_line) return;
|
||||
|
||||
int target = c->videoController->FrameAtTime(active_line->Start.GetMS(), agi::vfr::START);
|
||||
int target = c->videoController->FrameAtTime(active_line->Start, agi::vfr::START);
|
||||
if (target > c->videoController->GetFrameN()) {
|
||||
c->videoController->JumpToFrame(target);
|
||||
return;
|
||||
}
|
||||
|
||||
target = c->videoController->FrameAtTime(active_line->End.GetMS(), agi::vfr::END);
|
||||
target = c->videoController->FrameAtTime(active_line->End, agi::vfr::END);
|
||||
if (target > c->videoController->GetFrameN()) {
|
||||
c->videoController->JumpToFrame(target);
|
||||
return;
|
||||
|
@ -368,7 +368,7 @@ struct video_frame_next_boundary : public validator_video_loaded {
|
|||
c->selectionController->NextLine();
|
||||
AssDialogue *new_line = c->selectionController->GetActiveLine();
|
||||
if (new_line != active_line)
|
||||
c->videoController->JumpToTime(new_line->Start.GetMS());
|
||||
c->videoController->JumpToTime(new_line->Start);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -424,13 +424,13 @@ struct video_frame_prev_boundary : public validator_video_loaded {
|
|||
AssDialogue *active_line = c->selectionController->GetActiveLine();
|
||||
if (!active_line) return;
|
||||
|
||||
int target = c->videoController->FrameAtTime(active_line->End.GetMS(), agi::vfr::END);
|
||||
int target = c->videoController->FrameAtTime(active_line->End, agi::vfr::END);
|
||||
if (target < c->videoController->GetFrameN()) {
|
||||
c->videoController->JumpToFrame(target);
|
||||
return;
|
||||
}
|
||||
|
||||
target = c->videoController->FrameAtTime(active_line->Start.GetMS(), agi::vfr::START);
|
||||
target = c->videoController->FrameAtTime(active_line->Start, agi::vfr::START);
|
||||
if (target < c->videoController->GetFrameN()) {
|
||||
c->videoController->JumpToFrame(target);
|
||||
return;
|
||||
|
@ -439,7 +439,7 @@ struct video_frame_prev_boundary : public validator_video_loaded {
|
|||
c->selectionController->PrevLine();
|
||||
AssDialogue *new_line = c->selectionController->GetActiveLine();
|
||||
if (new_line != active_line)
|
||||
c->videoController->JumpToTime(new_line->End.GetMS(), agi::vfr::END);
|
||||
c->videoController->JumpToTime(new_line->End, agi::vfr::END);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -560,7 +560,7 @@ struct video_jump_end : public validator_video_loaded {
|
|||
|
||||
void operator()(agi::Context *c) {
|
||||
if (AssDialogue *active_line = c->selectionController->GetActiveLine()) {
|
||||
c->videoController->JumpToTime(active_line->End.GetMS(), agi::vfr::END);
|
||||
c->videoController->JumpToTime(active_line->End, agi::vfr::END);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -574,7 +574,7 @@ struct video_jump_start : public validator_video_loaded {
|
|||
|
||||
void operator()(agi::Context *c) {
|
||||
if (AssDialogue *active_line = c->selectionController->GetActiveLine()) {
|
||||
c->videoController->JumpToTime(active_line->Start.GetMS());
|
||||
c->videoController->JumpToTime(active_line->Start);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -62,8 +62,7 @@ DialogJumpTo::DialogJumpTo(agi::Context *c)
|
|||
SetIcon(BitmapToIcon(GETIMAGE(jumpto_button_24)));
|
||||
|
||||
// Set initial values
|
||||
AssTime jumptime;
|
||||
jumptime.SetMS(c->videoController->TimeAtFrame(jumpframe));
|
||||
AssTime jumptime = c->videoController->TimeAtFrame(jumpframe);
|
||||
wxString maxLength = wxString::Format("%i",c->videoController->GetLength() - 1);
|
||||
|
||||
// Times
|
||||
|
@ -111,7 +110,7 @@ void DialogJumpTo::OnOK(wxCommandEvent &) {
|
|||
}
|
||||
|
||||
void DialogJumpTo::OnEditTime (wxCommandEvent &) {
|
||||
long newframe = c->videoController->FrameAtTime(JumpTime->GetMS());
|
||||
long newframe = c->videoController->FrameAtTime(JumpTime->GetTime());
|
||||
if (jumpframe != newframe) {
|
||||
jumpframe = newframe;
|
||||
JumpFrame->ChangeValue(wxString::Format("%i", jumpframe));
|
||||
|
@ -120,5 +119,5 @@ void DialogJumpTo::OnEditTime (wxCommandEvent &) {
|
|||
|
||||
void DialogJumpTo::OnEditFrame (wxCommandEvent &event) {
|
||||
JumpFrame->GetValue().ToLong(&jumpframe);
|
||||
JumpTime->SetMS(c->videoController->TimeAtFrame(jumpframe));
|
||||
JumpTime->SetTime(c->videoController->TimeAtFrame(jumpframe));
|
||||
}
|
||||
|
|
|
@ -193,7 +193,7 @@ void DialogShiftTimes::OnClose(wxCommandEvent &) {
|
|||
long shift;
|
||||
shift_frames->GetValue().ToLong(&shift);
|
||||
|
||||
OPT_SET("Tool/Shift Times/Time")->SetInt(shift_time->GetMS());
|
||||
OPT_SET("Tool/Shift Times/Time")->SetInt(shift_time->GetTime());
|
||||
OPT_SET("Tool/Shift Times/Frames")->SetInt(shift);
|
||||
OPT_SET("Tool/Shift Times/ByTime")->SetBool(shift_by_time->GetValue());
|
||||
OPT_SET("Tool/Shift Times/Type")->SetInt(time_fields->GetSelection());
|
||||
|
@ -289,7 +289,7 @@ void DialogShiftTimes::Process(wxCommandEvent &) {
|
|||
|
||||
long shift;
|
||||
if (by_time) {
|
||||
shift = shift_time->GetMS();
|
||||
shift = shift_time->GetTime();
|
||||
if (shift == 0) {
|
||||
Close();
|
||||
return;
|
||||
|
@ -323,9 +323,9 @@ void DialogShiftTimes::Process(wxCommandEvent &) {
|
|||
block_start = row_number;
|
||||
|
||||
if (start)
|
||||
line->Start.SetMS(Shift(line->Start.GetMS(), shift, by_time, agi::vfr::START));
|
||||
line->Start = Shift(line->Start, shift, by_time, agi::vfr::START);
|
||||
if (end)
|
||||
line->End.SetMS(Shift(line->End.GetMS(), shift, by_time, agi::vfr::END));
|
||||
line->End = Shift(line->End, shift, by_time, agi::vfr::END);
|
||||
}
|
||||
|
||||
context->ass->Commit(_("shifting"), AssFile::COMMIT_DIAG_TIME);
|
||||
|
|
|
@ -180,7 +180,7 @@ void DialogStyling::OnActiveLineChanged(AssDialogue *new_line) {
|
|||
style_list->SetStringSelection(active_line->Style);
|
||||
|
||||
if (auto_seek->IsChecked() && IsActive())
|
||||
c->videoController->JumpToTime(active_line->Start.GetMS());
|
||||
c->videoController->JumpToTime(active_line->Start);
|
||||
}
|
||||
|
||||
void DialogStyling::Commit(bool next) {
|
||||
|
@ -201,7 +201,7 @@ void DialogStyling::OnActivate(wxActivateEvent &) {
|
|||
style_list->Set(c->ass->GetStyles());
|
||||
|
||||
if (auto_seek->IsChecked())
|
||||
c->videoController->JumpToTime(active_line->Start.GetMS());
|
||||
c->videoController->JumpToTime(active_line->Start);
|
||||
|
||||
style_name->SetFocus();
|
||||
}
|
||||
|
|
|
@ -299,7 +299,7 @@ void DialogTimingProcessor::OnApply(wxCommandEvent &) {
|
|||
// Check if rows are valid
|
||||
for (entryIter cur = c->ass->Line.begin(); cur != c->ass->Line.end(); ++cur) {
|
||||
if (AssDialogue *tempDiag = dynamic_cast<AssDialogue*>(*cur)) {
|
||||
if (tempDiag->Start.GetMS() > tempDiag->End.GetMS()) {
|
||||
if (tempDiag->Start > tempDiag->End) {
|
||||
wxMessageBox(
|
||||
wxString::Format(
|
||||
_("One of the lines in the file (%i) has negative duration. Aborting."),
|
||||
|
@ -371,7 +371,7 @@ void DialogTimingProcessor::Process() {
|
|||
|
||||
// Compare to every previous line (yay for O(n^2)!) to see if it's OK to add lead-in
|
||||
if (inVal) {
|
||||
int startLead = cur->Start.GetMS() - inVal;
|
||||
int startLead = cur->Start - inVal;
|
||||
for (int j=0;j<i;j++) {
|
||||
AssDialogue *comp = Sorted[j];
|
||||
|
||||
|
@ -379,14 +379,14 @@ void DialogTimingProcessor::Process() {
|
|||
if (cur->CollidesWith(comp)) continue;
|
||||
|
||||
// Get comparison times
|
||||
startLead = std::max(startLead, comp->End.GetMS());
|
||||
startLead = std::max<int>(startLead, comp->End);
|
||||
}
|
||||
cur->Start.SetMS(startLead);
|
||||
cur->Start = startLead;
|
||||
}
|
||||
|
||||
// Compare to every line to see how far can lead-out be extended
|
||||
if (outVal) {
|
||||
int endLead = cur->End.GetMS() + outVal;
|
||||
int endLead = cur->End + outVal;
|
||||
for (int j=i+1;j<rows;j++) {
|
||||
AssDialogue *comp = Sorted[j];
|
||||
|
||||
|
@ -394,9 +394,9 @@ void DialogTimingProcessor::Process() {
|
|||
if (cur->CollidesWith(comp)) continue;
|
||||
|
||||
// Get comparison times
|
||||
endLead = std::min(endLead, comp->Start.GetMS());
|
||||
endLead = std::min<int>(endLead, comp->Start);
|
||||
}
|
||||
cur->End.SetMS(endLead);
|
||||
cur->End = endLead;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -417,13 +417,11 @@ void DialogTimingProcessor::Process() {
|
|||
if (cur->CollidesWith(prev)) continue;
|
||||
|
||||
// Compare distance
|
||||
int curStart = cur->Start.GetMS();
|
||||
int prevEnd = prev->End.GetMS();
|
||||
int dist = curStart-prevEnd;
|
||||
int dist = cur->Start - prev->End;
|
||||
if (dist > 0 && dist <= adjsThres) {
|
||||
int setPos = prevEnd+int(dist*bias);
|
||||
cur->Start.SetMS(setPos);
|
||||
prev->End.SetMS(setPos);
|
||||
int setPos = prev->End + int(dist*bias);
|
||||
cur->Start = setPos;
|
||||
prev->End = setPos;
|
||||
}
|
||||
|
||||
prev = cur;
|
||||
|
@ -449,19 +447,19 @@ void DialogTimingProcessor::Process() {
|
|||
AssDialogue *cur = Sorted[i];
|
||||
|
||||
// Get start/end frames
|
||||
int startF = c->videoController->FrameAtTime(cur->Start.GetMS(),agi::vfr::START);
|
||||
int endF = c->videoController->FrameAtTime(cur->End.GetMS(),agi::vfr::END);
|
||||
int startF = c->videoController->FrameAtTime(cur->Start,agi::vfr::START);
|
||||
int endF = c->videoController->FrameAtTime(cur->End,agi::vfr::END);
|
||||
|
||||
// Get closest for start
|
||||
int closest = GetClosestKeyFrame(startF);
|
||||
if ((closest > startF && closest-startF <= beforeStart) || (closest < startF && startF-closest <= afterStart)) {
|
||||
cur->Start.SetMS(c->videoController->TimeAtFrame(closest,agi::vfr::START));
|
||||
cur->Start = c->videoController->TimeAtFrame(closest,agi::vfr::START);
|
||||
}
|
||||
|
||||
// Get closest for end
|
||||
closest = GetClosestKeyFrame(endF)-1;
|
||||
if ((closest > endF && closest-endF <= beforeEnd) || (closest < endF && endF-closest <= afterEnd)) {
|
||||
cur->End.SetMS(c->videoController->TimeAtFrame(closest,agi::vfr::END));
|
||||
cur->End = c->videoController->TimeAtFrame(closest,agi::vfr::END);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -226,7 +226,7 @@ void DialogTranslation::UpdateDisplay() {
|
|||
|
||||
original_text->SetReadOnly(true);
|
||||
|
||||
if (seek_video->IsChecked()) c->videoController->JumpToTime(active_line->Start.GetMS());
|
||||
if (seek_video->IsChecked()) c->videoController->JumpToTime(active_line->Start);
|
||||
|
||||
translated_text->ClearAll();
|
||||
translated_text->SetFocus();
|
||||
|
|
|
@ -176,7 +176,7 @@ void AssTransformFramerateFilter::TransformTimeTags(wxString name,int n,AssOverr
|
|||
|
||||
switch (curParam->classification) {
|
||||
case PARCLASS_RELATIVE_TIME_START: {
|
||||
int value = instance->ConvertTime(trunc_cs(curDiag->Start.GetMS()) + parVal) - instance->newStart;
|
||||
int value = instance->ConvertTime(trunc_cs(curDiag->Start) + parVal) - instance->newStart;
|
||||
|
||||
// An end time of 0 is actually the end time of the line, so ensure
|
||||
// nonzero is never converted to 0
|
||||
|
@ -188,10 +188,10 @@ void AssTransformFramerateFilter::TransformTimeTags(wxString name,int n,AssOverr
|
|||
break;
|
||||
}
|
||||
case PARCLASS_RELATIVE_TIME_END:
|
||||
curParam->Set(instance->newEnd - instance->ConvertTime(trunc_cs(curDiag->End.GetMS()) - parVal));
|
||||
curParam->Set(instance->newEnd - instance->ConvertTime(trunc_cs(curDiag->End) - parVal));
|
||||
break;
|
||||
case PARCLASS_KARAOKE: {
|
||||
int start = curDiag->Start.GetMS() / 10 + instance->oldK + parVal;
|
||||
int start = curDiag->Start / 10 + instance->oldK + parVal;
|
||||
int value = (instance->ConvertTime(start * 10) - instance->newStart) / 10 - instance->newK;
|
||||
instance->oldK += parVal;
|
||||
instance->newK += value;
|
||||
|
@ -212,14 +212,14 @@ void AssTransformFramerateFilter::TransformFrameRate(AssFile *subs) {
|
|||
line = curDialogue;
|
||||
newK = 0;
|
||||
oldK = 0;
|
||||
newStart = trunc_cs(ConvertTime(curDialogue->Start.GetMS()));
|
||||
newEnd = trunc_cs(ConvertTime(curDialogue->End.GetMS()) + 9);
|
||||
newStart = trunc_cs(ConvertTime(curDialogue->Start));
|
||||
newEnd = trunc_cs(ConvertTime(curDialogue->End) + 9);
|
||||
|
||||
// Process stuff
|
||||
curDialogue->ParseASSTags();
|
||||
curDialogue->ProcessParameters(TransformTimeTags, this);
|
||||
curDialogue->Start.SetMS(newStart);
|
||||
curDialogue->End.SetMS(newEnd);
|
||||
curDialogue->Start = newStart;
|
||||
curDialogue->End = newEnd;
|
||||
curDialogue->UpdateText();
|
||||
curDialogue->ClearBlocks();
|
||||
}
|
||||
|
|
|
@ -96,9 +96,8 @@ static void read_subtitles(agi::ProgressSink *ps, MatroskaFile *file, MkvStdIO *
|
|||
|
||||
// Get start and end times
|
||||
longlong timecodeScaleLow = 1000000;
|
||||
AssTime subStart,subEnd;
|
||||
subStart.SetMS(startTime / timecodeScaleLow);
|
||||
subEnd.SetMS(endTime / timecodeScaleLow);
|
||||
AssTime subStart = startTime / timecodeScaleLow;
|
||||
AssTime subEnd = endTime / timecodeScaleLow;
|
||||
|
||||
// Process SSA/ASS
|
||||
if (!srt) {
|
||||
|
|
|
@ -433,7 +433,7 @@ void SubsEditBox::OnActiveLineChanged(AssDialogue *new_line) {
|
|||
|
||||
if (sync) {
|
||||
c->videoController->Stop();
|
||||
c->videoController->JumpToTime(line->Start.GetMS());
|
||||
c->videoController->JumpToTime(line->Start);
|
||||
}
|
||||
}
|
||||
SetEvtHandlerEnabled(true);
|
||||
|
|
|
@ -69,8 +69,8 @@ static void trim_text(AssDialogue *diag) {
|
|||
}
|
||||
|
||||
static void expand_times(AssDialogue *src, AssDialogue *dst) {
|
||||
dst->Start.SetMS(std::min(dst->Start.GetMS(), src->Start.GetMS()));
|
||||
dst->End.SetMS(std::max(dst->End.GetMS(), src->End.GetMS()));
|
||||
dst->Start = std::min(dst->Start, src->Start);
|
||||
dst->End = std::max(dst->End, src->End);
|
||||
}
|
||||
|
||||
/// @brief Recombine
|
||||
|
@ -246,8 +246,8 @@ void SubtitlesGrid::PasteLines(int n,bool pasteOver) {
|
|||
curdiag = new AssDialogue();
|
||||
curdiag->Text = curdata;
|
||||
// Make sure pasted plain-text lines always are blank-timed
|
||||
curdiag->Start.SetMS(0);
|
||||
curdiag->End.SetMS(0);
|
||||
curdiag->Start = 0;
|
||||
curdiag->End = 0;
|
||||
}
|
||||
|
||||
// Paste over
|
||||
|
@ -382,9 +382,9 @@ void SubtitlesGrid::DuplicateLines(int n1,int n2,bool nextFrame) {
|
|||
|
||||
// Shift to next frame
|
||||
if (nextFrame) {
|
||||
int posFrame = context->videoController->FrameAtTime(cur->End.GetMS(),agi::vfr::END) + 1;
|
||||
cur->Start.SetMS(context->videoController->TimeAtFrame(posFrame,agi::vfr::START));
|
||||
cur->End.SetMS(context->videoController->TimeAtFrame(posFrame,agi::vfr::END));
|
||||
int posFrame = context->videoController->FrameAtTime(cur->End,agi::vfr::END) + 1;
|
||||
cur->Start = context->videoController->TimeAtFrame(posFrame,agi::vfr::START);
|
||||
cur->End = context->videoController->TimeAtFrame(posFrame,agi::vfr::END);
|
||||
}
|
||||
|
||||
// Insert
|
||||
|
@ -411,9 +411,9 @@ void SubtitlesGrid::SplitLine(AssDialogue *n1,int pos,bool estimateTimes) {
|
|||
|
||||
if (estimateTimes) {
|
||||
double splitPos = double(pos)/orig.Length();
|
||||
int splitTime = (int)((n1->End.GetMS() - n1->Start.GetMS())*splitPos) + n1->Start.GetMS();
|
||||
n1->End.SetMS(splitTime);
|
||||
n2->Start.SetMS(splitTime);
|
||||
int splitTime = (int)((n1->End - n1->Start)*splitPos) + n1->Start;
|
||||
n1->End = splitTime;
|
||||
n2->Start = splitTime;
|
||||
}
|
||||
|
||||
context->ass->Commit(_("split"), AssFile::COMMIT_DIAG_ADDREM | AssFile::COMMIT_DIAG_FULL);
|
||||
|
|
|
@ -76,7 +76,7 @@ void EncoreSubtitleFormat::WriteFile(wxString const& filename, wxString const& e
|
|||
for (std::list<AssEntry*>::iterator cur=Line->begin();cur!=Line->end();cur++) {
|
||||
if (AssDialogue *current = dynamic_cast<AssDialogue*>(*cur)) {
|
||||
++i;
|
||||
file.WriteLineToFile(wxString::Format("%i %s %s %s", i, ft.FromAssTime(current->Start, sep), ft.FromAssTime(current->End, sep), current->Text));
|
||||
file.WriteLineToFile(wxString::Format("%i %s %s %s", i, ft.ToSMPTE(current->Start, sep), ft.ToSMPTE(current->End, sep), current->Text));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -116,8 +116,8 @@ void MicroDVDSubtitleFormat::ReadFile(wxString const& filename, wxString const&
|
|||
AssDialogue *line = new AssDialogue;
|
||||
line->group = "[Events]";
|
||||
line->Style = "Default";
|
||||
line->Start.SetMS(fps.TimeAtFrame(f1, agi::vfr::START));
|
||||
line->End.SetMS(fps.TimeAtFrame(f2, agi::vfr::END));
|
||||
line->Start = fps.TimeAtFrame(f1, agi::vfr::START);
|
||||
line->End = fps.TimeAtFrame(f2, agi::vfr::END);
|
||||
line->Text = text;
|
||||
Line->push_back(line);
|
||||
}
|
||||
|
@ -146,8 +146,8 @@ void MicroDVDSubtitleFormat::WriteFile(wxString const& filename, wxString const&
|
|||
// Write lines
|
||||
for (std::list<AssEntry*>::iterator cur=Line->begin();cur!=Line->end();cur++) {
|
||||
if (AssDialogue *current = dynamic_cast<AssDialogue*>(*cur)) {
|
||||
int start = fps.FrameAtTime(current->Start.GetMS(), agi::vfr::START);
|
||||
int end = fps.FrameAtTime(current->End.GetMS(), agi::vfr::END);
|
||||
int start = fps.FrameAtTime(current->Start, agi::vfr::START);
|
||||
int end = fps.FrameAtTime(current->End, agi::vfr::END);
|
||||
|
||||
file.WriteLineToFile(wxString::Format("{%i}{%i}%s", start, end, current->Text));
|
||||
}
|
||||
|
|
|
@ -350,14 +350,12 @@ allparsed:
|
|||
while (ms_chars < 3) ms *= 10, ms_chars++;
|
||||
while (ms_chars > 3) ms /= 10, ms_chars--;
|
||||
|
||||
AssTime res;
|
||||
res.SetMS(ms + 1000*(s + 60*(m + 60*(h + d*24))));
|
||||
return res;
|
||||
return ms + 1000*(s + 60*(m + 60*(h + d*24)));
|
||||
}
|
||||
|
||||
wxString WriteSRTTime(AssTime const& ts)
|
||||
{
|
||||
int time = ts.GetMS();
|
||||
int time = ts;
|
||||
|
||||
int ms_part = time % 1000;
|
||||
time /= 1000; // now holds seconds
|
||||
|
|
|
@ -77,7 +77,7 @@ void TranStationSubtitleFormat::WriteFile(wxString const& filename, wxString con
|
|||
AssDialogue *cur = dynamic_cast<AssDialogue*>(*it);
|
||||
|
||||
if (prev && cur) {
|
||||
file.WriteLineToFile(ConvertLine(prev, &ft, cur->Start.GetMS()));
|
||||
file.WriteLineToFile(ConvertLine(prev, &ft, cur->Start));
|
||||
file.WriteLineToFile("");
|
||||
}
|
||||
|
||||
|
@ -118,10 +118,10 @@ wxString TranStationSubtitleFormat::ConvertLine(AssDialogue *current, Fractional
|
|||
// Subtract one frame if the end time of the current line is equal to the
|
||||
// start of next one, since the end timestamp is inclusive and the lines
|
||||
// would overlap if left as is.
|
||||
if (nextl_start > 0 && end.GetMS() == nextl_start)
|
||||
end.SetMS(ft->FPS().TimeAtFrame(ft->FPS().FrameAtTime(end.GetMS(), agi::vfr::END) - 1, agi::vfr::END));
|
||||
if (nextl_start > 0 && end == nextl_start)
|
||||
end = ft->FPS().TimeAtFrame(ft->FPS().FrameAtTime(end, agi::vfr::END) - 1, agi::vfr::END);
|
||||
|
||||
wxString header = wxString::Format("SUB[%i%s%s ", valign, halign, type) + ft->FromAssTime(start) + ">" + ft->FromAssTime(end) + "]\r\n";
|
||||
wxString header = wxString::Format("SUB[%i%s%s ", valign, halign, type) + ft->ToSMPTE(start) + ">" + ft->ToSMPTE(end) + "]\r\n";
|
||||
|
||||
// Process text
|
||||
wxString lineEnd = "\r\n";
|
||||
|
|
|
@ -102,8 +102,8 @@ void TTXTSubtitleFormat::ReadFile(wxString const& filename, wxString const& forc
|
|||
AssDialogue *line = new AssDialogue();
|
||||
line->group = "[Events]";
|
||||
line->Style = "Default";
|
||||
line->Start.SetMS(0);
|
||||
line->End.SetMS(5000);
|
||||
line->Start = 0;
|
||||
line->End = 5000;
|
||||
Line->push_back(line);
|
||||
}
|
||||
}
|
||||
|
@ -127,8 +127,8 @@ bool TTXTSubtitleFormat::ProcessLine(wxXmlNode *node) {
|
|||
if (!text.IsEmpty()) {
|
||||
// Create dialogue
|
||||
diag = new AssDialogue();
|
||||
diag->Start.SetMS(time.GetMS());
|
||||
diag->End.SetMS(36000000-10);
|
||||
diag->Start = time;
|
||||
diag->End = 36000000-10;
|
||||
diag->group = "[Events]";
|
||||
diag->Style = "Default";
|
||||
diag->Comment = false;
|
||||
|
@ -297,8 +297,8 @@ void TTXTSubtitleFormat::ConvertToTTXT () {
|
|||
|
||||
// Insert blank line at the end
|
||||
AssDialogue *diag = new AssDialogue();
|
||||
diag->Start.SetMS(lastTime.GetMS());
|
||||
diag->End.SetMS(lastTime.GetMS()+OPT_GET("Timing/Default Duration")->GetInt());
|
||||
diag->Start = lastTime;
|
||||
diag->End = lastTime+OPT_GET("Timing/Default Duration")->GetInt();
|
||||
diag->group = "[Events]";
|
||||
diag->Style = "Default";
|
||||
diag->Comment = false;
|
||||
|
|
|
@ -117,13 +117,10 @@ void TXTSubtitleFormat::ReadFile(wxString const& filename, wxString const& encod
|
|||
|
||||
// Sets line up
|
||||
AssDialogue *line = new AssDialogue;
|
||||
line->group = "[Events]";
|
||||
line->Style = "Default";
|
||||
line->Actor = isComment ? "" : line->Actor;
|
||||
line->Comment = isComment;
|
||||
line->Text = value;
|
||||
line->Start.SetMS(0);
|
||||
line->End.SetMS(0);
|
||||
line->End = 0;
|
||||
|
||||
// Adds line
|
||||
Line->push_back(line);
|
||||
|
@ -133,10 +130,7 @@ void TXTSubtitleFormat::ReadFile(wxString const& filename, wxString const& encod
|
|||
// No lines?
|
||||
if (lines == 0) {
|
||||
AssDialogue *line = new AssDialogue;
|
||||
line->group = "[Events]";
|
||||
line->Style = "Default";
|
||||
line->Start.SetMS(0);
|
||||
line->End.SetMS(OPT_GET("Timing/Default Duration")->GetInt());
|
||||
line->End = OPT_GET("Timing/Default Duration")->GetInt();
|
||||
Line->push_back(line);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -55,7 +55,7 @@ struct invisible_line : public std::unary_function<const AssEntry*, bool> {
|
|||
invisible_line(double time) : time(time * 1000.) { }
|
||||
bool operator()(const AssEntry *entry) const {
|
||||
const AssDialogue *diag = dynamic_cast<const AssDialogue*>(entry);
|
||||
return diag && (diag->Start.GetMS() > time || diag->End.GetMS() <= time);
|
||||
return diag && (diag->Start > time || diag->End <= time);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -96,9 +96,9 @@ TimeEdit::TimeEdit(wxWindow* parent, wxWindowID id, agi::Context *c, const wxStr
|
|||
Bind(wxEVT_COMMAND_MENU_SELECTED, std::tr1::bind(&TimeEdit::PasteTime, this), Time_Edit_Paste);
|
||||
}
|
||||
|
||||
void TimeEdit::SetMS(int ms) {
|
||||
if (ms != time.GetMS()) {
|
||||
time.SetMS(ms);
|
||||
void TimeEdit::SetTime(AssTime new_time) {
|
||||
if (time != new_time) {
|
||||
time = new_time;
|
||||
UpdateText();
|
||||
}
|
||||
}
|
||||
|
@ -125,7 +125,7 @@ void TimeEdit::OnModified(wxCommandEvent &event) {
|
|||
|
||||
void TimeEdit::UpdateText() {
|
||||
if (byFrame)
|
||||
ChangeValue(wxString::Format("%d", c->videoController->FrameAtTime(time.GetMS(), isEnd ? agi::vfr::END : agi::vfr::START)));
|
||||
ChangeValue(wxString::Format("%d", c->videoController->FrameAtTime(time, isEnd ? agi::vfr::END : agi::vfr::START)));
|
||||
else
|
||||
ChangeValue(time.GetASSFormated());
|
||||
}
|
||||
|
|
|
@ -75,12 +75,7 @@ public:
|
|||
/// Get the current time as an AssTime object
|
||||
AssTime GetTime() const { return time; }
|
||||
/// Set the time
|
||||
void SetTime(AssTime time) { SetMS(time.GetMS()); }
|
||||
|
||||
/// Get the current time as milliseconds
|
||||
int GetMS() const { return time.GetMS(); }
|
||||
/// Set the time to the specified milliseconds
|
||||
void SetMS(int ms);
|
||||
void SetTime(AssTime time);
|
||||
|
||||
/// Set whether the time is displayed as a time or the corresponding frame number
|
||||
/// @param enableByFrame If true, frame numbers are displayed
|
||||
|
|
|
@ -185,8 +185,8 @@ void VideoBox::UpdateTimeBoxes() {
|
|||
else {
|
||||
VideoSubsPos->SetValue(wxString::Format(
|
||||
"%+dms; %+dms",
|
||||
time - active_line->Start.GetMS(),
|
||||
time - active_line->End.GetMS()));
|
||||
time - active_line->Start,
|
||||
time - active_line->End));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -352,13 +352,13 @@ void VideoContext::PlayLine() {
|
|||
|
||||
// Start playing audio
|
||||
context->audioController->PlayRange(SampleRange(
|
||||
context->audioController->SamplesFromMilliseconds(curline->Start.GetMS()),
|
||||
context->audioController->SamplesFromMilliseconds(curline->End.GetMS())));
|
||||
context->audioController->SamplesFromMilliseconds(curline->Start),
|
||||
context->audioController->SamplesFromMilliseconds(curline->End)));
|
||||
|
||||
// Round-trip conversion to convert start to exact
|
||||
int startFrame = FrameAtTime(context->selectionController->GetActiveLine()->Start.GetMS(),agi::vfr::START);
|
||||
int startFrame = FrameAtTime(context->selectionController->GetActiveLine()->Start,agi::vfr::START);
|
||||
startMS = TimeAtFrame(startFrame);
|
||||
endFrame = FrameAtTime(context->selectionController->GetActiveLine()->End.GetMS(),agi::vfr::END) + 1;
|
||||
endFrame = FrameAtTime(context->selectionController->GetActiveLine()->End,agi::vfr::END) + 1;
|
||||
|
||||
// Jump to start
|
||||
JumpToFrame(startFrame);
|
||||
|
|
|
@ -134,8 +134,8 @@ bool VisualToolBase::IsDisplayed(AssDialogue *line) const {
|
|||
int frame = c->videoController->GetFrameN();
|
||||
return
|
||||
line &&
|
||||
c->videoController->FrameAtTime(line->Start.GetMS(), agi::vfr::START) <= frame &&
|
||||
c->videoController->FrameAtTime(line->End.GetMS(), agi::vfr::END) >= frame;
|
||||
c->videoController->FrameAtTime(line->Start, agi::vfr::START) <= frame &&
|
||||
c->videoController->FrameAtTime(line->End, agi::vfr::END) >= frame;
|
||||
}
|
||||
|
||||
void VisualToolBase::Commit(wxString message) {
|
||||
|
|
|
@ -87,8 +87,8 @@ void VisualToolDrag::OnSubTool(wxCommandEvent &) {
|
|||
else {
|
||||
p1 = GetLinePosition(line);
|
||||
// Round the start and end times to exact frames
|
||||
int start = vc->TimeAtFrame(vc->FrameAtTime(line->Start.GetMS(), agi::vfr::START)) - line->Start.GetMS();
|
||||
int end = vc->TimeAtFrame(vc->FrameAtTime(line->Start.GetMS(), agi::vfr::END)) - line->Start.GetMS();
|
||||
int start = vc->TimeAtFrame(vc->FrameAtTime(line->Start, agi::vfr::START)) - line->Start;
|
||||
int end = vc->TimeAtFrame(vc->FrameAtTime(line->Start, agi::vfr::END)) - line->Start;
|
||||
SetOverride(line, "\\move", wxString::Format("(%s,%s,%d,%d)", p1.Str(), p1.Str(), start, end));
|
||||
}
|
||||
}
|
||||
|
@ -255,7 +255,7 @@ bool VisualToolDrag::InitializeDrag(feature_iterator feature) {
|
|||
// Set time of clicked feature to the current frame and shift all other
|
||||
// selected features by the same amount
|
||||
if (feature->type != DRAG_ORIGIN) {
|
||||
int time = c->videoController->TimeAtFrame(frame_number) - feature->line->Start.GetMS();
|
||||
int time = c->videoController->TimeAtFrame(frame_number) - feature->line->Start;
|
||||
int change = time - feature->time;
|
||||
|
||||
for (sel_iterator cur = sel_features.begin(); cur != sel_features.end(); ++cur) {
|
||||
|
|
Loading…
Reference in a new issue