diff options
| author | Carl Hetherington <cth@carlh.net> | 2012-10-17 00:06:10 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2012-10-17 00:06:10 +0100 |
| commit | 7ef2ba523ca2ddc0470f5837bc88ad9c597361e2 (patch) | |
| tree | 9aaa33632f2c41e8c3129543c8214c8c3d7274cb /src/lib | |
| parent | 9e93c860759b8d04277596781706488f59a3cc12 (diff) | |
| parent | c37c744bbb236b1fd39f86e4f0ab36652d403d67 (diff) | |
Merge branch 'master' of /home/carl/git/dvdomatic
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/film.h | 12 | ||||
| -rw-r--r-- | src/lib/film_state.cc | 8 | ||||
| -rw-r--r-- | src/lib/film_state.h | 3 | ||||
| -rw-r--r-- | src/lib/server.cc | 2 | ||||
| -rw-r--r-- | src/lib/subtitle.cc | 25 | ||||
| -rw-r--r-- | src/lib/subtitle.h | 10 | ||||
| -rw-r--r-- | src/lib/util.cc | 20 | ||||
| -rw-r--r-- | src/lib/util.h | 3 |
8 files changed, 77 insertions, 6 deletions
diff --git a/src/lib/film.h b/src/lib/film.h index a1cf26bc6..ae0ad7ad1 100644 --- a/src/lib/film.h +++ b/src/lib/film.h @@ -76,6 +76,7 @@ public: return _state.dcp_name (); } + /** @return true to use a DCI-spec name for the DCP */ bool use_dci_name () const { return _state.use_dci_name; } @@ -105,6 +106,7 @@ public: return _state.dcp_frames; } + /** @return what to do with the end of an encode when trimming */ TrimAction dcp_trim_action () const { return _state.dcp_trim_action; } @@ -117,26 +119,36 @@ public: return _state.dcp_ab; } + /** @return gain that should be applied to the audio when making a DCP + (in dB). + */ float audio_gain () const { return _state.audio_gain; } + /** @return delay to apply to audio (positive moves audio later) in milliseconds */ int audio_delay () const { return _state.audio_delay; } + /** @return duration to make still-sourced films (in seconds) */ int still_duration () const { return _state.still_duration; } + /** @return true to encode DCP with subtitles, if they are available */ bool with_subtitles () const { return _state.with_subtitles; } + /** @return offset to move subtitles by, in source pixels; +ve moves + them down the image, -ve moves them up. + */ int subtitle_offset () const { return _state.subtitle_offset; } + /** @return scaling factor to apply to subtitle images */ float subtitle_scale () const { return _state.subtitle_scale; } diff --git a/src/lib/film_state.cc b/src/lib/film_state.cc index 094342d7b..aa8bb5563 100644 --- a/src/lib/film_state.cc +++ b/src/lib/film_state.cc @@ -355,6 +355,7 @@ FilmState::dcp_length () const return length; } +/** @return a DCI-compliant name for a DCP of this film */ string FilmState::dci_name () const { @@ -367,6 +368,11 @@ FilmState::dci_name () const } } + /* Spec is that the name part should be maximum 14 characters, as I understand it */ + if (fixed_name.length() > 14) { + fixed_name = fixed_name.substr (0, 14); + } + d << fixed_name << "_"; if (dcp_content_type) { @@ -417,7 +423,7 @@ FilmState::dci_name () const } gregorian::date today = gregorian::day_clock::local_day (); - d << gregorian::to_iso_extended_string (today) << "_"; + d << gregorian::to_iso_string (today) << "_"; if (!facility.empty ()) { d << facility << "_"; diff --git a/src/lib/film_state.h b/src/lib/film_state.h index 01bcdfd5c..ea287fb3b 100644 --- a/src/lib/film_state.h +++ b/src/lib/film_state.h @@ -103,6 +103,7 @@ public: std::string directory; /** Name for DVD-o-matic */ std::string name; + /** True if a auto-generated DCI-compliant name should be used for our DCP */ bool use_dci_name; /** File or directory containing content; may be relative to our directory * or an absolute path. @@ -135,11 +136,13 @@ public: int audio_delay; /** Duration to make still-sourced films (in seconds) */ int still_duration; + /** True if subtitles should be shown for this film */ bool with_subtitles; /** y offset for placing subtitles, in source pixels; +ve is further down the frame, -ve is further up. */ int subtitle_offset; + /** scale factor to apply to subtitles */ float subtitle_scale; /* DCI naming stuff */ diff --git a/src/lib/server.cc b/src/lib/server.cc index e8a9804ed..10f64b482 100644 --- a/src/lib/server.cc +++ b/src/lib/server.cc @@ -90,7 +90,7 @@ Server::process (shared_ptr<Socket> socket) Size out_size (get_required_int (kv, "output_width"), get_required_int (kv, "output_height")); int padding = get_required_int (kv, "padding"); int subtitle_offset = get_required_int (kv, "subtitle_offset"); - int subtitle_scale = get_required_int (kv, "subtitle_scale"); + float subtitle_scale = get_required_float (kv, "subtitle_scale"); string scaler_id = get_required_string (kv, "scaler"); int frame = get_required_int (kv, "frame"); int frames_per_second = get_required_int (kv, "frames_per_second"); diff --git a/src/lib/subtitle.cc b/src/lib/subtitle.cc index 01e8cac13..dcb747828 100644 --- a/src/lib/subtitle.cc +++ b/src/lib/subtitle.cc @@ -17,6 +17,10 @@ */ +/** @file src/subtitle.cc + * @brief Representations of subtitles. + */ + #include "subtitle.h" #include "image.h" #include "exceptions.h" @@ -25,6 +29,10 @@ using namespace std; using namespace boost; +/** Construct a TimedSubtitle. This is a subtitle image, position, + * and a range of time over which it should be shown. + * @param sub AVSubtitle to read. + */ TimedSubtitle::TimedSubtitle (AVSubtitle const & sub) { /* subtitle PTS in seconds */ @@ -73,13 +81,27 @@ TimedSubtitle::displayed_at (double t) const return t >= _from && t <= _to; } +/** Construct a subtitle, which is an image and a position. + * @param p Position within the (uncropped) source frame. + * @param i Image of the subtitle (should be RGBA). + */ Subtitle::Subtitle (Position p, shared_ptr<Image> i) : _position (p) , _image (i) { } - + +/** Given the area of a subtitle, work out the area it should + * take up when its video frame is scaled up, and it is optionally + * itself scaled and offset. + * @param target_x_scale the x scaling of the video frame that the subtitle is in. + * @param target_y_scale the y scaling of the video frame that the subtitle is in. + * @param sub_area The area of the subtitle within the original source. + * @param subtitle_offset y offset to apply to the subtitle position (+ve is down) + * in the coordinate space of the source. + * @param subtitle_scale scaling factor to apply to the subtitle image. + */ Rectangle subtitle_transformed_area ( float target_x_scale, float target_y_scale, @@ -114,6 +136,7 @@ subtitle_transformed_area ( return tx; } +/** @return area that this subtitle take up, in the original uncropped source's coordinate space */ Rectangle Subtitle::area () const { diff --git a/src/lib/subtitle.h b/src/lib/subtitle.h index de8f02596..1cc906ce0 100644 --- a/src/lib/subtitle.h +++ b/src/lib/subtitle.h @@ -17,6 +17,10 @@ */ +/** @file src/subtitle.h + * @brief Representations of subtitles. + */ + #include <list> #include <boost/shared_ptr.hpp> #include "util.h" @@ -24,6 +28,7 @@ struct AVSubtitle; class Image; +/** A subtitle, consisting of an image and a position */ class Subtitle { public: @@ -53,7 +58,8 @@ subtitle_transformed_area ( float target_x_scale, float target_y_scale, Rectangle 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: @@ -66,8 +72,8 @@ public: } private: + /** the subtitle */ boost::shared_ptr<Subtitle> _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 */ diff --git a/src/lib/util.cc b/src/lib/util.cc index c2b24944d..cc201a0af 100644 --- a/src/lib/util.cc +++ b/src/lib/util.cc @@ -615,6 +615,12 @@ Rectangle::intersection (Rectangle const & other) const ); } +/** Round a number up to the nearest multiple of another number. + * @param a Number to round. + * @param t Multiple to round to. + * @return Rounded number. + */ + int round_up (int a, int t) { @@ -622,6 +628,13 @@ round_up (int a, int t) return a - (a % t); } +/** Read a sequence of key / value pairs from a text stream; + * the keys are the first words on the line, and the values are + * the remainder of the line following the key. Lines beginning + * with # are ignored. + * @param s Stream to read. + * @return key/value pairs. + */ multimap<string, string> read_key_value (istream &s) { @@ -675,6 +688,13 @@ get_required_int (multimap<string, string> const & kv, string k) return lexical_cast<int> (v); } +float +get_required_float (multimap<string, string> const & kv, string k) +{ + string const v = get_required_string (kv, k); + return lexical_cast<float> (v); +} + string get_optional_string (multimap<string, string> const & kv, string k) { diff --git a/src/lib/util.h b/src/lib/util.h index 5f2e9a7fa..da7e73f20 100644 --- a/src/lib/util.h +++ b/src/lib/util.h @@ -160,6 +160,7 @@ extern std::string colour_lut_index_to_name (int index); extern int round_up (int, int); extern std::multimap<std::string, std::string> read_key_value (std::istream& s); extern int get_required_int (std::multimap<std::string, std::string> const & kv, std::string k); +extern float get_required_float (std::multimap<std::string, std::string> const & kv, std::string k); extern std::string get_required_string (std::multimap<std::string, std::string> const & kv, std::string k); extern int get_optional_int (std::multimap<std::string, std::string> const & kv, std::string k); extern std::string get_optional_string (std::multimap<std::string, std::string> const & kv, std::string k); @@ -169,7 +170,7 @@ extern std::string get_optional_string (std::multimap<std::string, std::string> * that are useful for DVD-o-matic. * * This class wraps some things that I could not work out how to do with boost; - * most notably, sync read/write calls with timeouts, and the ability to peak into + * most notably, sync read/write calls with timeouts, and the ability to peek into * data being read. */ class Socket |
