projects
/
dcpomatic.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Note that newer libsub version is required.
[dcpomatic.git]
/
src
/
lib
/
active_text.cc
diff --git
a/src/lib/active_text.cc
b/src/lib/active_text.cc
index 1180ce7b0bc42f3c6b1deb7ef1fb0fdbb789eecd..2a5c4d836468a7a8fb3e359e81085c31d807ad55 100644
(file)
--- a/
src/lib/active_text.cc
+++ b/
src/lib/active_text.cc
@@
-31,6
+31,24
@@
using std::shared_ptr;
using boost::optional;
using namespace dcpomatic;
using boost::optional;
using namespace dcpomatic;
+
+ActiveText::ActiveText(ActiveText&& other)
+ : _data(std::move(other._data))
+{
+
+}
+
+
+ActiveText&
+ActiveText::operator=(ActiveText&& other)
+{
+ if (this != &other) {
+ _data = std::move(other._data);
+ }
+ return *this;
+}
+
+
/** Get the open captions that should be burnt into a given period.
* @param period Period of interest.
* @param always_burn_captions Always burn captions even if their content is not set to burn.
/** Get the open captions that should be burnt into a given period.
* @param period Period of interest.
* @param always_burn_captions Always burn captions even if their content is not set to burn.
@@
-42,9
+60,9
@@
ActiveText::get_burnt (DCPTimePeriod period, bool always_burn_captions) const
list<PlayerText> ps;
list<PlayerText> ps;
- for (
Map::const_iterator i = _data.begin(); i != _data.end(); ++i
) {
+ for (
auto const& i: _data
) {
-
shared_ptr<const TextContent> caption = i->
first.lock ();
+
auto caption = i.
first.lock ();
if (!caption) {
continue;
}
if (!caption) {
continue;
}
@@
-54,9
+72,9
@@
ActiveText::get_burnt (DCPTimePeriod period, bool always_burn_captions) const
continue;
}
continue;
}
- for (auto j: i
->
second) {
+ for (auto j: i
.
second) {
DCPTimePeriod test (j.from, j.to.get_value_or(DCPTime::max()));
DCPTimePeriod test (j.from, j.to.get_value_or(DCPTime::max()));
-
optional<DCPTimePeriod>
overlap = period.overlap (test);
+
auto
overlap = period.overlap (test);
if (overlap && overlap->duration() > DCPTime(period.duration().get() / 2)) {
ps.push_back (j.subs);
}
if (overlap && overlap->duration() > DCPTime(period.duration().get() / 2)) {
ps.push_back (j.subs);
}
@@
-66,6
+84,7
@@
ActiveText::get_burnt (DCPTimePeriod period, bool always_burn_captions) const
return ps;
}
return ps;
}
+
/** Remove subtitles that finish before a given time from our list.
* @param time Time to remove before.
*/
/** Remove subtitles that finish before a given time from our list.
* @param time Time to remove before.
*/
@@
-75,20
+94,21
@@
ActiveText::clear_before (DCPTime time)
boost::mutex::scoped_lock lm (_mutex);
Map updated;
boost::mutex::scoped_lock lm (_mutex);
Map updated;
- for (
Map::const_iterator i = _data.begin(); i != _data.end(); ++i
) {
+ for (
auto const& i: _data
) {
list<Period> as;
list<Period> as;
- for (auto j: i
->
second) {
+ for (auto j: i
.
second) {
if (!j.to || j.to.get() >= time) {
as.push_back (j);
}
}
if (!as.empty ()) {
if (!j.to || j.to.get() >= time) {
as.push_back (j);
}
}
if (!as.empty ()) {
- updated[i
->
first] = as;
+ updated[i
.
first] = as;
}
}
_data = updated;
}
}
}
_data = updated;
}
+
/** Add a new subtitle with a from time.
* @param content Content that the subtitle is from.
* @param ps Subtitles.
/** Add a new subtitle with a from time.
* @param content Content that the subtitle is from.
* @param ps Subtitles.
@@
-105,6
+125,7
@@
ActiveText::add_from (weak_ptr<const TextContent> content, PlayerText ps, DCPTim
_data[content].push_back (Period (ps, from));
}
_data[content].push_back (Period (ps, from));
}
+
/** Add the to time for the last subtitle added from a piece of content.
* @param content Content that the subtitle is from.
* @param to To time for the last subtitle submitted to add_from for this content.
/** Add the to time for the last subtitle added from a piece of content.
* @param content Content that the subtitle is from.
* @param to To time for the last subtitle submitted to add_from for this content.
@@
-126,6
+147,7
@@
ActiveText::add_to (weak_ptr<const TextContent> content, DCPTime to)
return make_pair (_data[content].back().subs, _data[content].back().from);
}
return make_pair (_data[content].back().subs, _data[content].back().from);
}
+
/** @param content Some content.
* @return true if we have any active subtitles from this content.
*/
/** @param content Some content.
* @return true if we have any active subtitles from this content.
*/
@@
-134,7
+156,7
@@
ActiveText::have (weak_ptr<const TextContent> content) const
{
boost::mutex::scoped_lock lm (_mutex);
{
boost::mutex::scoped_lock lm (_mutex);
-
Map::const_iterator
i = _data.find(content);
+
auto
i = _data.find(content);
if (i == _data.end()) {
return false;
}
if (i == _data.end()) {
return false;
}
@@
-142,6
+164,7
@@
ActiveText::have (weak_ptr<const TextContent> content) const
return !i->second.empty();
}
return !i->second.empty();
}
+
void
ActiveText::clear ()
{
void
ActiveText::clear ()
{