#include "util.h"
#include "film.h"
#include "exceptions.h"
+#include "frame_rate_change.h"
#include "i18n.h"
using std::setprecision;
using std::cout;
using std::vector;
+using std::min;
+using std::max;
using boost::shared_ptr;
using boost::optional;
using boost::dynamic_pointer_cast;
node->add_child("VideoHeight")->add_child_text (raw_convert<string> (_video_size.height));
node->add_child("VideoFrameRate")->add_child_text (raw_convert<string> (_video_frame_rate));
node->add_child("VideoFrameType")->add_child_text (raw_convert<string> (static_cast<int> (_video_frame_type)));
- node->add_child("LeftCrop")->add_child_text (raw_convert<string> (_crop.left));
- node->add_child("RightCrop")->add_child_text (raw_convert<string> (_crop.right));
- node->add_child("TopCrop")->add_child_text (raw_convert<string> (_crop.top));
- node->add_child("BottomCrop")->add_child_text (raw_convert<string> (_crop.bottom));
+ _crop.as_xml (node);
_scale.as_xml (node->add_child("Scale"));
_colour_conversion.as_xml (node->add_child("ColourConversion"));
}
shared_ptr<const Film> film = _film.lock ();
assert (film);
- FrameRateConversion frc (video_frame_rate(), film->video_frame_rate());
+ FrameRateChange frc (video_frame_rate(), film->video_frame_rate());
/* Here we are converting from time (in the DCP) to a frame number in the content.
Hence we need to use the DCP's frame rate and the double/skip correction, not
return t * film->video_frame_rate() / (frc.factor() * TIME_HZ);
}
+void
+VideoContent::scale_and_crop_to_fit_width ()
+{
+ shared_ptr<const Film> film = _film.lock ();
+ assert (film);
+
+ set_scale (VideoContentScale (film->container ()));
+
+ int const crop = max (0, int (video_size().height - double (film->frame_size().height) * video_size().width / film->frame_size().width));
+ set_top_crop (crop / 2);
+ set_bottom_crop (crop / 2);
+}
+
+void
+VideoContent::scale_and_crop_to_fit_height ()
+{
+ shared_ptr<const Film> film = _film.lock ();
+ assert (film);
+
+ set_scale (VideoContentScale (film->container ()));
+
+ int const crop = max (0, int (video_size().width - double (film->frame_size().width) * video_size().height / film->frame_size().height));
+ set_left_crop (crop / 2);
+ set_right_crop (crop / 2);
+}
+
+void
+VideoContent::set_video_frame_rate (float r)
+{
+ {
+ boost::mutex::scoped_lock lm (_mutex);
+ if (_video_frame_rate == r) {
+ return;
+ }
+
+ _video_frame_rate = r;
+ }
+
+ signal_changed (VideoContentProperty::VIDEO_FRAME_RATE);
+}
+
VideoContentScale::VideoContentScale (Ratio const * r)
: _ratio (r)
, _scale (true)