projects
/
dcpomatic.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Remove debug code.
[dcpomatic.git]
/
src
/
lib
/
subrip.cc
diff --git
a/src/lib/subrip.cc
b/src/lib/subrip.cc
index 04765532fc2bfaad0f287e8d833aba220f55c3df..3217a4df0803a1bd4b192e18c6846ff33f4ffaa8 100644
(file)
--- a/
src/lib/subrip.cc
+++ b/
src/lib/subrip.cc
@@
-18,6
+18,7
@@
*/
#include <boost/algorithm/string.hpp>
*/
#include <boost/algorithm/string.hpp>
+#include <boost/lexical_cast.hpp>
#include "subrip.h"
#include "subrip_content.h"
#include "subrip_subtitle.h"
#include "subrip.h"
#include "subrip_content.h"
#include "subrip_subtitle.h"
@@
-34,7
+35,7
@@
using boost::shared_ptr;
using boost::lexical_cast;
using boost::algorithm::trim;
using boost::lexical_cast;
using boost::algorithm::trim;
-SubRip::SubRip (shared_ptr<SubRipContent> content)
+SubRip::SubRip (shared_ptr<
const
SubRipContent> content)
{
FILE* f = fopen_boost (content->path (0), "r");
if (!f) {
{
FILE* f = fopen_boost (content->path (0), "r");
if (!f) {
@@
-89,8
+90,7
@@
SubRip::SubRip (shared_ptr<SubRipContent> content)
throw SubRipError (line, _("a time/position line"), content->path (0));
}
throw SubRipError (line, _("a time/position line"), content->path (0));
}
- current->from = convert_time (p[0]);
- current->to = convert_time (p[2]);
+ current->period = ContentTimePeriod (convert_time (p[0]), convert_time (p[2]));
if (p.size() > 3) {
current->x1 = convert_coordinate (p[3]);
if (p.size() > 3) {
current->x1 = convert_coordinate (p[3]);
@@
-123,21
+123,21
@@
SubRip::SubRip (shared_ptr<SubRipContent> content)
fclose (f);
}
fclose (f);
}
-Time
+
Content
Time
SubRip::convert_time (string t)
{
SubRip::convert_time (string t)
{
-
Time r = 0
;
+
ContentTime r
;
vector<string> a;
boost::algorithm::split (a, t, boost::is_any_of (":"));
assert (a.size() == 3);
vector<string> a;
boost::algorithm::split (a, t, boost::is_any_of (":"));
assert (a.size() == 3);
- r +=
lexical_cast<int> (a[0]) * 60 * 60 * TIME_HZ
;
- r +=
lexical_cast<int> (a[1]) * 60 * TIME_HZ
;
+ r +=
ContentTime::from_seconds (lexical_cast<int> (a[0]) * 60 * 60)
;
+ r +=
ContentTime::from_seconds (lexical_cast<int> (a[1]) * 60)
;
vector<string> b;
boost::algorithm::split (b, a[2], boost::is_any_of (","));
vector<string> b;
boost::algorithm::split (b, a[2], boost::is_any_of (","));
- r +=
lexical_cast<int> (b[0]) * TIME_HZ
;
- r +=
lexical_cast<int> (b[1]) * TIME_HZ / 1000
;
+ r +=
ContentTime::from_seconds (lexical_cast<int> (b[0]))
;
+ r +=
ContentTime::from_seconds (lexical_cast<double> (b[1]) / 1000)
;
return r;
}
return r;
}
@@
-225,12
+225,12
@@
SubRip::convert_content (list<string> t)
return pieces;
}
return pieces;
}
-Time
+
Content
Time
SubRip::length () const
{
if (_subtitles.empty ()) {
SubRip::length () const
{
if (_subtitles.empty ()) {
- return
0
;
+ return
ContentTime ()
;
}
}
- return _subtitles.back().to;
+ return _subtitles.back().
period.
to;
}
}