Fixed Atmos DataEssenceCoding UL
authorjhurst <jhurst@cinecert.com>
Sat, 13 Oct 2018 21:49:53 +0000 (21:49 +0000)
committerjhurst <>
Sat, 13 Oct 2018 21:49:53 +0000 (21:49 +0000)
src/AS_DCP_ATMOS.cpp
src/Dict.cpp

index a016f2789afdefd1aebbb0733ba773c1b4711f6a..2fc7d56d8d0927ff542969ef1737beea909fea10 100644 (file)
@@ -248,7 +248,7 @@ ASDCP::ATMOS::MXFReader::h__Reader::ReadFrame(ui32_t FrameNum, FrameBuffer& Fram
 
 ASDCP::ATMOS::MXFReader::MXFReader()
 {
-  m_Reader = new h__Reader(DefaultSMPTEDict());
+  m_Reader = new h__Reader(AtmosSMPTEDict());
 }
 
 
@@ -427,8 +427,7 @@ ASDCP::ATMOS::MXFWriter::h__Writer::DCData_DDesc_to_MD(ASDCP::DCData::DCDataDesc
 
   DDescObj->SampleRate = DDesc.EditRate;
   DDescObj->ContainerDuration = DDesc.ContainerDuration;
-  DDescObj->DataEssenceCoding.Set(DDesc.DataEssenceCoding);
-
+  DDescObj->DataEssenceCoding.Set(DDesc.DataEssenceCoding);  
   return RESULT_OK;
 }
 
@@ -554,7 +553,7 @@ ASDCP::ATMOS::MXFWriter::h__Writer::WriteFrame(const FrameBuffer& FrameBuf,
   ui64_t StreamOffset = m_StreamOffset;
 
   if ( ASDCP_SUCCESS(result) )
-    result = WriteEKLVPacket(FrameBuf, m_EssenceUL, Ctx, HMAC);
+    result = WriteEKLVPacket(FrameBuf, m_EssenceUL, MXF_BER_LENGTH, Ctx, HMAC);
 
   if ( ASDCP_SUCCESS(result) )
   {
@@ -648,7 +647,7 @@ ASDCP::ATMOS::MXFWriter::OpenWrite(const std::string& filename, const WriterInfo
     return RESULT_FORMAT;
   }
 
-  m_Writer = new h__Writer(DefaultSMPTEDict());
+  m_Writer = new h__Writer(AtmosSMPTEDict());
   m_Writer->m_Info = Info;
 
   Result_t result = m_Writer->OpenWrite(filename, HeaderSize, ADesc);
index fbf76b021bee40ad81629ebea5d319b5794a192c..752b81a9fee32f297d422d98bb0b230e0309a46a 100755 (executable)
@@ -1,5 +1,5 @@
 /*
-Copyright (c) 2006-2016, John Hurst
+Copyright (c) 2006-2018, John Hurst
 All rights reserved.
 
 Redistribution and use in source and binary forms, with or without
@@ -136,6 +136,38 @@ ASDCP::SMPTE_390_OPAtom_Entry() {
   return s_MDD_Table[MDD_OPAtom];
 }
 
+//
+//
+static ASDCP::Dictionary s_AtmosSMPTEDict;
+static Kumu::Mutex s_AtmosSMPTEDictLock;
+static bool s_AtmosSMPTEDictInit = false;
+
+//
+const ASDCP::Dictionary&
+ASDCP::AtmosSMPTEDict()
+{
+  if ( ! s_AtmosSMPTEDictInit )
+    {
+      Kumu::AutoMutex AL(s_AtmosSMPTEDictLock);
+
+      if ( ! s_AtmosSMPTEDictInit )
+       {
+         s_AtmosSMPTEDict.Init();
+
+         s_AtmosSMPTEDict.DeleteEntry(MDD_MXFInterop_OPAtom);
+         s_AtmosSMPTEDict.DeleteEntry(MDD_MXFInterop_CryptEssence);
+         s_AtmosSMPTEDict.DeleteEntry(MDD_MXFInterop_GenericDescriptor_SubDescriptors);
+
+         // legacy Atmos files have the wrong version byte
+         assert(s_AtmosSMPTEDict.Type(MDD_GenericDataEssenceDescriptor_DataEssenceCoding).ul[7] == 0x03);
+         s_AtmosSMPTEDict.MutableType(MDD_GenericDataEssenceDescriptor_DataEssenceCoding).ul[7] = 0x05;
+         
+         s_AtmosSMPTEDictInit = true;
+       }
+    }
+
+  return s_AtmosSMPTEDict;
+}
 
 //------------------------------------------------------------------------------------------
 //
@@ -252,6 +284,19 @@ ASDCP::Dictionary::Type(MDD_t type_id) const
   return m_MDD_Table[type_id];
 }
 
+//
+ASDCP::MDDEntry&
+ASDCP::Dictionary::MutableType(MDD_t type_id)
+{
+  assert(m_MDD_Table[0].name[0]);
+  std::map<ui32_t, ASDCP::UL>::iterator rii = m_md_rev_lookup.find(type_id);
+
+  if ( rii == m_md_rev_lookup.end() )
+    Kumu::DefaultLogSink().Warn("UL Dictionary: unknown UL type_id: %d\n", type_id);
+
+  return m_MDD_Table[type_id];
+}
+
 //
 const ASDCP::MDDEntry*
 ASDCP::Dictionary::FindULAnyVersion(const byte_t* ul_buf) const