/*
-Copyright (c) 2003-2009, John Hurst
+Copyright (c) 2003-2010, John Hurst
All rights reserved.
Redistribution and use in source and binary forms, with or without
{
fprintf(stream, "\n\
%s (asdcplib %s)\n\n\
-Copyright (c) 2003-2009 John Hurst\n\n\
+Copyright (c) 2003-2010 John Hurst\n\n\
asdcplib may be copied only under the terms of the license found at\n\
the top of every file in the asdcplib distribution kit.\n\n\
Specify the -h (help) option for further information about %s\n\n",
usage(FILE* stream = stdout)
{
fprintf(stream, "\
-USAGE: %s -c <output-file> [-3] [-b <buffer-size>] [-d <duration>] [-e|-E]\n\
- [-f <start-frame>] [-j <key-id-string>] [-k <key-string>] [-l <label>]\n\
- [-L] [-M] [-p <frame-rate>] [-R] [-s <num>] [-v] [-W]\n\
- <input-file> [<input-file-2> ...]\n\
+USAGE: %s -c <output-file> [-3] [-a <uuid>] [-b <buffer-size>]\n\
+ [-d <duration>] [-e|-E] [-f <start-frame>] [-j <key-id-string>]\n\
+ [-k <key-string>] [-l <label>] [-L] [-M] [-p <frame-rate>] [-R]\n\
+ [-s <num>] [-v] [-W] [-z|-Z] <input-file> [<input-file-2> ...]\n\
\n\
%s [-h|-help] [-V]\n\
\n\
fprintf(stream, "\
Read/Write Options:\n\
+ -a <UUID> - Specify the Asset ID of a file (with -c)\n\
-b <buffer-size> - Specify size in bytes of picture frame buffer.\n\
Defaults to 4,194,304 (4MB)\n\
-d <duration> - Number of frames to process, default all\n\
-W - Read input file only, do not write source file\n\
-w <width> - Width of numeric element in a series of frame file names\n\
(use with -x, default 6).\n\
+ -z - Fail if j2c inputs have unequal parameters (default)\n\
+ -Z - Ignore unequal parameters in j2c inputs\n\
\n");
fprintf(stream, "\
bool error_flag; // true if the given options are in error or not complete
bool key_flag; // true if an encryption key was given
bool key_id_flag; // true if a key ID was given
+ bool asset_id_flag; // true if an asset ID was given
bool encrypt_header_flag; // true if mpeg headers are to be encrypted
bool write_hmac; // true if HMAC values are to be generated and written
bool read_hmac; // true if HMAC values are to be validated
bool duration_flag; // true if duration argument given
bool do_repeat; // if true and -c -d, repeat first input frame
bool use_smpte_labels; // if true, SMPTE UL values will be written instead of MXF Interop values
+ bool j2c_pedantic; // passed to JP2K::SequenceParser::OpenRead
ui32_t picture_rate; // fps of picture when wrapping PCM
ui32_t fb_size; // size of picture frame buffer
ui32_t file_count; // number of elements in filenames[]
const char* out_file; // name of mxf file created by create mode
byte_t key_value[KeyLen]; // value of given encryption key (when key_flag is true)
byte_t key_id_value[UUIDlen];// value of given key ID (when key_id_flag is true)
+ byte_t asset_id_value[UUIDlen];// value of asset ID (when asset_id_flag is true)
const char* filenames[MAX_IN_FILES]; // list of filenames to be processed
PCM::ChannelFormat_t channel_fmt; // audio channel arrangement
//
CommandOptions(int argc, const char** argv) :
- mode(MMT_NONE), error_flag(true), key_flag(false), key_id_flag(false), encrypt_header_flag(true),
- write_hmac(true), read_hmac(false), split_wav(false), mono_wav(false),
+ mode(MMT_NONE), error_flag(true), key_flag(false), key_id_flag(false), asset_id_flag(false),
+ encrypt_header_flag(true), write_hmac(true), read_hmac(false), split_wav(false), mono_wav(false),
verbose_flag(false), fb_dump_size(0), showindex_flag(false), showheader_flag(false),
no_write_flag(false), version_flag(false), help_flag(false), stereo_image_flag(false),
number_width(6), start_frame(0),
- duration(0xffffffff), duration_flag(false), do_repeat(false), use_smpte_labels(false),
+ duration(0xffffffff), duration_flag(false), do_repeat(false), use_smpte_labels(false), j2c_pedantic(true),
picture_rate(24), fb_size(FRAME_BUFFER_SIZE), file_count(0), file_root(0), out_file(0),
channel_fmt(PCM::CF_NONE)
{
case '2': split_wav = true; break;
case '3': stereo_image_flag = true; break;
+ case 'a':
+ asset_id_flag = true;
+ TEST_EXTRA_ARG(i, 'a');
+ {
+ ui32_t length;
+ Kumu::hex2bin(argv[i], asset_id_value, UUIDlen, &length);
+
+ if ( length != UUIDlen )
+ {
+ fprintf(stderr, "Unexpected asset ID length: %u, expecting %u characters.\n", length, UUIDlen);
+ return;
+ }
+ }
+ break;
+
case 'b':
TEST_EXTRA_ARG(i, 'b');
fb_size = abs(atoi(argv[i]));
file_root = argv[i];
break;
+ case 'Z': j2c_pedantic = false; break;
+ case 'z': j2c_pedantic = true; break;
+
default:
fprintf(stderr, "Unrecognized option: %s\n", argv[i]);
return;
if ( ASDCP_SUCCESS(result) && ! Options.no_write_flag )
{
WriterInfo Info = s_MyInfo; // fill in your favorite identifiers here
- Kumu::GenRandomUUID(Info.AssetUUID);
+ if ( Options.asset_id_flag )
+ memcpy(Info.AssetUUID, Options.asset_id_value, UUIDlen);
+ else
+ Kumu::GenRandomUUID(Info.AssetUUID);
if ( Options.use_smpte_labels )
{
}
// set up essence parser
- Result_t result = ParserLeft.OpenRead(Options.filenames[0]);
+ Result_t result = ParserLeft.OpenRead(Options.filenames[0], Options.j2c_pedantic);
if ( ASDCP_SUCCESS(result) )
- result = ParserRight.OpenRead(Options.filenames[1]);
+ result = ParserRight.OpenRead(Options.filenames[1], Options.j2c_pedantic);
// set up MXF writer
if ( ASDCP_SUCCESS(result) )
if ( ASDCP_SUCCESS(result) && ! Options.no_write_flag )
{
WriterInfo Info = s_MyInfo; // fill in your favorite identifiers here
- Kumu::GenRandomUUID(Info.AssetUUID);
+ if ( Options.asset_id_flag )
+ memcpy(Info.AssetUUID, Options.asset_id_value, UUIDlen);
+ else
+ Kumu::GenRandomUUID(Info.AssetUUID);
if ( Options.use_smpte_labels )
{
Kumu::FortunaRNG RNG;
// set up essence parser
- Result_t result = Parser.OpenRead(Options.filenames[0]);
+ Result_t result = Parser.OpenRead(Options.filenames[0], Options.j2c_pedantic);
// set up MXF writer
if ( ASDCP_SUCCESS(result) )
if ( ASDCP_SUCCESS(result) && ! Options.no_write_flag )
{
WriterInfo Info = s_MyInfo; // fill in your favorite identifiers here
- Kumu::GenRandomUUID(Info.AssetUUID);
+ if ( Options.asset_id_flag )
+ memcpy(Info.AssetUUID, Options.asset_id_value, UUIDlen);
+ else
+ Kumu::GenRandomUUID(Info.AssetUUID);
if ( Options.use_smpte_labels )
{
if ( ASDCP_SUCCESS(result) && ! Options.no_write_flag )
{
WriterInfo Info = s_MyInfo; // fill in your favorite identifiers here
- Kumu::GenRandomUUID(Info.AssetUUID);
+ if ( Options.asset_id_flag )
+ memcpy(Info.AssetUUID, Options.asset_id_value, UUIDlen);
+ else
+ Kumu::GenRandomUUID(Info.AssetUUID);
if ( Options.use_smpte_labels )
{
if ( ASDCP_SUCCESS(result) && ! Options.no_write_flag )
{
WriterInfo Info = s_MyInfo; // fill in your favorite identifiers here
- Kumu::GenRandomUUID(Info.AssetUUID);
+ if ( Options.asset_id_flag )
+ memcpy(Info.AssetUUID, Options.asset_id_value, UUIDlen);
+ else
+ Kumu::GenRandomUUID(Info.AssetUUID);
if ( Options.use_smpte_labels )
{
{
fprintf(stderr, "File is not AS-DCP: %s\n", Options.filenames[0]);
Kumu::FileReader Reader;
- MXF::OPAtomHeader TestHeader(DefaultCompositeDict());
+ const Dictionary* Dict = &DefaultCompositeDict();
+ MXF::OPAtomHeader TestHeader(Dict);
result = Reader.OpenRead(Options.filenames[0]);