diff options
| author | jhurst <jhurst@cinecert.com> | 2015-11-10 19:40:55 +0000 |
|---|---|---|
| committer | jhurst <> | 2015-11-10 19:40:55 +0000 |
| commit | 02915821cfb49cb6851086f5d991cee58328102b (patch) | |
| tree | c71cb099421c6ecf71a5a5ac469ba5e7fcfc413d /src | |
| parent | f758bec505d45084d2563f20514ab4a81b27283a (diff) | |
release
Diffstat (limited to 'src')
| -rwxr-xr-x | src/KLV.cpp | 5 | ||||
| -rwxr-xr-x | src/KM_error.h | 30 | ||||
| -rwxr-xr-x | src/KM_util.cpp | 63 | ||||
| -rwxr-xr-x | src/KM_util.h | 1 | ||||
| -rwxr-xr-x | src/MXF.cpp | 33 | ||||
| -rwxr-xr-x | src/MXF.h | 32 | ||||
| -rwxr-xr-x | src/MXFTypes.cpp | 41 | ||||
| -rwxr-xr-x | src/MXFTypes.h | 20 | ||||
| -rwxr-xr-x | src/Metadata.cpp | 39 | ||||
| -rwxr-xr-x | src/Metadata.h | 152 | ||||
| -rw-r--r-- | src/TimedText_Parser.cpp | 27 | ||||
| -rwxr-xr-x | src/as-02-wrap.cpp | 27 | ||||
| -rwxr-xr-x | src/asdcp-wrap.cpp | 6 | ||||
| -rw-r--r-- | src/blackwave.cpp | 2 | ||||
| -rw-r--r-- | src/h__02_Reader.cpp | 6 | ||||
| -rwxr-xr-x | src/kmfilegen.cpp | 2 | ||||
| -rwxr-xr-x | src/phdr-wrap.cpp | 28 |
17 files changed, 308 insertions, 206 deletions
diff --git a/src/KLV.cpp b/src/KLV.cpp index f78f3ea..24a90a5 100755 --- a/src/KLV.cpp +++ b/src/KLV.cpp @@ -94,19 +94,20 @@ ASDCP::KLVPacket::InitFromBuffer(const byte_t* buf, ui32_t buf_len) if ( ber_len > ( buf_len - SMPTE_UL_LENGTH ) ) { - DefaultLogSink().Error("BER encoding length exceeds buffer size\n"); + DefaultLogSink().Error("BER encoding length exceeds buffer size.\n"); return RESULT_FAIL; } if ( ber_len == 0 ) { - DefaultLogSink().Error("KLV format error, zero BER length not allowed\n"); + DefaultLogSink().Error("KLV format error, zero BER length not allowed.\n"); return RESULT_FAIL; } ui64_t tmp_size; if ( ! Kumu::read_BER(buf + SMPTE_UL_LENGTH, &tmp_size) ) { + DefaultLogSink().Error("KLV format error, BER decode failure.\n"); return RESULT_FAIL; } diff --git a/src/KM_error.h b/src/KM_error.h index 77a0846..8270cc0 100755 --- a/src/KM_error.h +++ b/src/KM_error.h @@ -1,5 +1,5 @@ /* -Copyright (c) 2004-2014, John Hurst +Copyright (c) 2004-2015, John Hurst All rights reserved. Redistribution and use in source and binary forms, with or without @@ -34,6 +34,8 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef _KM_ERROR_H_ #define _KM_ERROR_H_ +#include <string> + #define KM_DECLARE_RESULT(sym, i, l) const Result_t RESULT_##sym = Result_t(i, #sym, l); namespace Kumu @@ -46,8 +48,7 @@ namespace Kumu class Result_t { int value; - const char* label; - const char* symbol; + std::string label, symbol, message; Result_t(); public: @@ -65,21 +66,26 @@ namespace Kumu static unsigned int End(); static const Result_t& Get(unsigned int); - Result_t(int v, const char* s, const char* l); + Result_t(int v, const std::string& s, const std::string& l); + Result_t(const Result_t& rhs); + const Result_t& operator=(const Result_t& rhs); ~Result_t(); + const Result_t operator()(const std::string& message) const; + const Result_t operator()(const int& line, const char* filename) const; + const Result_t operator()(const std::string& message, const int& line, const char* filename) const; + inline bool operator==(const Result_t& rhs) const { return value == rhs.value; } inline bool operator!=(const Result_t& rhs) const { return value != rhs.value; } - inline bool Success() const { return ( value >= 0 ); } + inline bool Success() const { return ! ( value < 0 ); } inline bool Failure() const { return ( value < 0 ); } inline int Value() const { return value; } inline operator int() const { return value; } - - inline const char* Label() const { return label; } - inline operator const char*() const { return label; } - - inline const char* Symbol() const { return symbol; } + inline const char* Label() const { return label.c_str(); } + inline operator const char*() const { return label.c_str(); } + inline const char* Symbol() const { return symbol.c_str(); } + inline const char* Message() const { return message.c_str(); } }; KM_DECLARE_RESULT(FALSE, 1, "Successful but not true."); @@ -122,7 +128,7 @@ namespace Kumu // See Result_t above for an explanation of RESULT_* symbols. # define KM_TEST_NULL(p) \ if ( (p) == 0 ) { \ - return Kumu::RESULT_PTR; \ + return Kumu::RESULT_PTR(__LINE__, __FILE__); \ } // Returns RESULT_PTR if the given argument is NULL. See Result_t @@ -133,7 +139,7 @@ namespace Kumu # define KM_TEST_NULL_STR(p) \ KM_TEST_NULL(p); \ if ( (p)[0] == '\0' ) { \ - return Kumu::RESULT_NULL_STR; \ + return Kumu::RESULT_NULL_STR(__LINE__, __FILE__); \ } // RESULT_STATE is ambiguous. Use these everywhere it is assigned to provide some context diff --git a/src/KM_util.cpp b/src/KM_util.cpp index 2ccf9e9..d263d6e 100755 --- a/src/KM_util.cpp +++ b/src/KM_util.cpp @@ -129,10 +129,10 @@ Kumu::Result_t::Get(unsigned int i) } // -Kumu::Result_t::Result_t(int v, const char* s, const char* l) : value(v), symbol(s), label(l) +Kumu::Result_t::Result_t(int v, const std::string& s, const std::string& l) : value(v), symbol(s), label(l) { - assert(l); - assert(s); + assert(!l.empty()); + assert(!s.empty()); if ( v == 0 ) return; @@ -162,8 +162,65 @@ Kumu::Result_t::Result_t(int v, const char* s, const char* l) : value(v), symbol return; } + +Kumu::Result_t::Result_t(const Result_t& rhs) +{ + value = rhs.value; + symbol = rhs.symbol; + label = rhs.label; + message = rhs.message; +} + Kumu::Result_t::~Result_t() {} +// +const Kumu::Result_t& +Kumu::Result_t::operator=(const Result_t& rhs) +{ + value = rhs.value; + symbol = rhs.symbol; + label = rhs.label; + message = rhs.message; + return *this; +} + +// +const Kumu::Result_t +Kumu::Result_t::operator()(const std::string& message) const +{ + Result_t result = *this; + result.message = message; + return result; +} + +static int const MESSAGE_BUF_MAX = 2048; + +// +const Kumu::Result_t +Kumu::Result_t::operator()(const int& line, const char* filename) const +{ + assert(filename); + char buf[MESSAGE_BUF_MAX]; + snprintf(buf, MESSAGE_BUF_MAX-1, "%s, line %d", filename, line); + + Result_t result = *this; + result.message = buf; + return result; +} + +// +const Kumu::Result_t +Kumu::Result_t::operator()(const std::string& message, const int& line, const char* filename) const +{ + assert(filename); + char buf[MESSAGE_BUF_MAX]; + snprintf(buf, MESSAGE_BUF_MAX-1, "%s, line %d", filename, line); + + Result_t result = *this; + result.message = message + buf; + return result; +} + //------------------------------------------------------------------------------------------ // DTrace internals diff --git a/src/KM_util.h b/src/KM_util.h index 51334de..4834891 100755 --- a/src/KM_util.h +++ b/src/KM_util.h @@ -36,7 +36,6 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include <KM_error.h> #include <KM_tai.h> #include <string.h> -#include <string> #include <list> namespace Kumu diff --git a/src/MXF.cpp b/src/MXF.cpp index 3053047..258bdbf 100755 --- a/src/MXF.cpp +++ b/src/MXF.cpp @@ -126,11 +126,11 @@ ASDCP::MXF::RIP::InitFromFile(const Kumu::FileReader& Reader) if ( ASDCP_SUCCESS(result) ) { Kumu::MemIOReader MemRDR(m_ValueStart, m_ValueLength - 4); - result = PairArray.Unarchive(&MemRDR) ? RESULT_OK : RESULT_KLV_CODING; + result = PairArray.Unarchive(&MemRDR) ? RESULT_OK : RESULT_KLV_CODING(__LINE__, __FILE__); } if ( ASDCP_FAILURE(result) ) - DefaultLogSink().Error("Failed to initialize RIP\n"); + DefaultLogSink().Error("Failed to initialize RIP.\n"); return result; } @@ -149,7 +149,7 @@ ASDCP::MXF::RIP::WriteToFile(Kumu::FileWriter& Writer) if ( ASDCP_SUCCESS(result) ) { - result = RESULT_KLV_CODING; + result = RESULT_KLV_CODING(__LINE__, __FILE__); Kumu::MemIOWriter MemWRT(Buffer.Data(), Buffer.Capacity()); if ( PairArray.Archive(&MemWRT) ) @@ -301,7 +301,7 @@ ASDCP::Result_t ASDCP::MXF::Partition::InitFromBuffer(const byte_t* p, ui32_t l) { Kumu::MemIOReader MemRDR(p, l); - Result_t result = RESULT_KLV_CODING; + Result_t result = RESULT_KLV_CODING(__LINE__, __FILE__); if ( MemRDR.ReadUi16BE(&MajorVersion) ) if ( MemRDR.ReadUi16BE(&MinorVersion) ) @@ -319,7 +319,7 @@ ASDCP::MXF::Partition::InitFromBuffer(const byte_t* p, ui32_t l) result = RESULT_OK; if ( ASDCP_FAILURE(result) ) - DefaultLogSink().Error("Failed to initialize Partition\n"); + DefaultLogSink().Error("Failed to initialize Partition.\n"); return result; } @@ -334,7 +334,7 @@ ASDCP::MXF::Partition::WriteToFile(Kumu::FileWriter& Writer, UL& PartitionLabel) if ( ASDCP_SUCCESS(result) ) { Kumu::MemIOWriter MemWRT(Buffer.Data(), Buffer.Capacity()); - result = RESULT_KLV_CODING; + result = RESULT_KLV_CODING(__LINE__, __FILE__); if ( MemWRT.WriteUi16BE(MajorVersion) ) if ( MemWRT.WriteUi16BE(MinorVersion) ) if ( MemWRT.WriteUi32BE(KAGSize) ) @@ -449,7 +449,7 @@ ASDCP::MXF::Primer::InitFromBuffer(const byte_t* p, ui32_t l) if ( ASDCP_SUCCESS(result) ) { Kumu::MemIOReader MemRDR(m_ValueStart, m_ValueLength); - result = LocalTagEntryBatch.Unarchive(&MemRDR) ? RESULT_OK : RESULT_KLV_CODING; + result = LocalTagEntryBatch.Unarchive(&MemRDR) ? RESULT_OK : RESULT_KLV_CODING(__LINE__, __FILE__); } if ( ASDCP_SUCCESS(result) ) @@ -459,7 +459,7 @@ ASDCP::MXF::Primer::InitFromBuffer(const byte_t* p, ui32_t l) } if ( ASDCP_FAILURE(result) ) - DefaultLogSink().Error("Failed to initialize Primer\n"); + DefaultLogSink().Error("Failed to initialize Primer.\n"); return result; } @@ -487,7 +487,7 @@ ASDCP::MXF::Primer::WriteToBuffer(ASDCP::FrameBuffer& Buffer) assert(m_Dict); ASDCP::FrameBuffer LocalTagBuffer; Kumu::MemIOWriter MemWRT(Buffer.Data() + kl_length, Buffer.Capacity() - kl_length); - Result_t result = LocalTagEntryBatch.Archive(&MemWRT) ? RESULT_OK : RESULT_KLV_CODING; + Result_t result = LocalTagEntryBatch.Archive(&MemWRT) ? RESULT_OK : RESULT_KLV_CODING(__LINE__, __FILE__); if ( ASDCP_SUCCESS(result) ) { @@ -737,9 +737,9 @@ ASDCP::MXF::OP1aHeader::InitFromFile(const Kumu::FileReader& Reader) if ( read_count != m_HeaderData.Capacity() ) { - DefaultLogSink().Error("Short read of OP-Atom header metadata; wanted %u, got %u\n", + DefaultLogSink().Error("Short read of OP-Atom header metadata; wanted %u, got %u.\n", m_HeaderData.Capacity(), read_count); - return RESULT_KLV_CODING; + return RESULT_KLV_CODING(__LINE__, __FILE__); } } @@ -783,9 +783,9 @@ ASDCP::MXF::OP1aHeader::InitFromBuffer(const byte_t* p, ui32_t l) object->m_Lookup = &m_Primer; result = object->InitFromBuffer(p, end_p - p); + const byte_t* redo_p = p; p += object->PacketLength(); - // hexdump(p, object->PacketLength()); if ( ASDCP_SUCCESS(result) ) { @@ -813,7 +813,8 @@ ASDCP::MXF::OP1aHeader::InitFromBuffer(const byte_t* p, ui32_t l) } else { - DefaultLogSink().Error("Error initializing packet\n"); + DefaultLogSink().Error("Error initializing OP1a header packet.\n"); + // Kumu::hexdump(p-object->PacketLength(), object->PacketLength()); delete object; } } @@ -1074,13 +1075,15 @@ ASDCP::MXF::OPAtomIndexFooter::InitFromBuffer(const byte_t* p, ui32_t l) } else { - DefaultLogSink().Error("Error initializing packet\n"); + DefaultLogSink().Error("Error initializing OPAtom footer packet.\n"); delete object; } } if ( ASDCP_FAILURE(result) ) - DefaultLogSink().Error("Failed to initialize OPAtomIndexFooter\n"); + { + DefaultLogSink().Error("Failed to initialize OPAtomIndexFooter.\n"); + } return result; } @@ -235,8 +235,12 @@ namespace ASDCP public: optional_property() : m_has_value(false) {} - optional_property(const PropertyType& value) : m_property(value), m_has_value(false) {} - const optional_property<PropertyType>& operator=(const PropertyType& rhs) { this->m_property = rhs; this->m_has_value = true; return *this; } + optional_property(const PropertyType& value) : m_property(value), m_has_value(true) {} + const optional_property<PropertyType>& operator=(const PropertyType& rhs) { + this->m_property = rhs; + this->m_has_value = true; + return *this; + } bool operator==(const PropertyType& rhs) const { return this->m_property == rhs; } bool operator==(const optional_property<PropertyType>& rhs) const { return this->m_property == rhs.m_property; } operator PropertyType&() { return this->m_property; } @@ -248,6 +252,30 @@ namespace ASDCP const PropertyType& const_get() const { return m_property; } }; + // wrapper object manages optional properties + template <class PropertyType> + class optional_container_property + { + PropertyType m_property; + + public: + optional_container_property() {} + optional_container_property(const PropertyType& value) : m_property(value) {} + const optional_container_property<PropertyType>& operator=(const PropertyType& rhs) { + this->Copy(rhs.m_property); + return *this; + } + + bool operator==(const PropertyType& rhs) const { return this->m_property == rhs; } + bool operator==(const optional_property<PropertyType>& rhs) const { return this->m_property == rhs.m_property; } + operator PropertyType&() { return this->m_property; } + void set(const PropertyType& rhs) { this->m_property = rhs; } + void reset(const PropertyType& rhs) { this->clear(); } + bool empty() const { return ! this->m_property.HasValue(); } + PropertyType& get() { return m_property; } + const PropertyType& const_get() const { return m_property; } + }; + // base class of all metadata objects // class InterchangeObject : public ASDCP::KLVPacket diff --git a/src/MXFTypes.cpp b/src/MXFTypes.cpp index 6f0358f..d4bbf44 100755 --- a/src/MXFTypes.cpp +++ b/src/MXFTypes.cpp @@ -439,7 +439,7 @@ ASDCP::MXF::TLVReader::TLVReader(const byte_t* p, ui32_t c, IPrimerLookup* Prime DefaultLogSink().Error("Malformed Set\n"); m_ElementMap.clear(); - result = RESULT_KLV_CODING; + result = RESULT_KLV_CODING(__LINE__, __FILE__); } } @@ -489,7 +489,10 @@ ASDCP::MXF::TLVReader::ReadObject(const MDDEntry& Entry, Kumu::IArchive* Object) if ( FindTL(Entry) ) { if ( m_size < m_capacity ) // don't try to unarchive an empty item - return Object->Unarchive(this) ? RESULT_OK : RESULT_KLV_CODING; + { + // TODO: carry on if uachive fails + return Object->Unarchive(this) ? RESULT_OK : RESULT_FALSE(__LINE__, __FILE__); + } } return RESULT_FALSE; @@ -502,7 +505,7 @@ ASDCP::MXF::TLVReader::ReadUi8(const MDDEntry& Entry, ui8_t* value) ASDCP_TEST_NULL(value); if ( FindTL(Entry) ) - return MemIOReader::ReadUi8(value) ? RESULT_OK : RESULT_KLV_CODING; + return MemIOReader::ReadUi8(value) ? RESULT_OK : RESULT_FALSE(__LINE__, __FILE__); return RESULT_FALSE; } @@ -514,7 +517,7 @@ ASDCP::MXF::TLVReader::ReadUi16(const MDDEntry& Entry, ui16_t* value) ASDCP_TEST_NULL(value); if ( FindTL(Entry) ) - return MemIOReader::ReadUi16BE(value) ? RESULT_OK : RESULT_KLV_CODING; + return MemIOReader::ReadUi16BE(value) ? RESULT_OK : RESULT_FALSE(__LINE__, __FILE__); return RESULT_FALSE; } @@ -526,7 +529,7 @@ ASDCP::MXF::TLVReader::ReadUi32(const MDDEntry& Entry, ui32_t* value) ASDCP_TEST_NULL(value); if ( FindTL(Entry) ) - return MemIOReader::ReadUi32BE(value) ? RESULT_OK : RESULT_KLV_CODING; + return MemIOReader::ReadUi32BE(value) ? RESULT_OK : RESULT_FALSE(__LINE__, __FILE__); return RESULT_FALSE; } @@ -538,7 +541,7 @@ ASDCP::MXF::TLVReader::ReadUi64(const MDDEntry& Entry, ui64_t* value) ASDCP_TEST_NULL(value); if ( FindTL(Entry) ) - return MemIOReader::ReadUi64BE(value) ? RESULT_OK : RESULT_KLV_CODING; + return MemIOReader::ReadUi64BE(value) ? RESULT_OK : RESULT_FALSE(__LINE__, __FILE__); return RESULT_FALSE; } @@ -570,8 +573,8 @@ ASDCP::MXF::TLVWriter::WriteTag(const MDDEntry& Entry) return RESULT_FAIL; } - if ( ! MemIOWriter::WriteUi8(TmpTag.a) ) return RESULT_KLV_CODING; - if ( ! MemIOWriter::WriteUi8(TmpTag.b) ) return RESULT_KLV_CODING; + if ( ! MemIOWriter::WriteUi8(TmpTag.a) ) return RESULT_KLV_CODING(__LINE__, __FILE__); + if ( ! MemIOWriter::WriteUi8(TmpTag.b) ) return RESULT_KLV_CODING(__LINE__, __FILE__); return RESULT_OK; } @@ -591,11 +594,11 @@ ASDCP::MXF::TLVWriter::WriteObject(const MDDEntry& Entry, Kumu::IArchive* Object // write a temp length byte_t* l_p = CurrentData(); - if ( ! MemIOWriter::WriteUi16BE(0) ) return RESULT_KLV_CODING; + if ( ! MemIOWriter::WriteUi16BE(0) ) return RESULT_KLV_CODING(__LINE__, __FILE__); ui32_t before = Length(); - if ( ! Object->Archive(this) ) return RESULT_KLV_CODING; - if ( (Length() - before) > 0xffffL ) return RESULT_KLV_CODING; + if ( ! Object->Archive(this) ) return RESULT_KLV_CODING(__LINE__, __FILE__); + if ( (Length() - before) > 0xffffL ) return RESULT_KLV_CODING(__LINE__, __FILE__); Kumu::i2p<ui16_t>(KM_i16_BE(Length() - before), l_p); } @@ -611,8 +614,8 @@ ASDCP::MXF::TLVWriter::WriteUi8(const MDDEntry& Entry, ui8_t* value) if ( ASDCP_SUCCESS(result) ) { - if ( ! MemIOWriter::WriteUi16BE(sizeof(ui8_t)) ) return RESULT_KLV_CODING; - if ( ! MemIOWriter::WriteUi8(*value) ) return RESULT_KLV_CODING; + if ( ! MemIOWriter::WriteUi16BE(sizeof(ui8_t)) ) return RESULT_KLV_CODING(__LINE__, __FILE__); + if ( ! MemIOWriter::WriteUi8(*value) ) return RESULT_KLV_CODING(__LINE__, __FILE__); } return result; @@ -627,8 +630,8 @@ ASDCP::MXF::TLVWriter::WriteUi16(const MDDEntry& Entry, ui16_t* value) if ( KM_SUCCESS(result) ) { - if ( ! MemIOWriter::WriteUi16BE(sizeof(ui16_t)) ) return RESULT_KLV_CODING; - if ( ! MemIOWriter::WriteUi16BE(*value) ) return RESULT_KLV_CODING; + if ( ! MemIOWriter::WriteUi16BE(sizeof(ui16_t)) ) return RESULT_KLV_CODING(__LINE__, __FILE__); + if ( ! MemIOWriter::WriteUi16BE(*value) ) return RESULT_KLV_CODING(__LINE__, __FILE__); } return result; @@ -643,8 +646,8 @@ ASDCP::MXF::TLVWriter::WriteUi32(const MDDEntry& Entry, ui32_t* value) if ( KM_SUCCESS(result) ) { - if ( ! MemIOWriter::WriteUi16BE(sizeof(ui32_t)) ) return RESULT_KLV_CODING; - if ( ! MemIOWriter::WriteUi32BE(*value) ) return RESULT_KLV_CODING; + if ( ! MemIOWriter::WriteUi16BE(sizeof(ui32_t)) ) return RESULT_KLV_CODING(__LINE__, __FILE__); + if ( ! MemIOWriter::WriteUi32BE(*value) ) return RESULT_KLV_CODING(__LINE__, __FILE__); } return result; @@ -659,8 +662,8 @@ ASDCP::MXF::TLVWriter::WriteUi64(const MDDEntry& Entry, ui64_t* value) if ( KM_SUCCESS(result) ) { - if ( ! MemIOWriter::WriteUi16BE(sizeof(ui64_t)) ) return RESULT_KLV_CODING; - if ( ! MemIOWriter::WriteUi64BE(*value) ) return RESULT_KLV_CODING; + if ( ! MemIOWriter::WriteUi16BE(sizeof(ui64_t)) ) return RESULT_KLV_CODING(__LINE__, __FILE__); + if ( ! MemIOWriter::WriteUi64BE(*value) ) return RESULT_KLV_CODING(__LINE__, __FILE__); } return result; diff --git a/src/MXFTypes.h b/src/MXFTypes.h index 701dfa1..f74f4f5 100755 --- a/src/MXFTypes.h +++ b/src/MXFTypes.h @@ -135,7 +135,11 @@ namespace ASDCP ui32_t item_count, item_size; if ( ! Reader->ReadUi32BE(&item_count) ) return false; if ( ! Reader->ReadUi32BE(&item_size) ) return false; - if ( this->ItemSize() != item_size ) return false; + + if ( item_count > 0 ) + { + if ( this->ItemSize() != item_size ) return false; + } bool result = true; for ( ui32_t i = 0; i < item_count && result; ++i ) @@ -203,7 +207,7 @@ namespace ASDCP virtual ~SimpleArray() {} // - virtual bool Unarchive(Kumu::MemIOReader* Reader) + bool Unarchive(Kumu::MemIOReader* Reader) { bool result = true; @@ -211,15 +215,19 @@ namespace ASDCP { T Tmp; result = Tmp.Unarchive(Reader); - this->push_back(Tmp); + + if ( result ) + { + this->push_back(Tmp); + } } return result; } - inline virtual bool HasValue() const { return ! this->empty(); } + inline bool HasValue() const { return ! this->empty(); } - virtual ui32_t ArchiveLength() const { + ui32_t ArchiveLength() const { ui32_t arch_size = 0; typename std::list<T>::const_iterator l_i = this->begin(); @@ -231,7 +239,7 @@ namespace ASDCP } // - virtual bool Archive(Kumu::MemIOWriter* Writer) const { + bool Archive(Kumu::MemIOWriter* Writer) const { bool result = true; typename std::list<T>::const_iterator l_i = this->begin(); diff --git a/src/Metadata.cpp b/src/Metadata.cpp index bec2530..af32e5b 100755 --- a/src/Metadata.cpp +++ b/src/Metadata.cpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2005-2012, John Hurst +Copyright (c) 2005-2015, John Hurst All rights reserved. Redistribution and use in source and binary forms, with or without @@ -1578,7 +1578,7 @@ WaveAudioDescriptor::WriteToBuffer(ASDCP::FrameBuffer& Buffer) // -GenericPictureEssenceDescriptor::GenericPictureEssenceDescriptor(const Dictionary*& d) : FileDescriptor(d), m_Dict(d), SignalStandard(0), SampledWidth(0), SampledXOffset(0), DisplayHeight(0), DisplayXOffset(0), DisplayF2Offset(0), AlphaTransparency(0), ImageAlignmentOffset(0), ImageEndOffset(0), ActiveWidth(0), ActiveXOffset(0) +GenericPictureEssenceDescriptor::GenericPictureEssenceDescriptor(const Dictionary*& d) : FileDescriptor(d), m_Dict(d), SignalStandard(0), SampledWidth(0), SampledXOffset(0), DisplayHeight(0), DisplayXOffset(0), DisplayF2Offset(0), AlphaTransparency(0), ImageAlignmentOffset(0), ImageEndOffset(0), ActiveHeight(0), ActiveYOffset(0) { assert(m_Dict); m_UL = m_Dict->ul(MDD_GenericPictureEssenceDescriptor); @@ -1683,7 +1683,9 @@ GenericPictureEssenceDescriptor::InitFromTLVSet(TLVReader& TLVSet) result = TLVSet.ReadObject(OBJ_READ_ARGS_OPT(GenericPictureEssenceDescriptor, ColorPrimaries)); ColorPrimaries.set_has_value( result == RESULT_OK ); } - if ( ASDCP_SUCCESS(result) ) result = TLVSet.ReadObject(OBJ_READ_ARGS(GenericPictureEssenceDescriptor, AlternativeCenterCuts)); + if ( ASDCP_SUCCESS(result) ) { + result = TLVSet.ReadObject(OBJ_READ_ARGS_OPT(GenericPictureEssenceDescriptor, AlternativeCenterCuts)); + } if ( ASDCP_SUCCESS(result) ) { result = TLVSet.ReadUi32(OBJ_READ_ARGS_OPT(GenericPictureEssenceDescriptor, ActiveWidth)); ActiveWidth.set_has_value( result == RESULT_OK ); @@ -1734,7 +1736,7 @@ GenericPictureEssenceDescriptor::WriteToTLVSet(TLVWriter& TLVSet) if ( ASDCP_SUCCESS(result) ) result = TLVSet.WriteObject(OBJ_WRITE_ARGS(GenericPictureEssenceDescriptor, PictureEssenceCoding)); if ( ASDCP_SUCCESS(result) && ! CodingEquations.empty() ) result = TLVSet.WriteObject(OBJ_WRITE_ARGS_OPT(GenericPictureEssenceDescriptor, CodingEquations)); if ( ASDCP_SUCCESS(result) && ! ColorPrimaries.empty() ) result = TLVSet.WriteObject(OBJ_WRITE_ARGS_OPT(GenericPictureEssenceDescriptor, ColorPrimaries)); - if ( ASDCP_SUCCESS(result) ) result = TLVSet.WriteObject(OBJ_WRITE_ARGS(GenericPictureEssenceDescriptor, AlternativeCenterCuts)); + if ( ASDCP_SUCCESS(result) && ! AlternativeCenterCuts.empty() ) result = TLVSet.WriteObject(OBJ_WRITE_ARGS_OPT(GenericPictureEssenceDescriptor, AlternativeCenterCuts)); if ( ASDCP_SUCCESS(result) && ! ActiveWidth.empty() ) result = TLVSet.WriteUi32(OBJ_WRITE_ARGS_OPT(GenericPictureEssenceDescriptor, ActiveWidth)); if ( ASDCP_SUCCESS(result) && ! ActiveHeight.empty() ) result = TLVSet.WriteUi32(OBJ_WRITE_ARGS_OPT(GenericPictureEssenceDescriptor, ActiveHeight)); if ( ASDCP_SUCCESS(result) && ! ActiveXOffset.empty() ) result = TLVSet.WriteUi32(OBJ_WRITE_ARGS_OPT(GenericPictureEssenceDescriptor, ActiveXOffset)); @@ -1855,8 +1857,10 @@ GenericPictureEssenceDescriptor::Dump(FILE* stream) if ( ! ColorPrimaries.empty() ) { fprintf(stream, " %22s = %s\n", "ColorPrimaries", ColorPrimaries.get().EncodeString(identbuf, IdentBufferLen)); } - fprintf(stream, " %22s:\n", "AlternativeCenterCuts"); - AlternativeCenterCuts.Dump(stream); + if ( ! AlternativeCenterCuts.empty() ) { + fprintf(stream, " %22s:\n", "AlternativeCenterCuts"); + AlternativeCenterCuts.get().Dump(stream); + } if ( ! ActiveWidth.empty() ) { fprintf(stream, " %22s = %d\n", "ActiveWidth", ActiveWidth.get()); } @@ -3319,7 +3323,10 @@ AudioChannelLabelSubDescriptor::InitFromTLVSet(TLVReader& TLVSet) { assert(m_Dict); Result_t result = MCALabelSubDescriptor::InitFromTLVSet(TLVSet); - if ( ASDCP_SUCCESS(result) ) result = TLVSet.ReadObject(OBJ_READ_ARGS(AudioChannelLabelSubDescriptor, SoundfieldGroupLinkID)); + if ( ASDCP_SUCCESS(result) ) { + result = TLVSet.ReadObject(OBJ_READ_ARGS_OPT(AudioChannelLabelSubDescriptor, SoundfieldGroupLinkID)); + SoundfieldGroupLinkID.set_has_value( result == RESULT_OK ); + } return result; } @@ -3329,7 +3336,7 @@ AudioChannelLabelSubDescriptor::WriteToTLVSet(TLVWriter& TLVSet) { assert(m_Dict); Result_t result = MCALabelSubDescriptor::WriteToTLVSet(TLVSet); - if ( ASDCP_SUCCESS(result) ) result = TLVSet.WriteObject(OBJ_WRITE_ARGS(AudioChannelLabelSubDescriptor, SoundfieldGroupLinkID)); + if ( ASDCP_SUCCESS(result) && ! SoundfieldGroupLinkID.empty() ) result = TLVSet.WriteObject(OBJ_WRITE_ARGS_OPT(AudioChannelLabelSubDescriptor, SoundfieldGroupLinkID)); return result; } @@ -3352,7 +3359,9 @@ AudioChannelLabelSubDescriptor::Dump(FILE* stream) stream = stderr; MCALabelSubDescriptor::Dump(stream); - fprintf(stream, " %22s = %s\n", "SoundfieldGroupLinkID", SoundfieldGroupLinkID.EncodeString(identbuf, IdentBufferLen)); + if ( ! SoundfieldGroupLinkID.empty() ) { + fprintf(stream, " %22s = %s\n", "SoundfieldGroupLinkID", SoundfieldGroupLinkID.get().EncodeString(identbuf, IdentBufferLen)); + } } // @@ -3394,7 +3403,9 @@ SoundfieldGroupLabelSubDescriptor::InitFromTLVSet(TLVReader& TLVSet) { assert(m_Dict); Result_t result = MCALabelSubDescriptor::InitFromTLVSet(TLVSet); - if ( ASDCP_SUCCESS(result) ) result = TLVSet.ReadObject(OBJ_READ_ARGS(SoundfieldGroupLabelSubDescriptor, GroupOfSoundfieldGroupsLinkID)); + if ( ASDCP_SUCCESS(result) ) { + result = TLVSet.ReadObject(OBJ_READ_ARGS_OPT(SoundfieldGroupLabelSubDescriptor, GroupOfSoundfieldGroupsLinkID)); + } return result; } @@ -3404,7 +3415,7 @@ SoundfieldGroupLabelSubDescriptor::WriteToTLVSet(TLVWriter& TLVSet) { assert(m_Dict); Result_t result = MCALabelSubDescriptor::WriteToTLVSet(TLVSet); - if ( ASDCP_SUCCESS(result) ) result = TLVSet.WriteObject(OBJ_WRITE_ARGS(SoundfieldGroupLabelSubDescriptor, GroupOfSoundfieldGroupsLinkID)); + if ( ASDCP_SUCCESS(result) && ! GroupOfSoundfieldGroupsLinkID.empty() ) result = TLVSet.WriteObject(OBJ_WRITE_ARGS_OPT(SoundfieldGroupLabelSubDescriptor, GroupOfSoundfieldGroupsLinkID)); return result; } @@ -3427,8 +3438,10 @@ SoundfieldGroupLabelSubDescriptor::Dump(FILE* stream) stream = stderr; MCALabelSubDescriptor::Dump(stream); - fprintf(stream, " %22s:\n", "GroupOfSoundfieldGroupsLinkID"); - GroupOfSoundfieldGroupsLinkID.Dump(stream); + if ( ! GroupOfSoundfieldGroupsLinkID.empty() ) { + fprintf(stream, " %22s:\n", "GroupOfSoundfieldGroupsLinkID"); + GroupOfSoundfieldGroupsLinkID.get().Dump(stream); + } } // diff --git a/src/Metadata.h b/src/Metadata.h index bc62665..55f06d4 100755 --- a/src/Metadata.h +++ b/src/Metadata.h @@ -1,5 +1,5 @@ /* -Copyright (c) 2005-2012, John Hurst +Copyright (c) 2005-2015, John Hurst All rights reserved. Redistribution and use in source and binary forms, with or without @@ -57,7 +57,7 @@ namespace ASDCP UUID ProductUID; Kumu::Timestamp ModificationDate; VersionType ToolkitVersion; - optional_property<UTF16String> Platform; + optional_property<UTF16String > Platform; Identification(const Dictionary*& d); Identification(const Identification& rhs); @@ -105,7 +105,7 @@ namespace ASDCP public: const Dictionary*& m_Dict; UMID LinkedPackageUID; - optional_property<ui32_t> IndexSID; + optional_property<ui32_t > IndexSID; ui32_t BodySID; EssenceContainerData(const Dictionary*& d); @@ -130,7 +130,7 @@ namespace ASDCP public: const Dictionary*& m_Dict; UMID PackageUID; - optional_property<UTF16String> Name; + optional_property<UTF16String > Name; Kumu::Timestamp PackageCreationDate; Kumu::Timestamp PackageModifiedDate; Array<UUID> Tracks; @@ -154,7 +154,7 @@ namespace ASDCP public: const Dictionary*& m_Dict; - optional_property<UUID> PackageMarker; + optional_property<UUID > PackageMarker; MaterialPackage(const Dictionary*& d); MaterialPackage(const MaterialPackage& rhs); @@ -202,8 +202,8 @@ namespace ASDCP const Dictionary*& m_Dict; ui32_t TrackID; ui32_t TrackNumber; - optional_property<UTF16String> TrackName; - optional_property<UUID> Sequence; + optional_property<UTF16String > TrackName; + optional_property<UUID > Sequence; GenericTrack(const Dictionary*& d); GenericTrack(const GenericTrack& rhs); @@ -271,7 +271,7 @@ namespace ASDCP public: const Dictionary*& m_Dict; UL DataDefinition; - optional_property<ui64_t> Duration; + optional_property<ui64_t > Duration; StructuralComponent(const Dictionary*& d); StructuralComponent(const StructuralComponent& rhs); @@ -387,11 +387,11 @@ namespace ASDCP public: const Dictionary*& m_Dict; - optional_property<ui32_t> LinkedTrackID; + optional_property<ui32_t > LinkedTrackID; Rational SampleRate; - optional_property<ui64_t> ContainerDuration; + optional_property<ui64_t > ContainerDuration; UL EssenceContainer; - optional_property<UL> Codec; + optional_property<UL > Codec; FileDescriptor(const Dictionary*& d); FileDescriptor(const FileDescriptor& rhs); @@ -416,11 +416,11 @@ namespace ASDCP const Dictionary*& m_Dict; Rational AudioSamplingRate; ui8_t Locked; - optional_property<ui8_t> AudioRefLevel; - optional_property<ui8_t> ElectroSpatialFormulation; + optional_property<ui8_t > AudioRefLevel; + optional_property<ui8_t > ElectroSpatialFormulation; ui32_t ChannelCount; ui32_t QuantizationBits; - optional_property<ui8_t> DialNorm; + optional_property<ui8_t > DialNorm; UL SoundEssenceCoding; GenericSoundEssenceDescriptor(const Dictionary*& d); @@ -445,11 +445,11 @@ namespace ASDCP public: const Dictionary*& m_Dict; ui16_t BlockAlign; - optional_property<ui8_t> SequenceOffset; + optional_property<ui8_t > SequenceOffset; ui32_t AvgBps; - optional_property<UL> ChannelAssignment; - optional_property<Rational> ReferenceImageEditRate; - optional_property<ui8_t> ReferenceAudioAlignmentLevel; + optional_property<UL > ChannelAssignment; + optional_property<Rational > ReferenceImageEditRate; + optional_property<ui8_t > ReferenceAudioAlignmentLevel; WaveAudioDescriptor(const Dictionary*& d); WaveAudioDescriptor(const WaveAudioDescriptor& rhs); @@ -472,36 +472,36 @@ namespace ASDCP public: const Dictionary*& m_Dict; - optional_property<ui8_t> SignalStandard; + optional_property<ui8_t > SignalStandard; ui8_t FrameLayout; ui32_t StoredWidth; ui32_t StoredHeight; - optional_property<ui32_t> StoredF2Offset; - optional_property<ui32_t> SampledWidth; - optional_property<ui32_t> SampledHeight; - optional_property<ui32_t> SampledXOffset; - optional_property<ui32_t> SampledYOffset; - optional_property<ui32_t> DisplayHeight; - optional_property<ui32_t> DisplayWidth; - optional_property<ui32_t> DisplayXOffset; - optional_property<ui32_t> DisplayYOffset; - optional_property<ui32_t> DisplayF2Offset; + optional_property<ui32_t > StoredF2Offset; + optional_property<ui32_t > SampledWidth; + optional_property<ui32_t > SampledHeight; + optional_property<ui32_t > SampledXOffset; + optional_property<ui32_t > SampledYOffset; + optional_property<ui32_t > DisplayHeight; + optional_property<ui32_t > DisplayWidth; + optional_property<ui32_t > DisplayXOffset; + optional_property<ui32_t > DisplayYOffset; + optional_property<ui32_t > DisplayF2Offset; Rational AspectRatio; - optional_property<ui8_t> ActiveFormatDescriptor; - optional_property<ui8_t> AlphaTransparency; - optional_property<UL> TransferCharacteristic; - optional_property<ui32_t> ImageAlignmentOffset; - optional_property<ui32_t> ImageStartOffset; - optional_property<ui32_t> ImageEndOffset; - optional_property<ui8_t> FieldDominance; + optional_property<ui8_t > ActiveFormatDescriptor; + optional_property<ui8_t > AlphaTransparency; + optional_property<UL > TransferCharacteristic; + optional_property<ui32_t > ImageAlignmentOffset; + optional_property<ui32_t > ImageStartOffset; + optional_property<ui32_t > ImageEndOffset; + optional_property<ui8_t > FieldDominance; UL PictureEssenceCoding; - optional_property<UL> CodingEquations; - optional_property<UL> ColorPrimaries; - Batch<UL> AlternativeCenterCuts; - optional_property<ui32_t> ActiveWidth; - optional_property<ui32_t> ActiveHeight; - optional_property<ui32_t> ActiveXOffset; - optional_property<ui32_t> ActiveYOffset; + optional_property<UL > CodingEquations; + optional_property<UL > ColorPrimaries; + optional_property<Batch<UL> > AlternativeCenterCuts; + optional_property<ui32_t > ActiveWidth; + optional_property<ui32_t > ActiveHeight; + optional_property<ui32_t > ActiveXOffset; + optional_property<ui32_t > ActiveYOffset; GenericPictureEssenceDescriptor(const Dictionary*& d); GenericPictureEssenceDescriptor(const GenericPictureEssenceDescriptor& rhs); @@ -524,11 +524,11 @@ namespace ASDCP public: const Dictionary*& m_Dict; - optional_property<ui32_t> ComponentMaxRef; - optional_property<ui32_t> ComponentMinRef; - optional_property<ui32_t> AlphaMinRef; - optional_property<ui32_t> AlphaMaxRef; - optional_property<ui8_t> ScanningDirection; + optional_property<ui32_t > ComponentMaxRef; + optional_property<ui32_t > ComponentMinRef; + optional_property<ui32_t > AlphaMinRef; + optional_property<ui32_t > AlphaMaxRef; + optional_property<ui8_t > ScanningDirection; RGBAEssenceDescriptor(const Dictionary*& d); RGBAEssenceDescriptor(const RGBAEssenceDescriptor& rhs); @@ -561,10 +561,10 @@ namespace ASDCP ui32_t XTOsize; ui32_t YTOsize; ui16_t Csize; - optional_property<Raw> PictureComponentSizing; - optional_property<Raw> CodingStyleDefault; - optional_property<Raw> QuantizationDefault; - optional_property<RGBALayout> J2CLayout; + optional_property<Raw > PictureComponentSizing; + optional_property<Raw > CodingStyleDefault; + optional_property<Raw > QuantizationDefault; + optional_property<RGBALayout > J2CLayout; JPEG2000PictureSubDescriptor(const Dictionary*& d); JPEG2000PictureSubDescriptor(const JPEG2000PictureSubDescriptor& rhs); @@ -589,14 +589,14 @@ namespace ASDCP const Dictionary*& m_Dict; ui32_t ComponentDepth; ui32_t HorizontalSubsampling; - optional_property<ui32_t> VerticalSubsampling; - optional_property<ui8_t> ColorSiting; - optional_property<ui8_t> ReversedByteOrder; - optional_property<ui16_t> PaddingBits; - optional_property<ui32_t> AlphaSampleDepth; - optional_property<ui32_t> BlackRefLevel; - optional_property<ui32_t> WhiteReflevel; - optional_property<ui32_t> ColorRange; + optional_property<ui32_t > VerticalSubsampling; + optional_property<ui8_t > ColorSiting; + optional_property<ui8_t > ReversedByteOrder; + optional_property<ui16_t > PaddingBits; + optional_property<ui32_t > AlphaSampleDepth; + optional_property<ui32_t > BlackRefLevel; + optional_property<ui32_t > WhiteReflevel; + optional_property<ui32_t > ColorRange; CDCIEssenceDescriptor(const Dictionary*& d); CDCIEssenceDescriptor(const CDCIEssenceDescriptor& rhs); @@ -619,16 +619,16 @@ namespace ASDCP public: const Dictionary*& m_Dict; - optional_property<ui8_t> SingleSequence; - optional_property<ui8_t> ConstantBFrames; - optional_property<ui8_t> CodedContentType; - optional_property<ui8_t> LowDelay; - optional_property<ui8_t> ClosedGOP; - optional_property<ui8_t> IdenticalGOP; - optional_property<ui8_t> MaxGOP; - optional_property<ui8_t> BPictureCount; - optional_property<ui32_t> BitRate; - optional_property<ui8_t> ProfileAndLevel; + optional_property<ui8_t > SingleSequence; + optional_property<ui8_t > ConstantBFrames; + optional_property<ui8_t > CodedContentType; + optional_property<ui8_t > LowDelay; + optional_property<ui8_t > ClosedGOP; + optional_property<ui8_t > IdenticalGOP; + optional_property<ui8_t > MaxGOP; + optional_property<ui8_t > BPictureCount; + optional_property<ui32_t > BitRate; + optional_property<ui8_t > ProfileAndLevel; MPEG2VideoDescriptor(const Dictionary*& d); MPEG2VideoDescriptor(const MPEG2VideoDescriptor& rhs); @@ -754,7 +754,7 @@ namespace ASDCP UUID ResourceID; UTF16String UCSEncoding; UTF16String NamespaceURI; - optional_property<UTF16String> RFC5646LanguageTagList; + optional_property<UTF16String > RFC5646LanguageTagList; TimedTextDescriptor(const Dictionary*& d); TimedTextDescriptor(const TimedTextDescriptor& rhs); @@ -872,9 +872,9 @@ namespace ASDCP UL MCALabelDictionaryID; UUID MCALinkID; UTF16String MCATagSymbol; - optional_property<UTF16String> MCATagName; - optional_property<ui32_t> MCAChannelID; - optional_property<ISO8String> RFC5646SpokenLanguage; + optional_property<UTF16String > MCATagName; + optional_property<ui32_t > MCAChannelID; + optional_property<ISO8String > RFC5646SpokenLanguage; MCALabelSubDescriptor(const Dictionary*& d); MCALabelSubDescriptor(const MCALabelSubDescriptor& rhs); @@ -897,7 +897,7 @@ namespace ASDCP public: const Dictionary*& m_Dict; - UUID SoundfieldGroupLinkID; + optional_property<UUID > SoundfieldGroupLinkID; AudioChannelLabelSubDescriptor(const Dictionary*& d); AudioChannelLabelSubDescriptor(const AudioChannelLabelSubDescriptor& rhs); @@ -920,7 +920,7 @@ namespace ASDCP public: const Dictionary*& m_Dict; - Array<UUID> GroupOfSoundfieldGroupsLinkID; + optional_property<Array<UUID> > GroupOfSoundfieldGroupsLinkID; SoundfieldGroupLabelSubDescriptor(const Dictionary*& d); SoundfieldGroupLabelSubDescriptor(const SoundfieldGroupLabelSubDescriptor& rhs); diff --git a/src/TimedText_Parser.cpp b/src/TimedText_Parser.cpp index 7ecd093..b6b2cc7 100644 --- a/src/TimedText_Parser.cpp +++ b/src/TimedText_Parser.cpp @@ -166,21 +166,6 @@ get_UUID_from_child_element(const char* name, XMLElement* Parent, UUID& outID) } // -static ASDCP::Rational -decode_rational(const char* str_rat) -{ - assert(str_rat); - ui32_t Num = atoi(str_rat); - ui32_t Den = 0; - - const char* den_str = strrchr(str_rat, ' '); - if ( den_str != 0 ) - Den = atoi(den_str+1); - - return ASDCP::Rational(Num, Den); -} - -// Result_t ASDCP::TimedText::DCSubtitleParser::h__SubtitleParser::OpenRead(const std::string& filename) { @@ -225,7 +210,7 @@ ASDCP::TimedText::DCSubtitleParser::h__SubtitleParser::OpenRead() if ( ns == 0 ) { - DefaultLogSink(). Warn("Document has no namespace name, assuming %s\n", c_dcst_namespace_name); + DefaultLogSink(). Warn("Document has no namespace name, assuming \"%s\".\n", c_dcst_namespace_name); m_TDesc.NamespaceName = c_dcst_namespace_name; } else @@ -236,7 +221,7 @@ ASDCP::TimedText::DCSubtitleParser::h__SubtitleParser::OpenRead() UUID DocID; if ( ! get_UUID_from_child_element("Id", &m_Root, DocID) ) { - DefaultLogSink(). Error("Id element missing from input document\n"); + DefaultLogSink(). Error("Id element missing from input document.\n"); return RESULT_FORMAT; } @@ -245,11 +230,15 @@ ASDCP::TimedText::DCSubtitleParser::h__SubtitleParser::OpenRead() if ( EditRate == 0 ) { - DefaultLogSink(). Error("EditRate element missing from input document\n"); + DefaultLogSink().Error("EditRate element missing from input document.\n"); return RESULT_FORMAT; } - m_TDesc.EditRate = decode_rational(EditRate->GetBody().c_str()); + if ( ! DecodeRational(EditRate->GetBody().c_str(), m_TDesc.EditRate) ) + { + DefaultLogSink().Error("Error decoding edit rate value: \"%s\"\n", EditRate->GetBody().c_str()); + return RESULT_FORMAT; + } if ( m_TDesc.EditRate != EditRate_23_98 && m_TDesc.EditRate != EditRate_24 diff --git a/src/as-02-wrap.cpp b/src/as-02-wrap.cpp index 09abd98..1da0509 100755 --- a/src/as-02-wrap.cpp +++ b/src/as-02-wrap.cpp @@ -167,20 +167,6 @@ Options:\n\ o All option arguments must be separated from the option by whitespace.\n\n"); } -// -static ASDCP::Rational -decode_rational(const char* str_rat) -{ - assert(str_rat); - ui32_t Num = atoi(str_rat); - ui32_t Den = 1; - - const char* den_str = strrchr(str_rat, '/'); - if ( den_str != 0 ) - Den = atoi(den_str+1); - - return ASDCP::Rational(Num, Den); -} // // @@ -263,7 +249,11 @@ public: { case 'A': TEST_EXTRA_ARG(i, 'A'); - edit_rate = decode_rational(argv[i]); + if ( ! DecodeRational(argv[i], aspect_ratio) ) + { + fprintf(stderr, "Error decoding aspect ratio value: %s\n", argv[i]); + return; + } break; case 'a': @@ -379,7 +369,12 @@ public: case 'r': TEST_EXTRA_ARG(i, 'r'); - edit_rate = decode_rational(argv[i]); + if ( ! DecodeRational(argv[i], edit_rate) ) + { + fprintf(stderr, "Error decoding edit rate value: %s\n", argv[i]); + return; + } + break; case 'R': diff --git a/src/asdcp-wrap.cpp b/src/asdcp-wrap.cpp index 97da552..7d730d4 100755 --- a/src/asdcp-wrap.cpp +++ b/src/asdcp-wrap.cpp @@ -1040,7 +1040,11 @@ write_PCM_file(CommandOptions& Options) return RESULT_FAIL; } - if ( Options.use_interop_sound_wtf ) + if ( Options.channel_assignment.HasValue() ) + { + essence_descriptor->ChannelAssignment = Options.channel_assignment; + } + else if ( Options.use_interop_sound_wtf ) { essence_descriptor->ChannelAssignment = g_dict->ul(MDD_DCAudioChannelCfg_4_WTF); } diff --git a/src/blackwave.cpp b/src/blackwave.cpp index 501f96a..1a89a0e 100644 --- a/src/blackwave.cpp +++ b/src/blackwave.cpp @@ -115,7 +115,7 @@ public: case 'd': TEST_EXTRA_ARG(i, 'd'); - duration = atoi(argv[i]); // TODO: test for negative value, should use strtol() + duration = Kumu::xabs(strtol(argv[i], 0, 10)); break; case '9': diff --git a/src/h__02_Reader.cpp b/src/h__02_Reader.cpp index cf2b00f..a81d1ae 100644 --- a/src/h__02_Reader.cpp +++ b/src/h__02_Reader.cpp @@ -281,13 +281,15 @@ AS_02::MXF::AS02IndexReader::InitFromBuffer(const byte_t* p, ui32_t l, const ui6 } else { - DefaultLogSink().Error("Error initializing packet\n"); + DefaultLogSink().Error("Error initializing index segment packet.\n"); delete object; } } if ( KM_FAILURE(result) ) - DefaultLogSink().Error("Failed to initialize AS02IndexReader\n"); + { + DefaultLogSink().Error("Failed to initialize AS02IndexReader.\n"); + } return result; } diff --git a/src/kmfilegen.cpp b/src/kmfilegen.cpp index 9ba816e..2ce0332 100755 --- a/src/kmfilegen.cpp +++ b/src/kmfilegen.cpp @@ -152,7 +152,7 @@ public: case 'c': mode = MMT_CREATE; TEST_EXTRA_ARG(i, 'c'); - chunk_count = atoi(argv[i]); + chunk_count = Kumu::xabs(strtol(argv[i], 0, 10)); break; case 'V': version_flag = true; break; diff --git a/src/phdr-wrap.cpp b/src/phdr-wrap.cpp index 9cdc346..32f9b23 100755 --- a/src/phdr-wrap.cpp +++ b/src/phdr-wrap.cpp @@ -152,21 +152,6 @@ Options:\n\ } // -static ASDCP::Rational -decode_rational(const char* str_rat) -{ - assert(str_rat); - ui32_t Num = atoi(str_rat); - ui32_t Den = 0; - - const char* den_str = strrchr(str_rat, '/'); - if ( den_str != 0 ) - Den = atoi(den_str+1); - - return ASDCP::Rational(Num, Den); -} - -// // class CommandOptions { @@ -246,7 +231,11 @@ public: { case 'A': TEST_EXTRA_ARG(i, 'A'); - edit_rate = decode_rational(argv[i]); + if ( ! DecodeRational(argv[i], aspect_ratio) ) + { + fprintf(stderr, "Error decoding aspect ratio value: %s\n", argv[i]); + return; + } break; case 'a': @@ -354,7 +343,12 @@ public: case 'r': TEST_EXTRA_ARG(i, 'r'); - edit_rate = decode_rational(argv[i]); + if ( ! DecodeRational(argv[i], edit_rate) ) + { + fprintf(stderr, "Error decoding edit rate value: %s\n", argv[i]); + return; + } + break; case 'R': |
