diff options
| author | Carl Hetherington <cth@carlh.net> | 2012-10-15 23:42:19 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2012-10-15 23:42:19 +0100 |
| commit | 63b7da59cee71ab2ade744a8b547b5d8f2ff6bfc (patch) | |
| tree | 6e107ab63deff4e5e8b5a462f767e6ed4685cbdb /src/lib/subtitle.cc | |
| parent | bd9906422fe59126a27a3002b2bb4ce497eef508 (diff) | |
Clean up subtitle classes a bit.
Diffstat (limited to 'src/lib/subtitle.cc')
| -rw-r--r-- | src/lib/subtitle.cc | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/src/lib/subtitle.cc b/src/lib/subtitle.cc index 2e9a89088..7e1ca2d2a 100644 --- a/src/lib/subtitle.cc +++ b/src/lib/subtitle.cc @@ -25,7 +25,7 @@ using namespace std; using namespace boost; -Subtitle::Subtitle (AVSubtitle const & sub) +TimedSubtitle::TimedSubtitle (AVSubtitle const & sub) { /* subtitle PTS in seconds */ float const packet_time = (sub.pts / AV_TIME_BASE) + float (sub.pts % AV_TIME_BASE) / 1e6; @@ -44,15 +44,14 @@ Subtitle::Subtitle (AVSubtitle const & sub) throw DecodeError ("non-bitmap subtitles not yet supported"); } - _position = Position (rect->x, rect->y); - _image.reset (new AlignedImage (PIX_FMT_RGBA, Size (rect->w, rect->h))); + shared_ptr<Image> image (new AlignedImage (PIX_FMT_RGBA, Size (rect->w, rect->h))); /* Start of the first line in the subtitle */ uint8_t* sub_p = rect->pict.data[0]; /* sub_p looks up into a RGB palette which is here */ uint32_t const * palette = (uint32_t *) rect->pict.data[1]; /* Start of the output data */ - uint32_t* out_p = (uint32_t *) _image->data()[0]; + uint32_t* out_p = (uint32_t *) image->data()[0]; for (int y = 0; y < rect->h; ++y) { uint8_t* sub_line_p = sub_p; @@ -61,26 +60,26 @@ Subtitle::Subtitle (AVSubtitle const & sub) *out_line_p++ = palette[*sub_line_p++]; } sub_p += rect->pict.linesize[0]; - out_p += _image->stride()[0] / sizeof (uint32_t); + out_p += image->stride()[0] / sizeof (uint32_t); } -} -Subtitle::Subtitle (Position p, shared_ptr<Image> i) - : _from (0) - , _to (0) - , _position (p) - , _image (i) -{ + _subtitle.reset (new Subtitle (Position (rect->x, rect->y), image)); +} -} - /** @param t Time in seconds from the start of the film */ bool -Subtitle::displayed_at (double t) +TimedSubtitle::displayed_at (double t) const { return t >= _from && t <= _to; } +Subtitle::Subtitle (Position p, shared_ptr<Image> i) + : _position (p) + , _image (i) +{ + +} + Rectangle subtitle_transformed_area ( float target_x_scale, float target_y_scale, |
