X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=src%2FMXFTypes.cpp;h=72338bbfda5f3290f8de2b9990345e4c52e92ba9;hb=HEAD;hp=9e481e2e35f5c6e63aad8038af26cefc54775cc7;hpb=2b101472bf1f76db63ae1c97cf5393fe7195bcb1;p=asdcplib.git diff --git a/src/MXFTypes.cpp b/src/MXFTypes.cpp index 9e481e2..72338bb 100755 --- a/src/MXFTypes.cpp +++ b/src/MXFTypes.cpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2005-2016, John Hurst +Copyright (c) 2005-2019, John Hurst All rights reserved. Redistribution and use in source and binary forms, with or without @@ -65,72 +65,6 @@ ASDCP::UL::operator==(const UL& rhs) const return false; } - -// -bool -ASDCP::UL::operator<(const UL& rhs) const -{ - if ( m_Value[0] < rhs.m_Value[0] ) return true; - if ( m_Value[0] == rhs.m_Value[0] ) - { - if ( m_Value[1] < rhs.m_Value[1] ) return true; - if ( m_Value[1] == rhs.m_Value[1] ) - { - if ( m_Value[2] < rhs.m_Value[2] ) return true; - if ( m_Value[2] == rhs.m_Value[2] ) - { - if ( m_Value[3] < rhs.m_Value[3] ) return true; - if ( m_Value[3] == rhs.m_Value[3] ) - { - if ( m_Value[4] < rhs.m_Value[4] ) return true; - if ( m_Value[4] == rhs.m_Value[4] ) - { - if ( m_Value[5] < rhs.m_Value[5] ) return true; - if ( m_Value[5] == rhs.m_Value[5] ) - { - if ( m_Value[6] < rhs.m_Value[6] ) return true; - if ( m_Value[6] == rhs.m_Value[6] ) - { - if ( m_Value[8] < rhs.m_Value[8] ) return true; - if ( m_Value[8] == rhs.m_Value[8] ) - { - if ( m_Value[9] < rhs.m_Value[9] ) return true; - if ( m_Value[9] == rhs.m_Value[9] ) - { - if ( m_Value[10] < rhs.m_Value[10] ) return true; - if ( m_Value[10] == rhs.m_Value[10] ) - { - if ( m_Value[11] < rhs.m_Value[11] ) return true; - if ( m_Value[11] == rhs.m_Value[11] ) - { - if ( m_Value[12] < rhs.m_Value[12] ) return true; - if ( m_Value[12] == rhs.m_Value[12] ) - { - if ( m_Value[13] < rhs.m_Value[13] ) return true; - if ( m_Value[13] == rhs.m_Value[13] ) - { - if ( m_Value[14] < rhs.m_Value[14] ) return true; - if ( m_Value[14] == rhs.m_Value[14] ) - { - if ( m_Value[15] < rhs.m_Value[15] ) return true; - } - } - } - } - } - } - } - } - } - } - } - } - } - } - - return false; -} - // bool ASDCP::UL::MatchIgnoreStream(const UL& rhs) const @@ -159,7 +93,7 @@ ASDCP::UL::MatchIgnoreStream(const UL& rhs) const // bool -ASDCP::UL::ExactMatch(const UL& rhs) const +ASDCP::UL::MatchExact(const UL& rhs) const { if ( m_Value[0] == rhs.m_Value[0] && m_Value[1] == rhs.m_Value[1] && @@ -345,11 +279,14 @@ ASDCP::MXF::UTF16String::Unarchive(Kumu::MemIOReader* Reader) erase(); const ui16_t* p = (ui16_t*)Reader->CurrentData(); ui32_t length = Reader->Remainder() / 2; - char mb_buf[MB_LEN_MAX+1]; + char mb_buf[MB_LEN_MAX]; + + mbstate_t ps; + memset(&ps, 0, sizeof(mbstate_t)); for ( ui32_t i = 0; i < length; i++ ) { - int count = wctomb(mb_buf, KM_i16_BE(p[i])); + int count = wcrtomb(mb_buf, KM_i16_BE(p[i]), &ps); if ( count == -1 ) { @@ -382,9 +319,12 @@ ASDCP::MXF::UTF16String::Archive(Kumu::MemIOWriter* Writer) const ui32_t length = size(); ui32_t i = 0; + mbstate_t ps; + memset(&ps, 0, sizeof(mbstate_t)); + while ( i < length ) { - int count = mbtowc(&wcp, mbp+i, remainder); + int count = mbrtowc(&wcp, mbp+i, remainder, &ps); if ( count == -1 ) { @@ -627,7 +567,7 @@ ASDCP::MXF::TLVWriter::WriteTag(const MDDEntry& Entry) { if ( m_Lookup == 0 ) { - DefaultLogSink().Error("No Primer object available\n"); + DefaultLogSink().Error("No Primer object available.\n"); return RESULT_FAIL; } @@ -834,6 +774,63 @@ ASDCP::MXF::Raw::EncodeString(char* str_buf, ui32_t buf_len) const return str_buf; } + +// +bool +ASDCP::MXF::J2KExtendedCapabilitiesType::Archive(Kumu::MemIOWriter* Writer) const { + if ( ! Writer->WriteUi32BE(Pcap) ) + { + return false; + } + + if ( ! Ccap.Archive(Writer) ) + { + return false; + } + + return true; +} + +// +bool +ASDCP::MXF::J2KExtendedCapabilitiesType::Unarchive(Kumu::MemIOReader* Reader) { + if ( ! Reader->ReadUi32BE(&Pcap) ) + { + return false; + } + + if ( ! Ccap.Unarchive(Reader) ) + { + return false; + } + + return true; +} + +// +const char* +ASDCP::MXF::J2KExtendedCapabilitiesType::EncodeString(char* str_buf, ui32_t buf_len) const +{ + const int str_len = ( sizeof(ui16_t) + 1 ) * JP2K::MaxCapabilities; + + if ( Pcap != 0 && buf_len > str_len ) + { + for ( int i = 0; i < Ccap.size(); ++i ) + { + snprintf(str_buf+(i*3), 4, "%02hx.", Ccap[i].value); + } + + str_buf[str_len-1] = 0; + } + else + { + str_buf[0] = 0; + } + + return str_buf; +} + + // // end MXFTypes.cpp //