summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorjhurst <jhurst@cinecert.com>2010-05-13 19:12:13 +0000
committerjhurst <>2010-05-13 19:12:13 +0000
commitf6382ee078c3d7de2dbf3a01f5624345d2c61e4a (patch)
tree9418a7065bdedb15e9551d97743ec1a9b8cd8f71 /src
parent6413d43575d39c8560673515ca7e75e1e2c789a9 (diff)
release candidate
Diffstat (limited to 'src')
-rwxr-xr-xsrc/AS_DCP.h8
-rwxr-xr-xsrc/AS_DCP_JP2K.cpp12
-rwxr-xr-xsrc/AS_DCP_MPEG2.cpp12
-rwxr-xr-xsrc/AS_DCP_PCM.cpp12
-rwxr-xr-xsrc/AS_DCP_internal.h10
-rwxr-xr-xsrc/KM_memio.h41
-rwxr-xr-xsrc/KM_util.h29
-rw-r--r--src/MDD.cpp4
-rwxr-xr-xsrc/h__Writer.cpp68
9 files changed, 123 insertions, 73 deletions
diff --git a/src/AS_DCP.h b/src/AS_DCP.h
index a9f8b44..383f270 100755
--- a/src/AS_DCP.h
+++ b/src/AS_DCP.h
@@ -1,5 +1,5 @@
/*
-Copyright (c) 2003-2009, John Hurst
+Copyright (c) 2003-2010, John Hurst
All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -267,9 +267,9 @@ namespace ASDCP {
const Rational SampleRate_48k(48000,1);
const Rational SampleRate_96k(96000,1);
- // Additional frame rates, see SMPTE 428-11
- // These rates are new and not supported by all systems. Do not assume that a package
- // made using on of these rates will work just anywhere!
+ // Additional frame rates, see ST 428-11
+ // These rates are new and not supported by all systems. Do not assume that
+ // a package made using on of these rates will work just anywhere!
const Rational EditRate_25(25,1);
const Rational EditRate_30(30,1);
const Rational EditRate_50(50,1);
diff --git a/src/AS_DCP_JP2K.cpp b/src/AS_DCP_JP2K.cpp
index 86327c2..51cc017 100755
--- a/src/AS_DCP_JP2K.cpp
+++ b/src/AS_DCP_JP2K.cpp
@@ -1,5 +1,5 @@
/*
-Copyright (c) 2004-2009, John Hurst
+Copyright (c) 2004-2010, John Hurst
All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -835,17 +835,17 @@ lh__Writer::SetSourceStream(const PictureDescriptor& PDesc, const std::string& l
Result_t result = JP2K_PDesc_to_MD(m_PDesc);
if ( ASDCP_SUCCESS(result) )
- result = WriteMXFHeader(label, UL(m_Dict->ul(MDD_JPEG_2000Wrapping)),
- PICT_DEF_LABEL, UL(m_Dict->ul(MDD_PictureDataDef)),
- LocalEditRate, 24 /* TCFrameRate */);
-
- if ( ASDCP_SUCCESS(result) )
{
memcpy(m_EssenceUL, m_Dict->ul(MDD_JPEG2000Essence), SMPTE_UL_LENGTH);
m_EssenceUL[SMPTE_UL_LENGTH-1] = 1; // first (and only) essence container
result = m_State.Goto_READY();
}
+ if ( ASDCP_SUCCESS(result) )
+ result = WriteMXFHeader(label, UL(m_Dict->ul(MDD_JPEG_2000Wrapping)),
+ PICT_DEF_LABEL, UL(m_EssenceUL), UL(m_Dict->ul(MDD_PictureDataDef)),
+ LocalEditRate, 24 /* TCFrameRate */);
+
return result;
}
diff --git a/src/AS_DCP_MPEG2.cpp b/src/AS_DCP_MPEG2.cpp
index aac0ddc..5801349 100755
--- a/src/AS_DCP_MPEG2.cpp
+++ b/src/AS_DCP_MPEG2.cpp
@@ -1,5 +1,5 @@
/*
-Copyright (c) 2004-2009, John Hurst
+Copyright (c) 2004-2010, John Hurst
All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -462,17 +462,17 @@ ASDCP::MPEG2::MXFWriter::h__Writer::SetSourceStream(const VideoDescriptor& VDesc
Result_t result = MPEG2_VDesc_to_MD(m_VDesc, (MPEG2VideoDescriptor*)m_EssenceDescriptor);
if ( ASDCP_SUCCESS(result) )
- result = WriteMXFHeader(MPEG_PACKAGE_LABEL, UL(m_Dict->ul(MDD_MPEG2_VESWrapping)),
- PICT_DEF_LABEL, UL(m_Dict->ul(MDD_PictureDataDef)),
- m_VDesc.EditRate, 24 /* TCFrameRate */);
-
- if ( ASDCP_SUCCESS(result) )
{
memcpy(m_EssenceUL, m_Dict->ul(MDD_MPEG2Essence), SMPTE_UL_LENGTH);
m_EssenceUL[SMPTE_UL_LENGTH-1] = 1; // first (and only) essence container
result = m_State.Goto_READY();
}
+ if ( ASDCP_SUCCESS(result) )
+ result = WriteMXFHeader(MPEG_PACKAGE_LABEL, UL(m_Dict->ul(MDD_MPEG2_VESWrapping)),
+ PICT_DEF_LABEL, UL(m_EssenceUL), UL(m_Dict->ul(MDD_PictureDataDef)),
+ m_VDesc.EditRate, 24 /* TCFrameRate */);
+
return result;
}
diff --git a/src/AS_DCP_PCM.cpp b/src/AS_DCP_PCM.cpp
index 9795c9d..4639c93 100755
--- a/src/AS_DCP_PCM.cpp
+++ b/src/AS_DCP_PCM.cpp
@@ -1,5 +1,5 @@
/*
-Copyright (c) 2004-2009, John Hurst
+Copyright (c) 2004-2010, John Hurst
All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -455,17 +455,17 @@ ASDCP::PCM::MXFWriter::h__Writer::SetSourceStream(const AudioDescriptor& ADesc)
Result_t result = PCM_ADesc_to_MD(m_ADesc, (WaveAudioDescriptor*)m_EssenceDescriptor);
if ( ASDCP_SUCCESS(result) )
- result = WriteMXFHeader(PCM_PACKAGE_LABEL, UL(m_Dict->ul(MDD_WAVWrapping)),
- SOUND_DEF_LABEL, UL(m_Dict->ul(MDD_SoundDataDef)),
- m_ADesc.EditRate, TCFrameRate, calc_CBR_frame_size(m_Info, m_ADesc));
-
- if ( ASDCP_SUCCESS(result) )
{
memcpy(m_EssenceUL, m_Dict->ul(MDD_WAVEssence), SMPTE_UL_LENGTH);
m_EssenceUL[SMPTE_UL_LENGTH-1] = 1; // first (and only) essence container
result = m_State.Goto_READY();
}
+ if ( ASDCP_SUCCESS(result) )
+ result = WriteMXFHeader(PCM_PACKAGE_LABEL, UL(m_Dict->ul(MDD_WAVWrapping)),
+ SOUND_DEF_LABEL, UL(m_EssenceUL), UL(m_Dict->ul(MDD_SoundDataDef)),
+ m_ADesc.EditRate, TCFrameRate, calc_CBR_frame_size(m_Info, m_ADesc));
+
return result;
}
diff --git a/src/AS_DCP_internal.h b/src/AS_DCP_internal.h
index d55d337..464771d 100755
--- a/src/AS_DCP_internal.h
+++ b/src/AS_DCP_internal.h
@@ -212,18 +212,18 @@ namespace ASDCP
void InitHeader();
void AddSourceClip(const MXF::Rational& EditRate, ui32_t TCFrameRate,
- const std::string& TrackName, const UL& DataDefinition,
- const std::string& PackageLabel);
+ const std::string& TrackName, const UL& EssenceUL,
+ const UL& DataDefinition, const std::string& PackageLabel);
void AddDMSegment(const MXF::Rational& EditRate, ui32_t TCFrameRate,
- const std::string& TrackName, const UL& DataDefinition,
+ const std::string& TrackName, const UL& DataDefinition,
const std::string& PackageLabel);
void AddEssenceDescriptor(const UL& WrappingUL);
Result_t CreateBodyPart(const MXF::Rational& EditRate, ui32_t BytesPerEditUnit = 0);
// all the above for a single source clip
Result_t WriteMXFHeader(const std::string& PackageLabel, const UL& WrappingUL,
- const std::string& TrackName, const UL& DataDefinition,
- const MXF::Rational& EditRate,
+ const std::string& TrackName, const UL& EssenceUL,
+ const UL& DataDefinition, const MXF::Rational& EditRate,
ui32_t TCFrameRate, ui32_t BytesPerEditUnit = 0);
Result_t WriteEKLVPacket(const ASDCP::FrameBuffer& FrameBuf,
diff --git a/src/KM_memio.h b/src/KM_memio.h
index 9c906d5..5349749 100755
--- a/src/KM_memio.h
+++ b/src/KM_memio.h
@@ -1,5 +1,5 @@
/*
-Copyright (c) 2006-2009, John Hurst
+Copyright (c) 2006-2010, John Hurst
All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -121,6 +121,13 @@ namespace Kumu
m_size += sizeof(ui64_t);
return true;
}
+
+ inline bool WriteString(const std::string& str)
+ {
+ if ( ! WriteUi32BE(str.length()) ) return false;
+ if ( ! WriteRaw((const byte_t*)str.c_str(), str.length()) ) return false;
+ return true;
+ }
};
//
@@ -207,27 +214,31 @@ namespace Kumu
m_size += sizeof(ui64_t);
return true;
}
+
+ inline bool ReadString(std::string& str)
+ {
+ ui32_t str_length;
+ if ( ! ReadUi32BE(&str_length) ) return false;
+ if ( ( m_size + str_length ) > m_capacity ) return false;
+ str.assign((const char*)CurrentData(), str_length);
+ if ( ! SkipOffset(str_length) ) return false;
+ return true;
+ }
};
//
inline bool
- UnarchiveString(MemIOReader& Reader, std::string& str)
- {
- ui32_t str_length;
- if ( ! Reader.ReadUi32BE(&str_length) ) return false;
- str.assign((const char*)Reader.CurrentData(), str_length);
- if ( ! Reader.SkipOffset(str_length) ) return false;
- return true;
- }
+ UnarchiveString(MemIOReader& Reader, std::string& str) {
+ return Reader.ReadString(str);
+ }
//
inline bool
- ArchiveString(MemIOWriter& Writer, const std::string& str)
- {
- if ( ! Writer.WriteUi32BE(str.length()) ) return false;
- if ( ! Writer.WriteRaw((const byte_t*)str.c_str(), str.length()) ) return false;
- return true;
- }
+ ArchiveString(MemIOWriter& Writer, const std::string& str)
+ {
+ return Writer.WriteString(str);
+ }
+
} // namespace Kumu
diff --git a/src/KM_util.h b/src/KM_util.h
index 7ca30e0..ea83e63 100755
--- a/src/KM_util.h
+++ b/src/KM_util.h
@@ -230,6 +230,35 @@ namespace Kumu
}
};
+ // archivable version of std::string
+
+ //
+ class ArchivableString : public std::string, public Kumu::IArchive
+ {
+
+ public:
+ ArchivableString() {}
+ ArchivableString(const char* sz) : std::string(sz) {}
+ ArchivableString(const std::string& s) : std::string(s) {}
+ virtual ~ArchivableString() {}
+
+ bool HasValue() const { return ! this->empty(); }
+ ui32_t ArchiveLength() const { return sizeof(ui32_t) + this->size(); }
+
+ bool Archive(MemIOWriter* Writer) const {
+ if ( Writer == 0 ) return false;
+ return Writer->WriteString(*this);
+ }
+
+ bool Unarchive(MemIOReader* Reader) {
+ if ( Reader == 0 ) return false;
+ return Reader->ReadString(*this);
+ }
+ };
+
+ //
+ typedef Kumu::ArchivableList<ArchivableString> StringList;
+
//
// the base of all identifier classes, Identifier is not usually used directly
// see UUID and SymmetricKey below for more detail.
diff --git a/src/MDD.cpp b/src/MDD.cpp
index 08c5c5f..832c771 100644
--- a/src/MDD.cpp
+++ b/src/MDD.cpp
@@ -806,7 +806,7 @@ static const ASDCP::MDDEntry s_MDD_Table[] = {
{ { 0x06, 0x0e, 0x2b, 0x34, 0x01, 0x02, 0x01, 0x09, // 256
0x0d, 0x01, 0x03, 0x01, 0x17, 0x01, 0x0b, 0x01 },
{0}, false, "TimedTextEssence" },
- { { 0x06, 0x0e, 0x2b, 0x34, 0x02, 0x7f, 0x01, 0x01, // 257
+ { { 0x06, 0x0e, 0x2b, 0x34, 0x02, 0x53, 0x01, 0x01, // 257
0x0d, 0x01, 0x01, 0x01, 0x01, 0x01, 0x64, 0x00 },
{0}, false, "TimedTextDescriptor" },
{ { 0x06, 0x0e, 0x2b, 0x34, 0x01, 0x01, 0x01, 0x0c, // 258
@@ -849,7 +849,7 @@ static const ASDCP::MDDEntry s_MDD_Table[] = {
0x04, 0x02, 0x01, 0x01, 0x05, 0x00, 0x00, 0x00 },
{0x3d, 0x32}, true, "WaveAudioDescriptor_ChannelAssignment" },
{ { 0x06, 0x0e, 0x2b, 0x34, 0x01, 0x01, 0x01, 0x0c, // 271
- 0x0d, 0x01, 0x05, 0x05, 0x01, 0x00, 0x00, 0x00 },
+ 0x0d, 0x01, 0x05, 0x09, 0x01, 0x00, 0x00, 0x00 },
{0x00, 0x00}, false, "GenericStream_DataElement" },
{ { 0x06, 0x0e, 0x2b, 0x34, 0x01, 0x01, 0x01, 0x02, // 272
0x06, 0x01, 0x01, 0x04, 0x06, 0x10, 0x00, 0x00 },
diff --git a/src/h__Writer.cpp b/src/h__Writer.cpp
index 64d6faa..6152a35 100755
--- a/src/h__Writer.cpp
+++ b/src/h__Writer.cpp
@@ -1,5 +1,5 @@
/*
-Copyright (c) 2004-2009, John Hurst
+Copyright (c) 2004-2010, John Hurst
All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -222,8 +222,8 @@ CreateTimecodeTrack(OPAtomHeader& Header, PackageT& Package,
//
void
ASDCP::h__Writer::AddSourceClip(const MXF::Rational& EditRate, ui32_t TCFrameRate,
- const std::string& TrackName, const UL& DataDefinition,
- const std::string& PackageLabel)
+ const std::string& TrackName, const UL& EssenceUL,
+ const UL& DataDefinition, const std::string& PackageLabel)
{
//
ContentStorage* Storage = new ContentStorage(m_Dict);
@@ -250,14 +250,16 @@ ASDCP::h__Writer::AddSourceClip(const MXF::Rational& EditRate, ui32_t TCFrameRat
m_HeaderPart.AddChildObject(m_MaterialPackage);
Storage->Packages.push_back(m_MaterialPackage->InstanceUID);
- TrackSet<TimecodeComponent> MPTCTrack = CreateTimecodeTrack<MaterialPackage>(m_HeaderPart, *m_MaterialPackage,
- EditRate, TCFrameRate, 0, m_Dict);
+ TrackSet<TimecodeComponent> MPTCTrack =
+ CreateTimecodeTrack<MaterialPackage>(m_HeaderPart, *m_MaterialPackage,
+ EditRate, TCFrameRate, 0, m_Dict);
m_DurationUpdateList.push_back(&(MPTCTrack.Sequence->Duration));
m_DurationUpdateList.push_back(&(MPTCTrack.Clip->Duration));
- TrackSet<SourceClip> MPTrack = CreateTrackAndSequence<MaterialPackage, SourceClip>(m_HeaderPart, *m_MaterialPackage,
- TrackName, EditRate, DataDefinition,
- 2, m_Dict);
+ TrackSet<SourceClip> MPTrack =
+ CreateTrackAndSequence<MaterialPackage, SourceClip>(m_HeaderPart, *m_MaterialPackage,
+ TrackName, EditRate, DataDefinition,
+ 2, m_Dict);
m_DurationUpdateList.push_back(&(MPTrack.Sequence->Duration));
MPTrack.Clip = new SourceClip(m_Dict);
@@ -280,17 +282,21 @@ ASDCP::h__Writer::AddSourceClip(const MXF::Rational& EditRate, ui32_t TCFrameRat
m_HeaderPart.AddChildObject(m_FilePackage);
Storage->Packages.push_back(m_FilePackage->InstanceUID);
- TrackSet<TimecodeComponent> FPTCTrack = CreateTimecodeTrack<SourcePackage>(m_HeaderPart, *m_FilePackage,
- EditRate, TCFrameRate,
- ui64_C(3600) * TCFrameRate, m_Dict);
+ TrackSet<TimecodeComponent> FPTCTrack =
+ CreateTimecodeTrack<SourcePackage>(m_HeaderPart, *m_FilePackage,
+ EditRate, TCFrameRate,
+ ui64_C(3600) * TCFrameRate, m_Dict);
m_DurationUpdateList.push_back(&(FPTCTrack.Sequence->Duration));
m_DurationUpdateList.push_back(&(FPTCTrack.Clip->Duration));
-
- TrackSet<SourceClip> FPTrack = CreateTrackAndSequence<SourcePackage, SourceClip>(m_HeaderPart, *m_FilePackage,
- TrackName, EditRate, DataDefinition,
- 2, m_Dict);
+ TrackSet<SourceClip> FPTrack =
+ CreateTrackAndSequence<SourcePackage, SourceClip>(m_HeaderPart, *m_FilePackage,
+ TrackName, EditRate, DataDefinition,
+ 2, m_Dict);
m_DurationUpdateList.push_back(&(FPTrack.Sequence->Duration));
+ // Consult ST 379:2004 Sec. 6.3, "Element to track relationship" to see where "12" comes from.
+ FPTrack.Track->TrackNumber = KM_i32_BE(Kumu::cp2i<ui32_t>((EssenceUL.Value() + 12)));
+
FPTrack.Clip = new SourceClip(m_Dict);
m_HeaderPart.AddChildObject(FPTrack.Clip);
FPTrack.Sequence->StructuralComponents.push_back(FPTrack.Clip->InstanceUID);
@@ -307,7 +313,7 @@ ASDCP::h__Writer::AddSourceClip(const MXF::Rational& EditRate, ui32_t TCFrameRat
//
void
ASDCP::h__Writer::AddDMSegment(const MXF::Rational& EditRate, ui32_t TCFrameRate,
- const std::string& TrackName, const UL& DataDefinition,
+ const std::string& TrackName, const UL& DataDefinition,
const std::string& PackageLabel)
{
//
@@ -335,14 +341,16 @@ ASDCP::h__Writer::AddDMSegment(const MXF::Rational& EditRate, ui32_t TCFrameRate
m_HeaderPart.AddChildObject(m_MaterialPackage);
Storage->Packages.push_back(m_MaterialPackage->InstanceUID);
- TrackSet<TimecodeComponent> MPTCTrack = CreateTimecodeTrack<MaterialPackage>(m_HeaderPart, *m_MaterialPackage,
- EditRate, TCFrameRate, 0, m_Dict);
+ TrackSet<TimecodeComponent> MPTCTrack =
+ CreateTimecodeTrack<MaterialPackage>(m_HeaderPart, *m_MaterialPackage,
+ EditRate, TCFrameRate, 0, m_Dict);
m_DurationUpdateList.push_back(&(MPTCTrack.Sequence->Duration));
m_DurationUpdateList.push_back(&(MPTCTrack.Clip->Duration));
- TrackSet<DMSegment> MPTrack = CreateTrackAndSequence<MaterialPackage, DMSegment>(m_HeaderPart, *m_MaterialPackage,
- TrackName, EditRate, DataDefinition,
- 2, m_Dict);
+ TrackSet<DMSegment> MPTrack =
+ CreateTrackAndSequence<MaterialPackage, DMSegment>(m_HeaderPart, *m_MaterialPackage,
+ TrackName, EditRate, DataDefinition,
+ 2, m_Dict);
m_DurationUpdateList.push_back(&(MPTrack.Sequence->Duration));
MPTrack.Clip = new DMSegment(m_Dict);
@@ -365,15 +373,17 @@ ASDCP::h__Writer::AddDMSegment(const MXF::Rational& EditRate, ui32_t TCFrameRate
m_HeaderPart.AddChildObject(m_FilePackage);
Storage->Packages.push_back(m_FilePackage->InstanceUID);
- TrackSet<TimecodeComponent> FPTCTrack = CreateTimecodeTrack<SourcePackage>(m_HeaderPart, *m_FilePackage,
- EditRate, TCFrameRate,
- ui64_C(3600) * TCFrameRate, m_Dict);
+ TrackSet<TimecodeComponent> FPTCTrack =
+ CreateTimecodeTrack<SourcePackage>(m_HeaderPart, *m_FilePackage,
+ EditRate, TCFrameRate,
+ ui64_C(3600) * TCFrameRate, m_Dict);
m_DurationUpdateList.push_back(&(FPTCTrack.Sequence->Duration));
m_DurationUpdateList.push_back(&(FPTCTrack.Clip->Duration));
- TrackSet<DMSegment> FPTrack = CreateTrackAndSequence<SourcePackage, DMSegment>(m_HeaderPart, *m_FilePackage,
- TrackName, EditRate, DataDefinition,
- 2, m_Dict);
+ TrackSet<DMSegment> FPTrack =
+ CreateTrackAndSequence<SourcePackage, DMSegment>(m_HeaderPart, *m_FilePackage,
+ TrackName, EditRate, DataDefinition,
+ 2, m_Dict);
m_DurationUpdateList.push_back(&(FPTrack.Sequence->Duration));
FPTrack.Clip = new DMSegment(m_Dict);
@@ -469,11 +479,11 @@ ASDCP::h__Writer::CreateBodyPart(const MXF::Rational& EditRate, ui32_t BytesPerE
//
Result_t
ASDCP::h__Writer::WriteMXFHeader(const std::string& PackageLabel, const UL& WrappingUL,
- const std::string& TrackName, const UL& DataDefinition,
+ const std::string& TrackName, const UL& EssenceUL, const UL& DataDefinition,
const MXF::Rational& EditRate, ui32_t TCFrameRate, ui32_t BytesPerEditUnit)
{
InitHeader();
- AddSourceClip(EditRate, TCFrameRate, TrackName, DataDefinition, PackageLabel);
+ AddSourceClip(EditRate, TCFrameRate, TrackName, EssenceUL, DataDefinition, PackageLabel);
AddEssenceDescriptor(WrappingUL);
Result_t result = m_HeaderPart.WriteToFile(m_File, m_HeaderSize);