summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2021-03-26 00:09:15 +0100
committerCarl Hetherington <cth@carlh.net>2021-03-26 00:09:15 +0100
commitb9c5e3f74550917676e14324791d6ba4d0c07cac (patch)
tree4e3264a68c365af195f682b548186f6c973246b7 /src
parentc7208194515e93f85441c76d78d11a47d79b36e1 (diff)
Write MCA tags based on the specified sound field.
I had previously assumed that one should write MCA information into the sound MXF based on what channels actually contain sound rather than silence. However a previous example of a stereo DCP gives a verification error in EasyDCP (see DoM bug #1935) which is solved by adding MCA tags for each channel in the specified sound field (e.g. at least 6 tags for a file which is marked as 5.1) even if the audio is really stereo. This commit removes the "active channels" stuff and makes sure that if we say a file is 5.1 we write at least 6 MCA tags (and similarly for 7.1).
Diffstat (limited to 'src')
-rw-r--r--src/sound_asset.cc4
-rw-r--r--src/sound_asset.h2
-rw-r--r--src/sound_asset_writer.cc26
-rw-r--r--src/sound_asset_writer.h4
-rw-r--r--src/types.cc30
5 files changed, 37 insertions, 29 deletions
diff --git a/src/sound_asset.cc b/src/sound_asset.cc
index 1c0a181f..fe0c5dd0 100644
--- a/src/sound_asset.cc
+++ b/src/sound_asset.cc
@@ -222,13 +222,13 @@ SoundAsset::equals (shared_ptr<const Asset> other, EqualityOptions opt, NoteHand
shared_ptr<SoundAssetWriter>
-SoundAsset::start_write (boost::filesystem::path file, vector<Channel> active_channels, bool atmos_sync)
+SoundAsset::start_write (boost::filesystem::path file, bool atmos_sync)
{
if (atmos_sync && _channels < 14) {
throw MiscError ("Insufficient channels to write ATMOS sync (there must be at least 14)");
}
- return shared_ptr<SoundAssetWriter> (new SoundAssetWriter(this, file, active_channels, atmos_sync));
+ return shared_ptr<SoundAssetWriter> (new SoundAssetWriter(this, file, atmos_sync));
}
diff --git a/src/sound_asset.h b/src/sound_asset.h
index e238de46..e58773e4 100644
--- a/src/sound_asset.h
+++ b/src/sound_asset.h
@@ -75,7 +75,7 @@ public:
explicit SoundAsset (boost::filesystem::path file);
SoundAsset (Fraction edit_rate, int sampling_rate, int channels, LanguageTag language, Standard standard);
- std::shared_ptr<SoundAssetWriter> start_write (boost::filesystem::path file, std::vector<Channel> active_channels, bool atmos_sync = false);
+ std::shared_ptr<SoundAssetWriter> start_write (boost::filesystem::path file, bool atmos_sync = false);
std::shared_ptr<SoundAssetReader> start_read () const;
bool equals (
diff --git a/src/sound_asset_writer.cc b/src/sound_asset_writer.cc
index c0cdf0cb..205a45ab 100644
--- a/src/sound_asset_writer.cc
+++ b/src/sound_asset_writer.cc
@@ -66,12 +66,11 @@ struct SoundAssetWriter::ASDCPState
};
-SoundAssetWriter::SoundAssetWriter (SoundAsset* asset, boost::filesystem::path file, vector<Channel> active_channels, bool sync)
+SoundAssetWriter::SoundAssetWriter (SoundAsset* asset, boost::filesystem::path file, bool sync)
: AssetWriter (asset, file)
, _state (new SoundAssetWriter::ASDCPState)
, _asset (asset)
, _sync (sync)
- , _active_channels (active_channels)
{
DCP_ASSERT (!_sync || _asset->channels() >= 14);
DCP_ASSERT (!_sync || _asset->standard() == Standard::SMPTE);
@@ -117,7 +116,7 @@ SoundAssetWriter::start ()
boost::throw_exception (FileError("could not open audio MXF for writing", _file.string(), r));
}
- if (_asset->standard() == Standard::SMPTE && !_active_channels.empty()) {
+ if (_asset->standard() == Standard::SMPTE) {
ASDCP::MXF::WaveAudioDescriptor* essence_descriptor = nullptr;
_state->mxf_writer.OP1aHeader().GetMDObjectByType(
@@ -145,15 +144,26 @@ SoundAssetWriter::start ()
_state->mxf_writer.OP1aHeader().AddChildObject(soundfield);
essence_descriptor->SubDescriptors.push_back(soundfield->InstanceUID);
- for (auto i: _active_channels) {
+ /* We must describe at least the number of channels in `field', even if they aren't
+ * in the asset (I think)
+ */
+ int descriptors = max(_asset->channels(), field == MCASoundField::FIVE_POINT_ONE ? 6 : 8);
+
+ auto const used = used_audio_channels();
+
+ for (auto i = 0; i < descriptors; ++i) {
+ auto dcp_channel = static_cast<dcp::Channel>(i);
+ if (find(used.begin(), used.end(), dcp_channel) == used.end()) {
+ continue;
+ }
auto channel = new ASDCP::MXF::AudioChannelLabelSubDescriptor(asdcp_smpte_dict);
GenRandomValue (channel->MCALinkID);
channel->SoundfieldGroupLinkID = soundfield->MCALinkID;
- channel->MCAChannelID = static_cast<int>(i) + 1;
- channel->MCATagSymbol = "ch" + channel_to_mca_id(i, field);
- channel->MCATagName = channel_to_mca_name(i, field);
+ channel->MCAChannelID = i + 1;
+ channel->MCATagSymbol = "ch" + channel_to_mca_id(dcp_channel, field);
+ channel->MCATagName = channel_to_mca_name(dcp_channel, field);
channel->RFC5646SpokenLanguage = _asset->language();
- channel->MCALabelDictionaryID = channel_to_mca_universal_label(i, field, asdcp_smpte_dict);
+ channel->MCALabelDictionaryID = channel_to_mca_universal_label(dcp_channel, field, asdcp_smpte_dict);
_state->mxf_writer.OP1aHeader().AddChildObject(channel);
essence_descriptor->SubDescriptors.push_back(channel->InstanceUID);
}
diff --git a/src/sound_asset_writer.h b/src/sound_asset_writer.h
index d2eba024..b024749f 100644
--- a/src/sound_asset_writer.h
+++ b/src/sound_asset_writer.h
@@ -78,7 +78,7 @@ private:
friend class SoundAsset;
friend struct ::sync_test1;
- SoundAssetWriter (SoundAsset *, boost::filesystem::path, std::vector<Channel> active_channels, bool sync);
+ SoundAssetWriter (SoundAsset *, boost::filesystem::path, bool sync);
void start ();
void write_current_frame ();
@@ -99,8 +99,6 @@ private:
/** index of the sync packet (0-3) which starts the next edit unit */
int _sync_packet = 0;
FSK _fsk;
-
- std::vector<Channel> _active_channels;
};
}
diff --git a/src/types.cc b/src/types.cc
index b4c10ddc..44422ca9 100644
--- a/src/types.cc
+++ b/src/types.cc
@@ -827,20 +827,20 @@ dcp::channel_to_mca_universal_label (Channel c, MCASoundField field, ASDCP::Dict
vector<dcp::Channel>
dcp::used_audio_channels ()
{
- vector<Channel> c;
- c.push_back (Channel::LEFT);
- c.push_back (Channel::RIGHT);
- c.push_back (Channel::CENTRE);
- c.push_back (Channel::LFE);
- c.push_back (Channel::LS);
- c.push_back (Channel::RS);
- c.push_back (Channel::HI);
- c.push_back (Channel::VI);
- c.push_back (Channel::BSL);
- c.push_back (Channel::BSR);
- c.push_back (Channel::MOTION_DATA);
- c.push_back (Channel::SYNC_SIGNAL);
- c.push_back (Channel::SIGN_LANGUAGE);
- return c;
+ return {
+ Channel::LEFT,
+ Channel::RIGHT,
+ Channel::CENTRE,
+ Channel::LFE,
+ Channel::LS,
+ Channel::RS,
+ Channel::HI,
+ Channel::VI,
+ Channel::BSL,
+ Channel::BSR,
+ Channel::MOTION_DATA,
+ Channel::SYNC_SIGNAL,
+ Channel::SIGN_LANGUAGE
+ };
}