diff options
| author | jhurst <jhurst@cinecert.com> | 2009-12-22 21:46:39 +0000 |
|---|---|---|
| committer | jhurst <> | 2009-12-22 21:46:39 +0000 |
| commit | ecfb614c4c7f16db4b9d76e650053ba4896b79cc (patch) | |
| tree | 1ba363a7b768b09a560911180bba23a0e4b9eea6 | |
| parent | c063fb19776c6f3f650698e47b27e219958d40fb (diff) | |
big KLV support
| -rwxr-xr-x | README | 19 | ||||
| -rw-r--r-- | configure.ac | 2 | ||||
| -rwxr-xr-x | src/KM_util.cpp | 23 | ||||
| -rwxr-xr-x | src/KM_util.h | 4 | ||||
| -rwxr-xr-x | src/h__Writer.cpp | 40 |
5 files changed, 63 insertions, 25 deletions
@@ -111,6 +111,12 @@ utilities all respond to -h. Change History +-- NEW STUFF FROM JH -- + o Added get_BER_length_for_value() subroutine. + o Modified ASDCP::h__Writer::WriteEKLVPacket() to allow larger BER + lengths for KLV packets larger than 16 MB. This was required to + support large font files in the SMPTE 429-5 implementation. + 2009.11.06 - bug fixes, enhancements, v1.5.29 o Fixed a bug that could cause HMAC values to be incorrectly stored in MXF files. Files created with versions of asdcplib @@ -119,12 +125,13 @@ Change History o Jpeg2000 codestream EditRate and SampleRate mismatches now warns instead of returning an error. o Improved error handling in Jpeg2000 sequence parsing routines. - o Added two methods to Kumu::Timestamp, AddSeconds(), to add (or subtract) - seconds to a time value, and GetSecondsSinceEpoch() to get the number of - seconds since the unix epoch. - o Added new option to asdcp-test, '-a', to specify a UUID when creating MXF files. - o Added support for specifying the intrinsic duration of MXF files containing - timed text. + o Added two methods to Kumu::Timestamp, AddSeconds(), to add (or + subtract) seconds to a time value, and GetSecondsSinceEpoch() + to get the number of seconds since the unix epoch. + o Added new option to asdcp-test, '-a', to specify a UUID when + creating MXF files. + o Added support for specifying the intrinsic duration of MXF files + containing timed text. o Added new option to wavesplit, '-i', to display WAV file metadata. diff --git a/configure.ac b/configure.ac index 92f37b4..21e94d5 100644 --- a/configure.ac +++ b/configure.ac @@ -37,7 +37,7 @@ AC_PREREQ([2.59]) # For example, if asdcplib version 1.0.0 were modified to accomodate changes # in file format, and if no changes were made to AS_DCP.h, the new version would be # 1.0.1. If changes were also required in AS_DCP.h, the new version would be 1.1.1. -AC_INIT([asdcplib], [1.5.30], [asdcplib@cinecert.com]) +AC_INIT([asdcplib], [1.5.31], [asdcplib@cinecert.com]) AC_CONFIG_AUX_DIR([build-aux]) AC_CONFIG_SRCDIR([src/KM_error.h]) diff --git a/src/KM_util.cpp b/src/KM_util.cpp index b155362..b5dfce6 100755 --- a/src/KM_util.cpp +++ b/src/KM_util.cpp @@ -539,9 +539,6 @@ Kumu::GenRandomValue(SymmetricKey& Key) //------------------------------------------------------------------------------------------ // read a ber value from the buffer and compare with test value. // Advances buffer to first character after BER value. - -// read a ber value from the buffer and compare with test value. -// Advances buffer to first character after BER value. // bool Kumu::read_test_BER(byte_t **buf, ui64_t test_value) @@ -605,6 +602,20 @@ static const ui64_t ber_masks[9] = 0 }; +// +ui32_t +Kumu::get_BER_length_for_value(ui64_t val) +{ + for ( ui32_t i = 0; i < 9; i++ ) + { + if ( ( val & ber_masks[i] ) == 0 ) + return i + 1; + } + + ui64Printer tmp_i(val); + DefaultLogSink().Error("BER integer encoding not supported for large value %s\n", tmp_i.c_str()); + return 0; +} // bool @@ -626,14 +637,14 @@ Kumu::write_BER(byte_t* buf, ui64_t val, ui32_t ber_len) { // sanity check BER length if ( ber_len > 9 ) { - DefaultLogSink().Error("BER size %u exceeds maximum size of 9\n", ber_len); + DefaultLogSink().Error("BER integer length %u exceeds maximum size of 9\n", ber_len); return false; } - if ( val & ber_masks[ber_len - 1] ) + if ( ( val & ber_masks[ber_len - 1] ) != 0 ) { ui64Printer tmp_i(val); - DefaultLogSink().Error("BER size %u too small for value %s\n", tmp_i.c_str()); + DefaultLogSink().Error("BER integer length %u too small for value %s\n", ber_len, tmp_i.c_str()); return false; } } diff --git a/src/KM_util.h b/src/KM_util.h index 0f2af46..7ca30e0 100755 --- a/src/KM_util.h +++ b/src/KM_util.h @@ -154,6 +154,10 @@ namespace Kumu return (*buf & 0x0f) + 1; } + // Return the BER length required to encode value. A return value of zero + // indicates a value too large for this library. + ui32_t get_BER_length_for_value(ui64_t valuse); + // read a BER value bool read_BER(const byte_t* buf, ui64_t* val); diff --git a/src/h__Writer.cpp b/src/h__Writer.cpp index 69873b6..64d6faa 100755 --- a/src/h__Writer.cpp +++ b/src/h__Writer.cpp @@ -527,24 +527,40 @@ ASDCP::h__Writer::WriteEKLVPacket(const ASDCP::FrameBuffer& FrameBuf, const byte // construct encrypted triplet header ui32_t ETLength = klv_cryptinfo_size + m_CtFrameBuf.Size(); + ui32_t BER_length = MXF_BER_LENGTH; if ( m_Info.UsesHMAC ) ETLength += klv_intpack_size; else ETLength += (MXF_BER_LENGTH * 3); // for empty intpack - Overhead.WriteBER(ETLength, MXF_BER_LENGTH); // write encrypted triplet length - Overhead.WriteBER(UUIDlen, MXF_BER_LENGTH); // write ContextID length - Overhead.WriteRaw(m_Info.ContextID, UUIDlen); // write ContextID - Overhead.WriteBER(sizeof(ui64_t), MXF_BER_LENGTH); // write PlaintextOffset length - Overhead.WriteUi64BE(FrameBuf.PlaintextOffset()); // write PlaintextOffset - Overhead.WriteBER(SMPTE_UL_LENGTH, MXF_BER_LENGTH); // write essence UL length - Overhead.WriteRaw((byte_t*)EssenceUL, SMPTE_UL_LENGTH); // write the essence UL - Overhead.WriteBER(sizeof(ui64_t), MXF_BER_LENGTH); // write SourceLength length - Overhead.WriteUi64BE(FrameBuf.Size()); // write SourceLength - Overhead.WriteBER(m_CtFrameBuf.Size(), MXF_BER_LENGTH); // write ESV length - - result = m_File.Writev(Overhead.Data(), Overhead.Length()); + if ( ETLength > 0x00ffffff ) // Need BER integer longer than MXF_BER_LENGTH bytes + { + BER_length = Kumu::get_BER_length_for_value(ETLength); + + if ( BER_length == 0 ) + result = RESULT_KLV_CODING; + } + + if ( ASDCP_SUCCESS(result) ) + { + if ( ! ( Overhead.WriteBER(ETLength, BER_length) // write encrypted triplet length + && Overhead.WriteBER(UUIDlen, MXF_BER_LENGTH) // write ContextID length + && Overhead.WriteRaw(m_Info.ContextID, UUIDlen) // write ContextID + && Overhead.WriteBER(sizeof(ui64_t), MXF_BER_LENGTH) // write PlaintextOffset length + && Overhead.WriteUi64BE(FrameBuf.PlaintextOffset()) // write PlaintextOffset + && Overhead.WriteBER(SMPTE_UL_LENGTH, MXF_BER_LENGTH) // write essence UL length + && Overhead.WriteRaw((byte_t*)EssenceUL, SMPTE_UL_LENGTH) // write the essence UL + && Overhead.WriteBER(sizeof(ui64_t), MXF_BER_LENGTH) // write SourceLength length + && Overhead.WriteUi64BE(FrameBuf.Size()) // write SourceLength + && Overhead.WriteBER(m_CtFrameBuf.Size(), BER_length) ) ) // write ESV length + { + result = RESULT_KLV_CODING; + } + } + + if ( ASDCP_SUCCESS(result) ) + result = m_File.Writev(Overhead.Data(), Overhead.Length()); } if ( ASDCP_SUCCESS(result) ) |
