Playlist::move_later (shared_ptr<const Film> film, shared_ptr<Content> c)
{
auto cont = content ();
- auto i = cont.begin();
- while (i != cont.end() && *i != c) {
- ++i;
- }
- DCPOMATIC_ASSERT (i != cont.end());
-
- ContentList::iterator next = i;
- ++next;
+ auto iter = std::find(cont.begin(), cont.end(), c);
+ DCPOMATIC_ASSERT(iter != cont.end());
+ ContentList::iterator next = std::next(iter);
if (next == cont.end()) {
+ /* This content is already at the end */
return;
}
- auto next_c = *next;
-
- next_c->set_position (film, c->position());
- c->set_position (film, c->position() + next_c->length_after_trim(film));
+ (*next)->set_position(film, c->position());
+ c->set_position(film, c->position() + (*next)->length_after_trim(film));
}
int64_t
Playlist::required_disk_space (shared_ptr<const Film> film, int j2k_bandwidth, int audio_channels, int audio_frame_rate) const
{
- int64_t video = uint64_t (j2k_bandwidth / 8) * length(film).seconds();
- int64_t audio = uint64_t (audio_channels * audio_frame_rate * 3) * length(film).seconds();
+ int64_t video = uint64_t(j2k_bandwidth / 8) * length(film).seconds();
+ int64_t audio = uint64_t(audio_channels) * audio_frame_rate * 3 * length(film).seconds();
for (auto i: content()) {
auto d = dynamic_pointer_cast<DCPContent> (i);
video -= uint64_t (j2k_bandwidth / 8) * d->length_after_trim(film).seconds();
}
if (d->reference_audio()) {
- audio -= uint64_t (audio_channels * audio_frame_rate * 3) * d->length_after_trim(film).seconds();
+ audio -= uint64_t(audio_channels) * audio_frame_rate * 3 * d->length_after_trim(film).seconds();
}
}
}
}
if (score > best_score) {
- best_summary = i->path(0).leaf().string();
+ best_summary = i->path(0).filename().string();
best_score = score;
}
}