2006-01-16 22:02:54 +01:00
|
|
|
// Copyright (c) 2005, 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.
|
|
|
|
//
|
2009-07-29 07:43:02 +02:00
|
|
|
// Aegisub Project http://www.aegisub.org/
|
2006-01-16 22:02:54 +01:00
|
|
|
//
|
2009-07-29 07:43:02 +02:00
|
|
|
// $Id$
|
|
|
|
|
|
|
|
/// @file ass_time.cpp
|
|
|
|
/// @brief Class for managing timestamps in subtitles
|
|
|
|
/// @ingroup subs_storage
|
|
|
|
///
|
2006-01-16 22:02:54 +01:00
|
|
|
|
|
|
|
|
|
|
|
////////////
|
|
|
|
// Includes
|
2009-10-09 18:34:38 +02:00
|
|
|
#include "config.h"
|
|
|
|
|
2009-09-10 15:06:40 +02:00
|
|
|
#ifndef AGI_PRE
|
2009-05-13 22:24:21 +02:00
|
|
|
#include <math.h>
|
2009-09-10 15:06:40 +02:00
|
|
|
|
2006-01-16 22:02:54 +01:00
|
|
|
#include <algorithm>
|
2009-09-10 15:06:40 +02:00
|
|
|
#include <fstream>
|
2006-01-16 22:02:54 +01:00
|
|
|
|
2009-09-10 15:06:40 +02:00
|
|
|
#include <wx/regex.h>
|
|
|
|
#endif
|
2006-01-16 22:02:54 +01:00
|
|
|
|
2009-09-10 15:06:40 +02:00
|
|
|
#include "ass_time.h"
|
|
|
|
#include "utils.h"
|
|
|
|
#include "vfr.h"
|
2006-01-16 22:02:54 +01:00
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
2010-05-19 02:44:44 +02:00
|
|
|
/// @brief AssTime constructors
|
|
|
|
AssTime::AssTime () : time(0) { }
|
|
|
|
AssTime::AssTime (int time) : time(time) { }
|
2006-01-16 22:02:54 +01:00
|
|
|
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// @brief Note that this function is atomic, it won't touch the values if it's invalid. --------------- Parses from ASS
|
|
|
|
/// @param text
|
|
|
|
/// @return
|
|
|
|
///
|
2007-04-21 00:17:42 +02:00
|
|
|
void AssTime::ParseASS (const wxString text) {
|
2006-01-16 22:02:54 +01:00
|
|
|
// Prepare
|
|
|
|
size_t pos = 0;
|
|
|
|
size_t end = 0;
|
2007-06-23 08:07:32 +02:00
|
|
|
long th=0,tm=0,tms=0;
|
|
|
|
|
|
|
|
// Count the number of colons
|
|
|
|
size_t len = text.Length();
|
|
|
|
int colons = 0;
|
|
|
|
for (pos=0;pos<len;pos++) if (text[pos] == _T(':')) colons++;
|
|
|
|
pos = 0;
|
|
|
|
|
|
|
|
// Set start so that there are only two colons at most
|
|
|
|
if (colons > 2) {
|
|
|
|
for (pos=0;pos<len;pos++) {
|
|
|
|
if (text[pos] == _T(':')) {
|
|
|
|
colons--;
|
|
|
|
if (colons == 2) break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
pos++;
|
|
|
|
end = pos;
|
|
|
|
}
|
2006-01-16 22:02:54 +01:00
|
|
|
|
|
|
|
try {
|
|
|
|
// Hours
|
2007-06-23 08:07:32 +02:00
|
|
|
if (colons == 2) {
|
2009-09-02 10:19:24 +02:00
|
|
|
while (text[end++] != _T(':')) {};
|
2009-04-06 22:01:42 +02:00
|
|
|
th = AegiStringToInt(text,pos,end);
|
2007-06-23 08:07:32 +02:00
|
|
|
pos = end;
|
|
|
|
}
|
2006-01-16 22:02:54 +01:00
|
|
|
|
|
|
|
// Minutes
|
2007-06-23 08:07:32 +02:00
|
|
|
if (colons >= 1) {
|
2009-09-02 10:19:24 +02:00
|
|
|
while (text[end++] != _T(':')) {};
|
2009-04-06 22:01:42 +02:00
|
|
|
tm = AegiStringToInt(text,pos,end);
|
2007-06-23 08:07:32 +02:00
|
|
|
pos = end;
|
|
|
|
}
|
2006-01-16 22:02:54 +01:00
|
|
|
|
2007-04-21 00:17:42 +02:00
|
|
|
// Miliseconds (includes seconds)
|
|
|
|
end = text.Length();
|
2009-04-06 22:01:42 +02:00
|
|
|
tms = AegiStringToFix(text,3,pos,end);
|
2006-01-16 22:02:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Something went wrong, don't change anything
|
|
|
|
catch (...) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// OK, set values
|
2007-04-21 00:17:42 +02:00
|
|
|
time = tms + tm*60000 + th*3600000;
|
2006-01-16 22:02:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// @brief Parses from SRT
|
|
|
|
/// @param _text
|
|
|
|
///
|
2006-01-16 22:02:54 +01:00
|
|
|
void AssTime::ParseSRT (const wxString _text) {
|
|
|
|
// Prepare
|
|
|
|
wxString text = _text;
|
|
|
|
text.Trim(false);
|
|
|
|
text.Trim(true);
|
|
|
|
long tempv;
|
|
|
|
wxString temp;
|
2006-02-21 23:09:15 +01:00
|
|
|
int ms,s,m,h;
|
2006-01-16 22:02:54 +01:00
|
|
|
|
|
|
|
// Parse
|
|
|
|
temp = text.Mid(0,2);
|
|
|
|
temp.ToLong(&tempv);
|
|
|
|
h = tempv;
|
|
|
|
temp = text.Mid(3,2);
|
|
|
|
temp.ToLong(&tempv);
|
|
|
|
m = tempv;
|
|
|
|
temp = text.Mid(6,2);
|
|
|
|
temp.ToLong(&tempv);
|
|
|
|
s = tempv;
|
|
|
|
temp = text.Mid(9,3);
|
|
|
|
temp.ToLong(&tempv);
|
|
|
|
ms = tempv;
|
2006-02-21 23:09:15 +01:00
|
|
|
|
|
|
|
// Set value
|
|
|
|
time = ms + s*1000 + m*60000 + h*3600000;
|
2006-01-16 22:02:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// @brief AssTime conversion to/from miliseconds
|
|
|
|
/// @return
|
|
|
|
///
|
2009-05-15 01:27:38 +02:00
|
|
|
int AssTime::GetMS () const {
|
2006-02-21 23:09:15 +01:00
|
|
|
if (!UseMSPrecision) return time/10*10;
|
|
|
|
else return time;
|
2006-01-16 22:02:54 +01:00
|
|
|
}
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// @brief DOCME
|
|
|
|
/// @param _ms
|
|
|
|
///
|
2006-01-16 22:02:54 +01:00
|
|
|
void AssTime::SetMS (int _ms) {
|
2006-02-21 23:09:15 +01:00
|
|
|
time = _ms;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// @brief ASS Formated
|
|
|
|
/// @param msPrecision
|
|
|
|
/// @return
|
|
|
|
///
|
2007-06-19 00:20:50 +02:00
|
|
|
wxString AssTime::GetASSFormated (bool msPrecision) {
|
2006-02-21 23:09:15 +01:00
|
|
|
int h,m,s,ms;
|
|
|
|
int _ms = time;
|
|
|
|
|
2006-01-16 22:02:54 +01:00
|
|
|
// Centisecond precision
|
2007-06-19 02:44:18 +02:00
|
|
|
msPrecision = msPrecision || UseMSPrecision;
|
|
|
|
if (!msPrecision) _ms = _ms/10*10;
|
2006-01-16 22:02:54 +01:00
|
|
|
|
|
|
|
// Reset
|
|
|
|
h = m = s = ms = 0;
|
|
|
|
if (_ms < 0) _ms = 0;
|
|
|
|
|
|
|
|
// Hours
|
|
|
|
while (_ms >= 3600000) {
|
|
|
|
_ms -= 3600000;
|
|
|
|
h++;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Ass overflow
|
|
|
|
if (h > 9) {
|
|
|
|
h = 9;
|
|
|
|
m = 59;
|
|
|
|
s = 59;
|
|
|
|
ms = 999;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Minutes
|
|
|
|
while (_ms >= 60000) {
|
|
|
|
_ms -= 60000;
|
|
|
|
m++;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Seconds
|
|
|
|
while (_ms >= 1000) {
|
|
|
|
_ms -= 1000;
|
|
|
|
s++;
|
|
|
|
}
|
2006-02-22 08:36:38 +01:00
|
|
|
ms = _ms;
|
2006-01-16 22:02:54 +01:00
|
|
|
|
2007-06-19 02:44:18 +02:00
|
|
|
if (msPrecision) return wxString::Format(_T("%01i:%02i:%02i.%03i"),h,m,s,ms);
|
2006-01-16 22:02:54 +01:00
|
|
|
else return wxString::Format(_T("%01i:%02i:%02i.%02i"),h,m,s,ms/10);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// @brief SRT Formated
|
|
|
|
/// @return
|
|
|
|
///
|
2006-01-16 22:02:54 +01:00
|
|
|
wxString AssTime::GetSRTFormated () {
|
2006-02-21 23:09:15 +01:00
|
|
|
int h,m,s,ms;
|
|
|
|
int _ms = time;
|
|
|
|
|
|
|
|
// Centisecond precision
|
|
|
|
if (!UseMSPrecision) _ms = _ms/10*10;
|
|
|
|
|
|
|
|
// Reset
|
|
|
|
h = m = s = ms = 0;
|
|
|
|
if (_ms < 0) _ms = 0;
|
|
|
|
|
|
|
|
// Hours
|
|
|
|
while (_ms >= 3600000) {
|
|
|
|
_ms -= 3600000;
|
|
|
|
h++;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Ass overflow
|
|
|
|
if (h > 9) {
|
|
|
|
h = 9;
|
|
|
|
m = 59;
|
|
|
|
s = 59;
|
|
|
|
ms = 999;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Minutes
|
|
|
|
while (_ms >= 60000) {
|
|
|
|
_ms -= 60000;
|
|
|
|
m++;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Seconds
|
|
|
|
while (_ms >= 1000) {
|
|
|
|
_ms -= 1000;
|
|
|
|
s++;
|
|
|
|
}
|
2006-02-22 08:36:38 +01:00
|
|
|
ms = _ms;
|
2006-02-21 23:09:15 +01:00
|
|
|
|
2006-01-16 22:02:54 +01:00
|
|
|
wxString result = wxString::Format(_T("%02i:%02i:%02i,%03i"),h,m,s,ms);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// @brief AssTime comparison
|
|
|
|
/// @param t1
|
|
|
|
/// @param t2
|
|
|
|
/// @return
|
|
|
|
///
|
2010-05-19 02:44:44 +02:00
|
|
|
bool operator < (const AssTime &t1, const AssTime &t2) {
|
2006-01-16 22:02:54 +01:00
|
|
|
return (t1.GetMS() < t2.GetMS());
|
|
|
|
}
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// @brief DOCME
|
|
|
|
/// @param t1
|
|
|
|
/// @param t2
|
|
|
|
/// @return
|
|
|
|
///
|
2010-05-19 02:44:44 +02:00
|
|
|
bool operator > (const AssTime &t1, const AssTime &t2) {
|
2006-01-16 22:02:54 +01:00
|
|
|
return (t1.GetMS() > t2.GetMS());
|
|
|
|
}
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// @brief DOCME
|
|
|
|
/// @param t1
|
|
|
|
/// @param t2
|
|
|
|
/// @return
|
|
|
|
///
|
2010-05-19 02:44:44 +02:00
|
|
|
bool operator <= (const AssTime &t1, const AssTime &t2) {
|
2006-01-16 22:02:54 +01:00
|
|
|
return (t1.GetMS() <= t2.GetMS());
|
|
|
|
}
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// @brief DOCME
|
|
|
|
/// @param t1
|
|
|
|
/// @param t2
|
|
|
|
/// @return
|
|
|
|
///
|
2010-05-19 02:44:44 +02:00
|
|
|
bool operator >= (const AssTime &t1, const AssTime &t2) {
|
2006-01-16 22:02:54 +01:00
|
|
|
return (t1.GetMS() >= t2.GetMS());
|
|
|
|
}
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// @brief DOCME
|
|
|
|
/// @param t1
|
|
|
|
/// @param t2
|
|
|
|
/// @return
|
|
|
|
///
|
2010-05-19 02:44:44 +02:00
|
|
|
bool operator == (const AssTime &t1, const AssTime &t2) {
|
2006-01-16 22:02:54 +01:00
|
|
|
return (t1.GetMS() == t2.GetMS());
|
|
|
|
}
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// @brief DOCME
|
|
|
|
/// @param t1
|
|
|
|
/// @param t2
|
|
|
|
/// @return
|
|
|
|
///
|
2010-05-19 02:44:44 +02:00
|
|
|
bool operator != (const AssTime &t1, const AssTime &t2) {
|
2006-01-16 22:02:54 +01:00
|
|
|
return (t1.GetMS() != t2.GetMS());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// DOCME
|
2006-01-16 22:02:54 +01:00
|
|
|
bool AssTime::UseMSPrecision = false;
|
2007-06-19 07:04:15 +02:00
|
|
|
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// @brief Get
|
|
|
|
/// @return
|
|
|
|
///
|
2007-06-19 07:04:15 +02:00
|
|
|
int AssTime::GetTimeHours() { return time / 3600000; }
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// @brief DOCME
|
|
|
|
/// @return
|
|
|
|
///
|
2007-06-19 07:04:15 +02:00
|
|
|
int AssTime::GetTimeMinutes() { return (time % 3600000)/60000; }
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// @brief DOCME
|
|
|
|
/// @return
|
|
|
|
///
|
2007-06-19 07:04:15 +02:00
|
|
|
int AssTime::GetTimeSeconds() { return (time % 60000)/1000; }
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// @brief DOCME
|
|
|
|
/// @return
|
|
|
|
///
|
2007-06-19 07:04:15 +02:00
|
|
|
int AssTime::GetTimeMiliseconds() { return (time % 1000); }
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// @brief DOCME
|
|
|
|
/// @return
|
|
|
|
///
|
2007-06-19 07:04:15 +02:00
|
|
|
int AssTime::GetTimeCentiseconds() { return (time % 1000)/10; }
|
2009-05-10 05:50:58 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// @brief Constructor
|
|
|
|
/// @param separator
|
|
|
|
/// @param numerator
|
|
|
|
/// @param denominator
|
|
|
|
/// @param dropframe
|
|
|
|
///
|
2009-05-13 22:24:21 +02:00
|
|
|
FractionalTime::FractionalTime (wxString separator, int numerator, int denominator, bool dropframe) {
|
|
|
|
drop = dropframe;
|
|
|
|
if (drop) {
|
|
|
|
// no dropframe for any other framerates
|
|
|
|
num = 30000;
|
|
|
|
den = 1001;
|
|
|
|
} else {
|
|
|
|
num = numerator;
|
|
|
|
den = denominator;
|
|
|
|
}
|
2009-05-10 05:50:58 +02:00
|
|
|
sep = separator;
|
|
|
|
|
|
|
|
// fractions < 1 are not welcome here
|
|
|
|
if ((num <= 0 || den <= 0) || (num < den))
|
|
|
|
throw _T("FractionalTime: nonsensical enumerator or denominator");
|
|
|
|
if (sep.IsEmpty())
|
|
|
|
throw _T("FractionalTime: no separator specified");
|
|
|
|
}
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// @brief Destructor
|
|
|
|
///
|
2009-05-10 05:50:58 +02:00
|
|
|
FractionalTime::~FractionalTime () {
|
|
|
|
sep.Clear();
|
|
|
|
}
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// @brief SMPTE text string to milliseconds conversion
|
|
|
|
/// @param _text
|
|
|
|
/// @return
|
|
|
|
///
|
2009-05-13 22:24:21 +02:00
|
|
|
int FractionalTime::ToMillisecs (wxString _text) {
|
2009-05-10 05:50:58 +02:00
|
|
|
wxString text = _text;
|
|
|
|
wxString re_str = _T("");
|
|
|
|
text.Trim(false);
|
|
|
|
text.Trim(true);
|
2009-05-15 14:31:09 +02:00
|
|
|
long h=0,m=0,s=0,f=0;
|
2009-05-10 05:50:58 +02:00
|
|
|
|
2009-05-13 22:24:21 +02:00
|
|
|
// hour minute second fraction
|
|
|
|
re_str << _T("(\\d+)") << sep << _T("(\\d+)") << sep << _T("(\\d+)") << sep << _T("(\\d+)");
|
2009-05-10 05:50:58 +02:00
|
|
|
|
|
|
|
wxRegEx re(re_str, wxRE_ADVANCED);
|
|
|
|
if (!re.IsValid())
|
|
|
|
throw _T("FractionalTime: regex failure");
|
|
|
|
if (!re.Matches(text))
|
|
|
|
return 0; // FIXME: throw here too?
|
|
|
|
|
2009-05-13 22:24:21 +02:00
|
|
|
re.GetMatch(text,1).ToLong(&h);
|
|
|
|
re.GetMatch(text,2).ToLong(&m);
|
|
|
|
re.GetMatch(text,3).ToLong(&s);
|
|
|
|
re.GetMatch(text,4).ToLong(&f);
|
|
|
|
|
|
|
|
int msecs_f = 0;
|
|
|
|
int fn = 0;
|
|
|
|
// dropframe? do silly things
|
|
|
|
if (drop) {
|
|
|
|
fn += h * frames_per_period * 6;
|
|
|
|
fn += (m % 10) * frames_per_period;
|
|
|
|
|
|
|
|
if (m > 0) {
|
|
|
|
fn += 1800;
|
|
|
|
m--;
|
|
|
|
|
|
|
|
fn += m * 1798; // two timestamps dropped per minute after the first
|
|
|
|
fn += s * 30 + f - 2;
|
|
|
|
}
|
|
|
|
else { // minute is evenly divisible by 10, keep first two timestamps
|
|
|
|
fn += s * 30;
|
|
|
|
fn += f;
|
|
|
|
}
|
|
|
|
|
|
|
|
msecs_f = (fn * num) / den;
|
|
|
|
}
|
|
|
|
// no dropframe, may or may not sync with wallclock time
|
|
|
|
// (see comment in FromMillisecs for an explanation of why it's done like this)
|
|
|
|
else {
|
|
|
|
int fps_approx = floor((double(num)/double(den))+0.5);
|
|
|
|
fn += h * 3600 * fps_approx;
|
|
|
|
fn += m * 60 * fps_approx;
|
|
|
|
fn += s * fps_approx;
|
|
|
|
fn += f;
|
|
|
|
|
|
|
|
msecs_f = (fn * num) / den;
|
|
|
|
}
|
|
|
|
|
|
|
|
return msecs_f;
|
2009-05-10 05:50:58 +02:00
|
|
|
}
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// @brief SMPTE text string to AssTime conversion
|
|
|
|
/// @param _text
|
|
|
|
/// @return
|
|
|
|
///
|
2009-05-10 05:50:58 +02:00
|
|
|
AssTime FractionalTime::ToAssTime (wxString _text) {
|
|
|
|
AssTime time;
|
|
|
|
time.SetMS((int)ToMillisecs(_text));
|
|
|
|
return time;
|
|
|
|
}
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// @brief AssTime to SMPTE text string conversion
|
|
|
|
/// @param time
|
|
|
|
/// @return
|
|
|
|
///
|
2009-05-10 05:50:58 +02:00
|
|
|
wxString FractionalTime::FromAssTime(AssTime time) {
|
2009-05-13 22:24:21 +02:00
|
|
|
return FromMillisecs(time.GetMS());
|
2009-05-10 05:50:58 +02:00
|
|
|
}
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// @brief Milliseconds to SMPTE text string conversion
|
|
|
|
/// @param msec
|
|
|
|
///
|
2009-05-10 05:50:58 +02:00
|
|
|
wxString FractionalTime::FromMillisecs(int64_t msec) {
|
2009-05-13 22:24:21 +02:00
|
|
|
int h=0, m=0, s=0, f=0; // hours, minutes, seconds, fractions
|
2009-05-15 14:31:09 +02:00
|
|
|
int fn = (msec*(int64_t)num) / (1000*den); // frame number
|
2009-05-15 14:18:33 +02:00
|
|
|
|
|
|
|
// return 00:00:00:00
|
|
|
|
if (msec <= 0)
|
|
|
|
goto RETURN;
|
|
|
|
|
2009-05-13 22:24:21 +02:00
|
|
|
// dropframe?
|
|
|
|
if (drop) {
|
|
|
|
fn += 2 * (fn / (30 * 60)) - 2 * (fn / (30 * 60 * 10));
|
|
|
|
h = fn / (30 * 60 * 60);
|
|
|
|
m = (fn / (30 * 60)) % 60;
|
|
|
|
s = (fn / 30) % 60;
|
|
|
|
f = fn % 30;
|
|
|
|
}
|
|
|
|
// no dropframe; h/m/s may or may not sync to wallclock time
|
|
|
|
else {
|
|
|
|
/*
|
|
|
|
This is truly the dumbest shit. What we're trying to ensure here
|
|
|
|
is that non-integer framerates are desynced from the wallclock
|
|
|
|
time by a correct amount of time. For example, in the
|
|
|
|
NTSC-without-dropframe case, 3600*num/den would be 107892
|
|
|
|
(when truncated to int), which is quite a good approximation of
|
|
|
|
how a long an hour is when counted in 30000/1001 frames per second.
|
|
|
|
Unfortunately, that's not what we want, since frame numbers will
|
|
|
|
still range from 00 to 29, meaning that we're really getting _30_
|
|
|
|
frames per second and not 29.97 and the full hour will be off by
|
|
|
|
almost 4 seconds (108000 frames versus 107892).
|
|
|
|
|
|
|
|
DEATH TO SMPTE
|
|
|
|
*/
|
|
|
|
int fps_approx = floor((double(num)/double(den))+0.5);
|
|
|
|
int frames_per_h = 3600*fps_approx;
|
|
|
|
int frames_per_m = 60*fps_approx;
|
|
|
|
int frames_per_s = fps_approx;
|
|
|
|
while (fn >= frames_per_h) {
|
|
|
|
h++; fn -= frames_per_h;
|
|
|
|
}
|
|
|
|
while (fn >= frames_per_m) {
|
|
|
|
m++; fn -= frames_per_m;
|
|
|
|
}
|
|
|
|
while (fn >= frames_per_s) {
|
|
|
|
s++; fn -= frames_per_s;
|
|
|
|
}
|
|
|
|
f = fn;
|
|
|
|
}
|
|
|
|
|
2009-05-15 14:18:33 +02:00
|
|
|
RETURN:
|
2009-05-10 05:50:58 +02:00
|
|
|
return wxString::Format(_T("%02i") + sep + _T("%02i") + sep + _T("%02i") + sep + _T("%02i"),h,m,s,f);
|
|
|
|
}
|
2009-07-29 07:43:02 +02:00
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|