summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorjhurst <jhurst@cinecert.com>2009-08-04 18:43:10 +0000
committerjhurst <>2009-08-04 18:43:10 +0000
commit61a1033e5c75e8318340a3789c35ec6d008432cd (patch)
tree130747f1c540402382cb9c09240f0c6b95d2dcae /src
parenta102d4a41e97e39d36220cbaaaca30079b36d7f0 (diff)
build JP2K parsers with file lists
Diffstat (limited to 'src')
-rwxr-xr-xsrc/AS_DCP.h9
-rwxr-xr-xsrc/AS_DCP_MXF.cpp25
-rwxr-xr-xsrc/JP2K_Sequence_Parser.cpp99
-rw-r--r--src/KM_fileio.cpp4
-rwxr-xr-xsrc/KM_util.h2
5 files changed, 102 insertions, 37 deletions
diff --git a/src/AS_DCP.h b/src/AS_DCP.h
index da18976..3cbc481 100755
--- a/src/AS_DCP.h
+++ b/src/AS_DCP.h
@@ -1070,6 +1070,15 @@ namespace ASDCP {
// mismatch is detected.
Result_t OpenRead(const char* filename, bool pedantic = false) const;
+ // Opens a file sequence for reading. The sequence is expected to contain one or
+ // more filenames, each naming a file containing the codestream for exactly one
+ // picture. The parser will automatically parse enough data
+ // from the first file to provide a complete set of stream metadata for the
+ // MXFWriter below. If the "pedantic" parameter is given and is true, the
+ // parser will check the metadata for each codestream and fail if a
+ // mismatch is detected.
+ Result_t OpenRead(const std::list<std::string>& file_list, bool pedantic = false) const;
+
// Fill a PictureDescriptor struct with the values from the first file's codestream.
// Returns RESULT_INIT if the directory is not open.
Result_t FillPictureDescriptor(PictureDescriptor&) const;
diff --git a/src/AS_DCP_MXF.cpp b/src/AS_DCP_MXF.cpp
index 7251b7d..95e219e 100755
--- a/src/AS_DCP_MXF.cpp
+++ b/src/AS_DCP_MXF.cpp
@@ -234,7 +234,11 @@ ASDCP::RawEssenceType(const char* filename, EssenceType_t& type)
{
type = ESS_MPEG2_VES;
}
- else if ( ASDCP_SUCCESS(WavHeader.ReadFromBuffer(p, read_count, &data_offset)) )
+ else if ( memcmp(FB.RoData(), ASDCP::JP2K::Magic, sizeof(ASDCP::JP2K::Magic)) == 0 )
+ {
+ type = ESS_JPEG_2000;
+ }
+ else if ( ASDCP_SUCCESS(WavHeader.ReadFromBuffer(FB.RoData(), read_count, &data_offset)) )
{
switch ( WavHeader.samplespersec )
{
@@ -244,11 +248,11 @@ ASDCP::RawEssenceType(const char* filename, EssenceType_t& type)
return RESULT_FORMAT;
}
}
- else if ( ASDCP_SUCCESS(AIFFHeader.ReadFromBuffer(p, read_count, &data_offset)) )
+ else if ( ASDCP_SUCCESS(AIFFHeader.ReadFromBuffer(FB.RoData(), read_count, &data_offset)) )
{
type = ESS_PCM_24b_48k;
}
- else if ( Kumu::StringIsXML((const char*)p, FB.Size()) )
+ else if ( Kumu::StringIsXML((const char*)FB.RoData(), FB.Size()) )
{
type = ESS_TIMED_TEXT;
}
@@ -281,10 +285,19 @@ ASDCP::RawEssenceType(const char* filename, EssenceType_t& type)
if ( ASDCP_SUCCESS(result) )
{
if ( memcmp(FB.RoData(), ASDCP::JP2K::Magic, sizeof(ASDCP::JP2K::Magic)) == 0 )
- type = ESS_JPEG_2000;
-
+ {
+ type = ESS_JPEG_2000;
+ }
else if ( ASDCP_SUCCESS(WavHeader.ReadFromBuffer(FB.RoData(), 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;
+ }
+ }
}
break;
diff --git a/src/JP2K_Sequence_Parser.cpp b/src/JP2K_Sequence_Parser.cpp
index 5cb4e91..77de5be 100755
--- a/src/JP2K_Sequence_Parser.cpp
+++ b/src/JP2K_Sequence_Parser.cpp
@@ -50,6 +50,12 @@ public:
FileList() {}
~FileList() {}
+ const FileList& operator=(const std::list<std::string>& pathlist) {
+ std::list<std::string>::const_iterator i;
+ for ( i = pathlist.begin(); i != pathlist.end(); i++ )
+ push_back(*i);
+ }
+
//
Result_t InitFromDirectory(const char* path)
{
@@ -89,13 +95,16 @@ class ASDCP::JP2K::SequenceParser::h__SequenceParser
FileList m_FileList;
FileList::iterator m_CurrentFile;
CodestreamParser m_Parser;
+ bool m_Pedantic;
+
+ Result_t OpenRead();
ASDCP_NO_COPY_CONSTRUCT(h__SequenceParser);
public:
PictureDescriptor m_PDesc;
- h__SequenceParser() : m_FramesRead(0)
+ h__SequenceParser() : m_FramesRead(0), m_Pedantic(false)
{
memset(&m_PDesc, 0, sizeof(m_PDesc));
m_PDesc.EditRate = Rational(24,1);
@@ -106,7 +115,8 @@ public:
Close();
}
- Result_t OpenRead(const char* filename);
+ Result_t OpenRead(const char* filename, bool pedantic);
+ Result_t OpenRead(const std::list<std::string>& file_list, bool pedantic);
void Close() {}
Result_t Reset()
@@ -122,48 +132,61 @@ public:
//
ASDCP::Result_t
-ASDCP::JP2K::SequenceParser::h__SequenceParser::OpenRead(const char* filename)
+ASDCP::JP2K::SequenceParser::h__SequenceParser::OpenRead()
{
- ASDCP_TEST_NULL_STR(filename);
-
- Result_t result = m_FileList.InitFromDirectory(filename);
-
if ( m_FileList.empty() )
return RESULT_ENDOFFILE;
- if ( ASDCP_SUCCESS(result) )
- {
- m_CurrentFile = m_FileList.begin();
+ m_CurrentFile = m_FileList.begin();
+ CodestreamParser Parser;
+ FrameBuffer TmpBuffer;
- CodestreamParser Parser;
- FrameBuffer TmpBuffer;
+ Kumu::fsize_t file_size = Kumu::FileSize((*m_CurrentFile).c_str());
- Kumu::fsize_t file_size = Kumu::FileSize((*m_CurrentFile).c_str());
+ if ( file_size == 0 )
+ return RESULT_NOT_FOUND;
- if ( file_size == 0 )
- result = RESULT_NOT_FOUND;
+ assert(file_size <= 0xFFFFFFFFL);
+ Result_t result = TmpBuffer.Capacity((ui32_t) file_size);
- if ( ASDCP_SUCCESS(result) )
- {
- assert(file_size <= 0xFFFFFFFFL);
- result = TmpBuffer.Capacity((ui32_t) file_size);
- }
-
- if ( ASDCP_SUCCESS(result) )
- result = Parser.OpenReadFrame((*m_CurrentFile).c_str(), TmpBuffer);
+ if ( ASDCP_SUCCESS(result) )
+ result = Parser.OpenReadFrame((*m_CurrentFile).c_str(), TmpBuffer);
- if ( ASDCP_SUCCESS(result) )
- result = Parser.FillPictureDescriptor(m_PDesc);
+ if ( ASDCP_SUCCESS(result) )
+ result = Parser.FillPictureDescriptor(m_PDesc);
- // how big is it?
- if ( ASDCP_SUCCESS(result) )
- m_PDesc.ContainerDuration = m_FileList.size();
- }
+ // how big is it?
+ if ( ASDCP_SUCCESS(result) )
+ m_PDesc.ContainerDuration = m_FileList.size();
+
+ return result;
+}
+
+//
+ASDCP::Result_t
+ASDCP::JP2K::SequenceParser::h__SequenceParser::OpenRead(const char* filename, bool pedantic)
+{
+ ASDCP_TEST_NULL_STR(filename);
+ m_Pedantic = pedantic;
+
+ Result_t result = m_FileList.InitFromDirectory(filename);
+
+ if ( ASDCP_SUCCESS(result) )
+ result = OpenRead();
return result;
}
+
//
+ASDCP::Result_t
+ASDCP::JP2K::SequenceParser::h__SequenceParser::OpenRead(const std::list<std::string>& file_list, bool pedantic)
+{
+ m_Pedantic = pedantic;
+ m_FileList = file_list;
+ return OpenRead();
+}
+
//
ASDCP::Result_t
ASDCP::JP2K::SequenceParser::h__SequenceParser::ReadFrame(FrameBuffer& FB)
@@ -201,7 +224,21 @@ ASDCP::JP2K::SequenceParser::OpenRead(const char* filename, bool pedantic) const
{
const_cast<ASDCP::JP2K::SequenceParser*>(this)->m_Parser = new h__SequenceParser;
- Result_t result = m_Parser->OpenRead(filename);
+ Result_t result = m_Parser->OpenRead(filename, pedantic);
+
+ if ( ASDCP_FAILURE(result) )
+ const_cast<ASDCP::JP2K::SequenceParser*>(this)->m_Parser.release();
+
+ return result;
+}
+
+//
+Result_t
+ASDCP::JP2K::SequenceParser::OpenRead(const std::list<std::string>& file_list, bool pedantic) const
+{
+ const_cast<ASDCP::JP2K::SequenceParser*>(this)->m_Parser = new h__SequenceParser;
+
+ Result_t result = m_Parser->OpenRead(file_list, pedantic);
if ( ASDCP_FAILURE(result) )
const_cast<ASDCP::JP2K::SequenceParser*>(this)->m_Parser.release();
@@ -209,6 +246,7 @@ ASDCP::JP2K::SequenceParser::OpenRead(const char* filename, bool pedantic) const
return result;
}
+
// Rewinds the stream to the beginning.
ASDCP::Result_t
ASDCP::JP2K::SequenceParser::Reset() const
@@ -230,6 +268,7 @@ ASDCP::JP2K::SequenceParser::ReadFrame(FrameBuffer& FB) const
return m_Parser->ReadFrame(FB);
}
+//
ASDCP::Result_t
ASDCP::JP2K::SequenceParser::FillPictureDescriptor(PictureDescriptor& PDesc) const
{
diff --git a/src/KM_fileio.cpp b/src/KM_fileio.cpp
index fba8578..b9257ab 100644
--- a/src/KM_fileio.cpp
+++ b/src/KM_fileio.cpp
@@ -1455,7 +1455,9 @@ Kumu::DeleteFile(const std::string& filename)
Result_t
h__DeletePath(const std::string& pathname)
{
- fprintf(stderr, "h__DeletePath %s\n", pathname.c_str());
+ if ( pathname.empty() )
+ return RESULT_NULL_STR;
+
Result_t result = RESULT_OK;
if ( ! PathIsDirectory(pathname) )
diff --git a/src/KM_util.h b/src/KM_util.h
index 6bf2366..a9c96c6 100755
--- a/src/KM_util.h
+++ b/src/KM_util.h
@@ -342,6 +342,8 @@ namespace Kumu
void GenRandomUUID(byte_t* buf); // buf must be UUID_Length or longer
void GenRandomValue(UUID&);
+ typedef ArchivableList<UUID> UUIDList;
+
// a self-wiping key container
//
const ui32_t SymmetricKey_Length = 16;