X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2FAS_DCP_JP2K.cpp;h=39dceedd72b4e681f93bdfe39f8108911e0dc62d;hb=3e1ee0a500bd0b513db4bdf18a9cb052f42404d4;hp=e0852b1154b906357ec9812c59722f8f1572d714;hpb=4808d5031d03ffe14e7e1fa9dfd4ef2c6c0c48d2;p=asdcplib.git diff --git a/src/AS_DCP_JP2K.cpp b/src/AS_DCP_JP2K.cpp index e0852b1..39dceed 100755 --- a/src/AS_DCP_JP2K.cpp +++ b/src/AS_DCP_JP2K.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 @@ -32,7 +32,7 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "AS_DCP_internal.h" using namespace ASDCP::JP2K; - +using Kumu::GenRandomValue; //------------------------------------------------------------------------------------------ @@ -84,7 +84,8 @@ ASDCP::JP2K::PictureDescriptorDump(const PictureDescriptor& PDesc, FILE* stream) fprintf(stream, " ImageComponents:\n"); fprintf(stream, " bits h-sep v-sep\n"); - for ( ui32_t i = 0; i < PDesc.Csize; i++ ) + ui32_t i; + for ( i = 0; i < PDesc.Csize; i++ ) { fprintf(stream, " %4d %5d %5d\n", PDesc.ImageComponents[i].Ssize + 1, // See ISO 15444-1, Table A11, for the origin of '+1' @@ -106,7 +107,7 @@ ASDCP::JP2K::PictureDescriptorDump(const PictureDescriptor& PDesc, FILE* stream) fprintf(stream, " Transformation: %hd\n", PDesc.CodingStyleDefault.SPcod.Transformation); - ui32_t precinct_set_size = 0, i; + ui32_t precinct_set_size = 0; for ( i = 0; PDesc.CodingStyleDefault.SPcod.PrecinctSize[i] != 0 && i < MaxPrecincts; i++ ) precinct_set_size++; @@ -159,7 +160,8 @@ lh__Reader::MD_to_JP2K_PDesc(JP2K::PictureDescriptor& PDesc) MXF::RGBAEssenceDescriptor* PDescObj = (MXF::RGBAEssenceDescriptor*)m_EssenceDescriptor; PDesc.EditRate = m_EditRate; - PDesc.ContainerDuration = PDescObj->ContainerDuration; + assert(PDescObj->ContainerDuration <= 0xFFFFFFFFL); + PDesc.ContainerDuration = (ui32_t) PDescObj->ContainerDuration; PDesc.StoredWidth = PDescObj->StoredWidth; PDesc.StoredHeight = PDescObj->StoredHeight; PDesc.AspectRatio = PDescObj->AspectRatio; @@ -225,7 +227,7 @@ lh__Reader::OpenRead(const char* filename, EssenceType_t type) if ( ObjectList.empty() ) { - DefaultLogSink().Error("MXF Metadata contains no Track Sets\n"); + DefaultLogSink().Error("MXF Metadata contains no Track Sets.\n"); return RESULT_FORMAT; } @@ -235,16 +237,23 @@ lh__Reader::OpenRead(const char* filename, EssenceType_t type) { if ( m_EditRate != m_EssenceDescriptor->SampleRate ) { - DefaultLogSink().Error("EditRate and SampleRate do not match (%.03f, %.03f)\n", + DefaultLogSink().Error("EditRate and SampleRate do not match (%.03f, %.03f).\n", m_EditRate.Quotient(), m_EssenceDescriptor->SampleRate.Quotient()); - return RESULT_SFORMAT; + + if ( m_EditRate == EditRate_24 && m_EssenceDescriptor->SampleRate == EditRate_48 ) + { + DefaultLogSink().Error("File may contain JPEG Interop stereoscopic images.\n"); + return RESULT_SFORMAT; + } + + return RESULT_FORMAT; } } else if ( type == ASDCP::ESS_JPEG_2000_S ) { if ( ! ( m_EditRate == EditRate_24 && m_EssenceDescriptor->SampleRate == EditRate_48 ) ) { - DefaultLogSink().Error("EditRate and SampleRate not correct for 24/48 stereoscopic essence\n"); + DefaultLogSink().Error("EditRate and SampleRate not correct for 24/48 stereoscopic essence.\n"); return RESULT_FORMAT; } } @@ -800,14 +809,12 @@ ASDCP::JP2K::MXFWriter::OpenWrite(const char* filename, const WriterInfo& Info, const PictureDescriptor& PDesc, ui32_t HeaderSize) { m_Writer = new h__Writer; - + m_Writer->m_Info = Info; + Result_t result = m_Writer->OpenWrite(filename, ASDCP::ESS_JPEG_2000, HeaderSize); if ( ASDCP_SUCCESS(result) ) - { - m_Writer->m_Info = Info; - result = m_Writer->SetSourceStream(PDesc, JP2K_PACKAGE_LABEL); - } + result = m_Writer->SetSourceStream(PDesc, JP2K_PACKAGE_LABEL); if ( ASDCP_FAILURE(result) ) m_Writer.release(); @@ -905,11 +912,15 @@ ASDCP::JP2K::MXFSWriter::OpenWrite(const char* filename, const WriterInfo& Info, return RESULT_FORMAT; } + if ( PDesc.StoredWidth > 2048 ) + DefaultLogSink().Warn("Wrapping non-standard 4K stereoscopic content. I hope you know what you are doing!\n"); + + m_Writer->m_Info = Info; + Result_t result = m_Writer->OpenWrite(filename, ASDCP::ESS_JPEG_2000_S, HeaderSize); if ( ASDCP_SUCCESS(result) ) { - m_Writer->m_Info = Info; PictureDescriptor TmpPDesc = PDesc; TmpPDesc.EditRate = ASDCP::EditRate_48;