removed extraneous assert(), added multi-/ test to path-test.cpp
authorjhurst <jhurst@cinecert.com>
Fri, 15 Aug 2008 22:47:07 +0000 (22:47 +0000)
committerjhurst <>
Fri, 15 Aug 2008 22:47:07 +0000 (22:47 +0000)
src/AS_DCP_JP2K.cpp
src/AS_DCP_MXF.cpp
src/AS_DCP_TimedText.cpp
src/Index.cpp
src/KM_fileio.cpp
src/KM_fileio.h
src/MXF.cpp
src/TimedText_Parser.cpp
src/Wav.cpp
src/Wav.h
src/path-test.cpp

index d6754f5872dc60d4e0715b4e722f605e4630d895..9a334a6ac6013c1c32bdc409a98ecd31c010742d 100755 (executable)
@@ -50,6 +50,7 @@ ASDCP::JP2K::operator << (std::ostream& strm, const PictureDescriptor& PDesc)
 {
   strm << "       AspectRatio: " << PDesc.AspectRatio.Numerator << "/" << PDesc.AspectRatio.Denominator << std::endl;
   strm << "          EditRate: " << PDesc.EditRate.Numerator << "/" << PDesc.EditRate.Denominator << std::endl;
+  strm << "        SampleRate: " << PDesc.SampleRate.Numerator << "/" << PDesc.SampleRate.Denominator << std::endl;
   strm << "       StoredWidth: " << (unsigned) PDesc.StoredWidth << std::endl;
   strm << "      StoredHeight: " << (unsigned) PDesc.StoredHeight << std::endl;
   strm << "             Rsize: " << (unsigned) PDesc.Rsize << std::endl;
@@ -118,6 +119,7 @@ ASDCP::JP2K::PictureDescriptorDump(const PictureDescriptor& PDesc, FILE* stream)
   fprintf(stream, "\
        AspectRatio: %d/%d\n\
           EditRate: %d/%d\n\
+        SampleRate: %d/%d\n\
        StoredWidth: %u\n\
       StoredHeight: %u\n\
              Rsize: %u\n\
@@ -132,6 +134,7 @@ ASDCP::JP2K::PictureDescriptorDump(const PictureDescriptor& PDesc, FILE* stream)
  ContainerDuration: %u\n",
          PDesc.AspectRatio.Numerator, PDesc.AspectRatio.Denominator,
          PDesc.EditRate.Numerator, PDesc.EditRate.Denominator,
+         PDesc.SampleRate.Numerator, PDesc.SampleRate.Denominator,
          PDesc.StoredWidth,
          PDesc.StoredHeight,
          PDesc.Rsize,
@@ -206,6 +209,7 @@ class lh__Reader : public ASDCP::h__Reader
   RGBAEssenceDescriptor*        m_EssenceDescriptor;
   JPEG2000PictureSubDescriptor* m_EssenceSubDescriptor;
   ASDCP::Rational               m_EditRate;
+  ASDCP::Rational               m_SampleRate;
   EssenceType_t                 m_Format;
 
   ASDCP_NO_COPY_CONSTRUCT(lh__Reader);
@@ -227,6 +231,7 @@ lh__Reader::MD_to_JP2K_PDesc(JP2K::PictureDescriptor& PDesc)
   MXF::RGBAEssenceDescriptor* PDescObj = (MXF::RGBAEssenceDescriptor*)m_EssenceDescriptor;
 
   PDesc.EditRate           = m_EditRate;
+  PDesc.SampleRate         = m_SampleRate;
   assert(PDescObj->ContainerDuration <= 0xFFFFFFFFL);
   PDesc.ContainerDuration  = (ui32_t) PDescObj->ContainerDuration;
   PDesc.StoredWidth        = PDescObj->StoredWidth;
@@ -299,17 +304,18 @@ lh__Reader::OpenRead(const char* filename, EssenceType_t type)
        }
 
       m_EditRate = ((Track*)ObjectList.front())->EditRate;
+      m_SampleRate = m_EssenceDescriptor->SampleRate;
 
       if ( type == ASDCP::ESS_JPEG_2000 )
        {
-         if ( m_EditRate != m_EssenceDescriptor->SampleRate )
+         if ( m_EditRate != m_SampleRate )
            {
              DefaultLogSink().Error("EditRate and SampleRate do not match (%.03f, %.03f).\n",
-                                    m_EditRate.Quotient(), m_EssenceDescriptor->SampleRate.Quotient());
+                                    m_EditRate.Quotient(), m_SampleRate.Quotient());
              
-             if ( m_EditRate == EditRate_24 && m_EssenceDescriptor->SampleRate == EditRate_48 )
+             if ( m_EditRate == EditRate_24 && m_SampleRate == EditRate_48 )
                {
-                 DefaultLogSink().Error("File may contain JPEG Interop stereoscopic images.\n");
+                 DefaultLogSink().Debug("File may contain JPEG Interop stereoscopic images.\n");
                  return RESULT_SFORMAT;
                }
 
@@ -318,7 +324,7 @@ lh__Reader::OpenRead(const char* filename, EssenceType_t type)
        }
       else if ( type == ASDCP::ESS_JPEG_2000_S )
        {
-         if ( ! ( m_EditRate == EditRate_24 && m_EssenceDescriptor->SampleRate == EditRate_48 ) )
+         if ( ! ( m_EditRate == EditRate_24 && m_SampleRate == EditRate_48 ) )
            {
              DefaultLogSink().Error("EditRate and SampleRate not correct for 24/48 stereoscopic essence.\n");
              return RESULT_FORMAT;
index 334d253754286e542a86e330d54ec799af6e4485..6b30da94d45f35100b1f8453c7eb808288ea8fec 100755 (executable)
@@ -228,16 +228,27 @@ ASDCP::RawEssenceType(const char* filename, EssenceType_t& type)
          while ( p[i] == 0 ) i++;
 
          if ( i > 1 && p[i] == 1 &&  (p[i+1] == ASDCP::MPEG2::SEQ_START || p[i+1] == ASDCP::MPEG2::PIC_START) )
-           type = ESS_MPEG2_VES;
-
+           {
+             type = ESS_MPEG2_VES;
+           }
          else if ( ASDCP_SUCCESS(WavHeader.ReadFromBuffer(p, read_count, &data_offset)) )
-           type = ESS_PCM_24b_48k;
-
+           {
+             switch ( WavHeader.samplespersec )
+               {
+               case 48000: type = ESS_PCM_24b_48k; break;
+               case 96000: type = ESS_PCM_24b_96k; break;
+               default:
+                 return RESULT_FORMAT;
+               }
+           }
          else if ( ASDCP_SUCCESS(AIFFHeader.ReadFromBuffer(p, read_count, &data_offset)) )
-           type = ESS_PCM_24b_48k;
-
+           {
+             type = ESS_PCM_24b_48k;
+           }
          else if ( Kumu::StringIsXML((const char*)p, FB.Size()) )
-           type = ESS_TIMED_TEXT;
+           {
+             type = ESS_TIMED_TEXT;
+           }
        }
     }
   else if ( Kumu::PathIsDirectory(filename) )
index 81ebf8f70a7ce060b2c40bfb9c33248845dcbab7..b9bda073950a1a6798b8300d0665a0d7a307debd 100644 (file)
@@ -92,7 +92,7 @@ ASDCP::TimedText::DescriptorDump(ASDCP::TimedText::TimedTextDescriptor const& TD
   fprintf(stream, "ContainerDuration: %u\n",    TDesc.ContainerDuration);
   fprintf(stream, "          AssetID: %s\n",    TmpID.EncodeHex(buf, 64));
   fprintf(stream, "    NamespaceName: %s\n",    TDesc.NamespaceName.c_str());
-  fprintf(stream, "    ResourceCount: %lu\n",   TDesc.ResourceList.size());
+  fprintf(stream, "    ResourceCount: %du\n",   TDesc.ResourceList.size());
 
   TimedText::ResourceList_t::const_iterator ri;
   for ( ri = TDesc.ResourceList.begin() ; ri != TDesc.ResourceList.end(); ri++ )
@@ -173,7 +173,9 @@ ASDCP::TimedText::MXFReader::h__Reader::MD_to_TimedText_TDesc(TimedText::TimedTe
          TimedTextResourceDescriptor TmpResource;
          memcpy(TmpResource.ResourceID, DescObject->AncillaryResourceID.Value(), UUIDlen);
 
-         if ( DescObject->MIMEMediaType.find("font/") != std::string::npos )
+         if ( DescObject->MIMEMediaType.find("application/x-font-opentype") != std::string::npos
+              || DescObject->MIMEMediaType.find("application/x-opentype") != std::string::npos
+              || DescObject->MIMEMediaType.find("font/opentype") != std::string::npos )
            TmpResource.Type = MT_OPENTYPE;
 
          else if ( DescObject->MIMEMediaType.find("image/png") != std::string::npos )
@@ -316,7 +318,7 @@ ASDCP::TimedText::MXFReader::h__Reader::ReadAncillaryResource(const byte_t* uuid
 
              // read the essence packet
              if( ASDCP_SUCCESS(result) )
-               result = ReadEKLVPacket(0, 1, FrameBuf, Dict::ul(MDD_TimedTextDescriptor), Ctx, HMAC);
+               result = ReadEKLVPacket(0, 1, FrameBuf, Dict::ul(MDD_TimedTextEssence), Ctx, HMAC);
            }
        }
     }
index 5e0743c8333ed1e0d89b5e8a6ba5f76392b2e1d4..b08ad6fdfe9359552d6f65f95ad703dbb6cc5fef 100755 (executable)
@@ -125,7 +125,7 @@ ASDCP::MXF::IndexTableSegment::Dump(FILE* stream)
     }
   else
     {
-      fprintf(stream, "  IndexEntryArray: %lu entries\n", IndexEntryArray.size());
+      fprintf(stream, "  IndexEntryArray: %du entries\n", IndexEntryArray.size());
     }
 }
 
index 57b28a88482b8b070f66c8003d59e12824317f53..61b7c88591ddc8ee5e2cefb4af77c24c954bd4f6 100644 (file)
@@ -69,7 +69,6 @@ split(const std::string& str, char separator, std::list<std::string>& components
       if ( r > pstr )
        {
          std::string tmp_str;
-         assert(r - pstr < 100);
          tmp_str.assign(pstr, (r - pstr));
          components.push_back(tmp_str);
        }
index c7e102ef2010ccb99e7c95da1c967c38adfe7561..141ca587e599b5b1798c7f7d8fb3763237fe1248 100755 (executable)
@@ -95,7 +95,7 @@ namespace Kumu
   //
 #ifndef KM_SMALL_FILES_OK
   template <bool sizecheck>    void compile_time_size_checker();
-  template <>    inline void compile_time_size_checker<false>() {}
+  template <> inline void compile_time_size_checker<false>() {}
   //
   // READ THIS if your compiler is complaining about a previously declared implementation of
   // compile_time_size_checker(). For example, GCC 4.0.1 looks like this:
index bf99e3e522271ebc4bc9dd4538fcfe92a98fe586..d01393c9f26eab1e39c4d5c5c130f2a888de97ed 100755 (executable)
@@ -667,11 +667,12 @@ ASDCP::MXF::OPAtomHeader::InitFromFile(const Kumu::FileReader& Reader)
        }
       else
        {
-         if ( test_s < 2 || test_s > 3 )
+         if ( test_s < 2 )
            {
              // OP-Atom states that there will be either two or three partitions:
              // one closed header and one closed footer with an optional body
-             DefaultLogSink().Warn("RIP count is not 2 or 3: %u\n", test_s);
+             // SMPTE 429-5 files may have many partitions, see SMPTE 410M
+             DefaultLogSink().Warn("RIP count is less than 2: %u\n", test_s);
            }
 
          m_HasRIP = true;
index 099e9077c01833f818ad2facc3d7109ffede854d..8fc09fc9ed72cfb17c32d7ae39a884fb51ca08e1 100644 (file)
@@ -263,12 +263,13 @@ ASDCP::TimedText::DCSubtitleParser::h__SubtitleParser::OpenRead(const char* file
 
   if ( InstanceList.empty() )
     {
-      DefaultLogSink(). Error("XML document contains no Subtitle elements!\n");
+      DefaultLogSink(). Error("XML document contains no Subtitle elements.\n");
       return RESULT_FORMAT;
     }
 
   // assumes 24/1 or 48/1 as constrained above
-  S12MTimecode beginTC(InstanceList.front()->GetAttrWithName("TimeIn"), m_TDesc.EditRate.Numerator);
+
+  S12MTimecode beginTC(m_Root.GetChildWithName("StartTime")->GetBody(), m_TDesc.EditRate.Numerator);
 
   for ( ei = InstanceList.begin(); ei != InstanceList.end(); ei++ )
     {
@@ -277,7 +278,12 @@ ASDCP::TimedText::DCSubtitleParser::h__SubtitleParser::OpenRead(const char* file
        end_count = tmpTC.GetFrames();
     }
 
-  assert( end_count > beginTC.GetFrames() );
+  if ( end_count <= beginTC.GetFrames() )
+    {
+      DefaultLogSink(). Error("Timed Text file has zero-length timeline.\n");
+      return RESULT_FORMAT;
+    }
+
   m_TDesc.ContainerDuration = end_count - beginTC.GetFrames();
 
   return RESULT_OK;
index 9fb2423884978ca60ed28c9d342b4484fef3d594..ff063fbf09073c1dc3cc73b1bc34c78cfe3afa90 100755 (executable)
@@ -174,9 +174,9 @@ ASDCP::Wav::SimpleWaveHeader::ReadFromBuffer(const byte_t* buf, ui32_t buf_len,
        {
          ui16_t format = KM_i16_LE(*(ui16_t*)p); p += 2;
 
-         if ( format != 1 )
+         if ( format != WAVE_FORMAT_PCM && format != WAVE_FORMAT_EXTENSIBLE )
            {
-             DefaultLogSink().Error("Expecting uncompressed essence, got format type %hu\n", format);
+             DefaultLogSink().Error("Expecting uncompressed PCM data, got format type %hd\n", format);
              return RESULT_RAW_FORMAT;
            }
 
@@ -185,7 +185,7 @@ ASDCP::Wav::SimpleWaveHeader::ReadFromBuffer(const byte_t* buf, ui32_t buf_len,
          avgbps = KM_i32_LE(*(ui32_t*)p); p += 4;
          blockalign = KM_i16_LE(*(ui16_t*)p); p += 2;
          bitspersample = KM_i16_LE(*(ui16_t*)p); p += 2;
-         p += chunk_size - 16;
+         p += chunk_size - 16; // 16 is the number of bytes read in this block
        }
       else
        {
index bd890ce5022eb692c6724e264e008c38a2cad6d6..f7d9df8902f027dca33e8482c37df868fee2628e 100755 (executable)
--- a/src/Wav.h
+++ b/src/Wav.h
@@ -89,6 +89,9 @@ namespace ASDCP
       const fourcc FCC_fmt_("fmt ");
       const fourcc FCC_data("data");
 
+      const ui16_t WAVE_FORMAT_PCM = 1;
+      const ui16_t WAVE_FORMAT_EXTENSIBLE = 65534;
+
       //
       class SimpleWaveHeader
        {
index 0c5f9692a05311b02dfda5f030ec9b443ee81330..c0bbce6dfa96f3788c9cfa495d0d031472e5e4b3 100644 (file)
@@ -1,5 +1,5 @@
 /*
-Copyright (c) 2004-2007, John Hurst
+Copyright (c) 2004-2008, John Hurst
 All rights reserved.
 
 Redistribution and use in source and binary forms, with or without
@@ -84,6 +84,14 @@ main(int argc, const char** argv)
   assert(PathSetExtension("foo.bar", "") == "foo");
   assert(PathSetExtension(Path_3, "xml") == "baz.xml");
 
+  string Path_7 = "//tmp///////fooo";
+
+  PathCompList_t PathList_7;
+  PathToComponents(Path_7, PathList_7);
+  for ( PathCompList_t::const_iterator i = PathList_7.begin(); i != PathList_7.end(); i++ )
+    fprintf(stderr, "xx: \"%s\"\n", i->c_str());
+  assert(PathsAreEquivalent(PathMakeLocal(PathMakeCanonical(Path_7), "/tmp"), "fooo"));
+
   PathList_t InList, OutList;
   InList.push_back("tmp");
   InList.push_back("Darwin");