Use iostreams instead of file descriptors for dumping.
authormsheby <msheby@cinecert.com>
Fri, 11 Jul 2008 01:04:24 +0000 (01:04 +0000)
committermsheby <>
Fri, 11 Jul 2008 01:04:24 +0000 (01:04 +0000)
src/AS_DCP.h
src/AS_DCP_JP2K.cpp
src/AS_DCP_MPEG2.cpp
src/AS_DCP_PCM.cpp
src/AS_DCP_TimedText.cpp

index bda4c1359808a7fc299e70e611cd0900495d6736..b49746b9c9fc589b46537d9dbe01f8c9bfd8358d 100755 (executable)
@@ -90,7 +90,7 @@ This project depends upon the following libraries:
 #include <stdio.h>
 #include <stdarg.h>
 #include <math.h>
-#include <iostream>
+#include <iosfwd>
 #include <string>
 #include <list>
 
@@ -338,6 +338,8 @@ namespace ASDCP {
     }
   };
 
+  // Print WriterInfo to std::ostream
+  std::ostream& operator << (std::ostream& strm, const WriterInfo& winfo);
   // Print WriterInfo to stream, stderr by default.
   void WriterInfoDump(const WriterInfo&, FILE* = 0);
 
@@ -568,6 +570,8 @@ namespace ASDCP {
          ui32_t   ContainerDuration;       // 
       };
 
+      // Print VideoDescriptor to std::ostream
+      std::ostream& operator << (std::ostream& strm, const VideoDescriptor& vdesc);
       // Print VideoDescriptor to stream, stderr by default.
       void VideoDescriptorDump(const VideoDescriptor&, FILE* = 0);
 
@@ -760,6 +764,8 @@ namespace ASDCP {
          ui32_t   ContainerDuration;  // number of frames
       };
 
+      // Print AudioDescriptor to std::ostream
+      std::ostream& operator << (std::ostream& strm, const AudioDescriptor& adesc);
       // Print debugging information to stream (stderr default)
       void   AudioDescriptorDump(const AudioDescriptor&, FILE* = 0);
 
@@ -962,6 +968,8 @@ namespace ASDCP {
        QuantizationDefault_t QuantizationDefault;
       };
 
+      // Print debugging information to std::ostream
+      std::ostream& operator << (std::ostream& strm, const PictureDescriptor& pdesc);
       // Print debugging information to stream (stderr default)
       void   PictureDescriptorDump(const PictureDescriptor&, FILE* = 0);
 
@@ -1247,6 +1255,8 @@ namespace ASDCP {
       TimedTextDescriptor() : ContainerDuration(0), EncodingName("UTF-8") {} // D-Cinema format is always UTF-8
       };
 
+      // Print debugging information to std::ostream
+      std::ostream& operator << (std::ostream& strm, const TimedTextDescriptor& tinfo);
       // Print debugging information to stream (stderr default)
       void   DescriptorDump(const TimedTextDescriptor&, FILE* = 0);
 
index 39dceedd72b4e681f93bdfe39f8108911e0dc62d..d6754f5872dc60d4e0715b4e722f605e4630d895 100755 (executable)
@@ -30,6 +30,8 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
 
 #include "AS_DCP_internal.h"
+#include <iostream>
+#include <iomanip>
 
 using namespace ASDCP::JP2K;
 using Kumu::GenRandomValue;
@@ -42,6 +44,70 @@ static std::string PICT_DEF_LABEL = "Picture Track";
 
 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 << "       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)
@@ -130,6 +196,7 @@ ASDCP::JP2K::PictureDescriptorDump(const PictureDescriptor& PDesc, FILE* stream)
          );
 }
 
+
 //------------------------------------------------------------------------------------------
 //
 // hidden, internal implementation of JPEG 2000 reader
index bd2709e3344eae1f6a6c6d78e4cf57fd255baf22..9a81b9fb689ebf9768fe004257602405dd249e8b 100755 (executable)
@@ -30,6 +30,8 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
 
 #include "AS_DCP_internal.h"
+#include <iostream>
+#include <iomanip>
 
 
 //------------------------------------------------------------------------------------------
@@ -93,6 +95,27 @@ MPEG2_VDesc_to_MD(MPEG2::VideoDescriptor& VDesc, MXF::MPEG2VideoDescriptor* VDes
   return RESULT_OK;
 }
 
+//
+std::ostream&
+ASDCP::MPEG2::operator << (std::ostream& strm, const VideoDescriptor& VDesc)
+{
+  strm << "        SampleRate: " << VDesc.SampleRate.Numerator << "/" << VDesc.SampleRate.Denominator << std::endl;
+  strm << "       FrameLayout: " << (unsigned) VDesc.FrameLayout << std::endl;
+  strm << "       StoredWidth: " << (unsigned) VDesc.StoredWidth << std::endl;
+  strm << "      StoredHeight: " << (unsigned) VDesc.StoredHeight << std::endl;
+  strm << "       AspectRatio: " << VDesc.AspectRatio.Numerator << "/" << VDesc.AspectRatio.Denominator << std::endl;
+  strm << "    ComponentDepth: " << (unsigned) VDesc.ComponentDepth << std::endl;
+  strm << " HorizontalSubsmpl: " << (unsigned) VDesc.HorizontalSubsampling << std::endl;
+  strm << "   VerticalSubsmpl: " << (unsigned) VDesc.VerticalSubsampling << std::endl;
+  strm << "       ColorSiting: " << (unsigned) VDesc.ColorSiting << std::endl;
+  strm << "  CodedContentType: " << (unsigned) VDesc.CodedContentType << std::endl;
+  strm << "          LowDelay: " << (unsigned) VDesc.LowDelay << std::endl;
+  strm << "           BitRate: " << (unsigned) VDesc.BitRate << std::endl;
+  strm << "   ProfileAndLevel: " << (unsigned) VDesc.ProfileAndLevel << std::endl;
+  strm << " ContainerDuration: " << (unsigned) VDesc.ContainerDuration << std::endl;
+
+  return strm;
+}
 
 //
 void
index 5e03d1daea486409f5e34b24b9191747ae77a555..a50f24b6967c87a28ab43e53591e2851b0faae77 100755 (executable)
@@ -31,6 +31,8 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 #include "AS_DCP_internal.h"
 #include <map>
+#include <iostream>
+#include <iomanip>
 
 //------------------------------------------------------------------------------------------
 
@@ -72,6 +74,24 @@ MD_to_PCM_ADesc(MXF::WaveAudioDescriptor* ADescObj, PCM::AudioDescriptor& ADesc)
   return RESULT_OK;
 }
 
+//
+std::ostream&
+ASDCP::PCM::operator << (std::ostream& strm, const AudioDescriptor& ADesc)
+{
+  strm << "        SampleRate: " << ADesc.SampleRate.Numerator << "/" << ADesc.SampleRate.Denominator << std::endl;
+  strm << " AudioSamplingRate: " << ADesc.AudioSamplingRate.Numerator << "/" << ADesc.AudioSamplingRate.Denominator << std::endl;
+  strm << "            Locked: " << (unsigned) ADesc.Locked << std::endl;
+  strm << "      ChannelCount: " << (unsigned) ADesc.ChannelCount << std::endl;
+  strm << "  QuantizationBits: " << (unsigned) ADesc.QuantizationBits << std::endl;
+  strm << "        BlockAlign: " << (unsigned) ADesc.BlockAlign << std::endl;
+  strm << "            AvgBps: " << (unsigned) ADesc.AvgBps << std::endl;
+  strm << "     LinkedTrackID: " << (unsigned) ADesc.LinkedTrackID << std::endl;
+  strm << " ContainerDuration: " << (unsigned) ADesc.ContainerDuration << std::endl;
+
+  return strm;
+}
+
+//
 void
 ASDCP::PCM::AudioDescriptorDump(const AudioDescriptor& ADesc, FILE* stream)
 {
index 73341a5fc3a309afc35b1d4343c001f40d35cb4b..81ebf8f70a7ce060b2c40bfb9c33248845dcbab7 100644 (file)
@@ -32,6 +32,8 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 #include "AS_DCP_internal.h"
 #include "KM_xml.h"
+#include <iostream>
+#include <iomanip>
 
 using Kumu::GenRandomValue;
 
@@ -53,6 +55,29 @@ MIME2str(TimedText::MIMEType_t m)
   return "application/octet-stream";
 }
 
+//
+std::ostream&
+ASDCP::TimedText::operator << (std::ostream& strm, const TimedTextDescriptor& TDesc)
+{
+  UUID TmpID(TDesc.AssetID);
+  char buf[64];
+
+  strm << "         EditRate: " << (unsigned) TDesc.EditRate.Numerator << "/" << (unsigned) TDesc.EditRate.Denominator << std::endl;
+  strm << "ContainerDuration: " << (unsigned) TDesc.ContainerDuration << std::endl;
+  strm << "          AssetID: " << TmpID.EncodeHex(buf, 64) << std::endl;
+  strm << "    NamespaceName: " << TDesc.NamespaceName << std::endl;
+  strm << "    ResourceCount: " << (unsigned long) TDesc.ResourceList.size() << std::endl;
+
+  TimedText::ResourceList_t::const_iterator ri;
+  for ( ri = TDesc.ResourceList.begin() ; ri != TDesc.ResourceList.end(); ri++ )
+    {
+      TmpID.Set((*ri).ResourceID);
+      strm << "    " << TmpID.EncodeHex(buf, 64) << ": " << MIME2str((*ri).Type) << std::endl;
+    }
+
+  return strm;
+}
+
 //
 void
 ASDCP::TimedText::DescriptorDump(ASDCP::TimedText::TimedTextDescriptor const& TDesc, FILE* stream)