*/
-#include <libcxml/cxml.h>
-#include <boost/shared_ptr.hpp>
#include "playlist.h"
#include "sndfile_content.h"
#include "sndfile_decoder.h"
#include "config.h"
#include "util.h"
#include "md5_digester.h"
+#include <libcxml/cxml.h>
+#include <libxml++/libxml++.h>
+#include <boost/shared_ptr.hpp>
#include "i18n.h"
continue;
}
+ /* Best error for this content; we could use the content as-is or double its rate */
+ float best_error = min (
+ float (fabs (i->source - vc->video_frame_rate ())),
+ float (fabs (i->source - vc->video_frame_rate () * 2))
+ );
+
/* Use the largest difference between DCP and source as the "error" */
- this_error = max (this_error, float (fabs (i->source - vc->video_frame_rate ())));
+ this_error = max (this_error, best_error);
}
if (this_error < error) {
FrameRateChange
Playlist::active_frame_rate_change (DCPTime t, int dcp_video_frame_rate) const
{
- for (ContentList::const_iterator i = _content.begin(); i != _content.end(); ++i) {
+ for (ContentList::const_reverse_iterator i = _content.rbegin(); i != _content.rend(); ++i) {
shared_ptr<const VideoContent> vc = dynamic_pointer_cast<const VideoContent> (*i);
if (!vc) {
continue;
}
- if (vc->position() >= t && t < vc->end()) {
+ if (vc->position() <= t) {
+ /* This is the first piece of content (going backwards...) that starts before t,
+ so it's the active one.
+ */
return FrameRateChange (vc->video_frame_rate(), dcp_video_frame_rate);
}
}