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"
|
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
|
2011-12-22 22:18:54 +01:00
|
|
|
AssTime::AssTime() : time(0) { }
|
|
|
|
AssTime::AssTime(int time) { SetMS(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;
|
2011-09-28 21:43:11 +02:00
|
|
|
for (pos=0;pos<len;pos++) if (text[pos] == ':') colons++;
|
2007-06-23 08:07:32 +02:00
|
|
|
pos = 0;
|
|
|
|
|
|
|
|
// Set start so that there are only two colons at most
|
|
|
|
if (colons > 2) {
|
|
|
|
for (pos=0;pos<len;pos++) {
|
2011-09-28 21:43:11 +02:00
|
|
|
if (text[pos] == ':') {
|
2007-06-23 08:07:32 +02:00
|
|
|
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) {
|
2011-09-28 21:43:11 +02:00
|
|
|
while (text[end++] != ':') {};
|
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) {
|
2011-09-28 21:43:11 +02:00
|
|
|
while (text[end++] != ':') {};
|
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
|
2010-10-27 23:17:41 +02:00
|
|
|
SetMS(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 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
|
|
|
|
///
|
2010-10-27 23:17:41 +02:00
|
|
|
void AssTime::SetMS (int ms) {
|
2010-12-31 22:03:03 +01:00
|
|
|
time = mid(0, ms, 10 * 60 * 60 * 1000 - 1);
|
2006-02-21 23:09:15 +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 ASS Formated
|
|
|
|
/// @param msPrecision
|
|
|
|
/// @return
|
|
|
|
///
|
2010-07-08 09:14:55 +02:00
|
|
|
wxString AssTime::GetASSFormated (bool msPrecision) const {
|
2010-09-23 05:06:15 +02:00
|
|
|
int ms = time;
|
2006-02-21 23:09:15 +01:00
|
|
|
|
2006-01-16 22:02:54 +01:00
|
|
|
// Centisecond precision
|
2007-06-19 02:44:18 +02:00
|
|
|
msPrecision = msPrecision || UseMSPrecision;
|
2010-09-23 05:06:15 +02:00
|
|
|
if (!msPrecision) ms = ms/10*10;
|
2006-01-16 22:02:54 +01:00
|
|
|
|
2010-09-23 05:06:15 +02:00
|
|
|
int h = ms / (1000 * 60 * 60);
|
|
|
|
int m = (ms / (1000 * 60)) % 60;
|
|
|
|
int s = (ms / 1000) % 60;
|
|
|
|
ms = ms % 1000;
|
2006-01-16 22:02:54 +01:00
|
|
|
|
2011-09-28 21:43:11 +02:00
|
|
|
if (msPrecision) return wxString::Format("%01i:%02i:%02i.%03i",h,m,s,ms);
|
|
|
|
else return wxString::Format("%01i:%02i:%02i.%02i",h,m,s,ms/10);
|
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 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());
|
|
|
|
}
|
|
|
|
|
2010-07-20 05:11:11 +02:00
|
|
|
AssTime operator + (const AssTime &t1, const AssTime &t2) {
|
|
|
|
return AssTime(t1.GetMS() + t2.GetMS());
|
|
|
|
}
|
|
|
|
|
|
|
|
AssTime operator - (const AssTime &t1, const AssTime &t2) {
|
|
|
|
return AssTime(t1.GetMS() - t2.GetMS());
|
|
|
|
}
|
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
|
|
|
|
|
|
|
/// 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
|
|
|
|
2011-12-22 22:27:53 +01:00
|
|
|
FractionalTime::FractionalTime(int numerator, int denominator, bool dropframe)
|
2011-12-22 22:22:49 +01:00
|
|
|
: num(numerator)
|
|
|
|
, den(denominator)
|
|
|
|
, drop(dropframe)
|
|
|
|
{
|
2009-05-13 22:24:21 +02:00
|
|
|
if (drop) {
|
|
|
|
// no dropframe for any other framerates
|
|
|
|
num = 30000;
|
|
|
|
den = 1001;
|
|
|
|
}
|
2009-05-10 05:50:58 +02:00
|
|
|
|
|
|
|
// fractions < 1 are not welcome here
|
|
|
|
if ((num <= 0 || den <= 0) || (num < den))
|
2011-09-28 21:43:11 +02:00
|
|
|
throw "FractionalTime: nonsensical enumerator or denominator";
|
2009-05-10 05:50:58 +02:00
|
|
|
}
|
|
|
|
|
2011-12-22 22:27:53 +01:00
|
|
|
wxString FractionalTime::FromAssTime(AssTime time, char sep) {
|
|
|
|
return FromMillisecs(time.GetMS(), sep);
|
2009-05-10 05:50:58 +02:00
|
|
|
}
|
|
|
|
|
2011-12-22 22:27:53 +01:00
|
|
|
wxString FractionalTime::FromMillisecs(int64_t msec, char sep) {
|
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
|
2011-12-22 22:22:49 +01:00
|
|
|
if (msec <= 0) {
|
|
|
|
}
|
2009-05-13 22:24:21 +02:00
|
|
|
// dropframe?
|
2011-12-22 22:22:49 +01:00
|
|
|
else if (drop) {
|
2009-05-13 22:24:21 +02:00
|
|
|
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;
|
2011-12-22 22:22:49 +01:00
|
|
|
|
|
|
|
h = fn / frames_per_h;
|
|
|
|
fn = fn % frames_per_h;
|
|
|
|
|
|
|
|
m = fn / frames_per_m;
|
|
|
|
fn = fn % frames_per_m;
|
|
|
|
|
|
|
|
s = fn / frames_per_s;
|
|
|
|
fn = fn % frames_per_s;
|
|
|
|
|
2009-05-13 22:24:21 +02:00
|
|
|
f = fn;
|
|
|
|
}
|
|
|
|
|
2011-12-22 22:22:49 +01:00
|
|
|
return wxString::Format("%02i%c%02%c%02i%c%02i", h, sep, m, sep, s, sep, f);
|
2009-05-10 05:50:58 +02:00
|
|
|
}
|