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
40 changes: 39 additions & 1 deletion src/lib/dcp_content.cc
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ DCPContent::DCPContent(boost::filesystem::path p)
, _kdm_valid(false)
, _reference_video(false)
, _reference_audio(false)
, _reference_atmos(false)
, _three_d(false)
{
LOG_GENERAL("Creating DCP content from {}", p.string());
Expand Down Expand Up @@ -112,6 +113,7 @@ DCPContent::DCPContent(cxml::ConstNodePtr node, boost::optional<boost::filesyste
_kdm_valid = node->bool_child("KDMValid");
_reference_video = node->optional_bool_child("ReferenceVideo").get_value_or(false);
_reference_audio = node->optional_bool_child("ReferenceAudio").get_value_or(false);
_reference_atmos = node->optional_bool_child("ReferenceAtmos").get_value_or(false);
if (version >= 37) {
_reference_text[TextType::OPEN_SUBTITLE] = node->optional_bool_child("ReferenceOpenSubtitle").get_value_or(false);
_reference_text[TextType::CLOSED_CAPTION] = node->optional_bool_child("ReferenceClosedCaption").get_value_or(false);
Expand Down Expand Up @@ -450,6 +452,7 @@ DCPContent::as_xml(xmlpp::Element* element, bool with_paths, PathBehaviour path_
cxml::add_text_child(element, "KDMValid", _kdm_valid ? "1" : "0");
cxml::add_text_child(element, "ReferenceVideo", _reference_video ? "1" : "0");
cxml::add_text_child(element, "ReferenceAudio", _reference_audio ? "1" : "0");
cxml::add_text_child(element, "ReferenceAtmos", _reference_atmos ? "1" : "0");
cxml::add_text_child(element, "ReferenceOpenSubtitle", _reference_text[TextType::OPEN_SUBTITLE] ? "1" : "0");
cxml::add_text_child(element, "ReferenceClosedCaption", _reference_text[TextType::CLOSED_CAPTION] ? "1" : "0");
if (_standard) {
Expand Down Expand Up @@ -652,6 +655,17 @@ DCPContent::set_reference_audio(bool r)
}
}

void
DCPContent::set_reference_atmos(bool r)
{
ContentChangeSignaller cc(this, DCPContentProperty::REFERENCE_ATMOS);

{
boost::mutex::scoped_lock lm(_mutex);
_reference_atmos = r;
}
}

void
DCPContent::set_reference_text(TextType type, bool r)
{
Expand Down Expand Up @@ -833,6 +847,29 @@ DCPContent::can_reference_audio(shared_ptr<const Film> film, string& why_not) co
}


bool
DCPContent::can_reference_atmos(shared_ptr<const Film> film, string& why_not) const
{
if (!atmos) {
/// TRANSLATORS: this string will follow "Cannot reference this DCP: "
why_not = _("it has no Atmos track.");
return false;
}

auto part = [](shared_ptr<const Content> c) {
return static_cast<bool>(c->atmos);
};

if (overlaps(film, part)) {
/// TRANSLATORS: this string will follow "Cannot reference this DCP: "
why_not = _("it overlaps other Atmos content.");
return false;
}

return can_reference_anything(film, why_not);
}


bool
DCPContent::can_reference_text(shared_ptr<const Film> film, TextType type, string& why_not) const
{
Expand Down Expand Up @@ -884,6 +921,7 @@ DCPContent::take_settings_from(shared_ptr<const Content> c)

_reference_video = dc->_reference_video;
_reference_audio = dc->_reference_audio;
_reference_atmos = dc->_reference_atmos;
_reference_text = dc->_reference_text;
}

Expand Down Expand Up @@ -951,7 +989,7 @@ DCPContent::active_audio_channels() const
bool
DCPContent::reference_anything() const
{
if (reference_video() || reference_audio()) {
if (reference_video() || reference_audio() || reference_atmos()) {
return true;
}

Expand Down
14 changes: 14 additions & 0 deletions src/lib/dcp_content.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class DCPContentProperty
static int constexpr NAME = 605;
static int constexpr TEXTS = 606;
static int constexpr CPL = 607;
static int constexpr REFERENCE_ATMOS = 608;
};


Expand Down Expand Up @@ -161,6 +162,15 @@ class DCPContent : public Content

bool can_reference_text(std::shared_ptr<const Film> film, TextType type, std::string &) const;

void set_reference_atmos(bool r);

bool reference_atmos() const {
boost::mutex::scoped_lock lm(_mutex);
return _reference_atmos;
}

bool can_reference_atmos(std::shared_ptr<const Film> film, std::string &) const;

bool reference_anything() const;

void set_cpl(std::string id);
Expand Down Expand Up @@ -291,6 +301,10 @@ class DCPContent : public Content
* not what they are being used for.
*/
EnumIndexedVector<bool, TextType> _reference_text;
/** true if the Atmos track in this DCP should be included in the output by reference
* rather than by rewrapping.
*/
bool _reference_atmos;

boost::optional<dcp::Standard> _standard;
boost::optional<dcp::MainSoundConfiguration> _main_sound_configuration;
Expand Down
2 changes: 1 addition & 1 deletion src/lib/dcp_decoder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ DCPDecoder::get_readers()
_sound_reader->set_check_hmac(false);
}

if ((*_reel)->atmos()) {
if ((*_reel)->atmos() && (_decode_referenced || !_dcp_content->reference_atmos())) {
auto asset = (*_reel)->atmos()->asset();
_atmos_reader = asset->start_read();
_atmos_reader->set_check_hmac(false);
Expand Down
4 changes: 4 additions & 0 deletions src/lib/film.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1832,6 +1832,10 @@ Film::check_settings_consistency()
d->set_reference_audio(false);
change_made = true;
}
if (d->reference_atmos() && !d->can_reference_atmos(shared_from_this(), why_not)) {
d->set_reference_atmos(false);
change_made = true;
}
if (d->reference_text(TextType::OPEN_SUBTITLE) && !d->can_reference_text(shared_from_this(), TextType::OPEN_SUBTITLE, why_not)) {
d->set_reference_text(TextType::OPEN_SUBTITLE, false);
change_made = true;
Expand Down
2 changes: 1 addition & 1 deletion src/lib/film_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ dcpomatic::film::is_vf(shared_ptr<const Film> film)
any_text = true;
}
}
if (dcp->reference_video() || dcp->reference_audio() || any_text) {
if (dcp->reference_video() || dcp->reference_audio() || dcp->reference_atmos() || any_text) {
return true;
}
}
Expand Down
34 changes: 31 additions & 3 deletions src/lib/reel_writer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,36 @@ ReelWriter::create_reel_sound(shared_ptr<dcp::Reel> reel, list<ReferencedReelAss
}


void
ReelWriter::create_reel_atmos(shared_ptr<dcp::Reel> reel, list<ReferencedReelAsset> const & refs) const
{
if (_atmos_asset) {
/* We have made an Atmos asset of our own. Put it into the reel */
reel->add(make_shared<dcp::ReelAtmosAsset>(_atmos_asset, 0));
return;
}

/* We don't have an Atmos asset of our own; use one that we reference, if there is one */
for (auto ref: refs) {
if (auto atmos = dynamic_pointer_cast<dcp::ReelAtmosAsset>(ref.asset)) {
if (ref.period.contains(_period)) {
auto const vfr = film()->video_frame_rate();
auto reel_asset = make_shared<dcp::ReelAtmosAsset>(*atmos);
reel_asset->set_entry_point(
reel_asset->entry_point().get_value_or(0) + dcpomatic::DCPTime(_period.from - ref.period.from).frames_round(vfr)
);
reel_asset->set_duration(_period.duration().frames_round(vfr));
/* If we have a hash for this asset in the CPL, assume that it is correct */
if (atmos->hash()) {
atmos->asset_ref()->set_hash(atmos->hash().get());
}
reel->add(reel_asset);
}
}
}
}


/** @param ensure_closed_captions List of DCPTextTracks that we need to make sure exist in this reel */
void
ReelWriter::create_reel_text(
Expand Down Expand Up @@ -748,9 +778,7 @@ ReelWriter::create_reel(

create_reel_text(reel, refs, duration, output_dcp, ensure_subtitles, ensure_closed_captions);

if (_atmos_asset) {
reel->add(make_shared<dcp::ReelAtmosAsset>(_atmos_asset, 0));
}
create_reel_atmos(reel, refs);

return reel;
}
Expand Down
1 change: 1 addition & 0 deletions src/lib/reel_writer.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ class ReelWriter : public WeakConstFilm

std::shared_ptr<dcp::ReelPictureAsset> create_reel_picture(std::shared_ptr<dcp::Reel> reel, std::list<ReferencedReelAsset> const & refs) const;
void create_reel_sound(std::shared_ptr<dcp::Reel> reel, std::list<ReferencedReelAsset> const & refs) const;
void create_reel_atmos(std::shared_ptr<dcp::Reel> reel, std::list<ReferencedReelAsset> const & refs) const;
void create_reel_text(
std::shared_ptr<dcp::Reel> reel,
std::list<ReferencedReelAsset> const & refs,
Expand Down
7 changes: 6 additions & 1 deletion src/lib/referenced_reel_asset.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "referenced_reel_asset.h"
#include <dcp/reel.h>
#include <dcp/reel_asset.h>
#include <dcp/reel_atmos_asset.h>
#include <dcp/reel_picture_asset.h>
#include <dcp/reel_sound_asset.h>
#include <dcp/reel_text_asset.h>
Expand Down Expand Up @@ -69,7 +70,7 @@ get_referenced_reel_assets(shared_ptr<const Film> film, shared_ptr<const Playlis
continue;
}

if (!dcp->reference_video() && !dcp->reference_audio() && !dcp->reference_text(TextType::OPEN_SUBTITLE) && !dcp->reference_text(TextType::CLOSED_CAPTION)) {
if (!dcp->reference_video() && !dcp->reference_audio() && !dcp->reference_atmos() && !dcp->reference_text(TextType::OPEN_SUBTITLE) && !dcp->reference_text(TextType::CLOSED_CAPTION)) {
continue;
}

Expand Down Expand Up @@ -115,6 +116,10 @@ get_referenced_reel_assets(shared_ptr<const Film> film, shared_ptr<const Playlis
maybe_add_asset(reel_assets, reel->main_sound(), reel_trim_start, reel_trim_end, from, frame_rate);
}

if (dcp->reference_atmos() && reel->atmos()) {
maybe_add_asset(reel_assets, reel->atmos(), reel_trim_start, reel_trim_end, from, frame_rate);
}

if (dcp->reference_text(TextType::OPEN_SUBTITLE) && reel->main_subtitle()) {
maybe_add_asset(reel_assets, reel->main_subtitle(), reel_trim_start, reel_trim_end, from, frame_rate);
}
Expand Down
1 change: 1 addition & 0 deletions src/wx/dcp_panel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,7 @@ DCPPanel::film_content_changed(int property)
case VideoContentProperty::CROP:
case DCPContentProperty::REFERENCE_VIDEO:
case DCPContentProperty::REFERENCE_AUDIO:
case DCPContentProperty::REFERENCE_ATMOS:
case DCPContentProperty::REFERENCE_TEXT:
setup_dcp_name();
update_standards();
Expand Down
22 changes: 18 additions & 4 deletions src/wx/dcp_referencing_dialog.cc
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ DCPReferencingDialog::film_content_changed(ChangeType type, int property)
if (
property != DCPContentProperty::REFERENCE_VIDEO &&
property != DCPContentProperty::REFERENCE_AUDIO &&
property != DCPContentProperty::REFERENCE_ATMOS &&
property != DCPContentProperty::REFERENCE_TEXT) {
setup();
}
Expand All @@ -108,11 +109,11 @@ DCPReferencingDialog::setup()
wxFont font(*wxNORMAL_FONT);
font.SetWeight(wxFONTWEIGHT_BOLD);
text->SetFont(font);
_dcp_grid->Add(text, wxGBPosition(row, 1), wxGBSpan(1, 4), wxALIGN_CENTER);
_dcp_grid->Add(text, wxGBPosition(row, 1), wxGBSpan(1, 5), wxALIGN_CENTER);
++row;

int column = 0;
for (auto const& sub_heading: { _("OV DCP"), _("Picture"), _("Sound"), _("Subtitles"), _("Closed captions") }) {
for (auto const& sub_heading: { _("OV DCP"), _("Picture"), _("Sound"), _("Atmos"), _("Subtitles"), _("Closed captions") }) {
auto text = new StaticText(this, sub_heading);
wxFont font(*wxNORMAL_FONT);
font.SetWeight(wxFONTWEIGHT_BOLD);
Expand All @@ -122,7 +123,7 @@ DCPReferencingDialog::setup()
}
++row;

auto const all_parts = { Part::VIDEO, Part::AUDIO, Part::SUBTITLES, Part::CLOSED_CAPTIONS };
auto const all_parts = { Part::VIDEO, Part::AUDIO, Part::ATMOS, Part::SUBTITLES, Part::CLOSED_CAPTIONS };

for (auto& content: _film->content()) {
auto dcp_content = dynamic_pointer_cast<DCPContent>(content);
Expand All @@ -143,6 +144,9 @@ DCPReferencingDialog::setup()
case Part::AUDIO:
record.check_box[part]->set(dcp_content->reference_audio());
break;
case Part::ATMOS:
record.check_box[part]->set(dcp_content->reference_atmos());
break;
case Part::SUBTITLES:
record.check_box[part]->set(dcp_content->reference_text(TextType::OPEN_SUBTITLE));
break;
Expand All @@ -162,7 +166,7 @@ DCPReferencingDialog::setup()
wxFont font(*wxNORMAL_FONT);
font.SetStyle(wxFONTSTYLE_ITALIC);
reason->SetFont(font);
_dcp_grid->Add(reason, wxGBPosition(row, 0), wxGBSpan(1, 5), wxLEFT, DCPOMATIC_SIZER_X_GAP * 4);
_dcp_grid->Add(reason, wxGBPosition(row, 0), wxGBSpan(1, 6), wxLEFT, DCPOMATIC_SIZER_X_GAP * 4);
++row;
};

Expand All @@ -188,6 +192,13 @@ DCPReferencingDialog::setup()
}
}

if (!dcp_content->can_reference_atmos(_film, why_not)) {
record.check_box[Part::ATMOS]->Enable(false);
if (dcp_content->atmos) {
add_problem(_("Cannot reference this DCP's Atmos"), why_not);
}
}

if (!dcp_content->can_reference_text(_film, TextType::OPEN_SUBTITLE, why_not)) {
record.check_box[Part::SUBTITLES]->Enable(false);
if (dcp_content->text_of_original_type(TextType::OPEN_SUBTITLE)) {
Expand Down Expand Up @@ -227,6 +238,9 @@ DCPReferencingDialog::checkbox_changed(weak_ptr<DCPContent> weak_content, CheckB
case Part::AUDIO:
content->set_reference_audio(check_box->get());
break;
case Part::ATMOS:
content->set_reference_atmos(check_box->get());
break;
case Part::SUBTITLES:
content->set_reference_text(TextType::OPEN_SUBTITLE, check_box->get());
break;
Expand Down
1 change: 1 addition & 0 deletions src/wx/dcp_referencing_dialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class DCPReferencingDialog : public wxDialog
enum class Part {
VIDEO,
AUDIO,
ATMOS,
SUBTITLES,
CLOSED_CAPTIONS,
COUNT
Expand Down
1 change: 1 addition & 0 deletions src/wx/dcp_timeline.cc
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ DCPTimeline::film_content_changed(ChangeType type, int property)
property == DCPContentProperty::NEEDS_ASSETS ||
property == DCPContentProperty::REFERENCE_VIDEO ||
property == DCPContentProperty::REFERENCE_AUDIO ||
property == DCPContentProperty::REFERENCE_ATMOS ||
property == DCPContentProperty::REFERENCE_TEXT) {
setup_reel_types();
setup_sensitivity();
Expand Down
1 change: 1 addition & 0 deletions src/wx/video_panel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,7 @@ VideoPanel::film_content_changed(int property)
}
case DCPContentProperty::REFERENCE_VIDEO:
case DCPContentProperty::REFERENCE_AUDIO:
case DCPContentProperty::REFERENCE_ATMOS:
case DCPContentProperty::REFERENCE_TEXT:
setup_sensitivity();
break;
Expand Down
2 changes: 2 additions & 0 deletions test/README.tex
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ \subsection{Tests of fairly specific areas}
\hline
\textbf{File} & \textbf{Test summary} \\
\hline
\co{atmos\_reference\_asset\_test} & Referencing the Atmos track of an existing DCP from a VF. \\
\hline
\co{audio\_delay\_test} & Some FFmpeg content with audio delays. \\
\hline
\co{client\_server\_test} & An encode server running on \co{localhost}. \\
Expand Down
Loading
Loading