*/
#include "AS_DCP_internal.h"
+#include <iostream>
+#include <iomanip>
using namespace ASDCP::JP2K;
-
+using Kumu::GenRandomValue;
//------------------------------------------------------------------------------------------
int s_exp_lookup[16] = { 0, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024,2048, 4096, 8192, 16384, 32768 };
+//
+std::ostream&
+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;
+ strm << " Xsize: " << (unsigned) PDesc.Xsize << std::endl;
+ strm << " Ysize: " << (unsigned) PDesc.Ysize << std::endl;
+ strm << " XOsize: " << (unsigned) PDesc.XOsize << std::endl;
+ strm << " YOsize: " << (unsigned) PDesc.YOsize << std::endl;
+ strm << " XTsize: " << (unsigned) PDesc.XTsize << std::endl;
+ strm << " YTsize: " << (unsigned) PDesc.YTsize << std::endl;
+ strm << " XTOsize: " << (unsigned) PDesc.XTOsize << std::endl;
+ strm << " YTOsize: " << (unsigned) PDesc.YTOsize << std::endl;
+ strm << " ContainerDuration: " << (unsigned) PDesc.ContainerDuration << std::endl;
+
+ strm << "-- JPEG 2000 Metadata --" << std::endl;
+ strm << " ImageComponents:" << std::endl;
+ strm << " bits h-sep v-sep" << std::endl;
+
+ ui32_t i;
+ for ( i = 0; i < PDesc.Csize; i++ )
+ {
+ strm << " " << std::setw(4) << PDesc.ImageComponents[i].Ssize + 1 /* See ISO 15444-1, Table A11, for the origin of '+1' */
+ << " " << std::setw(5) << PDesc.ImageComponents[i].XRsize
+ << " " << std::setw(5) << PDesc.ImageComponents[i].YRsize
+ << std::endl;
+ }
+
+ strm << " Scod: " << (short) PDesc.CodingStyleDefault.Scod << std::endl;
+ strm << " ProgressionOrder: " << (short) PDesc.CodingStyleDefault.SGcod.ProgressionOrder << std::endl;
+ strm << " NumberOfLayers: " << (short) KM_i16_BE(Kumu::cp2i<ui16_t>(PDesc.CodingStyleDefault.SGcod.NumberOfLayers)) << std::endl;
+ strm << " MultiCompTransform: " << (short) PDesc.CodingStyleDefault.SGcod.MultiCompTransform << std::endl;
+ strm << "DecompositionLevels: " << (short) PDesc.CodingStyleDefault.SPcod.DecompositionLevels << std::endl;
+ strm << " CodeblockWidth: " << (short) PDesc.CodingStyleDefault.SPcod.CodeblockWidth << std::endl;
+ strm << " CodeblockHeight: " << (short) PDesc.CodingStyleDefault.SPcod.CodeblockHeight << std::endl;
+ strm << " CodeblockStyle: " << (short) PDesc.CodingStyleDefault.SPcod.CodeblockStyle << std::endl;
+ strm << " Transformation: " << (short) PDesc.CodingStyleDefault.SPcod.Transformation << std::endl;
+
+
+ ui32_t precinct_set_size = 0;
+
+ for ( i = 0; PDesc.CodingStyleDefault.SPcod.PrecinctSize[i] != 0 && i < MaxPrecincts; i++ )
+ precinct_set_size++;
+
+ strm << " Precincts: " << (short) precinct_set_size << std::endl;
+ strm << "precinct dimensions:" << std::endl;
+
+ for ( i = 0; i < precinct_set_size; i++ )
+ strm << " " << i + 1 << ": " << s_exp_lookup[PDesc.CodingStyleDefault.SPcod.PrecinctSize[i]&0x0f] << " x "
+ << s_exp_lookup[(PDesc.CodingStyleDefault.SPcod.PrecinctSize[i]>>4)&0x0f] << std::endl;
+
+ strm << " Sqcd: " << (short) PDesc.QuantizationDefault.Sqcd << std::endl;
+
+ char tmp_buf[MaxDefaults*2];
+ strm << " SPqcd: " << Kumu::bin2hex(PDesc.QuantizationDefault.SPqcd, PDesc.QuantizationDefault.SPqcdLength, tmp_buf, MaxDefaults*2)
+ << std::endl;
+
+ return strm;
+}
+
//
void
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\
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,
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'
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++;
);
}
+
//------------------------------------------------------------------------------------------
//
// hidden, internal implementation of JPEG 2000 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);
MXF::RGBAEssenceDescriptor* PDescObj = (MXF::RGBAEssenceDescriptor*)m_EssenceDescriptor;
PDesc.EditRate = m_EditRate;
- PDesc.ContainerDuration = PDescObj->ContainerDuration;
+ PDesc.SampleRate = m_SampleRate;
+ assert(PDescObj->ContainerDuration <= 0xFFFFFFFFL);
+ PDesc.ContainerDuration = (ui32_t) PDescObj->ContainerDuration;
PDesc.StoredWidth = PDescObj->StoredWidth;
PDesc.StoredHeight = PDescObj->StoredHeight;
PDesc.AspectRatio = PDescObj->AspectRatio;
if ( ObjectList.empty() )
{
- DefaultLogSink().Error("MXF Metadata contains no Track Sets\n");
+ DefaultLogSink().Error("MXF Metadata contains no Track Sets.\n");
return RESULT_FORMAT;
}
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());
- return RESULT_SFORMAT;
+ DefaultLogSink().Error("EditRate and SampleRate do not match (%.03f, %.03f).\n",
+ m_EditRate.Quotient(), m_SampleRate.Quotient());
+
+ if ( m_EditRate == EditRate_24 && m_SampleRate == EditRate_48 )
+ {
+ DefaultLogSink().Debug("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 ) )
+ if ( ! ( m_EditRate == EditRate_24 && m_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;
}
}
}
if ( PDesc.StoredWidth > 2048 )
- {
- DefaultLogSink().Error("Stereoscopic wrapping requires 2K image content.\n");
- return RESULT_FORMAT;
- }
+ DefaultLogSink().Warn("Wrapping non-standard 4K stereoscopic content. I hope you know what you are doing!\n");
m_Writer->m_Info = Info;