From a6d7c84d3734a21dbe7112a3a83b791ec211a315 Mon Sep 17 00:00:00 2001 From: jhurst Date: Fri, 15 Aug 2008 22:47:07 +0000 Subject: [PATCH] removed extraneous assert(), added multi-/ test to path-test.cpp --- src/AS_DCP_JP2K.cpp | 16 +++++++++++----- src/AS_DCP_MXF.cpp | 25 ++++++++++++++++++------- src/AS_DCP_TimedText.cpp | 8 +++++--- src/Index.cpp | 2 +- src/KM_fileio.cpp | 1 - src/KM_fileio.h | 2 +- src/MXF.cpp | 5 +++-- src/TimedText_Parser.cpp | 12 +++++++++--- src/Wav.cpp | 6 +++--- src/Wav.h | 3 +++ src/path-test.cpp | 10 +++++++++- 11 files changed, 63 insertions(+), 27 deletions(-) diff --git a/src/AS_DCP_JP2K.cpp b/src/AS_DCP_JP2K.cpp index d6754f5..9a334a6 100755 --- a/src/AS_DCP_JP2K.cpp +++ b/src/AS_DCP_JP2K.cpp @@ -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; diff --git a/src/AS_DCP_MXF.cpp b/src/AS_DCP_MXF.cpp index 334d253..6b30da9 100755 --- a/src/AS_DCP_MXF.cpp +++ b/src/AS_DCP_MXF.cpp @@ -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) ) diff --git a/src/AS_DCP_TimedText.cpp b/src/AS_DCP_TimedText.cpp index 81ebf8f..b9bda07 100644 --- a/src/AS_DCP_TimedText.cpp +++ b/src/AS_DCP_TimedText.cpp @@ -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); } } } diff --git a/src/Index.cpp b/src/Index.cpp index 5e0743c..b08ad6f 100755 --- a/src/Index.cpp +++ b/src/Index.cpp @@ -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()); } } diff --git a/src/KM_fileio.cpp b/src/KM_fileio.cpp index 57b28a8..61b7c88 100644 --- a/src/KM_fileio.cpp +++ b/src/KM_fileio.cpp @@ -69,7 +69,6 @@ split(const std::string& str, char separator, std::list& components if ( r > pstr ) { std::string tmp_str; - assert(r - pstr < 100); tmp_str.assign(pstr, (r - pstr)); components.push_back(tmp_str); } diff --git a/src/KM_fileio.h b/src/KM_fileio.h index c7e102e..141ca58 100755 --- a/src/KM_fileio.h +++ b/src/KM_fileio.h @@ -95,7 +95,7 @@ namespace Kumu // #ifndef KM_SMALL_FILES_OK template void compile_time_size_checker(); - template <> inline void compile_time_size_checker() {} + template <> inline void compile_time_size_checker() {} // // 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: diff --git a/src/MXF.cpp b/src/MXF.cpp index bf99e3e..d01393c 100755 --- a/src/MXF.cpp +++ b/src/MXF.cpp @@ -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; diff --git a/src/TimedText_Parser.cpp b/src/TimedText_Parser.cpp index 099e907..8fc09fc 100644 --- a/src/TimedText_Parser.cpp +++ b/src/TimedText_Parser.cpp @@ -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; diff --git a/src/Wav.cpp b/src/Wav.cpp index 9fb2423..ff063fb 100755 --- a/src/Wav.cpp +++ b/src/Wav.cpp @@ -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 { diff --git a/src/Wav.h b/src/Wav.h index bd890ce..f7d9df8 100755 --- 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 { diff --git a/src/path-test.cpp b/src/path-test.cpp index 0c5f969..c0bbce6 100644 --- a/src/path-test.cpp +++ b/src/path-test.cpp @@ -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"); -- 2.30.2