Update copyright dates.
[asdcplib.git] / src / AS_DCP_MPEG2.cpp
index 48d1c2d0caef40e2b819700cdeb08a45740f2cb7..98d55c62fcc1650ae82b89b1f9ee7124ea689446 100755 (executable)
@@ -1,5 +1,5 @@
 /*
-Copyright (c) 2004-2007, John Hurst
+Copyright (c) 2004-2009, John Hurst
 All rights reserved.
 
 Redistribution and use in source and binary forms, with or without
@@ -30,6 +30,8 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
 
 #include "AS_DCP_internal.h"
+#include <iostream>
+#include <iomanip>
 
 
 //------------------------------------------------------------------------------------------
@@ -46,7 +48,8 @@ MD_to_MPEG2_VDesc(MXF::MPEG2VideoDescriptor* VDescObj, MPEG2::VideoDescriptor& V
   VDesc.SampleRate             = VDescObj->SampleRate;
   VDesc.EditRate               = VDescObj->SampleRate;
   VDesc.FrameRate              = VDescObj->SampleRate.Numerator;
-  VDesc.ContainerDuration      = VDescObj->ContainerDuration;
+  assert(VDescObj->ContainerDuration <= 0xFFFFFFFFL);
+  VDesc.ContainerDuration      = (ui32_t) VDescObj->ContainerDuration;
 
   VDesc.FrameLayout            = VDescObj->FrameLayout;
   VDesc.StoredWidth            = VDescObj->StoredWidth;
@@ -92,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
@@ -492,7 +516,7 @@ ASDCP::MPEG2::MXFWriter::h__Writer::WriteFrame(const FrameBuffer& FrameBuf, AESE
 
   // update the index manager
   Entry.TemporalOffset = - FrameBuf.TemporalOffset();
-  Entry.KeyFrameOffset = - m_GOPOffset;
+  Entry.KeyFrameOffset = - m_GOPOffset;
   Entry.Flags = Flags;
   /*
   fprintf(stderr, "to: %4hd   ko: %4hd   c1: %4hd   c2: %4hd   fl: 0x%02x\n",