Hand-merge changes from master (110dc70..979739e)
authorCarl Hetherington <cth@carlh.net>
Fri, 16 May 2014 10:38:35 +0000 (11:38 +0100)
committerCarl Hetherington <cth@carlh.net>
Fri, 16 May 2014 10:38:35 +0000 (11:38 +0100)
asdcplib/src/AS_DCP_PCM.cpp
src/local_time.cc
src/raw_convert.h

index 8639cb0f2296a6b8d2a96651b16867e8308e3b0b..385d9035739ae658295d288d885a2c7a9ff00e29 100755 (executable)
@@ -232,6 +232,10 @@ ASDCP::PCM::MXFReader::h__Reader::OpenRead(const char* filename)
        }
     }
 
+  /* This check has been removed so that DCP-o-matic can use any edit rate
+     it wants.
+  */
+#if 0  
   // check for sample/frame rate sanity
   if ( ASDCP_SUCCESS(result)
        && m_ADesc.EditRate != EditRate_24
@@ -260,6 +264,7 @@ ASDCP::PCM::MXFReader::h__Reader::OpenRead(const char* filename)
          return RESULT_FORMAT;
        }
     }
+#endif  
 
   if( ASDCP_SUCCESS(result) )
     result = InitMXFIndex();
@@ -483,6 +488,10 @@ ASDCP::PCM::MXFWriter::h__Writer::SetSourceStream(const AudioDescriptor& ADesc)
   if ( ! m_State.Test_INIT() )
     return RESULT_STATE;
 
+#if 0
+  /* This check has been removed so that DCP-o-matic can use anye dit rate
+     it wants.
+  */
   if ( ADesc.EditRate != EditRate_24
        && ADesc.EditRate != EditRate_25
        && ADesc.EditRate != EditRate_30
@@ -498,6 +507,7 @@ ASDCP::PCM::MXFWriter::h__Writer::SetSourceStream(const AudioDescriptor& ADesc)
                             ADesc.EditRate.Numerator, ADesc.EditRate.Denominator);
       return RESULT_RAW_FORMAT;
     }
+#endif  
 
   if ( ADesc.AudioSamplingRate != SampleRate_48k && ADesc.AudioSamplingRate != SampleRate_96k )
     {
index 2388825cea4fdddb7be9c7946a52c222b2d3ae8f..fe58c07736388622d60b0d90e20c832044d584e1 100644 (file)
@@ -20,6 +20,7 @@
 #include "local_time.h"
 #include "exceptions.h"
 #include <boost/lexical_cast.hpp>
+#include <boost/date_time/c_local_time_adjustor.hpp>
 #include <cstdio>
 
 using std::string;
@@ -56,28 +57,12 @@ LocalTime::LocalTime (boost::posix_time::ptime t)
 void
 LocalTime::set_local_time_zone ()
 {
-       time_t now = time (0);
-       struct tm* tm = localtime (&now);
-
-       int offset = 0;
-       
-#ifdef LIBDCP_POSIX
-       offset = tm->tm_gmtoff / 60;
-#else
-       TIME_ZONE_INFORMATION tz;
-       GetTimeZoneInformation (&tz);
-       offset = tz.Bias;
-#endif
+       boost::posix_time::ptime const utc_now = boost::posix_time::second_clock::universal_time ();
+       boost::posix_time::ptime const now = boost::date_time::c_local_adjustor<boost::posix_time::ptime>::utc_to_local (utc_now);
+       boost::posix_time::time_duration offset = now - utc_now;
 
-       bool const negative = offset < 0;
-       offset = negative ? -offset : offset;
-
-       _tz_hour = offset / 60;
-       _tz_minute = offset % 60;
-
-       if (negative) {
-               _tz_hour = -_tz_hour;
-       }
+       _tz_hour = offset.hours ();
+       _tz_minute = offset.minutes ();
 }
 
 /** @param s A string of the form 2013-01-05T18:06:59+04:00 */
index 68bbaf7a13d61a2f2a16e2ae3ab65df9148a1cd2..37cddbf07cfd26db5e6275434fdaa04727915e93 100644 (file)
@@ -18,6 +18,7 @@
 */
 
 #include <sstream>
+#include <iomanip>
 
 namespace dcp {
 
@@ -30,6 +31,7 @@ raw_convert (Q v)
 {
        std::stringstream s;
        s.imbue (std::locale::classic ());
+       s << std::setprecision (16);
        s << v;
        P r;
        s >> r;