Implemented J2K desc to/from MD
[asdcplib.git] / src / AS_DCP.h
index 6b598cc301c14713763cbe10779b12e29d1bf876..0948cbf5b2bff9f854d5b60c5b6cb5b52a4e142b 100755 (executable)
@@ -1,5 +1,5 @@
 /*
-Copyright (c) 2003-2013, John Hurst
+Copyright (c) 2003-2018, John Hurst
 All rights reserved.
 
 Redistribution and use in source and binary forms, with or without
@@ -31,7 +31,7 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 The asdcplib library is a set of file access objects that offer simplified
 access to files conforming to the standards published by the SMPTE
 D-Cinema Technology Committee 21DC. The file format, labeled AS-DCP,
-is described in series of separate documents which include but may not
+is described in a series of documents which includes but may not
 be be limited to:
 
  o SMPTE ST 429-2:2011 DCP Operational Constraints
@@ -40,8 +40,10 @@ be be limited to:
  o SMPTE ST 429-5:2009 Timed Text Track File
  o SMPTE ST 429-6:2006 MXF Track File Essence Encryption
  o SMPTE ST 429-10:2008 Stereoscopic Picture Track File
+ o SMPTE ST 429-14:2008 Aux Data Track File
  o SMPTE ST 330:2004 - UMID
  o SMPTE ST 336:2001 - KLV
+ o SMPTE ST 377:2004 - MXF (old version, required)
  o SMPTE ST 377-1:2011 - MXF
  o SMPTE ST 377-4:2012 - MXF Multichannel Audio Labeling Framework
  o SMPTE ST 390:2011 - MXF OP-Atom
@@ -61,21 +63,13 @@ be be limited to:
 The following use cases are supported by the library:
 
  o Write essence to a plaintext or ciphertext AS-DCP file:
-     MPEG2 Video Elementary Stream
-     JPEG 2000 codestreams
-     JPEG 2000 stereoscopic codestream pairs
-     PCM audio streams
-     SMPTE 429-7 Timed Text XML with font and image resources
-     Proposed SMPTE Aux Data track file
-     Proposed Dolby (TM) Atmos track file
-
  o Read essence from a plaintext or ciphertext AS-DCP file:
      MPEG2 Video Elementary Stream
      JPEG 2000 codestreams
      JPEG 2000 stereoscopic codestream pairs
      PCM audio streams
      SMPTE 429-7 Timed Text XML with font and image resources
-     Proposed SMPTE Aux Data track file
+     Aux Data (frame-wrapped synchronous blob)
      Proposed Dolby (TM) Atmos track file
 
  o Read header metadata from an AS-DCP file
@@ -227,7 +221,8 @@ namespace ASDCP {
     ESS_AS02_PCM_24b_48k,     // the file contains one or more PCM audio pairs, clip wrapped
     ESS_AS02_PCM_24b_96k,     // the file contains one or more PCM audio pairs, clip wrapped
     ESS_AS02_TIMED_TEXT,      // the file contains a TTML document and zero or more resources
-
+    ESS_AS02_ISXD,            // the file contains an ISXD document stream (per SMPTE RDD 47)
+    ESS_AS02_ACES,            // the file contains two or more ACES codestreams (per SMPTE ST 2067-50)
     ESS_MAX
   };
 
@@ -280,6 +275,16 @@ namespace ASDCP {
     }
   };
 
+  // Encodes a rational number as a string having a single delimiter character between
+  // numerator and denominator.  Retuns the buffer pointer to allow convenient in-line use.
+  const char* EncodeRational(const Rational&, char* str_buf, ui32_t buf_len, char delimiter = ' ');
+
+  // Decodes a rational number havng a single non-digit delimiter character between
+  // the numerator and denominator.  Returns false if the string does not contain
+  // the expected syntax.
+  bool DecodeRational(const char* str_rat, Rational&);
+
+
   // common edit rates, use these instead of hard coded constants
   const Rational EditRate_24 = Rational(24,1);
   const Rational EditRate_23_98 = Rational(24000,1001); // Not a DCI-compliant value!
@@ -297,6 +302,9 @@ namespace ASDCP {
   const Rational EditRate_96 = Rational(96,1);
   const Rational EditRate_100 = Rational(100,1);
   const Rational EditRate_120 = Rational(120,1);
+  const Rational EditRate_192 = Rational(192,1);
+  const Rational EditRate_200 = Rational(200,1);
+  const Rational EditRate_240 = Rational(240,1);
 
   // Archival frame rates, see ST 428-21
   // These rates are new and not supported by all systems. Do not assume that
@@ -942,6 +950,8 @@ namespace ASDCP {
          // Reads the next sequential frame in the input file and places it in the
          // frame buffer. Fails if the buffer is too small or the stream is empty.
          Result_t ReadFrame(FrameBuffer&) const;
+
+         Result_t Seek(ui32_t frame_number) const;
        };
 
 
@@ -1038,6 +1048,9 @@ namespace ASDCP {
       const ui32_t MaxComponents = 3;
       const ui32_t MaxPrecincts = 32; // ISO 15444-1 Annex A.6.1
       const ui32_t MaxDefaults = 256; // made up
+      const ui8_t  MaxCapabilities = 32;
+                       const ui16_t MaxPRFN = 4;
+                       const ui16_t MaxCPFN = 4;
 
 #pragma pack(1)
       struct ImageComponent_t  // ISO 15444-1 Annex A.5.1
@@ -1075,6 +1088,25 @@ namespace ASDCP {
        ui8_t  SPqcd[MaxDefaults];
        ui8_t  SPqcdLength;
       };
+
+      struct ExtendedCapabilities_t // ISO 15444-1 Annex A.5.2
+      {
+       ui32_t  Pcap; // Pcap = 0 means that no extended capabilities are required
+       ui16_t  Ccap[MaxCapabilities]; // Ccap^i in ISO/IEC 15444-1 corresponds to Ccap[i - 1]
+      };
+
+                       struct Profile_t // ISO 15444-1
+      {
+       ui16_t  N; // N = 0 means that the profile is signaled through Rsiz exclusively
+       ui16_t  Pprf[MaxPRFN]; // Pprf^i in ISO/IEC 15444-1 corresponds to Pprf[i -1]
+      };
+
+                       struct CorrespondingProfile_t // ISO 15444-1
+      {
+       ui16_t  N; // N = 0 means that no corresponding profile is signaled
+       ui16_t  Pcpf[MaxCPFN]; // Pcpf^i in ISO/IEC 15444-1 corresponds to Pcpf[i -1]
+      };
+
 #pragma pack()
 
       struct PictureDescriptor
@@ -1098,6 +1130,9 @@ namespace ASDCP {
        ImageComponent_t      ImageComponents[MaxComponents];
        CodingStyleDefault_t  CodingStyleDefault;
        QuantizationDefault_t QuantizationDefault;
+  ExtendedCapabilities_t ExtendedCapabilities;
+  Profile_t   Profile;
+       CorrespondingProfile_t   CorrespondingProfile;    
       };
 
       // Print debugging information to std::ostream
@@ -1481,6 +1516,7 @@ namespace ASDCP {
 
        public:
          LocalFilenameResolver();
+         virtual ~LocalFilenameResolver();
          Result_t OpenRead(const std::string& dirname);
          Result_t ResolveRID(const byte_t* uuid, FrameBuffer& FrameBuf) const;
        };