From: Carl Hetherington Date: Tue, 4 Feb 2014 09:59:38 +0000 (+0000) Subject: Merge master. X-Git-Tag: v2.0.48~919 X-Git-Url: https://main.carlh.net/gitweb/?p=dcpomatic.git;a=commitdiff_plain;h=4ba8772aef261da209bbb882325fd61a8b479fd7 Merge master. --- 4ba8772aef261da209bbb882325fd61a8b479fd7 diff --cc src/lib/player.cc index cb6d51984,e661a7b36..3e6a1598d --- a/src/lib/player.cc +++ b/src/lib/player.cc @@@ -547,10 -521,13 +547,14 @@@ Player::content_changed (weak_ptr sc = dynamic_pointer_cast (piece->content); assert (sc); - dcpomatic::Rect in_rect = _in_subtitle.rect; + dcpomatic::Rect in_rect = _image_subtitle.subtitle->rect; libdcp::Size scaled_size; - in_rect.y += sc->subtitle_offset (); + in_rect.x += sc->subtitle_x_offset (); + in_rect.y += sc->subtitle_y_offset (); /* We will scale the subtitle up to fit _video_container_size, and also by the additional subtitle_scale */ scaled_size.width = in_rect.width * _video_container_size.width * sc->subtitle_scale (); @@@ -672,15 -684,24 +677,15 @@@ _out_subtitle.position.x = rint (_video_container_size.width * (in_rect.x + (in_rect.width * (1 - sc->subtitle_scale ()) / 2))); _out_subtitle.position.y = rint (_video_container_size.height * (in_rect.y + (in_rect.height * (1 - sc->subtitle_scale ()) / 2))); - _out_subtitle.image = _in_subtitle.image->scale ( + _out_subtitle.image = _image_subtitle.subtitle->image->scale ( scaled_size, Scaler::from_id ("bicubic"), - _in_subtitle.image->pixel_format (), + _image_subtitle.subtitle->image->pixel_format (), true ); - - /* XXX: hack */ - Time from = _in_subtitle.from; - Time to = _in_subtitle.to; - shared_ptr vc = dynamic_pointer_cast (piece->content); - if (vc) { - from = rint (from * vc->video_frame_rate() / _film->video_frame_rate()); - to = rint (to * vc->video_frame_rate() / _film->video_frame_rate()); - } - _out_subtitle.from = _image_subtitle.subtitle->dcp_time; - _out_subtitle.to = _image_subtitle.subtitle->dcp_time_to; - _out_subtitle.from = from + piece->content->position (); - _out_subtitle.to = to + piece->content->position (); ++ _out_subtitle.from = _image_subtitle.subtitle->dcp_time + piece->content->position (); ++ _out_subtitle.to = _image_subtitle.subtitle->dcp_time_to + piece->content->position (); } /** Re-emit the last frame that was emitted, using current settings for crop, ratio, scaler and subtitles. diff --cc src/lib/subrip_content.cc index 48d3528e1,000000000..73499a5f6 mode 100644,000000..100644 --- a/src/lib/subrip_content.cc +++ b/src/lib/subrip_content.cc @@@ -1,99 -1,0 +1,100 @@@ +/* + Copyright (C) 2014 Carl Hetherington + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +#include "subrip_content.h" +#include "util.h" +#include "subrip.h" + +#include "i18n.h" + +using std::stringstream; +using std::string; +using boost::shared_ptr; + +SubRipContent::SubRipContent (shared_ptr film, boost::filesystem::path path) + : Content (film, path) + , SubtitleContent (film, path) +{ + +} + - SubRipContent::SubRipContent (shared_ptr film, shared_ptr node, int) ++SubRipContent::SubRipContent (shared_ptr film, shared_ptr node, int version) + : Content (film, node) - , SubtitleContent (film, node) ++ , SubtitleContent (film, node, version) +{ + +} + +void +SubRipContent::examine (boost::shared_ptr job) +{ + Content::examine (job); + SubRip s (shared_from_this ()); + boost::mutex::scoped_lock lm (_mutex); + _length = s.length (); +} + +string +SubRipContent::summary () const +{ + return path_summary() + " " + _("[subtitles]"); +} + +string +SubRipContent::technical_summary () const +{ + return Content::technical_summary() + " - " + _("SubRip subtitles"); +} + +string +SubRipContent::information () const +{ + +} + +void +SubRipContent::as_xml (xmlpp::Node* node) +{ + node->add_child("Type")->add_child_text ("SubRip"); + Content::as_xml (node); + SubtitleContent::as_xml (node); +} + +DCPTime +SubRipContent::full_length () const +{ + /* XXX: this assumes that the timing of the SubRip file is appropriate + for the DCP's frame rate. + */ + return _length; +} + +string +SubRipContent::identifier () const +{ + LocaleGuard lg; + + stringstream s; + s << Content::identifier() + << "_" << subtitle_scale() - << "_" << subtitle_offset(); ++ << "_" << subtitle_x_offset() ++ << "_" << subtitle_y_offset(); + + return s.str (); +}