--- /dev/null
+/*
+ Copyright (C) 2014 Carl Hetherington <cth@carlh.net>
+
+ 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
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
+#include "audio_buffers.h"
+
+class ContentAudio
+{
+public:
+ ContentAudio ()
+ : audio (new AudioBuffers (0, 0))
+ , frame (0)
+ {}
+
+ ContentAudio (boost::shared_ptr<AudioBuffers> a, AudioFrame f)
+ : audio (a)
+ , frame (f)
+ {}
+
+ boost::shared_ptr<AudioBuffers> audio;
+ AudioFrame frame;
+};
--- /dev/null
+/*
+ Copyright (C) 2014 Carl Hetherington <cth@carlh.net>
+
+ 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
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
+#include "content_subtitle.h"
+
+ContentTime
+ContentTextSubtitle::from () const
+{
+ /* XXX: assuming we have some subs and they are all at the same time */
+ assert (!subs.empty ());
+ return ContentTime::from_seconds (double (subs.front().in().to_ticks()) / 250);
+}
+
+ContentTime
+ContentTextSubtitle::to () const
+{
+ /* XXX: assuming we have some subs and they are all at the same time */
+ assert (!subs.empty ());
+ return ContentTime::from_seconds (double (subs.front().out().to_ticks()) / 250);
+}
--- /dev/null
+/*
+ Copyright (C) 2014 Carl Hetherington <cth@carlh.net>
+
+ 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
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
+#ifndef DCPOMATIC_CONTENT_SUBTITLE_H
+#define DCPOMATIC_CONTENT_SUBTITLE_H
+
+#include <list>
+#include <dcp/subtitle_string.h>
+#include "dcpomatic_time.h"
+#include "rect.h"
+
+class Image;
+
+class ContentSubtitle
+{
+public:
+ virtual ContentTime from () const = 0;
+ virtual ContentTime to () const = 0;
+};
+
+class ContentImageSubtitle : public ContentSubtitle
+{
+public:
+ ContentImageSubtitle (ContentTime f, ContentTime t, boost::shared_ptr<Image> im, dcpomatic::Rect<double> r)
+ : image (im)
+ , rectangle (r)
+ , _from (f)
+ , _to (t)
+ {}
+
+ ContentTime from () const {
+ return _from;
+ }
+
+ ContentTime to () const {
+ return _to;
+ }
+
+ boost::shared_ptr<Image> image;
+ dcpomatic::Rect<double> rectangle;
+
+private:
+ ContentTime _from;
+ ContentTime _to;
+};
+
+class ContentTextSubtitle : public ContentSubtitle
+{
+public:
+ ContentTextSubtitle (std::list<dcp::SubtitleString> s)
+ : subs (s)
+ {}
+
+ ContentTime from () const;
+ ContentTime to () const;
+
+ std::list<dcp::SubtitleString> subs;
+};
+
+#endif
--- /dev/null
+/*
+ Copyright (C) 2013-2014 Carl Hetherington <cth@carlh.net>
+
+ 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
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
+/** @class ContentVideo
+ * @brief A frame of video straight out of some content.
+ */
+class ContentVideo
+{
+public:
+ ContentVideo ()
+ : eyes (EYES_BOTH)
+ {}
+
+ ContentVideo (boost::shared_ptr<const Image> i, Eyes e, VideoFrame f)
+ : image (i)
+ , eyes (e)
+ , frame (f)
+ {}
+
+ boost::shared_ptr<const Image> image;
+ Eyes eyes;
+ VideoFrame frame;
+};
--- /dev/null
+/*
+ Copyright (C) 2013-2014 Carl Hetherington <cth@carlh.net>
+
+ 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
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
+#include "dcp_video.h"
+#include "image.h"
+
+using boost::shared_ptr;
+
+/** From ContentVideo:
+ * @param in Image.
+ * @param eyes Eye(s) that the Image is for.
+ *
+ * From Content:
+ * @param crop Crop to apply.
+ * @param inter_size
+ * @param out_size
+ * @param scaler Scaler to use.
+ * @param conversion Colour conversion to use.
+ *
+ * @param time DCP time.
+ */
+DCPVideo::DCPVideo (
+ shared_ptr<const Image> in,
+ Eyes eyes,
+ Crop crop,
+ dcp::Size inter_size,
+ dcp::Size out_size,
+ Scaler const * scaler,
+ ColourConversion conversion,
+ DCPTime time
+ )
+ : _in (in)
+ , _eyes (eyes)
+ , _crop (crop)
+ , _inter_size (inter_size)
+ , _out_size (out_size)
+ , _scaler (scaler)
+ , _conversion (conversion)
+ , _time (time)
+{
+
+}
+
+void
+DCPVideo::set_subtitle (PositionImage s)
+{
+ _subtitle = s;
+}
+
+shared_ptr<Image>
+DCPVideo::image (AVPixelFormat format, bool aligned) const
+{
+ shared_ptr<Image> out = _in->crop_scale_window (_crop, _inter_size, _out_size, _scaler, format, aligned);
+
+ Position<int> const container_offset ((_out_size.width - _inter_size.width) / 2, (_out_size.height - _inter_size.width) / 2);
+
+ if (_subtitle.image) {
+ out->alpha_blend (_subtitle.image, _subtitle.position);
+ }
+
+ return out;
+}
+
--- /dev/null
+/*
+ Copyright (C) 2013-2014 Carl Hetherington <cth@carlh.net>
+
+ 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
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
+extern "C" {
+#include <libavutil/avutil.h>
+}
+#include <boost/shared_ptr.hpp>
+#include "types.h"
+#include "colour_conversion.h"
+#include "position.h"
+#include "position_image.h"
+
+class Image;
+class Scaler;
+
+/** @class DCPVideo
+ *
+ * A ContentVideo image with:
+ * - content parameters (crop, scaling, colour conversion)
+ * - merged content (subtitles)
+ * and with its time converted from a ContentTime to a DCPTime.
+ */
+class DCPVideo
+{
+public:
+ DCPVideo (boost::shared_ptr<const Image>, Eyes eyes, Crop, dcp::Size, dcp::Size, Scaler const *, ColourConversion conversion, DCPTime time);
+
+ void set_subtitle (PositionImage);
+ boost::shared_ptr<Image> image (AVPixelFormat, bool) const;
+
+ Eyes eyes () const {
+ return _eyes;
+ }
+
+ ColourConversion conversion () const {
+ return _conversion;
+ }
+
+private:
+ boost::shared_ptr<const Image> _in;
+ Eyes _eyes;
+ Crop _crop;
+ dcp::Size _inter_size;
+ dcp::Size _out_size;
+ Scaler const * _scaler;
+ ColourConversion _conversion;
+ DCPTime _time;
+ PositionImage _subtitle;
+};
--- /dev/null
+/*
+ Copyright (C) 2014 Carl Hetherington <cth@carlh.net>
+
+ 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
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
+#ifndef DCPOMATIC_POSITION_IMAGE_H
+#define DCPOMATIC_POSITION_IMAGE_H
+
+#include "position.h"
+
+class Image;
+
+class PositionImage
+{
+public:
+ PositionImage () {}
+
+ PositionImage (boost::shared_ptr<Image> i, Position<int> p)
+ : image (i)
+ , position (p)
+ {}
+
+ boost::shared_ptr<Image> image;
+ Position<int> position;
+};
+
+#endif