/*
-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
inline bool operator!=(const Rational& rhs) const {
return ( rhs.Numerator != Numerator || rhs.Denominator != Denominator );
}
+
+ inline bool operator<(const Rational& rhs) {
+ if ( Numerator < rhs.Numerator ) return true;
+ if ( Numerator == rhs.Numerator && Denominator < rhs.Denominator ) return true;
+ return false;
+ }
+
+ inline bool operator>(const Rational& rhs) {
+ if ( Numerator > rhs.Numerator ) return true;
+ if ( Numerator == rhs.Numerator && Denominator > rhs.Denominator ) return true;
+ return false;
+ }
};
// common edit rates, use these instead of hard coded constants
const Rational SampleRate_48k(48000,1);
const Rational SampleRate_96k(96000,1);
- // Additional frame rates, see SMPTE 428-11
- // These rates are new and not supported by all systems. Do not assume that a package
- // made using on of these rates will work just anywhere!
+ // Additional frame rates, see ST 428-11
+ // These rates are new and not supported by all systems. Do not assume that
+ // a package made using on of these rates will work just anywhere!
const Rational EditRate_25(25,1);
const Rational EditRate_30(30,1);
const Rational EditRate_50(50,1);
// MXF files use SMPTE Universal Labels to identify data items. The set of Labels
// in a file is determined by the MXF Operational Pattern and any constraining
// documentation. There are currently two flavors of AS-DCP file in use: MXF Interop
- // and SMPTE. The two differ only in the values of two labels:
+ // (AKA JPEG Interop) and SMPTE. The two differ in the values of three labels:
//
- // OP Atom / Interop : 06 0e 2b 34 04 01 01 01 0d 01 02 01 10 00 00 00
- // OP Atom / SMPTE : 06 0e 2b 34 04 01 01 02 0d 01 02 01 10 00 00 00
- // and
- // EKLV Packet / Interop : 06 0e 2b 34 02 04 01 07 0d 01 03 01 02 7e 01 00
- // EKLV Packet / SMPTE : 06 0e 2b 34 02 04 01 01 0d 01 03 01 02 7e 01 00
+ // OPAtom
+ // Interop : 06 0e 2b 34 04 01 01 01 0d 01 02 01 10 00 00 00
+ // SMPTE : 06 0e 2b 34 04 01 01 02 0d 01 02 01 10 00 00 00
+ //
+ // EKLV Packet:
+ // Interop : 06 0e 2b 34 02 04 01 07 0d 01 03 01 02 7e 01 00
+ // SMPTE : 06 0e 2b 34 02 04 01 01 0d 01 03 01 02 7e 01 00
+ //
+ // GenericDescriptor/SubDescriptors:
+ // Interop : 06 0e 2b 34 01 01 01 02 06 01 01 04 06 10 00 00
+ // SMPTE : 06 0e 2b 34 01 01 01 09 06 01 01 04 06 10 00 00
//
// asdcplib will read any (otherwise valid) file which has any combination of the
// above values. When writing files, MXF Interop labels are used by default. To
// write a file containing SMPTE labels, replace the default label set value in
// the WriterInfo before calling OpenWrite()
//
+ //
enum LabelSet_t
{
LS_MXF_UNKNOWN,
struct AudioDescriptor
{
- Rational SampleRate; // rate of frame wrapping
+ Rational EditRate; // rate of frame wrapping
Rational AudioSamplingRate; // rate of audio sample
ui32_t Locked; //
ui32_t ChannelCount; // number of channels
// Returns number of samples per frame of data described by ADesc
inline ui32_t CalcSamplesPerFrame(const AudioDescriptor& ADesc)
{
- double tmpd = ADesc.AudioSamplingRate.Quotient() / ADesc.SampleRate.Quotient();
+ double tmpd = ADesc.AudioSamplingRate.Quotient() / ADesc.EditRate.Quotient();
return (ui32_t)ceil(tmpd);
}
// mismatch is detected.
Result_t OpenRead(const char* filename, bool pedantic = false) const;
+ // Opens a file sequence for reading. The sequence is expected to contain one or
+ // more filenames, each naming a file containing the codestream for exactly one
+ // picture. The parser will automatically parse enough data
+ // from the first file to provide a complete set of stream metadata for the
+ // MXFWriter below. If the "pedantic" parameter is given and is true, the
+ // parser will check the metadata for each codestream and fail if a
+ // mismatch is detected.
+ Result_t OpenRead(const std::list<std::string>& file_list, bool pedantic = false) const;
+
// Fill a PictureDescriptor struct with the values from the first file's codestream.
// Returns RESULT_INIT if the directory is not open.
Result_t FillPictureDescriptor(PictureDescriptor&) const;
DCSubtitleParser();
virtual ~DCSubtitleParser();
- // Opens the XML file for reading, parse data to provide a complete
+ // Opens an XML file for reading, parses data to provide a complete
// set of stream metadata for the MXFWriter below.
Result_t OpenRead(const char* filename) const;
+ // Parses an XML document to provide a complete set of stream metadata
+ // for the MXFWriter below. The optional filename argument is used to
+ // initialize the default resource resolver (see ReadAncillaryResource).
+ Result_t OpenRead(const std::string& xml_doc, const char* filename = 0) const;
+
// Fill a TimedTextDescriptor struct with the values from the file's contents.
// Returns RESULT_INIT if the file is not open.
- Result_t FillDescriptor(TimedTextDescriptor&) const;
+ Result_t FillTimedTextDescriptor(TimedTextDescriptor&) const;
// Reads the complete Timed Text Resource into the given string.
Result_t ReadTimedTextResource(std::string&) const;
// Fill a TimedTextDescriptor struct with the values from the file's header.
// Returns RESULT_INIT if the file is not open.
- Result_t FillDescriptor(TimedTextDescriptor&) const;
+ Result_t FillTimedTextDescriptor(TimedTextDescriptor&) const;
// Fill a WriterInfo struct with the values from the file's header.
// Returns RESULT_INIT if the file is not open.