}
+int
+PixelQuanta::round_x (int x_) const
+{
+ return x_ - (x_ % x);
+}
+
+
+int
+PixelQuanta::round_y (int y_) const
+{
+ return y_ - (y_ % y);
+}
+
+
PixelQuanta
max (PixelQuanta const& a, PixelQuanta const& b)
{
void as_xml (xmlpp::Element* node) const;
+ int round_x (int x_) const;
+ int round_y (int y_) const;
+
int x;
int y;
};
_last_video[wp] = std::make_shared<PlayerVideo>(
video.image,
- piece->content->video->crop (),
+ piece->content->video->actual_crop(),
piece->content->video->fade (_film, video.frame),
scale_for_display(piece->content->video->scaled_size(_film->frame_size()), _video_container_size, _film->frame_size()),
_video_container_size,
return false;
}
- _crop = content->video->crop();
+ _crop = content->video->actual_crop();
_fade = content->video->fade(film, _video_frame.get());
_inter_size = scale_for_display(content->video->scaled_size(film->frame_size()), player_video_container_size, film->frame_size());
_out_size = player_video_container_size;
throw JoinError (_("Content to be joined must have the same video frame type."));
}
- if (c[i]->video->crop() != ref->crop()) {
+ if (c[i]->video->requested_crop() != ref->requested_crop()) {
throw JoinError (_("Content to be joined must have the same crop."));
}
_use = ref->use ();
_size = ref->size ();
_frame_type = ref->frame_type ();
- _crop = ref->crop ();
+ _crop = ref->requested_crop ();
_custom_ratio = ref->custom_ratio ();
_colour_conversion = ref->colour_conversion ();
_fade_in = ref->fade_in ();
VideoContent::identifier () const
{
char buffer[256];
+ auto const crop = actual_crop();
snprintf (
buffer, sizeof(buffer), "%d_%d_%d_%d_%d_%f_%d_%d%" PRId64 "_%" PRId64 "_%d",
(_use ? 1 : 0),
- crop().left,
- crop().right,
- crop().top,
- crop().bottom,
+ crop.left,
+ crop.right,
+ crop.top,
+ crop.bottom,
_custom_ratio.get_value_or(0),
_custom_size ? _custom_size->width : 0,
_custom_size ? _custom_size->height : 0,
dcp::Size
VideoContent::size_after_crop () const
{
- return crop().apply (size_after_3d_split ());
+ return actual_crop().apply(size_after_3d_split());
}
d += buffer;
}
- if ((crop().left || crop().right || crop().top || crop().bottom) && size() != dcp::Size (0, 0)) {
- dcp::Size cropped = size_after_crop ();
+ auto const crop = actual_crop();
+
+ if ((crop.left || crop.right || crop.top || crop.bottom) && size() != dcp::Size(0, 0)) {
+ auto const cropped = size_after_crop ();
d += String::compose (
_("\nCropped to %1x%2"),
cropped.width, cropped.height
{
maybe_set (_custom_size, size, VideoContentProperty::CUSTOM_SIZE);
}
+
+
+Crop
+VideoContent::actual_crop () const
+{
+ return Crop(
+ _pixel_quanta.round_x(_crop.left),
+ _pixel_quanta.round_x(_crop.right),
+ _pixel_quanta.round_y(_crop.top),
+ _pixel_quanta.round_y(_crop.bottom)
+ );
+}
+
return _frame_type;
}
- Crop crop () const {
+ Crop actual_crop () const;
+
+ Crop requested_crop () const {
boost::mutex::scoped_lock lm (_mutex);
return _crop;
}
- int left_crop () const {
+ int requested_left_crop () const {
boost::mutex::scoped_lock lm (_mutex);
return _crop.left;
}
- int right_crop () const {
+ int requested_right_crop () const {
boost::mutex::scoped_lock lm (_mutex);
return _crop.right;
}
- int top_crop () const {
+ int requested_top_crop () const {
boost::mutex::scoped_lock lm (_mutex);
return _crop.top;
}
- int bottom_crop () const {
+ int requested_bottom_crop () const {
boost::mutex::scoped_lock lm (_mutex);
return _crop.bottom;
}
if (c->video) {
cout << "\t" << c->video->size().width << "x" << c->video->size().height << "\n"
<< "\t" << c->active_video_frame_rate(film) << "fps\n"
- << "\tcrop left " << c->video->left_crop()
- << " right " << c->video->right_crop()
- << " top " << c->video->top_crop()
- << " bottom " << c->video->bottom_crop() << "\n";
+ << "\tcrop left " << c->video->requested_left_crop()
+ << " right " << c->video->requested_right_crop()
+ << " top " << c->video->requested_top_crop()
+ << " bottom " << c->video->requested_bottom_crop() << "\n";
if (c->video->custom_ratio()) {
cout << "\tscale to custom ratio " << *c->video->custom_ratio() << ":1\n";
}
new wxSpinCtrl (this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(crop_width, -1)),
VideoContentProperty::CROP,
&Content::video,
- boost::mem_fn (&VideoContent::left_crop),
+ boost::mem_fn (&VideoContent::requested_left_crop),
boost::mem_fn (&VideoContent::set_left_crop),
boost::bind (&VideoPanel::left_crop_changed, this)
);
new wxSpinCtrl (this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(crop_width, -1)),
VideoContentProperty::CROP,
&Content::video,
- boost::mem_fn (&VideoContent::right_crop),
+ boost::mem_fn (&VideoContent::requested_right_crop),
boost::mem_fn (&VideoContent::set_right_crop),
boost::bind (&VideoPanel::right_crop_changed, this)
);
new wxSpinCtrl (this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(crop_width, -1)),
VideoContentProperty::CROP,
&Content::video,
- boost::mem_fn (&VideoContent::top_crop),
+ boost::mem_fn (&VideoContent::requested_top_crop),
boost::mem_fn (&VideoContent::set_top_crop),
boost::bind (&VideoPanel::top_crop_changed, this)
);
new wxSpinCtrl (this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(crop_width, -1)),
VideoContentProperty::CROP,
&Content::video,
- boost::mem_fn (&VideoContent::bottom_crop),
+ boost::mem_fn (&VideoContent::requested_bottom_crop),
boost::mem_fn (&VideoContent::set_bottom_crop),
boost::bind (&VideoPanel::bottom_crop_changed, this)
);
_left_changed_last = true;
if (_left_right_link->GetValue()) {
for (auto i: _parent->selected_video()) {
- i->video->set_right_crop (i->video->left_crop());
+ i->video->set_right_crop (i->video->requested_left_crop());
}
}
}
_left_changed_last = false;
if (_left_right_link->GetValue()) {
for (auto i: _parent->selected_video()) {
- i->video->set_left_crop (i->video->right_crop());
+ i->video->set_left_crop (i->video->requested_right_crop());
}
}
}
_top_changed_last = true;
if (_top_bottom_link->GetValue()) {
for (auto i: _parent->selected_video()) {
- i->video->set_bottom_crop (i->video->top_crop());
+ i->video->set_bottom_crop (i->video->requested_top_crop());
}
}
}
_top_changed_last = false;
if (_top_bottom_link->GetValue()) {
for (auto i: _parent->selected_video()) {
- i->video->set_top_crop (i->video->bottom_crop());
+ i->video->set_top_crop (i->video->requested_bottom_crop());
}
}
}
-