Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/verify.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1646,6 +1646,10 @@ verify_cpl(Context& context, shared_ptr<const CPL> cpl)
size_t fewest_closed_captions = SIZE_MAX;
/* most number of closed caption assets seen in a reel */
size_t most_closed_captions = 0;
/* set to true if any reel has an Atmos asset */
auto have_atmos = false;
/* set to true if any reel has no Atmos asset */
auto have_no_atmos = false;
map<Marker, Time> markers_seen;

auto const main_picture_active_area = cpl->main_picture_active_area();
Expand Down Expand Up @@ -1690,6 +1694,11 @@ verify_cpl(Context& context, shared_ptr<const CPL> cpl)
&fewest_closed_captions,
&markers_seen
);
if (reel->atmos()) {
have_atmos = true;
} else {
have_no_atmos = true;
}
frame += reel->duration();
++reel_index;
}
Expand All @@ -1716,6 +1725,10 @@ verify_cpl(Context& context, shared_ptr<const CPL> cpl)
context.add_note(VerificationNote::Code::MISMATCHED_CLOSED_CAPTION_ASSET_COUNTS);
}

if (have_atmos && have_no_atmos) {
context.add_note(VerificationNote::Code::MISSING_ATMOS_FROM_SOME_REELS);
}

if (cpl->content_kind() == ContentKind::FEATURE) {
if (markers_seen.find(Marker::FFEC) == markers_seen.end()) {
context.add_note(VerificationNote::Code::MISSING_FFEC_IN_FEATURE);
Expand Down Expand Up @@ -2216,6 +2229,8 @@ dcp::note_to_string(VerificationNote note, function<string (string)> process_str
return compose("The CPL %1 has no <ContentVersion> tag", note.cpl_id().get());
case VerificationNote::Code::INVALID_PKL_NAMESPACE:
return compose("The namespace %1 in PKL %2 is invalid", *note.xml_namespace(), note.file()->filename());
case VerificationNote::Code::MISSING_ATMOS_FROM_SOME_REELS:
return process_string("At least one reel contains an Atmos asset, but some reel(s) do not.");
}

return "";
Expand Down Expand Up @@ -2349,6 +2364,7 @@ dcp::VerificationNote::type() const
case Code::THREED_ASSET_MARKED_AS_TWOD:
case Code::INVALID_SUBTITLE_DURATION_BV21:
case Code::INVALID_CLOSED_CAPTION_XML_SIZE_IN_BYTES:
case Code::MISSING_ATMOS_FROM_SOME_REELS:
return Type::WARNING;
};

Expand Down
4 changes: 4 additions & 0 deletions src/verify.h
Original file line number Diff line number Diff line change
Expand Up @@ -597,6 +597,10 @@ class VerificationNote
* file contains the PKL filename
*/
INVALID_PKL_NAMESPACE,
/** If one reel has an Atmos asset, all should have one (SMPTE ST 429-19:2019 section 6.2)
* cpl_id contains the CPL ID
*/
MISSING_ATMOS_FROM_SOME_REELS,
};

VerificationNote(Code code)
Expand Down
115 changes: 115 additions & 0 deletions test/verify_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
*/


#include "atmos_asset.h"
#include "atmos_asset_writer.h"
#include "combine.h"
#include "compose.hpp"
#include "cpl.h"
Expand All @@ -44,6 +46,7 @@
#include "openjpeg_image.h"
#include "raw_convert.h"
#include "reel.h"
#include "reel_atmos_asset.h"
#include "reel_interop_text_asset.h"
#include "reel_markers_asset.h"
#include "reel_mono_picture_asset.h"
Expand Down Expand Up @@ -3669,6 +3672,118 @@ BOOST_AUTO_TEST_CASE (verify_missing_main_subtitle_from_some_reels)
}


/** Make an Atmos asset of the given length; the content of the frames is not important here */
static
shared_ptr<dcp::AtmosAsset>
simple_atmos(path dir, string suffix, int frames)
{
auto asset = make_shared<dcp::AtmosAsset>(dcp::Fraction(24, 1), 0, 10, 118, 1);
auto writer = asset->start_write(dir / ("atmos" + suffix + ".mxf"));
std::vector<uint8_t> frame(256, 0);
for (int i = 0; i < frames; ++i) {
writer->write(frame.data(), frame.size());
}
writer->finalize();
return asset;
}


static
shared_ptr<dcp::CPL>
verify_atmos_should_be_in_all_reels_check(path dir, bool add_to_reel1, bool add_to_reel2)
{
prepare_directory(dir);
auto dcp = make_shared<dcp::DCP>(dir);
auto cpl = make_shared<dcp::CPL>("A Test DCP", dcp::ContentKind::TRAILER, dcp::Standard::SMPTE);

auto constexpr reel_length = 192;

auto reel1 = make_shared<dcp::Reel>(
make_shared<dcp::ReelMonoPictureAsset>(simple_picture(dir, "1", reel_length), 0),
make_shared<dcp::ReelSoundAsset>(simple_sound(dir, "1", dcp::MXFMetadata(), "en-US", reel_length), 0)
);

if (add_to_reel1) {
reel1->add(make_shared<dcp::ReelAtmosAsset>(simple_atmos(dir, "1", reel_length), 0));
}

auto markers1 = make_shared<dcp::ReelMarkersAsset>(dcp::Fraction(24, 1), reel_length);
markers1->set(dcp::Marker::FFOC, dcp::Time(1, 24, 24));
reel1->add(markers1);

cpl->add(reel1);

auto reel2 = make_shared<dcp::Reel>(
make_shared<dcp::ReelMonoPictureAsset>(simple_picture(dir, "2", reel_length), 0),
make_shared<dcp::ReelSoundAsset>(simple_sound(dir, "2", dcp::MXFMetadata(), "en-US", reel_length), 0)
);

if (add_to_reel2) {
reel2->add(make_shared<dcp::ReelAtmosAsset>(simple_atmos(dir, "2", reel_length), 0));
}

auto markers2 = make_shared<dcp::ReelMarkersAsset>(dcp::Fraction(24, 1), reel_length);
markers2->set(dcp::Marker::LFOC, dcp::Time(reel_length - 1, 24, 24));
reel2->add(markers2);

cpl->add(reel2);

dcp->add(cpl);
dcp->set_annotation_text("A Test DCP");
dcp->write_xml();

return cpl;
}


/** SMPTE ST 429-19:2019 section 6.2 says that each reel of a DCP with immersive audio should have it */
BOOST_AUTO_TEST_CASE(verify_missing_atmos_from_some_reels)
{
using VN = dcp::VerificationNote;
using VC = VN::Code;

auto ok_notes = [](path dir, shared_ptr<dcp::CPL> cpl) -> vector<VN> {
std::vector<string> const picture_ids = {
cpl->reels()[0]->main_picture()->asset()->id(),
cpl->reels()[1]->main_picture()->asset()->id()
};
return vector<VN>{
note(VC::NONE_ENCRYPTED, cpl),
VN(VC::VALID_CPL_ANNOTATION_TEXT).set_cpl_id(cpl->id()).set_annotation_text("A Test DCP"),
note(VC::MATCHING_PKL_ANNOTATION_TEXT_WITH_CPL, cpl),
note(VC::VALID_CONTENT_KIND, cpl).set_content_kind("trailer"),
note(VC::VALID_CONTENT_VERSION_LABEL_TEXT, cpl).set_content_version(cpl->content_version()->label_text),
note(VC::VALID_PICTURE_FRAME_SIZES_IN_BYTES, canonical(dir / "video1.mxf"), cpl).set_reel_index(0).set_asset_id(picture_ids[0]),
note(VC::VALID_PICTURE_FRAME_SIZES_IN_BYTES, canonical(dir / "video2.mxf"), cpl).set_reel_index(1).set_asset_id(picture_ids[1]),
note(VC::MATCHING_CPL_HASHES, cpl),
note(VC::CORRECT_PICTURE_HASH, canonical(dir / "video1.mxf"), cpl).set_reel_index(0).set_asset_id(picture_ids[0]),
note(VC::CORRECT_PICTURE_HASH, canonical(dir / "video2.mxf"), cpl).set_reel_index(1).set_asset_id(picture_ids[1]),
VN(VC::MISSING_CPL_METADATA, cpl->file().get()).set_cpl_id(cpl->id())
};
};

{
path dir("build/test/verify_missing_atmos_from_some_reels");
auto cpl = verify_atmos_should_be_in_all_reels_check(dir, true, false);
auto notes = ok_notes(dir, cpl);
notes.push_back(VN(VC::MISSING_ATMOS_FROM_SOME_REELS).set_cpl_id(cpl->id()));
check_verify_result({dir}, {}, notes);
}

{
path dir("build/test/verify_atmos_in_all_reels");
auto cpl = verify_atmos_should_be_in_all_reels_check(dir, true, true);
check_verify_result({dir}, {}, ok_notes(dir, cpl));
}

{
path dir("build/test/verify_atmos_in_no_reels");
auto cpl = verify_atmos_should_be_in_all_reels_check(dir, false, false);
check_verify_result({dir}, {}, ok_notes(dir, cpl));
}
}


static
shared_ptr<dcp::CPL>
verify_closed_captions_must_be_in_all_reels_check (path dir, int caps_in_reel1, int caps_in_reel2)
Expand Down