// Macros used to test command option data state.
// True if a major mode has already been selected.
-#define TEST_MAJOR_MODE() ( create_flag )
+#define TEST_MAJOR_MODE() ( create_flag || info_flag )
// Causes the caller to return if a major mode has already been selected,
// otherwise sets the given flag.
#define TEST_SET_MAJOR_MODE(f) if ( TEST_MAJOR_MODE() ) \
{ \
- fputs("Conflicting major mode, choose one of -(ic)).\n", stderr); \
+ fputs("Conflicting major mode, choose one of -(ic).\n", stderr); \
return; \
} \
(f) = true;
usage(FILE* stream = stderr)
{
fprintf(stream, "\
-USAGE: %s [-i|-c <root-name> [-v]] <filename>\n\
+USAGE: %s [-v] -V\n\
+ %s [-v] -c <root-name> [-d <duration>] [-f <start-frame>] <filename>\n\
+ %s [-v] -i <filename>\n\
\n\
Major modes:\n\
- -c <root-name> - Create a WAV file for each channel in the input file (default is two channel files)\n\
- -V - Show version\n\
- -h - Show help\n\
-\n\
-Read/Write Options:\n\
- -f <frame-num> - Starting frame number, default 0\n\
+ -c <root-name> - Create a WAV file for each channel in the input file\n\
+ (default is two-channel files)\n\
-d <duration> - Number of frames to process, default all\n\
+ -f <frame-num> - Starting frame number, default 0\n\
+ -h - Show help\n\
+ -i - Show input file metadata (no output created)\n\
+ -V - Show version\n\
-v - Print extra info while processing\n\
\n\
NOTES: o There is no option grouping, all options must be distinct arguments.\n\
o All option arguments must be separated from the option by whitespace.\n\
-\n", PROGRAM_NAME);
+\n", PROGRAM_NAME, PROGRAM_NAME, PROGRAM_NAME);
}
//
public:
bool error_flag; // true if the given options are in error or not complete
bool create_flag; // true if the file create mode was selected
+ bool info_flag; // true if the file info mode was selected
bool version_flag; // true if the version display option was selected
bool help_flag; // true if the help display option was selected
bool verbose_flag; // true for extra info during procesing
const char* filename; // filename to be processed
CommandOptions(int argc, const char** argv) :
- error_flag(true), create_flag(false),
+ error_flag(true), create_flag(false), info_flag(false),
version_flag(false), help_flag(false), start_frame(0),
duration(0xffffffff), file_root(0), filename(0)
{
{
switch ( argv[i][1] )
{
- case 'V': version_flag = true; break;
- case 'h': help_flag = true; break;
case 'c':
TEST_SET_MAJOR_MODE(create_flag);
TEST_EXTRA_ARG(i, 'c');
file_root = argv[i];
break;
+ case 'd':
+ TEST_EXTRA_ARG(i, 'd');
+ duration = Kumu::xabs(strtol(argv[i], 0, 10));
+ break;
+
case 'f':
TEST_EXTRA_ARG(i, 'f');
- start_frame = atoi(argv[i]); // TODO: test for negative value, should use strtol()
+ start_frame = Kumu::xabs(strtol(argv[i], 0, 10));
break;
- case 'd':
- TEST_EXTRA_ARG(i, 'd');
- duration = atoi(argv[i]); // TODO: test for negative value, should use strtol()
- break;
+ case 'h': help_flag = true; break;
+ case 'i': TEST_SET_MAJOR_MODE(info_flag); break;
+ case 'V': version_flag = true; break;
default:
fprintf(stderr, "Unrecognized option: %c\n", argv[i][1]);
}
};
-
//
+Result_t
+wav_file_info(CommandOptions& Options)
+{
+ PCM::AudioDescriptor ADesc;
+ Rational PictureRate = EditRate_24;
+ PCM::WAVParser Parser;
+
+ // set up essence parser
+ Result_t result = Parser.OpenRead(Options.filename, PictureRate);
+
+ if ( ASDCP_SUCCESS(result) )
+ {
+ Parser.FillAudioDescriptor(ADesc);
+ ADesc.EditRate = PictureRate;
+ fprintf(stderr, "48Khz PCM Audio, %s fps (%u spf)\n", "24",
+ PCM::CalcSamplesPerFrame(ADesc));
+ fputs("AudioDescriptor:\n", stderr);
+ PCM::AudioDescriptorDump(ADesc);
+ }
+
+ return result;
+}
+
//
void
split_buffer(ui32_t sample_size, PCM::FrameBuffer& FrameBuffer,
R_FrameBuffer.Size(R_FrameBuffer.Capacity());
}
-
-//
//
Result_t
split_wav_file(CommandOptions& Options)
{
Parser.FillAudioDescriptor(ADesc);
- ADesc.SampleRate = PictureRate;
+ ADesc.EditRate = PictureRate;
ui32_t fb_size = PCM::CalcFrameBufferSize(ADesc);
assert((fb_size % 2) == 0);
FrameBuffer.Capacity(fb_size);
if ( Options.version_flag )
banner();
- if ( Options.create_flag )
+ if ( Options.info_flag )
+ result = wav_file_info(Options);
+
+ else if ( Options.create_flag )
result = split_wav_file(Options);
if ( result != RESULT_OK )