X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fsubtitle.h;h=c74f5c1b9f0c7c6c775dc368aea684eea1048f82;hb=e01961397fbf87c69da4c8a8e79cef3c16480d3a;hp=38ba4e70e0170fabd5e2a71ee2ad9eadceb5a2ee;hpb=dedac27070ac5ad65265a0db1fa316b3e436cea7;p=dcpomatic.git diff --git a/src/lib/subtitle.h b/src/lib/subtitle.h index 38ba4e70e..c74f5c1b9 100644 --- a/src/lib/subtitle.h +++ b/src/lib/subtitle.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2012 Carl Hetherington + Copyright (C) 2013-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 @@ -17,65 +17,56 @@ */ -/** @file src/subtitle.h - * @brief Representations of subtitles. - */ - -#include #include -#include "util.h" +#include +#include +#include +#include "rect.h" +#include "types.h" -struct AVSubtitle; +class Film; +class Piece; class Image; -/** A subtitle, consisting of an image and a position */ class Subtitle { public: - Subtitle (Position p, boost::shared_ptr i); - void set_position (Position p) { - _position = p; + Subtitle (boost::shared_ptr, libdcp::Size, boost::weak_ptr, boost::shared_ptr, dcpomatic::Rect, Time, Time); + + void update (boost::shared_ptr, libdcp::Size); + void set_stop (Time t) { + _stop = t; + check_out_to (); } - Position position () const { - return _position; + bool covers (Time t) const; + bool ends_before (Time t) const { + return _out_to < t; } - - boost::shared_ptr image () const { - return _image; + + boost::shared_ptr out_image () const { + return _out_image; } - Rect area () const; + Position out_position () const { + return _out_position; + } private: - Position _position; - boost::shared_ptr _image; -}; - -Rect -subtitle_transformed_area ( - float target_x_scale, float target_y_scale, - Rect sub_area, int subtitle_offset, float subtitle_scale - ); - -/** A Subtitle class with details of the time over which it should be shown */ -class TimedSubtitle -{ -public: - TimedSubtitle (AVSubtitle const &); - - bool displayed_at (double t) const; + void check_out_to (); - boost::shared_ptr subtitle () const { - return _subtitle; - } + boost::weak_ptr _piece; + boost::shared_ptr _in_image; + dcpomatic::Rect _in_rect; + Time _in_from; + Time _in_to; -private: - /** the subtitle */ - boost::shared_ptr _subtitle; - /** display from time in seconds from the start of the film */ - double _from; - /** display to time in seconds from the start of the film */ - double _to; + boost::shared_ptr _out_image; + Position _out_position; + Time _out_from; + Time _out_to; + + /** Time at which this subtitle should stop (overriding _out_to) */ + boost::optional