big KLV support
authorjhurst <jhurst@cinecert.com>
Tue, 22 Dec 2009 21:46:39 +0000 (21:46 +0000)
committerjhurst <>
Tue, 22 Dec 2009 21:46:39 +0000 (21:46 +0000)
README
configure.ac
src/KM_util.cpp
src/KM_util.h
src/h__Writer.cpp

diff --git a/README b/README
index a7c6bfb2e162afcd29823e2f2b6a11739778104b..928e84f024c040e721e9e2b5c854a9c7d0e38d06 100755 (executable)
--- a/README
+++ b/README
@@ -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.
 
 
index 92f37b4017b000dc18e56df9c4a69ba02ed8e02e..21e94d5fef1d8533def4345dc432857149cfdc21 100644 (file)
@@ -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])
index b155362f61f4251752a73c9eb13a01632c7ae365..b5dfce624ae9ba32bbbf658399ce1e0d3e3fcb9d 100755 (executable)
@@ -537,9 +537,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.
 //
@@ -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;
         }
     }
index 0f2af46faada351878d2eee58c179cd9f34b667a..7ca30e0e7d4e7227efc3dbc038b4289ecab7513e 100755 (executable)
@@ -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);
 
index 69873b65fb59611eff9b62c702e4be0bc20b0044..64d6faabf9894f9a7da1912efe798c7fcb3f1211 100755 (executable)
@@ -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) )