Various alignment adjustments.
authorCarl Hetherington <cth@carlh.net>
Tue, 14 Sep 2021 23:00:33 +0000 (01:00 +0200)
committerCarl Hetherington <cth@carlh.net>
Mon, 27 Sep 2021 11:41:46 +0000 (13:41 +0200)
36 files changed:
src/lib/encoder.cc
src/lib/ffmpeg_decoder.cc
src/lib/ffmpeg_image_proxy.cc
src/lib/ffmpeg_image_proxy.h
src/lib/hints.cc
src/lib/image.cc
src/lib/image.h
src/lib/image_examiner.cc
src/lib/image_proxy.h
src/lib/j2k_image_proxy.cc
src/lib/j2k_image_proxy.h
src/lib/player.cc
src/lib/player.h
src/lib/player_video.cc
src/lib/raw_image_proxy.cc
src/lib/raw_image_proxy.h
src/lib/util.cc
src/lib/video_filter_graph.cc
src/tools/server_test.cc
src/wx/film_viewer.cc
src/wx/gl_video_view.cc
test/butler_test.cc
test/dcp_decoder_test.cc
test/dcp_playback_test.cc
test/ffmpeg_audio_only_test.cc
test/ffmpeg_audio_test.cc
test/ffmpeg_decoder_sequential_test.cc
test/image_test.cc
test/overlap_video_test.cc
test/pixel_formats_test.cc
test/player_test.cc
test/test.cc
test/time_calculation_test.cc
test/upmixer_a_test.cc
test/vf_test.cc
test/video_level_test.cc

index fe27cb7dd5a80574c69cc93213fba7f0cdc619d2..0b7c241d8f91cf0b52e835da9c9a9b394a0bddb2 100644 (file)
@@ -41,7 +41,7 @@
 Encoder::Encoder (std::shared_ptr<const Film> film, std::weak_ptr<Job> job)
        : _film (film)
        , _job (job)
-       , _player (new Player(film))
+       , _player (new Player(film, true))
 {
 
 }
index 72372fca88ab5b7a01e2411c9b30843f87e62c17..70f9b0545d109497df14fad72c4b114b6e1e9f05 100644 (file)
@@ -86,7 +86,7 @@ FFmpegDecoder::FFmpegDecoder (shared_ptr<const Film> film, shared_ptr<const FFmp
                video = make_shared<VideoDecoder>(this, c);
                _pts_offset = pts_offset (c->ffmpeg_audio_streams(), c->first_video(), c->active_video_frame_rate(film));
                /* It doesn't matter what size or pixel format this is, it just needs to be black */
-               _black_image.reset (new Image (AV_PIX_FMT_RGB24, dcp::Size (128, 128), true));
+               _black_image = make_shared<Image>(AV_PIX_FMT_RGB24, dcp::Size (128, 128), true);
                _black_image->make_black ();
        } else {
                _pts_offset = {};
index e7d5b424dc0da3bdb052eab77f14c90f3fd0716b..dd2f80e0e2a3ea5f94e0fa794fb07743645633d1 100644 (file)
@@ -122,7 +122,7 @@ FFmpegImageProxy::avio_seek (int64_t const pos, int whence)
 
 
 ImageProxy::Result
-FFmpegImageProxy::image (optional<dcp::Size>) const
+FFmpegImageProxy::image (bool aligned, optional<dcp::Size>) const
 {
        auto constexpr name_for_errors = "FFmpegImageProxy::image";
 
@@ -205,7 +205,7 @@ FFmpegImageProxy::image (optional<dcp::Size>) const
                throw DecodeError (N_("avcodec_receive_frame"), name_for_errors, r, *_path);
        }
 
-       _image = make_shared<Image>(frame);
+       _image = make_shared<Image>(frame, aligned);
 
        av_packet_unref (&packet);
        av_frame_free (&frame);
index 21109c9d6f2dccf9baf64f11ebbc3b2ac24618bc..f4e5bf66c57a626e5c5727ea7cf306807de5c76d 100644 (file)
@@ -32,6 +32,7 @@ public:
        FFmpegImageProxy (std::shared_ptr<Socket> socket);
 
        Result image (
+               bool aligned,
                boost::optional<dcp::Size> size = boost::optional<dcp::Size> ()
                ) const;
 
index 64122db8d5bab6be1ab41a6d14d5c68933a66d2a..f21c51db9e8f42b5f358e9ba94e3443a9033482b 100644 (file)
@@ -408,7 +408,7 @@ try
                emit (bind(boost::ref(Progress), _("Examining audio, subtitles and closed captions")));
        }
 
-       auto player = make_shared<Player>(film);
+       auto player = make_shared<Player>(film, false);
        player->set_ignore_video ();
        if (check_loudness_done) {
                /* We don't need to analyse audio because we already loaded a suitable analysis */
index d2f8fbbfd37714df542b8a55235e6aa48e9b8cbf..ce3f5817d5cd78e12f6ae1a67348e8711d224cf1 100644 (file)
@@ -1027,10 +1027,10 @@ Image::Image (Image const & other)
        }
 }
 
-Image::Image (AVFrame const * frame)
+Image::Image (AVFrame const * frame, bool aligned)
        : _size (frame->width, frame->height)
        , _pixel_format (static_cast<AVPixelFormat>(frame->format))
-       , _aligned (true)
+       , _aligned (aligned)
 {
        DCPOMATIC_ASSERT (_pixel_format != AV_PIX_FMT_NONE);
 
@@ -1139,7 +1139,7 @@ Image::aligned () const
 
 
 PositionImage
-merge (list<PositionImage> images)
+merge (list<PositionImage> images, bool aligned)
 {
        if (images.empty ()) {
                return {};
@@ -1154,7 +1154,7 @@ merge (list<PositionImage> images)
                all.extend (dcpomatic::Rect<int>(i.position, i.image->size().width, i.image->size().height));
        }
 
-       auto merged = make_shared<Image>(images.front().image->pixel_format(), dcp::Size(all.width, all.height), false);
+       auto merged = make_shared<Image>(images.front().image->pixel_format(), dcp::Size(all.width, all.height), aligned);
        merged->make_transparent ();
        for (auto const& i: images) {
                merged->alpha_blend (i.image, i.position - all.position());
@@ -1312,16 +1312,18 @@ Image::fade (float f)
        }
 }
 
+
 shared_ptr<const Image>
-Image::ensure_aligned (shared_ptr<const Image> image)
+Image::ensure_aligned (shared_ptr<const Image> image, bool aligned)
 {
-       if (image->aligned()) {
+       if (image->aligned() == aligned) {
                return image;
        }
 
-       return make_shared<Image>(image, true);
+       return make_shared<Image>(image, aligned);
 }
 
+
 size_t
 Image::memory_used () const
 {
index cb8f11ffc27d0eab3ab4ba86d4646b4498bc7b7a..3cba8f7e501ae0478f0cfcb247ebce2877eaa260 100644 (file)
@@ -41,7 +41,7 @@ class Image : public std::enable_shared_from_this<Image>
 {
 public:
        Image (AVPixelFormat p, dcp::Size s, bool aligned);
-       explicit Image (AVFrame const *);
+       explicit Image (AVFrame const *, bool aligned);
        explicit Image (Image const &);
        Image (std::shared_ptr<const Image>, bool);
        Image& operator= (Image const &);
@@ -94,7 +94,7 @@ public:
 
        void png_error (char const * message);
 
-       static std::shared_ptr<const Image> ensure_aligned (std::shared_ptr<const Image> image);
+       static std::shared_ptr<const Image> ensure_aligned (std::shared_ptr<const Image> image, bool aligned);
 
 private:
        friend struct pixel_formats_test;
@@ -115,7 +115,7 @@ private:
        bool _aligned;
 };
 
-extern PositionImage merge (std::list<PositionImage> images);
+extern PositionImage merge (std::list<PositionImage> images, bool aligned);
 extern bool operator== (Image const & a, Image const & b);
 
 #endif
index 89d1517ce5abf380d9e30c3a09777bd17a5a0293..8b209621407a568d86ab7f63def0fb0fa6563736 100644 (file)
@@ -67,7 +67,7 @@ ImageExaminer::ImageExaminer (shared_ptr<const Film> film, shared_ptr<const Imag
                delete[] buffer;
        } else {
                FFmpegImageProxy proxy(content->path(0));
-               _video_size = proxy.image().image->size();
+               _video_size = proxy.image(false).image->size();
        }
 
        if (content->still ()) {
index cf1fb9a2dc6035ccfe65e5e3caf0215d8bd0cce1..8817845d997d8d77643814328609489a42b26e79 100644 (file)
@@ -91,6 +91,7 @@ public:
         *  can be used as an optimisation.
         */
        virtual Result image (
+               bool aligned,
                boost::optional<dcp::Size> size = boost::optional<dcp::Size> ()
                ) const = 0;
 
@@ -102,7 +103,7 @@ public:
         *  This method may be called in a different thread to image().
         *  @return log2 of any scaling down that will be applied to the image.
         */
-       virtual int prepare (boost::optional<dcp::Size> = boost::optional<dcp::Size>()) const { return 0; }
+       virtual int prepare (bool, boost::optional<dcp::Size> = boost::optional<dcp::Size>()) const { return 0; }
        virtual size_t memory_used () const = 0;
 };
 
index c98273ad20043ed3cd81fc6ef81e3ffa5ac771fb..21507ca152c3c180e9816d6fa087b2ad3329e6eb 100644 (file)
@@ -108,7 +108,7 @@ J2KImageProxy::J2KImageProxy (shared_ptr<cxml::Node> xml, shared_ptr<Socket> soc
        if (xml->optional_number_child<int>("Eye")) {
                _eye = static_cast<dcp::Eye>(xml->number_child<int>("Eye"));
        }
-       shared_ptr<ArrayData> data(new ArrayData(xml->number_child<int>("Size")));
+       auto data = make_shared<ArrayData>(xml->number_child<int>("Size"));
        /* This only matters when we are using J2KImageProxy for the preview, which
           will never use this constructor (which is only used for passing data to
           encode servers).  So we can put anything in here.  It's a bit of a hack.
@@ -120,7 +120,7 @@ J2KImageProxy::J2KImageProxy (shared_ptr<cxml::Node> xml, shared_ptr<Socket> soc
 
 
 int
-J2KImageProxy::prepare (optional<dcp::Size> target_size) const
+J2KImageProxy::prepare (bool aligned, optional<dcp::Size> target_size) const
 {
        boost::mutex::scoped_lock lm (_mutex);
 
@@ -145,7 +145,7 @@ J2KImageProxy::prepare (optional<dcp::Size> target_size) const
        try {
                /* XXX: should check that potentially trashing _data here doesn't matter */
                auto decompressed = dcp::decompress_j2k (const_cast<uint8_t*>(_data->data()), _data->size(), reduce);
-               _image.reset (new Image (_pixel_format, decompressed->size(), false));
+               _image = make_shared<Image>(_pixel_format, decompressed->size(), aligned);
 
                int const shift = 16 - decompressed->precision (0);
 
@@ -169,7 +169,7 @@ J2KImageProxy::prepare (optional<dcp::Size> target_size) const
                        }
                }
        } catch (dcp::J2KDecompressionError& e) {
-               _image = make_shared<Image>(_pixel_format, _size, true);
+               _image = make_shared<Image>(_pixel_format, _size, aligned);
                _image->make_black ();
                _error = true;
        }
@@ -182,9 +182,9 @@ J2KImageProxy::prepare (optional<dcp::Size> target_size) const
 
 
 ImageProxy::Result
-J2KImageProxy::image (optional<dcp::Size> target_size) const
+J2KImageProxy::image (bool aligned, optional<dcp::Size> target_size) const
 {
-       int const r = prepare (target_size);
+       int const r = prepare (aligned, target_size);
 
        /* I think this is safe without a lock on mutex.  _image is guaranteed to be
           set up when prepare() has happened.
index 5235d8e42522d02c42dd7566ec18bc6c8301853c..a23ec6d987e8af153eb163973751506f03c6f94a 100644 (file)
@@ -57,6 +57,7 @@ public:
        J2KImageProxy (dcp::ArrayData data, dcp::Size size, AVPixelFormat pixel_format);
 
        Result image (
+               bool aligned,
                boost::optional<dcp::Size> size = boost::optional<dcp::Size> ()
                ) const;
 
@@ -64,7 +65,7 @@ public:
        void write_to_socket (std::shared_ptr<Socket>) const;
        /** @return true if our image is definitely the same as another, false if it is probably not */
        bool same (std::shared_ptr<const ImageProxy>) const;
-       int prepare (boost::optional<dcp::Size> = boost::optional<dcp::Size>()) const;
+       int prepare (bool aligned, boost::optional<dcp::Size> = boost::optional<dcp::Size>()) const;
 
        std::shared_ptr<const dcp::Data> j2k () const {
                return _data;
index 5de089ba91aa9ad297bbe299a2b2ad9b076ec76e..810d949d971278e81512138a203b78b9e743c3a0 100644 (file)
@@ -95,11 +95,12 @@ int const PlayerProperty::DCP_DECODE_REDUCTION = 704;
 int const PlayerProperty::PLAYBACK_LENGTH = 705;
 
 
-Player::Player (shared_ptr<const Film> film)
+Player::Player (shared_ptr<const Film> film, bool aligned)
        : _film (film)
        , _suspended (0)
        , _tolerant (film->tolerant())
        , _audio_merger (_film->audio_frame_rate())
+       , _aligned_subtitles (aligned)
 {
        construct ();
 }
@@ -827,7 +828,7 @@ Player::open_subtitles_for_frame (DCPTime time) const
                return {};
        }
 
-       return merge (captions);
+       return merge (captions, _aligned_subtitles);
 }
 
 
index 6cefbe2323bc6363ba59ca424d1cd1846ecee7cc..76721837931fecc910ec45d3bc2afd33c1342a61 100644 (file)
@@ -76,7 +76,7 @@ public:
 class Player : public std::enable_shared_from_this<Player>
 {
 public:
-       Player (std::shared_ptr<const Film>);
+       Player (std::shared_ptr<const Film>, bool aligned_subtitles);
        Player (std::shared_ptr<const Film>, std::shared_ptr<const Playlist> playlist);
 
        Player (Player const& Player) = delete;
@@ -233,6 +233,9 @@ private:
 
        dcpomatic::DCPTime _playback_length;
 
+       /** aligned flag for subtitle images that we create */
+       bool _aligned_subtitles = true;
+
        boost::signals2::scoped_connection _film_changed_connection;
        boost::signals2::scoped_connection _playlist_change_connection;
        boost::signals2::scoped_connection _playlist_content_change_connection;
index 0a6ce0d993cf08ac4f304288db60d42389feb418..a687e7ea536a1622c4f037dfce1cdec3cdd442c7 100644 (file)
@@ -122,10 +122,10 @@ PlayerVideo::image (function<AVPixelFormat (AVPixelFormat)> pixel_format, VideoR
 }
 
 
-shared_ptr<Image>
+shared_ptr<const Image>
 PlayerVideo::raw_image () const
 {
-       return _in->image(_inter_size).image;
+       return _in->image(false, _inter_size).image;
 }
 
 
@@ -144,7 +144,7 @@ PlayerVideo::make_image (function<AVPixelFormat (AVPixelFormat)> pixel_format, V
        _image_out_size = _out_size;
        _image_fade = _fade;
 
-       auto prox = _in->image (_inter_size);
+       auto prox = _in->image (true, _inter_size);
        _error = prox.error;
 
        auto total_crop = _crop;
@@ -184,7 +184,7 @@ PlayerVideo::make_image (function<AVPixelFormat (AVPixelFormat)> pixel_format, V
                );
 
        if (_text) {
-               _image->alpha_blend (Image::ensure_aligned (_text->image), _text->position);
+               _image->alpha_blend (Image::ensure_aligned(_text->image, true), _text->position);
        }
 
        if (_fade) {
@@ -300,7 +300,7 @@ PlayerVideo::keep_xyz_or_rgb (AVPixelFormat p)
 void
 PlayerVideo::prepare (function<AVPixelFormat (AVPixelFormat)> pixel_format, VideoRange video_range, bool aligned, bool fast, bool proxy_only)
 {
-       _in->prepare (_inter_size);
+       _in->prepare (aligned, _inter_size);
        boost::mutex::scoped_lock lm (_mutex);
        if (!_image && !proxy_only) {
                make_image (pixel_format, video_range, aligned, fast);
index fed40c45e7ec783faaa31fa94b55f91810177dc2..ac8ff0763d103556b20b649574bad94515171f04 100644 (file)
@@ -64,9 +64,10 @@ RawImageProxy::RawImageProxy (shared_ptr<cxml::Node> xml, shared_ptr<Socket> soc
 
 
 ImageProxy::Result
-RawImageProxy::image (optional<dcp::Size>) const
+RawImageProxy::image (bool aligned, optional<dcp::Size>) const
 {
-       return Result (_image, 0);
+       /* This ensure_aligned could be wasteful */
+       return Result (Image::ensure_aligned(_image, aligned), 0);
 }
 
 
@@ -95,7 +96,7 @@ RawImageProxy::same (shared_ptr<const ImageProxy> other) const
                return false;
        }
 
-       return (*_image.get()) == (*rp->image().image.get());
+       return (*_image.get()) == (*rp->image(_image->aligned()).image.get());
 }
 
 
index ec30f5a29aa3f8ad945c83f106b81f623c516956..7e08611041d45ee307fbfdc65bc49e200d71df79 100644 (file)
@@ -33,6 +33,7 @@ public:
        RawImageProxy (std::shared_ptr<cxml::Node> xml, std::shared_ptr<Socket> socket);
 
        Result image (
+               bool aligned,
                boost::optional<dcp::Size> size = boost::optional<dcp::Size> ()
                ) const;
 
index 0646a478772a086704cfcb6b7e4d2d87408ab18c..c65b2bc850fcac89c49195d55fcb901ab9216572 100644 (file)
@@ -956,7 +956,7 @@ emit_subtitle_image (ContentTimePeriod period, dcp::SubtitleImage sub, dcp::Size
 {
        /* XXX: this is rather inefficient; decoding the image just to get its size */
        FFmpegImageProxy proxy (sub.png_image());
-       auto image = proxy.image().image;
+       auto image = proxy.image(false).image;
        /* set up rect with height and width */
        dcpomatic::Rect<double> rect(0, 0, image->size().width / double(size.width), image->size().height / double(size.height));
 
index a61da6773bbb8517330895aa2a8b01eae3e39c76..b4198da723832a57b889e1eb94788ef81630e3c2 100644 (file)
@@ -59,7 +59,7 @@ VideoFilterGraph::process (AVFrame* frame)
        list<pair<shared_ptr<Image>, int64_t>> images;
 
        if (_copy) {
-               images.push_back (make_pair(make_shared<Image>(frame), frame->best_effort_timestamp));
+               images.push_back (make_pair(make_shared<Image>(frame, true), frame->best_effort_timestamp));
        } else {
                int r = av_buffersrc_write_frame (_buffer_src_context, frame);
                if (r < 0) {
@@ -71,7 +71,7 @@ VideoFilterGraph::process (AVFrame* frame)
                                break;
                        }
 
-                       images.push_back (make_pair(make_shared<Image>(_frame), frame->best_effort_timestamp));
+                       images.push_back (make_pair(make_shared<Image>(_frame, true), frame->best_effort_timestamp));
                        av_frame_unref (_frame);
                }
        }
index 6c7371253fc3df789342bd5e1961dd57049457a9..e32fd327e7a877cd3459379e1ad35d5b951b5fac 100644 (file)
@@ -155,7 +155,7 @@ main (int argc, char* argv[])
                film = make_shared<Film>(film_dir);
                film->read_metadata ();
 
-               auto player = make_shared<Player>(film);
+               auto player = make_shared<Player>(film, false);
                player->Video.connect (bind(&process_video, _1));
                while (!player->pass ()) {}
        } catch (std::exception& e) {
index 98948b1f2b6c7f6deeef6ef9b23725d99a24e7b1..735ba02eba88925b5412348cfe592890fe9dc756 100644 (file)
@@ -169,7 +169,7 @@ FilmViewer::set_film (shared_ptr<Film> film)
        }
 
        try {
-               _player = make_shared<Player>(_film);
+               _player = make_shared<Player>(_film, !_optimise_for_j2k);
                _player->set_fast ();
                if (_dcp_decode_reduction) {
                        _player->set_dcp_decode_reduction (_dcp_decode_reduction);
@@ -221,7 +221,7 @@ FilmViewer::recreate_butler ()
                _audio_channels,
                bind(&PlayerVideo::force, _1, AV_PIX_FMT_RGB24),
                VideoRange::FULL,
-               false,
+               !_optimise_for_j2k,
                true,
                dynamic_pointer_cast<GLVideoView>(_video_view) && _optimise_for_j2k
                );
index 4c51326d384cc01da7fe7d71f65242f575beff74..6288a24a3e1e7b350cbd94b593781b5d575ca786 100644 (file)
@@ -497,9 +497,12 @@ GLVideoView::draw (Position<int>, dcp::Size)
 void
 GLVideoView::set_image (shared_ptr<const PlayerVideo> pv)
 {
-       auto video = _optimise_for_j2k ? pv->raw_image() : pv->image(bind(&PlayerVideo::force, _1, AV_PIX_FMT_RGB24), VideoRange::FULL, false, true);
+       shared_ptr<const Image> video = _optimise_for_j2k ? pv->raw_image() : pv->image(bind(&PlayerVideo::force, _1, AV_PIX_FMT_RGB24), VideoRange::FULL, false, true);
 
-       DCPOMATIC_ASSERT (!video->aligned());
+       /* Only the player's black frames should be aligned at this stage, so this should
+        * almost always have no work to do.
+        */
+       video = Image::ensure_aligned (video, false);
 
        /** If _optimise_for_j2k is true we render a XYZ image, doing the colourspace
         *  conversion, scaling and video range conversion in the GL shader.
index 65c9139d76145134d382e978ee8e841f1167fd5f..99bd95fce38307b499b91ca15612c554f224ad1a 100644 (file)
@@ -59,7 +59,7 @@ BOOST_AUTO_TEST_CASE (butler_test1)
                map.set (i, i, 1);
        }
 
-       Butler butler (film, make_shared<Player>(film), map, 6, bind(&PlayerVideo::force, _1, AV_PIX_FMT_RGB24), VideoRange::FULL, false, false, false);
+       Butler butler (film, make_shared<Player>(film, false), map, 6, bind(&PlayerVideo::force, _1, AV_PIX_FMT_RGB24), VideoRange::FULL, false, false, false);
 
        BOOST_CHECK (butler.get_video(true, 0).second == DCPTime());
        BOOST_CHECK (butler.get_video(true, 0).second == DCPTime::from_frames(1, 24));
index a52a0ccc59941fb0af7c687bf7f45682d7652747..9461effc541e0b6e50f2b2a490bd44e57774fe03 100644 (file)
@@ -87,7 +87,7 @@ BOOST_AUTO_TEST_CASE (check_reuse_old_data_test)
        ov_content = make_shared<DCPContent>(ov->dir(ov->dcp_name(false)));
        test->examine_and_add_content (ov_content);
        BOOST_REQUIRE (!wait_for_jobs());
-       auto player = make_shared<Player>(test);
+       auto player = make_shared<Player>(test, false);
 
        auto decoder = std::dynamic_pointer_cast<DCPDecoder>(player->_pieces.front()->decoder);
        BOOST_REQUIRE (decoder);
@@ -105,7 +105,7 @@ BOOST_AUTO_TEST_CASE (check_reuse_old_data_test)
        auto vf_content = make_shared<DCPContent>(vf->dir(vf->dcp_name(false)));
        test->examine_and_add_content (vf_content);
        BOOST_REQUIRE (!wait_for_jobs());
-       player.reset (new Player(test));
+       player = make_shared<Player>(test, false);
 
        decoder = std::dynamic_pointer_cast<DCPDecoder>(player->_pieces.front()->decoder);
        BOOST_REQUIRE (decoder);
@@ -123,7 +123,7 @@ BOOST_AUTO_TEST_CASE (check_reuse_old_data_test)
        auto encrypted_content = make_shared<DCPContent>(encrypted->dir(encrypted->dcp_name(false)));
        test->examine_and_add_content (encrypted_content);
        BOOST_REQUIRE (!wait_for_jobs());
-       player = make_shared<Player>(test);
+       player = make_shared<Player>(test, false);
 
        decoder = std::dynamic_pointer_cast<DCPDecoder>(player->_pieces.front()->decoder);
        BOOST_REQUIRE (decoder);
index efe7138e1173f7718aed67af2b62be3ec9e4a036..2ea638d74c3b82c2ba27b80a0de11ed66fe431af 100644 (file)
@@ -28,9 +28,7 @@
 
 
 using std::make_shared;
-using std::pair;
-using std::shared_ptr;
-using boost::optional;
+using std::make_shared;
 #if BOOST_VERSION >= 106100
 using namespace boost::placeholders;
 #endif
@@ -47,7 +45,7 @@ BOOST_AUTO_TEST_CASE (dcp_playback_test)
 
        auto butler = std::make_shared<Butler>(
                film,
-               shared_ptr<Player>(new Player(film)),
+               make_shared<Player>(film, false),
                AudioMapping(6, 6),
                6,
                bind(&PlayerVideo::force, _1, AV_PIX_FMT_RGB24),
index a68f7cf5761859447e6a10790305608941eb8532..9f185fdf39e0b853fbcc0a1c916c66692b76417f 100644 (file)
@@ -101,7 +101,7 @@ test (boost::filesystem::path file)
        ref_buffer_size = info.samplerate * info.channels;
        ref_buffer = new float[ref_buffer_size];
 
-       auto player = make_shared<Player>(film);
+       auto player = make_shared<Player>(film, false);
 
        player->Audio.connect (bind (&audio, _1, info.channels));
        while (!player->pass ()) {}
index 5a36b99f40c23600ea98ef637e27a6f83538b9a8..0cc602a9a50e5cef77de5c502135544a44d98d6f 100644 (file)
@@ -135,7 +135,7 @@ BOOST_AUTO_TEST_CASE (ffmpeg_audio_test2)
        film->examine_and_add_content (content);
        BOOST_REQUIRE (!wait_for_jobs ());
 
-       auto player = make_shared<Player>(film);
+       auto player = make_shared<Player>(film, false);
        while (!player->pass ()) {}
 }
 
@@ -148,7 +148,7 @@ BOOST_AUTO_TEST_CASE (ffmpeg_audio_test3)
        film->examine_and_add_content (content);
        BOOST_REQUIRE (!wait_for_jobs ());
 
-       auto player = make_shared<Player>(film);
+       auto player = make_shared<Player>(film, false);
        player->set_fast ();
        while (!player->pass ()) {}
 }
@@ -162,7 +162,7 @@ BOOST_AUTO_TEST_CASE (ffmpeg_audio_test4)
        film->examine_and_add_content (content);
        BOOST_REQUIRE (!wait_for_jobs ());
 
-       auto player = make_shared<Player>(film);
+       auto player = make_shared<Player>(film, false);
        player->set_fast ();
        BOOST_CHECK_NO_THROW (while (!player->pass()) {});
 }
index b2069a8b16b522bd5163a45ebe16d30782997b8d..7d6d547ffc937f20556d791ed254556352222da4 100644 (file)
@@ -75,7 +75,7 @@ ffmpeg_decoder_sequential_test_one (boost::filesystem::path file, float fps, int
        film->examine_and_add_content (content);
        BOOST_REQUIRE (!wait_for_jobs());
        film->write_metadata ();
-       auto player = make_shared<Player>(film);
+       auto player = make_shared<Player>(film, false);
 
        BOOST_REQUIRE (content->video_frame_rate());
        BOOST_CHECK_CLOSE (content->video_frame_rate().get(), fps, 0.01);
index 3993b3efbdeaf7f99e4cff9f4b1f04caf4d7c4dd..9d0d4366416f9efc7e890272d06f4b1d7840e3b8 100644 (file)
@@ -148,7 +148,7 @@ void
 alpha_blend_test_one (AVPixelFormat format, string suffix)
 {
        auto proxy = make_shared<FFmpegImageProxy>(TestPaths::private_data() / "prophet_frame.tiff");
-       auto raw = proxy->image().image;
+       auto raw = proxy->image(false).image;
        auto background = raw->convert_pixel_format (dcp::YUVToRGB::REC709, format, true, false);
 
        auto overlay = make_shared<Image>(AV_PIX_FMT_BGRA, dcp::Size(431, 891), true);
@@ -221,7 +221,7 @@ BOOST_AUTO_TEST_CASE (merge_test1)
 
        list<PositionImage> all;
        all.push_back (PositionImage (A, Position<int>(0, 0)));
-       auto merged = merge (all);
+       auto merged = merge (all, false);
 
        BOOST_CHECK (merged.position == Position<int>(0, 0));
        BOOST_CHECK_EQUAL (memcmp (merged.image->data()[0], A->data()[0], stride * 48), 0);
@@ -254,7 +254,7 @@ BOOST_AUTO_TEST_CASE (merge_test2)
        list<PositionImage> all;
        all.push_back (PositionImage(A, Position<int>(0, 0)));
        all.push_back (PositionImage(B, Position<int>(0, 0)));
-       auto merged = merge (all);
+       auto merged = merge (all, false);
 
        BOOST_CHECK (merged.position == Position<int>(0, 0));
 
@@ -274,7 +274,7 @@ BOOST_AUTO_TEST_CASE (merge_test2)
 BOOST_AUTO_TEST_CASE (crop_scale_window_test)
 {
        auto proxy = make_shared<FFmpegImageProxy>("test/data/flat_red.png");
-       auto raw = proxy->image().image;
+       auto raw = proxy->image(false).image;
        auto out = raw->crop_scale_window(
                Crop(), dcp::Size(1998, 836), dcp::Size(1998, 1080), dcp::YUVToRGB::REC709, VideoRange::FULL, AV_PIX_FMT_YUV420P, VideoRange::FULL, true, false
                );
@@ -300,7 +300,7 @@ BOOST_AUTO_TEST_CASE (crop_scale_window_test2)
 BOOST_AUTO_TEST_CASE (crop_scale_window_test3)
 {
        auto proxy = make_shared<FFmpegImageProxy>(TestPaths::private_data() / "player_seek_test_0.png");
-       auto xyz = proxy->image().image->convert_pixel_format(dcp::YUVToRGB::REC709, AV_PIX_FMT_RGB24, true, false);
+       auto xyz = proxy->image(false).image->convert_pixel_format(dcp::YUVToRGB::REC709, AV_PIX_FMT_RGB24, true, false);
        auto cropped = xyz->crop_scale_window(
                Crop(512, 0, 0, 0), dcp::Size(1486, 1080), dcp::Size(1998, 1080), dcp::YUVToRGB::REC709, VideoRange::FULL, AV_PIX_FMT_RGB24, VideoRange::FULL, false, false
                );
@@ -312,7 +312,7 @@ BOOST_AUTO_TEST_CASE (crop_scale_window_test3)
 BOOST_AUTO_TEST_CASE (crop_scale_window_test4)
 {
        auto proxy = make_shared<FFmpegImageProxy>(TestPaths::private_data() / "player_seek_test_0.png");
-       auto xyz = proxy->image().image->convert_pixel_format(dcp::YUVToRGB::REC709, AV_PIX_FMT_RGB24, true, false);
+       auto xyz = proxy->image(false).image->convert_pixel_format(dcp::YUVToRGB::REC709, AV_PIX_FMT_RGB24, true, false);
        auto cropped = xyz->crop_scale_window(
                Crop(512, 0, 0, 0), dcp::Size(1486, 1080), dcp::Size(1998, 1080), dcp::YUVToRGB::REC709, VideoRange::FULL, AV_PIX_FMT_XYZ12LE, VideoRange::FULL, false, false
                );
@@ -324,7 +324,7 @@ BOOST_AUTO_TEST_CASE (crop_scale_window_test4)
 BOOST_AUTO_TEST_CASE (crop_scale_window_test5)
 {
        auto proxy = make_shared<FFmpegImageProxy>(TestPaths::private_data() / "player_seek_test_0.png");
-       auto xyz = proxy->image().image->convert_pixel_format(dcp::YUVToRGB::REC709, AV_PIX_FMT_XYZ12LE, true, false);
+       auto xyz = proxy->image(false).image->convert_pixel_format(dcp::YUVToRGB::REC709, AV_PIX_FMT_XYZ12LE, true, false);
        auto cropped = xyz->crop_scale_window(
                Crop(512, 0, 0, 0), dcp::Size(1486, 1080), dcp::Size(1998, 1080), dcp::YUVToRGB::REC709, VideoRange::FULL, AV_PIX_FMT_RGB24, VideoRange::FULL, false, false
                );
@@ -336,7 +336,7 @@ BOOST_AUTO_TEST_CASE (crop_scale_window_test5)
 BOOST_AUTO_TEST_CASE (crop_scale_window_test6)
 {
        auto proxy = make_shared<FFmpegImageProxy>(TestPaths::private_data() / "player_seek_test_0.png");
-       auto xyz = proxy->image().image->convert_pixel_format(dcp::YUVToRGB::REC709, AV_PIX_FMT_XYZ12LE, true, false);
+       auto xyz = proxy->image(false).image->convert_pixel_format(dcp::YUVToRGB::REC709, AV_PIX_FMT_XYZ12LE, true, false);
        auto cropped = xyz->crop_scale_window(
                Crop(512, 0, 0, 0), dcp::Size(1486, 1080), dcp::Size(1998, 1080), dcp::YUVToRGB::REC709, VideoRange::FULL, AV_PIX_FMT_XYZ12LE, VideoRange::FULL, false, false
                );
@@ -351,7 +351,7 @@ BOOST_AUTO_TEST_CASE (crop_scale_window_test7)
        using namespace boost::filesystem;
        for (int left_crop = 0; left_crop < 8; ++left_crop) {
                auto proxy = make_shared<FFmpegImageProxy>("test/data/rgb_grey_testcard.png");
-               auto yuv = proxy->image().image->convert_pixel_format(dcp::YUVToRGB::REC709, AV_PIX_FMT_YUV420P, true, false);
+               auto yuv = proxy->image(false).image->convert_pixel_format(dcp::YUVToRGB::REC709, AV_PIX_FMT_YUV420P, true, false);
                int rounded = left_crop - (left_crop % 2);
                auto cropped = yuv->crop_scale_window(
                        Crop(left_crop, 0, 0, 0),
@@ -374,7 +374,7 @@ BOOST_AUTO_TEST_CASE (crop_scale_window_test7)
 BOOST_AUTO_TEST_CASE (as_png_test)
 {
        auto proxy = make_shared<FFmpegImageProxy>("test/data/3d_test/000001.png");
-       auto image_rgb = proxy->image().image;
+       auto image_rgb = proxy->image(false).image;
        auto image_bgr = image_rgb->convert_pixel_format(dcp::YUVToRGB::REC709, AV_PIX_FMT_BGRA, true, false);
        image_rgb->as_png().write ("build/test/as_png_rgb.png");
        image_bgr->as_png().write ("build/test/as_png_bgr.png");
@@ -402,7 +402,7 @@ static void
 fade_test_format_red (AVPixelFormat f, float amount, string name)
 {
        auto proxy = make_shared<FFmpegImageProxy>("test/data/flat_red.png");
-       auto red = proxy->image().image->convert_pixel_format(dcp::YUVToRGB::REC709, f, true, false);
+       auto red = proxy->image(false).image->convert_pixel_format(dcp::YUVToRGB::REC709, f, true, false);
        red->fade (amount);
        string const filename = "fade_test_red_" + name + ".png";
        red->convert_pixel_format(dcp::YUVToRGB::REC709, AV_PIX_FMT_RGBA, true, false)->as_png().write("build/test/" + filename);
@@ -506,7 +506,7 @@ BOOST_AUTO_TEST_CASE (make_black_test)
 BOOST_AUTO_TEST_CASE (make_part_black_test)
 {
        auto proxy = make_shared<FFmpegImageProxy>("test/data/flat_red.png");
-       auto original = proxy->image().image;
+       auto original = proxy->image(false).image;
 
        list<AVPixelFormat> pix_fmts = {
                AV_PIX_FMT_RGB24,
index 724f4e75ba1354359ec5422a72f3d1aa2ace17ae..d0d5a8bbfa361d356d88bfa8f2a7367bf8aa97c9 100644 (file)
@@ -57,7 +57,7 @@ BOOST_AUTO_TEST_CASE (overlap_video_test1)
        B->video->set_length (24);
        B->set_position (film, dcpomatic::DCPTime::from_seconds(1));
 
-       auto player = make_shared<Player>(film);
+       auto player = make_shared<Player>(film, false);
        auto pieces = player->_pieces;
        BOOST_REQUIRE_EQUAL (pieces.size(), 2U);
        BOOST_CHECK_EQUAL (pieces.front()->content, A);
index f59c594e9705f07ab1c405ad2bfd4b10118bcd3b..a4d42e399375c11bb96c768b7afdde1c79755e3f 100644 (file)
@@ -88,7 +88,7 @@ BOOST_AUTO_TEST_CASE (pixel_formats_test)
                f->height = 480;
                f->format = static_cast<int> (i.format);
                av_frame_get_buffer (f, true);
-               Image t (f);
+               Image t (f, false);
                BOOST_CHECK_EQUAL(t.planes(), i.planes);
                BOOST_CHECK_EQUAL(t.sample_size(0).height, i.lines[0]);
                BOOST_CHECK_EQUAL(t.sample_size(1).height, i.lines[1]);
index 1f5b543aa36e573f284e291646fba79f8f76b62e..c1e2d2cbe971366bb51c5a07d55fe469ae86a837 100644 (file)
@@ -84,7 +84,7 @@ BOOST_AUTO_TEST_CASE (player_silence_padding_test)
 
        accumulated = std::make_shared<AudioBuffers>(film->audio_channels(), 0);
 
-       auto player = std::make_shared<Player>(film);
+       auto player = std::make_shared<Player>(film, false);
        player->Audio.connect (bind (&accumulate, _1, _2));
        while (!player->pass ()) {}
        BOOST_REQUIRE (accumulated->frames() >= 48000);
@@ -164,7 +164,7 @@ BOOST_AUTO_TEST_CASE (player_subframe_test)
        /* Length should be rounded up from B's length to the next video frame */
        BOOST_CHECK (film->length() == DCPTime::from_frames(3 * 24 + 1, 24));
 
-       auto player = std::make_shared<Player>(film);
+       auto player = std::make_shared<Player>(film, false);
        player->setup_pieces ();
        BOOST_REQUIRE_EQUAL (player->_black._periods.size(), 1U);
        BOOST_CHECK (player->_black._periods.front() == DCPTimePeriod(DCPTime::from_frames(3 * 24, 24), DCPTime::from_frames(3 * 24 + 1, 24)));
@@ -206,7 +206,7 @@ BOOST_AUTO_TEST_CASE (player_interleave_test)
        film->examine_and_add_content (s);
        BOOST_REQUIRE (!wait_for_jobs ());
 
-       auto player = std::make_shared<Player>(film);
+       auto player = std::make_shared<Player>(film, false);
        player->Video.connect (bind (&video, _1, _2));
        player->Audio.connect (bind (&audio, _1, _2));
        video_frames = audio_frames = 0;
@@ -229,7 +229,7 @@ BOOST_AUTO_TEST_CASE (player_seek_test)
        BOOST_REQUIRE (!wait_for_jobs ());
        dcp->only_text()->set_use (true);
 
-       auto player = std::make_shared<Player>(film);
+       auto player = std::make_shared<Player>(film, false);
        player->set_fast ();
        player->set_always_burn_open_subtitles ();
        player->set_play_referenced ();
@@ -261,7 +261,7 @@ BOOST_AUTO_TEST_CASE (player_seek_test2)
        BOOST_REQUIRE (!wait_for_jobs ());
        dcp->only_text()->set_use (true);
 
-       auto player = std::make_shared<Player>(film);
+       auto player = std::make_shared<Player>(film, false);
        player->set_fast ();
        player->set_always_burn_open_subtitles ();
        player->set_play_referenced ();
@@ -335,7 +335,7 @@ BOOST_AUTO_TEST_CASE (player_ignore_video_and_audio_test)
        text->only_text()->set_type (TextType::CLOSED_CAPTION);
        text->only_text()->set_use (true);
 
-       auto player = std::make_shared<Player>(film);
+       auto player = std::make_shared<Player>(film, false);
        player->set_ignore_video ();
        player->set_ignore_audio ();
 
@@ -355,7 +355,7 @@ BOOST_AUTO_TEST_CASE (player_trim_crash)
        film->examine_and_add_content (boon);
        BOOST_REQUIRE (!wait_for_jobs());
 
-       auto player = std::make_shared<Player>(film);
+       auto player = std::make_shared<Player>(film, false);
        player->set_fast ();
        auto butler = std::make_shared<Butler>(film, player, AudioMapping(), 6, bind(&PlayerVideo::force, _1, AV_PIX_FMT_RGB24), VideoRange::FULL, false, true, false);
 
index 4dab0cff1b5895c0e197e19c0db140092662757e..3395d9672ba66ecdce90a3beb3f448746485a80a 100644 (file)
@@ -364,9 +364,9 @@ double
 rms_error (boost::filesystem::path ref, boost::filesystem::path check)
 {
        FFmpegImageProxy ref_proxy (ref);
-       auto ref_image = ref_proxy.image().image;
+       auto ref_image = ref_proxy.image(false).image;
        FFmpegImageProxy check_proxy (check);
-       auto check_image = check_proxy.image().image;
+       auto check_image = check_proxy.image(false).image;
 
        BOOST_REQUIRE_EQUAL (ref_image->pixel_format(), check_image->pixel_format());
        AVPixelFormat const format = ref_image->pixel_format();
index ffe77c2b786ec2aa98000a254cecf288fa5a6df2..285285395bc8de931fae7b806d1b8fbf4f66e784 100644 (file)
@@ -197,7 +197,7 @@ BOOST_AUTO_TEST_CASE (player_time_calculation_test1)
        film->set_sequence (false);
        film->add_content (content);
 
-       auto player = make_shared<Player>(film);
+       auto player = make_shared<Player>(film, false);
 
        /* Position 0, no trim, content rate = DCP rate */
        content->set_position (film, DCPTime());
@@ -206,7 +206,7 @@ BOOST_AUTO_TEST_CASE (player_time_calculation_test1)
        film->set_video_frame_rate (24);
        player->setup_pieces ();
        BOOST_REQUIRE_EQUAL (player->_pieces.size(), 1U);
-       shared_ptr<Piece> piece = player->_pieces.front ();
+       auto piece = player->_pieces.front();
        BOOST_CHECK_EQUAL (player->dcp_to_content_video (piece, DCPTime ()), 0);
        BOOST_CHECK_EQUAL (player->dcp_to_content_video (piece, DCPTime::from_seconds (0.5)), 12);
        BOOST_CHECK_EQUAL (player->dcp_to_content_video (piece, DCPTime::from_seconds (3.0)), 72);
@@ -403,7 +403,7 @@ BOOST_AUTO_TEST_CASE (player_time_calculation_test2)
        film->set_sequence (false);
        film->add_content (content);
 
-       auto player = make_shared<Player>(film);
+       auto player = make_shared<Player>(film, false);
 
        /* Position 0, no trim, content rate = DCP rate */
        content->set_position (film, DCPTime());
@@ -412,7 +412,7 @@ BOOST_AUTO_TEST_CASE (player_time_calculation_test2)
        film->set_video_frame_rate (24);
        player->setup_pieces ();
        BOOST_REQUIRE_EQUAL (player->_pieces.size(), 1U);
-       shared_ptr<Piece> piece = player->_pieces.front ();
+       auto piece = player->_pieces.front ();
        BOOST_CHECK_EQUAL (player->content_video_to_dcp (piece, 0).get(), 0);
        BOOST_CHECK_EQUAL (player->content_video_to_dcp (piece, 12).get(), DCPTime::from_seconds(0.5).get());
        BOOST_CHECK_EQUAL (player->content_video_to_dcp (piece, 72).get(), DCPTime::from_seconds(3.0).get());
@@ -580,7 +580,7 @@ BOOST_AUTO_TEST_CASE (player_time_calculation_test3)
        film->set_sequence (false);
        film->add_content (content);
 
-       auto player = make_shared<Player>(film);
+       auto player = make_shared<Player>(film, false);
 
        /* Position 0, no trim, video/audio content rate = video/audio DCP rate */
        content->set_position (film, DCPTime());
index 0dc4962751eadb736c3a22cedfb5448125235708..3310a927736ae2493ec605a529cbab93f9d280bd 100644 (file)
@@ -89,7 +89,7 @@ BOOST_AUTO_TEST_CASE (upmixer_a_test)
        Ls = sf_open ("build/test/upmixer_a_test/Ls.wav", SFM_WRITE, &info);
        Rs = sf_open ("build/test/upmixer_a_test/Rs.wav", SFM_WRITE, &info);
 
-       auto player = make_shared<Player>(film);
+       auto player = make_shared<Player>(film, false);
        player->Audio.connect (bind (&write, _1, _2));
        while (!player->pass()) {}
 
index b7e97604124d6aa3dd9bcf756a864a93b9cab5d4..d25eb3cca3eea28a0953871489f886566ec16b15 100644 (file)
@@ -291,7 +291,7 @@ BOOST_AUTO_TEST_CASE (vf_test5)
        make_and_verify_dcp (vf, {dcp::VerificationNote::Code::EXTERNAL_ASSET});
 
        /* Check that the selected reel assets are right */
-       auto player = make_shared<Player>(vf);
+       auto player = make_shared<Player>(vf, false);
        auto a = player->get_reel_assets();
        BOOST_REQUIRE_EQUAL (a.size(), 4U);
        auto i = a.begin();
index be54cd3f90075f18837f75c059919fbd38336eac..8d82e9d7670256115f1a84a8aaf7e94223d74217 100644 (file)
@@ -94,7 +94,7 @@ BOOST_AUTO_TEST_CASE (ffmpeg_image_full_range_not_changed)
        write_image (grey_image(size, grey_pixel), file);
 
        FFmpegImageProxy proxy (file);
-       ImageProxy::Result result = proxy.image ();
+       ImageProxy::Result result = proxy.image (false);
        BOOST_REQUIRE (!result.error);
 
        for (int y = 0; y < size.height; ++y) {
@@ -214,7 +214,7 @@ pixel_range (shared_ptr<const Film> film, shared_ptr<const Content> content)
                BOOST_REQUIRE (!decoder->pass());
        }
 
-       return pixel_range (content_video->image->image().image);
+       return pixel_range (content_video->image->image(false).image);
 }