buggy less
authorjhurst <jhurst@cinecert.com>
Wed, 9 Jun 2010 21:27:32 +0000 (21:27 +0000)
committerjhurst <>
Wed, 9 Jun 2010 21:27:32 +0000 (21:27 +0000)
README
configure.ac
src/asdcp-test.cpp
src/h__Reader.cpp
src/h__Writer.cpp

diff --git a/README b/README
index 3d19e1fce6d345473486a09524363a1c3c139536..610ed20ccec3593788d5bf386478b3d6da46532e 100755 (executable)
--- a/README
+++ b/README
@@ -112,6 +112,14 @@ utilities all respond to -h.
 
 Change History
 
+2010.06.09 -  bug fixes, v1.6.36
+ o Added support for new Edit Rates to asdcp-test.cpp.
+ o Expanded timed-text file reader in asdcp-test.cpp.
+ o Fixed large BER value encoding (plaintext) and decoding
+   (plaintext and ciphertext). This feature was introduced in
+   v1.5.31).
+
+
 2010.05.13 -  bug fixes, enhancements, v1.6.34
  o ST 429-5 files have corrected ULs for DCTimedTextDescriptor and
    GenericStream DataElement. Files made with previous versions of
index fa88e15564794a5c003f935af56bcd81f28e05b6..e9a42aad7fe0cf87595cae6e2f9b60dbb16e8857 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.6.35], [asdcplib@cinecert.com])
+AC_INIT([asdcplib], [1.6.36], [asdcplib@cinecert.com])
 
 AC_CONFIG_AUX_DIR([build-aux])
 AC_CONFIG_SRCDIR([src/KM_error.h])
index 2af20f249e710133709acd495091938df8bc0ddb..53d3bf082ceb5eea152e0a6cd547a93652354447 100755 (executable)
@@ -286,7 +286,11 @@ public:
   Rational PictureRate()
   {
     if ( picture_rate == 23 ) return EditRate_23_98;
+    if ( picture_rate == 25 ) return EditRate_25;
+    if ( picture_rate == 30 ) return EditRate_30;
     if ( picture_rate == 48 ) return EditRate_48;
+    if ( picture_rate == 50 ) return EditRate_50;
+    if ( picture_rate == 60 ) return EditRate_60;
     return EditRate_24;
   }
 
@@ -294,7 +298,11 @@ public:
   const char* szPictureRate()
   {
     if ( picture_rate == 23 ) return "23.976";
+    if ( picture_rate == 25 ) return "25";
+    if ( picture_rate == 30 ) return "30";
     if ( picture_rate == 48 ) return "48";
+    if ( picture_rate == 50 ) return "50";
+    if ( picture_rate == 60 ) return "60";
     return "24";
   }
 
@@ -1448,7 +1456,7 @@ write_timed_text_file(CommandOptions& Options)
   if ( ASDCP_SUCCESS(result) )
     {
       Parser.FillTimedTextDescriptor(TDesc);
-      FrameBuffer.Capacity(2*Kumu::Megabyte);
+      FrameBuffer.Capacity(Options.fb_size);
 
       if ( Options.verbose_flag )
        {
@@ -1562,7 +1570,7 @@ read_timed_text_file(CommandOptions& Options)
   if ( ASDCP_SUCCESS(result) )
     {
       Reader.FillTimedTextDescriptor(TDesc);
-      FrameBuffer.Capacity(2*Kumu::Megabyte);
+      FrameBuffer.Capacity(Options.fb_size);
 
       if ( Options.verbose_flag )
        TimedText::DescriptorDump(TDesc);
@@ -1594,23 +1602,38 @@ read_timed_text_file(CommandOptions& Options)
     return result;
 
   std::string XMLDoc;
+  std::string out_path = Kumu::PathDirname(Options.file_root);
+  ui32_t write_count;
+  char buf[64];
   TimedText::ResourceList_t::const_iterator ri;
 
   result = Reader.ReadTimedTextResource(XMLDoc, Context, HMAC);
 
-  // do something with the XML here
-  fprintf(stderr, "XMLDoc size: %lu\n", XMLDoc.size());
+  if ( ASDCP_SUCCESS(result) )
+    {
+      Kumu::FileWriter Writer;
+      result = Writer.OpenWrite(Options.file_root);
+
+      if ( ASDCP_SUCCESS(result) )
+       result = Writer.Write(reinterpret_cast<const byte_t*>(XMLDoc.c_str()), XMLDoc.size(), &write_count);
+    }
 
   for ( ri = TDesc.ResourceList.begin() ; ri != TDesc.ResourceList.end() && ASDCP_SUCCESS(result); ri++ )
     {
-      result = Reader.ReadAncillaryResource((*ri).ResourceID, FrameBuffer, Context, HMAC);
+      result = Reader.ReadAncillaryResource(ri->ResourceID, FrameBuffer, Context, HMAC);
 
       if ( ASDCP_SUCCESS(result) )
        {
-         //      if ( Options.verbose_flag )
-           FrameBuffer.Dump(stderr, Options.fb_dump_size);
+         Kumu::FileWriter Writer;
+         result = Writer.OpenWrite(Kumu::PathJoin(out_path, Kumu::UUID(ri->ResourceID).EncodeHex(buf, 64)).c_str());
 
-         // do something with the resource data here
+         if ( ASDCP_SUCCESS(result) )
+           {
+             if ( Options.verbose_flag )
+               FrameBuffer.Dump(stderr, Options.fb_dump_size);
+
+             result = Writer.Write(FrameBuffer.RoData(), FrameBuffer.Size(), &write_count);
+           }
        }
     }
 
index a463ae1096d15b6cb1ab7dc1f5c1f2f12492c1bb..b0f88702ee23f780077cf15b288e682aebe0f694 100755 (executable)
@@ -1,5 +1,5 @@
 /*
-Copyright (c) 2004-2009, John Hurst
+Copyright (c) 2004-2010, John Hurst
 All rights reserved.
 
 Redistribution and use in source and binary forms, with or without
@@ -159,16 +159,51 @@ ASDCP::KLReader::ReadKLFromFile(Kumu::FileReader& Reader)
   ui32_t header_length = SMPTE_UL_LENGTH + MXF_BER_LENGTH;
   Result_t result = Reader.Read(m_KeyBuf, header_length, &read_count);
 
-  if ( ASDCP_SUCCESS(result) )
+  if ( ASDCP_FAILURE(result) )
+    return result;
+
+  if ( read_count != header_length )
+    return RESULT_READFAIL;
+
+  const byte_t* ber_start = m_KeyBuf + SMPTE_UL_LENGTH;
+
+  if ( ( *ber_start & 0x80 ) == 0 )
     {
-      if ( read_count != header_length )
-       result = RESULT_READFAIL;
-  
-      else
-       result = InitFromBuffer(m_KeyBuf, header_length);
+      DefaultLogSink().Error("BER encoding error.\n");
+      return RESULT_FORMAT;
     }
 
-  return result;
+  ui8_t ber_size = ( *ber_start & 0x0f ) + 1;
+
+  if ( ber_size > 9 )
+    {
+      DefaultLogSink().Error("BER size encoding error.\n");
+      return RESULT_FORMAT;
+    }
+
+  if ( ber_size < MXF_BER_LENGTH )
+    {
+      DefaultLogSink().Error("BER size %d shorter than AS-DCP minimum %d.\n",
+                            ber_size, MXF_BER_LENGTH);
+      return RESULT_FORMAT;
+    }
+
+  if ( ber_size > MXF_BER_LENGTH )
+    {
+      ui32_t diff = ber_size - MXF_BER_LENGTH;
+      assert((SMPTE_UL_LENGTH + MXF_BER_LENGTH + diff) <= (SMPTE_UL_LENGTH * 2));
+      result = Reader.Read(m_KeyBuf + SMPTE_UL_LENGTH + MXF_BER_LENGTH, diff, &read_count);
+
+      if ( ASDCP_FAILURE(result) )
+       return result;
+
+      if ( read_count != diff )
+       return RESULT_READFAIL;
+
+      header_length += diff;
+    }
+
+  return InitFromBuffer(m_KeyBuf, header_length);
 }
 
 // standard method of reading a plaintext or encrypted frame
index 6152a3546b28c6196ace87f2972d816b11ed478b..2882e33b2525c6931b935247496b7aac886a52da 100755 (executable)
@@ -605,9 +605,21 @@ ASDCP::h__Writer::WriteEKLVPacket(const ASDCP::FrameBuffer& FrameBuf, const byte
     }
   else
     {
+      ui32_t BER_length = MXF_BER_LENGTH;
+
+      if ( FrameBuf.Size() > 0x00ffffff ) // Need BER integer longer than MXF_BER_LENGTH bytes
+       {
+         BER_length = Kumu::get_BER_length_for_value(FrameBuf.Size());
+
+         if ( BER_length == 0 )
+           result = RESULT_KLV_CODING;
+       }
+
       Overhead.WriteRaw((byte_t*)EssenceUL, SMPTE_UL_LENGTH);
-      Overhead.WriteBER(FrameBuf.Size(), MXF_BER_LENGTH);
-      result = m_File.Writev(Overhead.Data(), Overhead.Length());
+      Overhead.WriteBER(FrameBuf.Size(), BER_length);
+
+      if ( ASDCP_SUCCESS(result) )
+       result = m_File.Writev(Overhead.Data(), Overhead.Length());
  
       if ( ASDCP_SUCCESS(result) )
        result = m_File.Writev((byte_t*)FrameBuf.RoData(), FrameBuf.Size());