summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2024-04-18 11:51:03 +0200
committerCarl Hetherington <cth@carlh.net>2024-04-18 11:51:03 +0200
commit816365d20e0c6ef37b6bf499a42a0d3ecad22c05 (patch)
treee3ffd2029657ef0b316f729579077baf051f50a5 /tools
parent3ab56573dbfb395fea493096182dc14c09fb961f (diff)
parent869462070671b273ac528e075ac1c00a417cc8a0 (diff)
Merge remote-tracking branch 'origin/main' into v1.9.x
Diffstat (limited to 'tools')
-rw-r--r--tools/dcpdecryptmxf.cc35
1 files changed, 33 insertions, 2 deletions
diff --git a/tools/dcpdecryptmxf.cc b/tools/dcpdecryptmxf.cc
index 1cdb58ec..451a4d34 100644
--- a/tools/dcpdecryptmxf.cc
+++ b/tools/dcpdecryptmxf.cc
@@ -43,6 +43,8 @@
#include "key.h"
#include "mono_picture_asset.h"
#include "mono_picture_asset_writer.h"
+#include "sound_asset.h"
+#include "sound_asset_writer.h"
#include "util.h"
#include "version.h"
#include <asdcp/AS_DCP.h>
@@ -62,14 +64,14 @@ static void
help (string n)
{
cerr << "Re-write a MXF (decrypting it if required)\n"
- << "Syntax: " << n << " [OPTION] <MXF>]\n"
+ << "Syntax: " << n << " [OPTION] <MXF>\n"
<< " --version show libdcp version\n"
<< " -v, --verbose be verbose\n"
<< " -h, --help show this help\n"
<< " -o, --output output filename\n"
<< " -k, --kdm KDM file\n"
<< " -p, --private-key private key file\n"
- << " -t, --type MXF type: picture or atmos\n"
+ << " -t, --type MXF type: picture, sound or atmos\n"
<< " -i, --ignore-hmac don't raise an error if HMACs don't agree\n";
}
@@ -99,6 +101,7 @@ main (int argc, char* argv[])
enum class Type {
PICTURE,
+ SOUND,
ATMOS,
};
@@ -146,6 +149,8 @@ main (int argc, char* argv[])
case 't':
if (strcmp(optarg, "picture") == 0) {
type = Type::PICTURE;
+ } else if (strcmp(optarg, "sound") == 0) {
+ type = Type::SOUND;
} else if (strcmp(optarg, "atmos") == 0) {
type = Type::ATMOS;
} else {
@@ -234,6 +239,32 @@ main (int argc, char* argv[])
copy (in, writer, ignore_hmac);
break;
}
+ case Type::SOUND:
+ {
+ dcp::SoundAsset in(input_file);
+ add_key(in, decrypted_kdm);
+ /* XXX: this is all a bit of a hack */
+ dcp::SoundAsset out(in.edit_rate(), in.sampling_rate(), in.channels(), dcp::LanguageTag(in.language().get_value_or("en-GB")), dcp::Standard::SMPTE);
+ auto writer = out.start_write(output_file.get(), {}, dcp::SoundAsset::AtmosSync::DISABLED, dcp::SoundAsset::MCASubDescriptors::DISABLED);
+ auto reader = in.start_read();
+ reader->set_check_hmac(!ignore_hmac);
+ for (int64_t i = 0; i < in.intrinsic_duration(); ++i) {
+ auto frame = reader->get_frame(i);
+ std::vector<int32_t*> pointers(frame->channels());
+ for (auto channel = 0; channel < frame->channels(); ++channel) {
+ pointers[channel] = new int32_t[frame->samples()];
+ for (auto sample = 0; sample < frame->samples(); ++sample) {
+ pointers[channel][sample] = frame->get(channel, sample);
+ }
+ }
+ writer->write(pointers.data(), frame->channels(), frame->samples());
+ for (auto channel = 0; channel < frame->channels(); ++channel) {
+ delete[] pointers[channel];
+ }
+ }
+ writer->finalize();
+ break;
+ }
}
} catch (dcp::ReadError& e) {
cerr << "Read error: " << e.what() << "\n";