using std::string;
using std::cout;
+using std::pair;
using boost::shared_ptr;
using boost::weak_ptr;
using boost::dynamic_pointer_cast;
image->read_from_socket (socket);
- _subtitle = PositionImage (image, Position<int> (node->number_child<int> ("SubtitleX"), node->number_child<int> ("SubtitleY")));
+ _caption = PositionImage (image, Position<int> (node->number_child<int> ("SubtitleX"), node->number_child<int> ("SubtitleY")));
}
}
void
-PlayerVideo::set_subtitle (PositionImage image)
+PlayerVideo::set_caption (PositionImage image)
{
- _subtitle = image;
+ _caption = image;
}
/** Create an image for this frame.
shared_ptr<Image>
PlayerVideo::image (dcp::NoteHandler note, function<AVPixelFormat (AVPixelFormat)> pixel_format, bool aligned, bool fast) const
{
- shared_ptr<Image> im = _in->image (optional<dcp::NoteHandler> (note), _inter_size);
+ pair<shared_ptr<Image>, int> prox = _in->image (optional<dcp::NoteHandler> (note), _inter_size);
+ shared_ptr<Image> im = prox.first;
+ int const reduce = prox.second;
Crop total_crop = _crop;
switch (_part) {
break;
}
+ if (reduce > 0) {
+ /* Scale the crop down to account for the scaling that has already happened in ImageProxy::image */
+ int const r = pow(2, reduce);
+ total_crop.left /= r;
+ total_crop.right /= r;
+ total_crop.top /= r;
+ total_crop.bottom /= r;
+ }
+
dcp::YUVToRGB yuv_to_rgb = dcp::YUV_TO_RGB_REC601;
if (_colour_conversion) {
yuv_to_rgb = _colour_conversion.get().yuv_to_rgb();
total_crop, _inter_size, _out_size, yuv_to_rgb, pixel_format (_in->pixel_format()), aligned, fast
);
- if (_subtitle) {
- out->alpha_blend (Image::ensure_aligned (_subtitle->image), _subtitle->position);
+ if (_caption) {
+ out->alpha_blend (Image::ensure_aligned (_caption->image), _caption->position);
}
if (_fade) {
if (_colour_conversion) {
_colour_conversion.get().as_xml (node);
}
- if (_subtitle) {
- node->add_child ("SubtitleWidth")->add_child_text (raw_convert<string> (_subtitle->image->size().width));
- node->add_child ("SubtitleHeight")->add_child_text (raw_convert<string> (_subtitle->image->size().height));
- node->add_child ("SubtitleX")->add_child_text (raw_convert<string> (_subtitle->position.x));
- node->add_child ("SubtitleY")->add_child_text (raw_convert<string> (_subtitle->position.y));
+ if (_caption) {
+ node->add_child ("SubtitleWidth")->add_child_text (raw_convert<string> (_caption->image->size().width));
+ node->add_child ("SubtitleHeight")->add_child_text (raw_convert<string> (_caption->image->size().height));
+ node->add_child ("SubtitleX")->add_child_text (raw_convert<string> (_caption->position.x));
+ node->add_child ("SubtitleY")->add_child_text (raw_convert<string> (_caption->position.y));
}
}
PlayerVideo::send_binary (shared_ptr<Socket> socket) const
{
_in->send_binary (socket);
- if (_subtitle) {
- _subtitle->image->write_to_socket (socket);
+ if (_caption) {
+ _caption->image->write_to_socket (socket);
}
}
return false;
}
- return _crop == Crop () && _out_size == j2k->size() && !_subtitle && !_fade && !_colour_conversion;
+ return _crop == Crop () && _out_size == j2k->size() && !_caption && !_fade && !_colour_conversion;
}
Data
return false;
}
- if ((!_subtitle && other->_subtitle) || (_subtitle && !other->_subtitle)) {
- /* One has a subtitle and the other doesn't */
+ if ((!_caption && other->_caption) || (_caption && !other->_caption)) {
+ /* One has a caption and the other doesn't */
return false;
}
- if (_subtitle && other->_subtitle && !_subtitle->same (other->_subtitle.get ())) {
- /* They both have subtitles but they are different */
+ if (_caption && other->_caption && !_caption->same (other->_caption.get ())) {
+ /* They both have captions but they are different */
return false;
}
return _in->memory_used();
}
-/** @return Shallow copy of this; _in and _subtitle are shared between the original and the copy */
+/** @return Shallow copy of this; _in and _caption are shared between the original and the copy */
shared_ptr<PlayerVideo>
PlayerVideo::shallow_copy () const
{
);
}
-/** Re-read crop, fade, inter/out size and colour conversion from our content */
-void
+/** Re-read crop, fade, inter/out size and colour conversion from our content.
+ * @return true if this was possible, false if not.
+ */
+bool
PlayerVideo::reset_metadata (dcp::Size video_container_size, dcp::Size film_frame_size)
{
shared_ptr<Content> content = _content.lock();
- DCPOMATIC_ASSERT (content);
- DCPOMATIC_ASSERT (_video_frame);
+ if (!content || !_video_frame) {
+ return false;
+ }
_crop = content->video->crop();
_fade = content->video->fade(_video_frame.get());
_inter_size = content->video->scale().size(content->video, video_container_size, film_frame_size);
_out_size = video_container_size;
_colour_conversion = content->video->colour_conversion();
+
+ return true;
}