/*
-Copyright (c) 2004-2009, John Hurst
+Copyright (c) 2004-2012, John Hurst
All rights reserved.
Redistribution and use in source and binary forms, with or without
DefaultLogSink().Error("Unexpected PictureComponentSizing size: %u, should be 17\n", tmp_size);
// CodingStyleDefault
- memset(&m_PDesc.CodingStyleDefault, 0, sizeof(CodingStyleDefault_t));
- memcpy(&m_PDesc.CodingStyleDefault,
+ memset(&PDesc.CodingStyleDefault, 0, sizeof(CodingStyleDefault_t));
+ memcpy(&PDesc.CodingStyleDefault,
m_EssenceSubDescriptor->CodingStyleDefault.RoData(),
m_EssenceSubDescriptor->CodingStyleDefault.Length());
// QuantizationDefault
- memset(&m_PDesc.QuantizationDefault, 0, sizeof(QuantizationDefault_t));
- memcpy(&m_PDesc.QuantizationDefault,
+ memset(&PDesc.QuantizationDefault, 0, sizeof(QuantizationDefault_t));
+ memcpy(&PDesc.QuantizationDefault,
m_EssenceSubDescriptor->QuantizationDefault.RoData(),
m_EssenceSubDescriptor->QuantizationDefault.Length());
- m_PDesc.QuantizationDefault.SPqcdLength = m_EssenceSubDescriptor->QuantizationDefault.Length() - 1;
+ PDesc.QuantizationDefault.SPqcdLength = m_EssenceSubDescriptor->QuantizationDefault.Length() - 1;
}
return RESULT_OK;
{
if ( m_EditRate != m_SampleRate )
{
- DefaultLogSink().Error("EditRate and SampleRate do not match (%.03f, %.03f).\n",
- m_EditRate.Quotient(), m_SampleRate.Quotient());
+ DefaultLogSink().Warn("EditRate and SampleRate do not match (%.03f, %.03f).\n",
+ m_EditRate.Quotient(), m_SampleRate.Quotient());
- if ( m_EditRate == EditRate_24 && m_SampleRate == EditRate_48 )
+ if ( m_EditRate == EditRate_24 && m_SampleRate == EditRate_48 ||
+ m_EditRate == EditRate_25 && m_SampleRate == EditRate_50 ||
+ m_EditRate == EditRate_30 && m_SampleRate == EditRate_60 ||
+ m_EditRate == EditRate_48 && m_SampleRate == EditRate_96 ||
+ m_EditRate == EditRate_50 && m_SampleRate == EditRate_100 ||
+ m_EditRate == EditRate_60 && m_SampleRate == EditRate_120 )
{
DefaultLogSink().Debug("File may contain JPEG Interop stereoscopic images.\n");
return RESULT_SFORMAT;
}
else if ( type == ASDCP::ESS_JPEG_2000_S )
{
- if ( ! ( m_EditRate == EditRate_24 && m_SampleRate == EditRate_48 ) )
+ if ( m_EditRate == EditRate_24 )
{
- DefaultLogSink().Error("EditRate and SampleRate not correct for 24/48 stereoscopic essence.\n");
+ if ( m_SampleRate != EditRate_48 )
+ {
+ DefaultLogSink().Error("EditRate and SampleRate not correct for 24/48 stereoscopic essence.\n");
+ return RESULT_FORMAT;
+ }
+ }
+ else if ( m_EditRate == EditRate_25 )
+ {
+ if ( m_SampleRate != EditRate_50 )
+ {
+ DefaultLogSink().Error("EditRate and SampleRate not correct for 25/50 stereoscopic essence.\n");
+ return RESULT_FORMAT;
+ }
+ }
+ else if ( m_EditRate == EditRate_30 )
+ {
+ if ( m_SampleRate != EditRate_60 )
+ {
+ DefaultLogSink().Error("EditRate and SampleRate not correct for 30/60 stereoscopic essence.\n");
+ return RESULT_FORMAT;
+ }
+ }
+ else if ( m_EditRate == EditRate_48 )
+ {
+ if ( m_SampleRate != EditRate_96 )
+ {
+ DefaultLogSink().Error("EditRate and SampleRate not correct for 48/96 stereoscopic essence.\n");
+ return RESULT_FORMAT;
+ }
+ }
+ else if ( m_EditRate == EditRate_50 )
+ {
+ if ( m_SampleRate != EditRate_100 )
+ {
+ DefaultLogSink().Error("EditRate and SampleRate not correct for 50/100 stereoscopic essence.\n");
+ return RESULT_FORMAT;
+ }
+ }
+ else if ( m_EditRate == EditRate_60 )
+ {
+ if ( m_SampleRate != EditRate_120 )
+ {
+ DefaultLogSink().Error("EditRate and SampleRate not correct for 60/120 stereoscopic essence.\n");
+ return RESULT_FORMAT;
+ }
+ }
+ else
+ {
+ DefaultLogSink().Error("EditRate not correct for stereoscopic essence: %d/%d.\n",
+ m_EditRate.Numerator, m_EditRate.Denominator);
return RESULT_FORMAT;
}
}
if ( ! m_File.IsOpen() )
return RESULT_INIT;
- return ReadEKLVFrame(FrameNum, FrameBuf, m_Dict.ul(MDD_JPEG2000Essence), Ctx, HMAC);
+ assert(m_Dict);
+ return ReadEKLVFrame(FrameNum, FrameBuf, m_Dict->ul(MDD_JPEG2000Essence), Ctx, HMAC);
}
{
}
+// Warning: direct manipulation of MXF structures can interfere
+// with the normal operation of the wrapper. Caveat emptor!
+//
+ASDCP::MXF::OPAtomHeader&
+ASDCP::JP2K::MXFReader::OPAtomHeader()
+{
+ if ( m_Reader.empty() )
+ {
+ assert(g_OPAtomHeader);
+ return *g_OPAtomHeader;
+ }
+
+ return m_Reader->m_HeaderPart;
+}
+
+// Warning: direct manipulation of MXF structures can interfere
+// with the normal operation of the wrapper. Caveat emptor!
+//
+ASDCP::MXF::OPAtomIndexFooter&
+ASDCP::JP2K::MXFReader::OPAtomIndexFooter()
+{
+ if ( m_Reader.empty() )
+ {
+ assert(g_OPAtomIndexFooter);
+ return *g_OPAtomIndexFooter;
+ }
+
+ return m_Reader->m_FooterPart;
+}
+
// Open the file for reading. The file must exist. Returns error if the
// operation cannot be completed.
ASDCP::Result_t
m_Reader->m_FooterPart.Dump(stream);
}
+//
+ASDCP::Result_t
+ASDCP::JP2K::MXFReader::Close() const
+{
+ if ( m_Reader && m_Reader->m_File.IsOpen() )
+ {
+ m_Reader->Close();
+ return RESULT_OK;
+ }
+
+ return RESULT_INIT;
+}
+
//------------------------------------------------------------------------------------------
{
ui32_t SequenceNum = FrameNum * 2;
SequenceNum += ( phase == SP_RIGHT ) ? 2 : 1;
- result = ReadEKLVPacket(FrameNum, SequenceNum, FrameBuf, m_Dict.ul(MDD_JPEG2000Essence), Ctx, HMAC);
+ assert(m_Dict);
+ result = ReadEKLVPacket(FrameNum, SequenceNum, FrameBuf, m_Dict->ul(MDD_JPEG2000Essence), Ctx, HMAC);
}
return result;
{
}
+// Warning: direct manipulation of MXF structures can interfere
+// with the normal operation of the wrapper. Caveat emptor!
+//
+ASDCP::MXF::OPAtomHeader&
+ASDCP::JP2K::MXFSReader::OPAtomHeader()
+{
+ if ( m_Reader.empty() )
+ {
+ assert(g_OPAtomHeader);
+ return *g_OPAtomHeader;
+ }
+
+ return m_Reader->m_HeaderPart;
+}
+
+// Warning: direct manipulation of MXF structures can interfere
+// with the normal operation of the wrapper. Caveat emptor!
+//
+ASDCP::MXF::OPAtomIndexFooter&
+ASDCP::JP2K::MXFSReader::OPAtomIndexFooter()
+{
+ if ( m_Reader.empty() )
+ {
+ assert(g_OPAtomIndexFooter);
+ return *g_OPAtomIndexFooter;
+ }
+
+ return m_Reader->m_FooterPart;
+}
+
// Open the file for reading. The file must exist. Returns error if the
// operation cannot be completed.
ASDCP::Result_t
m_Reader->m_FooterPart.Dump(stream);
}
+//
+ASDCP::Result_t
+ASDCP::JP2K::MXFSReader::Close() const
+{
+ if ( m_Reader && m_Reader->m_File.IsOpen() )
+ {
+ m_Reader->Close();
+ return RESULT_OK;
+ }
+
+ return RESULT_INIT;
+}
+
+
//------------------------------------------------------------------------------------------
// PixelLayout byte_t[PixelLayoutSize] = s_PixelLayoutXYZ
// }
+ assert(m_Dict);
if ( PDesc.StoredWidth < 2049 )
{
- PDescObj->PictureEssenceCoding.Set(m_Dict.ul(MDD_JP2KEssenceCompression_2K));
+ PDescObj->PictureEssenceCoding.Set(m_Dict->ul(MDD_JP2KEssenceCompression_2K));
m_EssenceSubDescriptor->Rsize = 3;
}
else
{
- PDescObj->PictureEssenceCoding.Set(m_Dict.ul(MDD_JP2KEssenceCompression_4K));
+ PDescObj->PictureEssenceCoding.Set(m_Dict->ul(MDD_JP2KEssenceCompression_4K));
m_EssenceSubDescriptor->Rsize = 4;
}
ASDCP::Result_t
lh__Writer::SetSourceStream(const PictureDescriptor& PDesc, const std::string& label, ASDCP::Rational LocalEditRate)
{
+ assert(m_Dict);
if ( ! m_State.Test_INIT() )
return RESULT_STATE;
m_PDesc = PDesc;
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);
+ 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) )
+ {
+ ui32_t TCFrameRate = ( m_PDesc.EditRate == EditRate_23_98 ) ? 24 : m_PDesc.EditRate.Numerator;
+
+ result = WriteMXFHeader(label, UL(m_Dict->ul(MDD_JPEG_2000Wrapping)),
+ PICT_DEF_LABEL, UL(m_EssenceUL), UL(m_Dict->ul(MDD_PictureDataDef)),
+ LocalEditRate, TCFrameRate);
+ }
+
return result;
}
{
}
+// Warning: direct manipulation of MXF structures can interfere
+// with the normal operation of the wrapper. Caveat emptor!
+//
+ASDCP::MXF::OPAtomHeader&
+ASDCP::JP2K::MXFWriter::OPAtomHeader()
+{
+ if ( m_Writer.empty() )
+ {
+ assert(g_OPAtomHeader);
+ return *g_OPAtomHeader;
+ }
+
+ return m_Writer->m_HeaderPart;
+}
+
+// Warning: direct manipulation of MXF structures can interfere
+// with the normal operation of the wrapper. Caveat emptor!
+//
+ASDCP::MXF::OPAtomIndexFooter&
+ASDCP::JP2K::MXFWriter::OPAtomIndexFooter()
+{
+ if ( m_Writer.empty() )
+ {
+ assert(g_OPAtomIndexFooter);
+ return *g_OPAtomIndexFooter;
+ }
+
+ return m_Writer->m_FooterPart;
+}
// Open the file for writing. The file must not exist. Returns error if
// the operation cannot be completed.
{
}
+// Warning: direct manipulation of MXF structures can interfere
+// with the normal operation of the wrapper. Caveat emptor!
+//
+ASDCP::MXF::OPAtomHeader&
+ASDCP::JP2K::MXFSWriter::OPAtomHeader()
+{
+ if ( m_Writer.empty() )
+ {
+ assert(g_OPAtomHeader);
+ return *g_OPAtomHeader;
+ }
+
+ return m_Writer->m_HeaderPart;
+}
+
+// Warning: direct manipulation of MXF structures can interfere
+// with the normal operation of the wrapper. Caveat emptor!
+//
+ASDCP::MXF::OPAtomIndexFooter&
+ASDCP::JP2K::MXFSWriter::OPAtomIndexFooter()
+{
+ if ( m_Writer.empty() )
+ {
+ assert(g_OPAtomIndexFooter);
+ return *g_OPAtomIndexFooter;
+ }
+
+ return m_Writer->m_FooterPart;
+}
// Open the file for writing. The file must not exist. Returns error if
// the operation cannot be completed.
else
m_Writer = new h__SWriter(DefaultInteropDict());
- if ( PDesc.EditRate != ASDCP::EditRate_24 )
+ if ( PDesc.EditRate != ASDCP::EditRate_24
+ && PDesc.EditRate != ASDCP::EditRate_25
+ && PDesc.EditRate != ASDCP::EditRate_30
+ && PDesc.EditRate != ASDCP::EditRate_48
+ && PDesc.EditRate != ASDCP::EditRate_50
+ && PDesc.EditRate != ASDCP::EditRate_60 )
{
- DefaultLogSink().Error("Stereoscopic wrapping requires 24 fps input streams.\n");
+ DefaultLogSink().Error("Stereoscopic wrapping requires 24, 25, 30, 48, 50 or 60 fps input streams.\n");
return RESULT_FORMAT;
}
if ( ASDCP_SUCCESS(result) )
{
PictureDescriptor TmpPDesc = PDesc;
- TmpPDesc.EditRate = ASDCP::EditRate_48;
- result = m_Writer->SetSourceStream(TmpPDesc, JP2K_S_PACKAGE_LABEL, ASDCP::EditRate_24);
+ if ( PDesc.EditRate == ASDCP::EditRate_24 )
+ TmpPDesc.EditRate = ASDCP::EditRate_48;
+
+ else if ( PDesc.EditRate == ASDCP::EditRate_25 )
+ TmpPDesc.EditRate = ASDCP::EditRate_50;
+
+ else if ( PDesc.EditRate == ASDCP::EditRate_30 )
+ TmpPDesc.EditRate = ASDCP::EditRate_60;
+
+ else if ( PDesc.EditRate == ASDCP::EditRate_48 )
+ TmpPDesc.EditRate = ASDCP::EditRate_96;
+
+ else if ( PDesc.EditRate == ASDCP::EditRate_50 )
+ TmpPDesc.EditRate = ASDCP::EditRate_100;
+
+ else if ( PDesc.EditRate == ASDCP::EditRate_60 )
+ TmpPDesc.EditRate = ASDCP::EditRate_120;
+
+ result = m_Writer->SetSourceStream(TmpPDesc, JP2K_S_PACKAGE_LABEL, PDesc.EditRate);
}
if ( ASDCP_FAILURE(result) )