X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fsubtitle.h;h=c74f5c1b9f0c7c6c775dc368aea684eea1048f82;hb=82926443230084739cb673a83b2ab1f9d733a07b;hp=6fd0d8772643fe3ca8d92d27238a452b53bd867e;hpb=13511ed2fcc23f4d5f9c507c775c3c5cfd82d155;p=dcpomatic.git diff --git a/src/lib/subtitle.h b/src/lib/subtitle.h index 6fd0d8772..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,59 +17,56 @@ */ -#include #include -#include "util.h" - -struct AVSubtitle; -class SubtitleImage; +#include +#include +#include +#include "rect.h" +#include "types.h" + +class Film; +class Piece; class Image; -class FilmState; class Subtitle { public: - Subtitle (AVSubtitle const &); - bool displayed_at (double t); + Subtitle (boost::shared_ptr, libdcp::Size, boost::weak_ptr, boost::shared_ptr, dcpomatic::Rect, Time, Time); - std::list > images () const { - return _images; + void update (boost::shared_ptr, libdcp::Size); + void set_stop (Time t) { + _stop = t; + check_out_to (); } -private: - /** 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; - std::list > _images; -}; - -extern Rectangle transformed_subtitle_area ( - float target_x_scale, float target_y_scale, - Rectangle sub_area, int subtitle_offset, float subtitle_scale - ); - -class SubtitleImage -{ -public: - SubtitleImage (AVSubtitleRect const *); + bool covers (Time t) const; + bool ends_before (Time t) const { + return _out_to < t; + } - void set_position (Position p) { - _position = p; + boost::shared_ptr out_image () const { + return _out_image; } - Position position () const { - return _position; + Position out_position () const { + return _out_position; } - boost::shared_ptr image () const { - return _image; - } - - Rectangle area () const; - private: - Position _position; - boost::shared_ptr _image; + void check_out_to (); + + boost::weak_ptr _piece; + boost::shared_ptr _in_image; + dcpomatic::Rect _in_rect; + Time _in_from; + Time _in_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