2K.4K switching
[asdcplib.git] / src / h__Reader.cpp
index 268f3086624f74e038484cd68bfdaea2cb2bccef..2179ca68459675a5ef6bc1ce233c9e3e0fb49ce8 100755 (executable)
@@ -108,19 +108,23 @@ ASDCP::h__Reader::OpenMXFRead(const char* filename)
   if ( ASDCP_SUCCESS(result) )
     result = m_HeaderPart.InitFromFile(m_File);
 
-  // if this is a three partition file, go to the body
-  // partition and read off the partition pack
-  if ( m_HeaderPart.m_RIP.PairArray.size() == 3 )
+  if ( ASDCP_SUCCESS(result) )
     {
-      Array<RIP::Pair>::iterator r_i = m_HeaderPart.m_RIP.PairArray.begin();
-      r_i++;
-      m_File.Seek((*r_i).ByteOffset);
+      // if this is a three partition file, go to the body
+      // partition and read the partition pack
+      if ( m_HeaderPart.m_RIP.PairArray.size() == 3 )
+       {
+         Array<RIP::Pair>::iterator r_i = m_HeaderPart.m_RIP.PairArray.begin();
+         r_i++;
+         m_File.Seek((*r_i).ByteOffset);
+
+         result = m_BodyPart.InitFromFile(m_File);
+       }
 
-      result = m_BodyPart.InitFromFile(m_File);
+      m_EssenceStart = m_File.Tell();
     }
 
-  m_EssenceStart = m_File.Tell();
-  return RESULT_OK;
+  return result;
 }
 
 
@@ -186,7 +190,7 @@ ASDCP::h__Reader::ReadEKLVPacket(ui32_t FrameNum, ASDCP::FrameBuffer& FrameBuf,
 
   if ( ASDCP_FAILURE(m_FooterPart.Lookup(FrameNum, TmpEntry)) )
     {
-      DefaultLogSink().Error("Frame value out of range: %lu\n", FrameNum);
+      DefaultLogSink().Error("Frame value out of range: %u\n", FrameNum);
       return RESULT_RANGE;
     }
 
@@ -285,7 +289,7 @@ ASDCP::h__Reader::ReadEKLVPacket(ui32_t FrameNum, ASDCP::FrameBuffer& FrameBuf,
          
       if ( FrameBuf.Capacity() < SourceLength )
        {
-         DefaultLogSink().Error("FrameBuf.Capacity: %lu SourceLength: %lu\n", FrameBuf.Capacity(), SourceLength);
+         DefaultLogSink().Error("FrameBuf.Capacity: %u SourceLength: %u\n", FrameBuf.Capacity(), SourceLength);
          return RESULT_SMALLBUF;
        }
 
@@ -294,7 +298,7 @@ ASDCP::h__Reader::ReadEKLVPacket(ui32_t FrameNum, ASDCP::FrameBuffer& FrameBuf,
       // read ESV length
       if ( ! Kumu::read_test_BER(&ess_p, esv_length) )
        {
-         DefaultLogSink().Error("read_test_BER did not return %lu\n", esv_length);
+         DefaultLogSink().Error("read_test_BER did not return %u\n", esv_length);
          return RESULT_FORMAT;
        }
 
@@ -329,7 +333,12 @@ ASDCP::h__Reader::ReadEKLVPacket(ui32_t FrameNum, ASDCP::FrameBuffer& FrameBuf,
       else // return ciphertext to caller
        {
          if ( FrameBuf.Capacity() < tmp_len )
-           return RESULT_SMALLBUF;
+           {
+             char intbuf[IntBufferLen];
+             DefaultLogSink().Error("FrameBuf.Capacity: %u FrameLength: %s\n",
+                                    FrameBuf.Capacity(), ui64sz(PacketLength, intbuf));
+             return RESULT_SMALLBUF;
+           }
 
          memcpy(FrameBuf.Data(), ess_p, tmp_len);
          FrameBuf.Size(tmp_len);
@@ -342,7 +351,7 @@ ASDCP::h__Reader::ReadEKLVPacket(ui32_t FrameNum, ASDCP::FrameBuffer& FrameBuf,
        if ( FrameBuf.Capacity() < PacketLength )
        {
          char intbuf[IntBufferLen];
-         DefaultLogSink().Error("FrameBuf.Capacity: %lu FrameLength: %s\n",
+         DefaultLogSink().Error("FrameBuf.Capacity: %u FrameLength: %s\n",
                                 FrameBuf.Capacity(), ui64sz(PacketLength, intbuf));
          return RESULT_SMALLBUF;
        }