X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2FAS_DCP.h;h=383f270b6ca25b3e8f89722687db37be9868b495;hb=9ae565acc75f39fd0e043135761aa3fb62e09025;hp=3cbc4810368daa56fb8a8d961936a5b6f6a73f22;hpb=61a1033e5c75e8318340a3789c35ec6d008432cd;p=asdcplib.git diff --git a/src/AS_DCP.h b/src/AS_DCP.h index 3cbc481..383f270 100755 --- a/src/AS_DCP.h +++ b/src/AS_DCP.h @@ -1,5 +1,5 @@ /* -Copyright (c) 2003-2009, John Hurst +Copyright (c) 2003-2010, John Hurst All rights reserved. Redistribution and use in source and binary forms, with or without @@ -246,6 +246,18 @@ namespace ASDCP { inline bool operator!=(const Rational& rhs) const { return ( rhs.Numerator != Numerator || rhs.Denominator != Denominator ); } + + inline bool operator<(const Rational& rhs) { + if ( Numerator < rhs.Numerator ) return true; + if ( Numerator == rhs.Numerator && Denominator < rhs.Denominator ) return true; + return false; + } + + inline bool operator>(const Rational& rhs) { + if ( Numerator > rhs.Numerator ) return true; + if ( Numerator == rhs.Numerator && Denominator > rhs.Denominator ) return true; + return false; + } }; // common edit rates, use these instead of hard coded constants @@ -255,9 +267,9 @@ namespace ASDCP { const Rational SampleRate_48k(48000,1); const Rational SampleRate_96k(96000,1); - // Additional frame rates, see SMPTE 428-11 - // These rates are new and not supported by all systems. Do not assume that a package - // made using on of these rates will work just anywhere! + // Additional frame rates, see ST 428-11 + // These rates are new and not supported by all systems. Do not assume that + // a package made using on of these rates will work just anywhere! const Rational EditRate_25(25,1); const Rational EditRate_30(30,1); const Rational EditRate_50(50,1); @@ -785,7 +797,7 @@ namespace ASDCP { struct AudioDescriptor { - Rational SampleRate; // rate of frame wrapping + Rational EditRate; // rate of frame wrapping Rational AudioSamplingRate; // rate of audio sample ui32_t Locked; // ui32_t ChannelCount; // number of channels @@ -811,7 +823,7 @@ namespace ASDCP { // Returns number of samples per frame of data described by ADesc inline ui32_t CalcSamplesPerFrame(const AudioDescriptor& ADesc) { - double tmpd = ADesc.AudioSamplingRate.Quotient() / ADesc.SampleRate.Quotient(); + double tmpd = ADesc.AudioSamplingRate.Quotient() / ADesc.EditRate.Quotient(); return (ui32_t)ceil(tmpd); } @@ -1346,10 +1358,15 @@ namespace ASDCP { DCSubtitleParser(); virtual ~DCSubtitleParser(); - // Opens the XML file for reading, parse data to provide a complete + // Opens an XML file for reading, parses data to provide a complete // set of stream metadata for the MXFWriter below. Result_t OpenRead(const char* filename) const; + // Parses an XML document to provide a complete set of stream metadata + // for the MXFWriter below. The optional filename argument is used to + // initialize the default resource resolver (see ReadAncillaryResource). + Result_t OpenRead(const std::string& xml_doc, const char* filename = 0) const; + // Fill a TimedTextDescriptor struct with the values from the file's contents. // Returns RESULT_INIT if the file is not open. Result_t FillTimedTextDescriptor(TimedTextDescriptor&) const;