From 70b1f90c6986e36afc2af36ee127f6a3eb8653cd Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Tue, 25 Mar 2014 09:42:05 +0000 Subject: [PATCH] Missing files from previous. --- src/lib/content_audio.h | 37 +++++++++++++++++ src/lib/content_subtitle.cc | 36 +++++++++++++++++ src/lib/content_subtitle.h | 76 +++++++++++++++++++++++++++++++++++ src/lib/content_video.h | 39 ++++++++++++++++++ src/lib/dcp_video.cc | 79 +++++++++++++++++++++++++++++++++++++ src/lib/dcp_video.h | 65 ++++++++++++++++++++++++++++++ src/lib/position_image.h | 41 +++++++++++++++++++ 7 files changed, 373 insertions(+) create mode 100644 src/lib/content_audio.h create mode 100644 src/lib/content_subtitle.cc create mode 100644 src/lib/content_subtitle.h create mode 100644 src/lib/content_video.h create mode 100644 src/lib/dcp_video.cc create mode 100644 src/lib/dcp_video.h create mode 100644 src/lib/position_image.h diff --git a/src/lib/content_audio.h b/src/lib/content_audio.h new file mode 100644 index 000000000..6ee702f2c --- /dev/null +++ b/src/lib/content_audio.h @@ -0,0 +1,37 @@ +/* + Copyright (C) 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 + 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 a, AudioFrame f) + : audio (a) + , frame (f) + {} + + boost::shared_ptr audio; + AudioFrame frame; +}; diff --git a/src/lib/content_subtitle.cc b/src/lib/content_subtitle.cc new file mode 100644 index 000000000..11873afee --- /dev/null +++ b/src/lib/content_subtitle.cc @@ -0,0 +1,36 @@ +/* + Copyright (C) 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 + 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); +} diff --git a/src/lib/content_subtitle.h b/src/lib/content_subtitle.h new file mode 100644 index 000000000..8c266f483 --- /dev/null +++ b/src/lib/content_subtitle.h @@ -0,0 +1,76 @@ +/* + Copyright (C) 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 + 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 +#include +#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 im, dcpomatic::Rect r) + : image (im) + , rectangle (r) + , _from (f) + , _to (t) + {} + + ContentTime from () const { + return _from; + } + + ContentTime to () const { + return _to; + } + + boost::shared_ptr image; + dcpomatic::Rect rectangle; + +private: + ContentTime _from; + ContentTime _to; +}; + +class ContentTextSubtitle : public ContentSubtitle +{ +public: + ContentTextSubtitle (std::list s) + : subs (s) + {} + + ContentTime from () const; + ContentTime to () const; + + std::list subs; +}; + +#endif diff --git a/src/lib/content_video.h b/src/lib/content_video.h new file mode 100644 index 000000000..96ce5450c --- /dev/null +++ b/src/lib/content_video.h @@ -0,0 +1,39 @@ +/* + 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 + 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 i, Eyes e, VideoFrame f) + : image (i) + , eyes (e) + , frame (f) + {} + + boost::shared_ptr image; + Eyes eyes; + VideoFrame frame; +}; diff --git a/src/lib/dcp_video.cc b/src/lib/dcp_video.cc new file mode 100644 index 000000000..8ea5cec88 --- /dev/null +++ b/src/lib/dcp_video.cc @@ -0,0 +1,79 @@ +/* + 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 + 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 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 +DCPVideo::image (AVPixelFormat format, bool aligned) const +{ + shared_ptr out = _in->crop_scale_window (_crop, _inter_size, _out_size, _scaler, format, aligned); + + Position 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; +} + diff --git a/src/lib/dcp_video.h b/src/lib/dcp_video.h new file mode 100644 index 000000000..75823f31d --- /dev/null +++ b/src/lib/dcp_video.h @@ -0,0 +1,65 @@ +/* + 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 + 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 +} +#include +#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, Eyes eyes, Crop, dcp::Size, dcp::Size, Scaler const *, ColourConversion conversion, DCPTime time); + + void set_subtitle (PositionImage); + boost::shared_ptr image (AVPixelFormat, bool) const; + + Eyes eyes () const { + return _eyes; + } + + ColourConversion conversion () const { + return _conversion; + } + +private: + boost::shared_ptr _in; + Eyes _eyes; + Crop _crop; + dcp::Size _inter_size; + dcp::Size _out_size; + Scaler const * _scaler; + ColourConversion _conversion; + DCPTime _time; + PositionImage _subtitle; +}; diff --git a/src/lib/position_image.h b/src/lib/position_image.h new file mode 100644 index 000000000..dbd3c600e --- /dev/null +++ b/src/lib/position_image.h @@ -0,0 +1,41 @@ +/* + Copyright (C) 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 + 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 i, Position p) + : image (i) + , position (p) + {} + + boost::shared_ptr image; + Position position; +}; + +#endif -- 2.30.2