X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fsubtitle.h;h=c74f5c1b9f0c7c6c775dc368aea684eea1048f82;hb=884093edac5f63d26c02d411c73dfb52376ccf8f;hp=52bd35923b8c0e1b9101dcd676c7ea8d507e083e;hpb=237a0052c60af768f4d62b00321932918b7ba4d9;p=dcpomatic.git diff --git a/src/lib/subtitle.h b/src/lib/subtitle.h index 52bd35923..c74f5c1b9 100644 --- a/src/lib/subtitle.h +++ b/src/lib/subtitle.h @@ -1,7 +1,5 @@ -/* -*- c-basic-offset: 8; default-tab-width: 8; -*- */ - /* - 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 @@ -19,65 +17,56 @@ */ -/** @file src/subtitle.h - * @brief Representations of subtitles. - */ - -#include #include +#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 (Time) const; + void check_out_to (); - boost::shared_ptr subtitle () const { - return _subtitle; - } - -private: - /** the subtitle */ - boost::shared_ptr _subtitle; - /** display from time from the start of the content */ - Time _from; - /** display to time from the start of the content */ - Time _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