diff options
| author | Carl Hetherington <cth@carlh.net> | 2012-10-11 21:54:52 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2012-10-11 21:54:52 +0100 |
| commit | f78ce22dc46e42e4f041ebf877fd7199232e4856 (patch) | |
| tree | 0e2a4a2c3cd3618ca32d14696437993b21d9c23b /src/lib | |
| parent | a8b56b931203f984ae7e3f66bc5b9e66d0942199 (diff) | |
Basic sub offset support.
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/film.cc | 14 | ||||
| -rw-r--r-- | src/lib/film.h | 12 | ||||
| -rw-r--r-- | src/lib/film_state.cc | 6 | ||||
| -rw-r--r-- | src/lib/film_state.h | 7 |
4 files changed, 39 insertions, 0 deletions
diff --git a/src/lib/film.cc b/src/lib/film.cc index 08ef938d1..e4155c9f6 100644 --- a/src/lib/film.cc +++ b/src/lib/film.cc @@ -670,6 +670,20 @@ Film::set_with_subtitles (bool w) signal_changed (WITH_SUBTITLES); } +void +Film::set_subtitle_offset (int o) +{ + _state.subtitle_offset = o; + signal_changed (SUBTITLE_OFFSET); +} + +void +Film::set_subtitle_scale (float s) +{ + _state.subtitle_scale = s; + signal_changed (SUBTITLE_SCALE); +} + list<pair<Position, string> > Film::thumb_subtitles (int n) const { diff --git a/src/lib/film.h b/src/lib/film.h index 1e01747a2..c006eae36 100644 --- a/src/lib/film.h +++ b/src/lib/film.h @@ -123,6 +123,14 @@ public: bool with_subtitles () const { return _state.with_subtitles; } + + int subtitle_offset () const { + return _state.subtitle_offset; + } + + float subtitle_scale () const { + return _state.subtitle_scale; + } void set_filters (std::vector<Filter const *> const &); @@ -149,6 +157,8 @@ public: void set_audio_delay (int); void set_still_duration (int); void set_with_subtitles (bool); + void set_subtitle_offset (int); + void set_subtitle_scale (float); /** @return size, in pixels, of the source (ignoring cropping) */ Size size () const { @@ -230,6 +240,8 @@ public: AUDIO_SAMPLE_RATE, STILL_DURATION, WITH_SUBTITLES, + SUBTITLE_OFFSET, + SUBTITLE_SCALE }; boost::shared_ptr<FilmState> state_copy () const; diff --git a/src/lib/film_state.cc b/src/lib/film_state.cc index 610362dcd..a4d88d0e0 100644 --- a/src/lib/film_state.cc +++ b/src/lib/film_state.cc @@ -81,6 +81,8 @@ FilmState::write_metadata (ofstream& f) const f << "audio_delay " << audio_delay << "\n"; f << "still_duration " << still_duration << "\n"; f << "with_subtitles " << with_subtitles << "\n"; + f << "subtitle_offset " << subtitle_offset << "\n"; + f << "subtitle_scale " << subtitle_scale << "\n"; /* Cached stuff; this is information about our content; we could look it up each time, but that's slow. @@ -146,6 +148,10 @@ FilmState::read_metadata (string k, string v) still_duration = atoi (v.c_str ()); } else if (k == "with_subtitles") { with_subtitles = (v == "1"); + } else if (k == "subtitle_offset") { + subtitle_offset = atoi (v.c_str ()); + } else if (k == "subtitle_scale") { + subtitle_scale = atof (v.c_str ()); } /* Cached stuff */ diff --git a/src/lib/film_state.h b/src/lib/film_state.h index 5b3ef8367..d53c6a969 100644 --- a/src/lib/film_state.h +++ b/src/lib/film_state.h @@ -63,6 +63,8 @@ public: , audio_delay (0) , still_duration (10) , with_subtitles (false) + , subtitle_offset (0) + , subtitle_scale (1) , length (0) , audio_channels (0) , audio_sample_rate (0) @@ -130,6 +132,11 @@ public: /** Duration to make still-sourced films (in seconds) */ int still_duration; bool with_subtitles; + /** y offset for placing subtitles, in source pixels; +ve is further down + the frame, -ve is further up. + */ + int subtitle_offset; + float subtitle_scale; /* Data which is cached to speed things up */ |
