Fix enabled/disable overlapping video/audio with DCP content (part of #1355)
authorCarl Hetherington <cth@carlh.net>
Tue, 19 May 2020 11:17:10 +0000 (13:17 +0200)
committerCarl Hetherington <cth@carlh.net>
Wed, 20 May 2020 23:33:48 +0000 (01:33 +0200)
src/lib/dcp_content.cc
src/lib/player.cc
test/no_use_video_test.cc [new file with mode: 0644]
test/wscript

index 4280ad13aa7474b698a5255c3e2e635216d15ba2..ca210b5587ce45cbdd4eee40037649843246f41a 100644 (file)
@@ -610,7 +610,7 @@ DCPContent::can_reference (shared_ptr<const Film> film, function<bool (shared_pt
 static
 bool check_video (shared_ptr<const Content> c)
 {
 static
 bool check_video (shared_ptr<const Content> c)
 {
-       return static_cast<bool>(c->video);
+       return static_cast<bool>(c->video) && c->video->use();
 }
 
 bool
 }
 
 bool
@@ -643,7 +643,7 @@ DCPContent::can_reference_video (shared_ptr<const Film> film, string& why_not) c
 static
 bool check_audio (shared_ptr<const Content> c)
 {
 static
 bool check_audio (shared_ptr<const Content> c)
 {
-       return static_cast<bool>(c->audio);
+       return static_cast<bool>(c->audio) && !c->audio->mapping().mapped_output_channels().empty();
 }
 
 bool
 }
 
 bool
index d2e5ed52104b136b136b5c578f08d745ab12c4a9..fc821d6c70e55f10a697fb23861e0fcffff9ff2b 100644 (file)
@@ -795,6 +795,10 @@ Player::video (weak_ptr<Piece> wp, ContentVideo video)
                return;
        }
 
                return;
        }
 
+       if (!piece->content->video->use()) {
+               return;
+       }
+
        FrameRateChange frc (_film, piece->content);
        if (frc.skip && (video.frame % 2) == 1) {
                return;
        FrameRateChange frc (_film, piece->content);
        if (frc.skip && (video.frame % 2) == 1) {
                return;
diff --git a/test/no_use_video_test.cc b/test/no_use_video_test.cc
new file mode 100644 (file)
index 0000000..2577f93
--- /dev/null
@@ -0,0 +1,159 @@
+/*
+    Copyright (C) 2020 Carl Hetherington <cth@carlh.net>
+
+    This file is part of DCP-o-matic.
+
+    DCP-o-matic 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.
+
+    DCP-o-matic 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 DCP-o-matic.  If not, see <http://www.gnu.org/licenses/>.
+
+*/
+
+
+/** @file  test/test_no_use_video.cc
+ *  @brief Test some cases where the video parts of inputs are ignored, to
+ *  check that the right DCPs are made.
+ *  @ingroup completedcp
+ */
+
+
+#include "lib/audio_content.h"
+#include "lib/content.h"
+#include "lib/content_factory.h"
+#include "lib/film.h"
+#include "lib/dcp_content.h"
+#include "lib/video_content.h"
+#include "test.h"
+#include <dcp/cpl.h>
+#include <dcp/dcp.h>
+#include <dcp/reel.h>
+#include <dcp/reel_sound_asset.h>
+#include <dcp/reel_picture_asset.h>
+#include <boost/test/unit_test.hpp>
+
+
+using boost::dynamic_pointer_cast;
+using boost::shared_ptr;
+
+
+/** Overlay two video-only bits of content, don't use the video on one and
+ *  make sure the other one is in the DCP.
+ */
+BOOST_AUTO_TEST_CASE (no_use_video_test1)
+{
+       shared_ptr<Film> film = new_test_film2 ("no_use_video_test1");
+       shared_ptr<Content> A = content_factory ("test/data/flat_red.png").front();
+       shared_ptr<Content> B = content_factory ("test/data/flat_green.png").front();
+       film->examine_and_add_content (A);
+       film->examine_and_add_content (B);
+       BOOST_REQUIRE (!wait_for_jobs());
+
+       A->set_position (film, dcpomatic::DCPTime());
+       B->set_position (film, dcpomatic::DCPTime());
+       A->video->set_use (false);
+
+       film->make_dcp ();
+       BOOST_REQUIRE (!wait_for_jobs());
+
+       check_dcp ("test/data/no_use_video_test1", film);
+}
+
+
+/** Overlay two muxed sources and disable the video on one */
+BOOST_AUTO_TEST_CASE (no_use_video_test2)
+{
+       shared_ptr<Film> film = new_test_film2 ("no_use_video_test2");
+       shared_ptr<Content> A = content_factory (TestPaths::private_data / "dolby_aurora.vob").front();
+       shared_ptr<Content> B = content_factory (TestPaths::private_data / "big_buck_bunny_trailer_480p.mov").front();
+       film->examine_and_add_content (A);
+       film->examine_and_add_content (B);
+       BOOST_REQUIRE (!wait_for_jobs());
+
+       A->set_position (film, dcpomatic::DCPTime());
+       B->set_position (film, dcpomatic::DCPTime());
+       A->video->set_use (false);
+
+       film->make_dcp ();
+       BOOST_REQUIRE (!wait_for_jobs());
+
+       check_dcp ("test/data/no_use_video_test2", film);
+}
+
+
+/** Make two DCPs and make a VF with the audio from one and the video from another */
+BOOST_AUTO_TEST_CASE (no_use_video_test3)
+{
+       shared_ptr<Film> ov_a = new_test_film2 ("no_use_video_test3_ov_a");
+       shared_ptr<Content> ov_a_pic = content_factory ("test/data/flat_red.png").front();
+       BOOST_REQUIRE (ov_a_pic);
+       shared_ptr<Content> ov_a_snd = content_factory ("test/data/sine_16_48_220_10.wav").front();
+       BOOST_REQUIRE (ov_a_snd);
+       ov_a->examine_and_add_content (ov_a_pic);
+       ov_a->examine_and_add_content (ov_a_snd);
+       BOOST_REQUIRE (!wait_for_jobs());
+       ov_a->make_dcp ();
+       BOOST_REQUIRE (!wait_for_jobs());
+
+       shared_ptr<Film> ov_b = new_test_film2 ("no_use_video_test3_ov_b");
+       shared_ptr<Content> ov_b_pic = content_factory ("test/data/flat_green.png").front();
+       BOOST_REQUIRE (ov_b_pic);
+       shared_ptr<Content> ov_b_snd = content_factory ("test/data/sine_16_48_880_10.wav").front();
+       BOOST_REQUIRE (ov_b_snd);
+       ov_b->examine_and_add_content (ov_b_pic);
+       ov_b->examine_and_add_content (ov_b_snd);
+       BOOST_REQUIRE (!wait_for_jobs());
+       ov_b->make_dcp ();
+       BOOST_REQUIRE (!wait_for_jobs());
+
+       shared_ptr<Film> vf = new_test_film2 ("no_use_video_test3_vf");
+       shared_ptr<DCPContent> A (new DCPContent(ov_a->dir(ov_a->dcp_name())));
+       shared_ptr<DCPContent> B (new DCPContent(ov_b->dir(ov_b->dcp_name())));
+       vf->examine_and_add_content (A);
+       vf->examine_and_add_content (B);
+       BOOST_REQUIRE (!wait_for_jobs());
+
+       A->set_position (vf, dcpomatic::DCPTime());
+       A->video->set_use (false);
+       B->set_position (vf, dcpomatic::DCPTime());
+       AudioMapping mapping (16, 16);
+       mapping.make_zero ();
+       B->audio->set_mapping(mapping);
+
+       A->set_reference_audio (true);
+       B->set_reference_video (true);
+
+       vf->make_dcp ();
+       BOOST_REQUIRE (!wait_for_jobs());
+
+       dcp::DCP ov_a_check (ov_a->dir(ov_a->dcp_name()));
+       ov_a_check.read ();
+       BOOST_REQUIRE_EQUAL (ov_a_check.cpls().size(), 1);
+       BOOST_REQUIRE_EQUAL (ov_a_check.cpls().front()->reels().size(), 1);
+       shared_ptr<dcp::Reel> ov_a_reel (ov_a_check.cpls().front()->reels().front());
+
+       dcp::DCP ov_b_check (ov_b->dir(ov_b->dcp_name()));
+       ov_b_check.read ();
+       BOOST_REQUIRE_EQUAL (ov_b_check.cpls().size(), 1);
+       BOOST_REQUIRE_EQUAL (ov_b_check.cpls().front()->reels().size(), 1);
+       shared_ptr<dcp::Reel> ov_b_reel (ov_b_check.cpls().front()->reels().front());
+
+       dcp::DCP vf_check (vf->dir(vf->dcp_name()));
+       vf_check.read ();
+       BOOST_REQUIRE_EQUAL (vf_check.cpls().size(), 1);
+       BOOST_REQUIRE_EQUAL (vf_check.cpls().front()->reels().size(), 1);
+       shared_ptr<dcp::Reel> vf_reel (vf_check.cpls().front()->reels().front());
+
+       BOOST_CHECK_EQUAL (vf_reel->main_picture()->asset_ref().id(), ov_b_reel->main_picture()->asset_ref().id());
+       BOOST_CHECK_EQUAL (vf_reel->main_sound()->asset_ref().id(), ov_a_reel->main_sound()->asset_ref().id());
+}
+
+
index 1c3d750c32269fbddae7f57104e80d13aaba2236..9c67eacc4a2711f661b54639eba0184a974f43ae 100644 (file)
@@ -94,6 +94,7 @@ def build(bld):
                  job_test.cc
                  kdm_naming_test.cc
                  make_black_test.cc
                  job_test.cc
                  kdm_naming_test.cc
                  make_black_test.cc
+                 no_use_video_test.cc
                  optimise_stills_test.cc
                  pixel_formats_test.cc
                  player_test.cc
                  optimise_stills_test.cc
                  pixel_formats_test.cc
                  player_test.cc