PBRT
/home/felix/UBC/projects/AdaptiveLightfieldSampling/pbrt_v2/src/3rdparty/openexr-1.7.0/ImfTimeCode.h
00001 
00002 //
00003 // Copyright (c) 2004, Industrial Light & Magic, a division of Lucas
00004 // Digital Ltd. LLC
00005 // 
00006 // All rights reserved.
00007 // 
00008 // Redistribution and use in source and binary forms, with or without
00009 // modification, are permitted provided that the following conditions are
00010 // met:
00011 // *       Redistributions of source code must retain the above copyright
00012 // notice, this list of conditions and the following disclaimer.
00013 // *       Redistributions in binary form must reproduce the above
00014 // copyright notice, this list of conditions and the following disclaimer
00015 // in the documentation and/or other materials provided with the
00016 // distribution.
00017 // *       Neither the name of Industrial Light & Magic nor the names of
00018 // its contributors may be used to endorse or promote products derived
00019 // from this software without specific prior written permission. 
00020 // 
00021 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00022 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00023 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
00024 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
00025 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
00026 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
00027 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
00028 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
00029 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00030 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00031 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00032 //
00034 
00035 
00036 #ifndef INCLUDED_IMF_TIME_CODE_H
00037 #define INCLUDED_IMF_TIME_CODE_H
00038 
00039 //-----------------------------------------------------------------------------
00040 //
00041 //      class TimeCode
00042 //      
00043 //      A TimeCode object stores time and control codes as described
00044 //      in SMPTE standard 12M-1999.  A TimeCode object contains the
00045 //      following fields:
00046 //
00047 //          Time Address:
00048 //
00049 //              hours                   integer, range 0 - 23
00050 //              minutes                 integer, range 0 - 59
00051 //              seconds                 integer, range 0 - 59
00052 //              frame                   integer, range 0 - 29
00053 //
00054 //          Flags:
00055 //
00056 //              drop frame flag         boolean
00057 //              color frame flag        boolean
00058 //              field/phase flag        boolean
00059 //              bgf0                    boolean
00060 //              bgf1                    boolean
00061 //              bgf2                    boolean
00062 //
00063 //          Binary groups for user-defined data and control codes:
00064 //
00065 //              binary group 1          integer, range 0 - 15
00066 //              binary group 2          integer, range 0 - 15
00067 //              ...
00068 //              binary group 8          integer, range 0 - 15
00069 //
00070 //      Class TimeCode contains methods to convert between the fields
00071 //      listed above and a more compact representation where the fields
00072 //      are packed into two unsigned 32-bit integers.  In the packed
00073 //      integer representations, bit 0 is the least significant bit,
00074 //      and bit 31 is the most significant bit of the integer value.
00075 //
00076 //      The time address and flags fields can be packed in three
00077 //      different ways:
00078 //
00079 //            bits      packing for       packing for       packing for
00080 //                      24-frame          60-field          50-field
00081 //                      film              television        television
00082 //
00083 //           0 -  3     frame units       frame units       frame units
00084 //           4 -  5     frame tens        frame tens        frame tens
00085 //           6          unused, set to 0  drop frame flag   unused, set to 0
00086 //           7          unused, set to 0  color frame flag  color frame flag
00087 //           8 - 11     seconds units     seconds units     seconds units
00088 //          12 - 14     seconds tens      seconds tens      seconds tens
00089 //          15          phase flag        field/phase flag  bgf0
00090 //          16 - 19     minutes units     minutes units     minutes units
00091 //          20 - 22     minutes tens      minutes tens      minutes tens
00092 //          23          bgf0              bgf0              bgf2
00093 //          24 - 27     hours units       hours units       hours units
00094 //          28 - 29     hours tens        hours tens        hours tens
00095 //          30          bgf1              bgf1              bgf1
00096 //          31          bgf2              bgf2              field/phase flag
00097 //
00098 //      User-defined data and control codes are packed as follows:
00099 //
00100 //            bits      field
00101 //
00102 //           0 -  3     binary group 1
00103 //           4 -  7     binary group 2
00104 //           8 - 11     binary group 3
00105 //          12 - 15     binary group 4
00106 //          16 - 19     binary group 5
00107 //          20 - 23     binary group 6
00108 //          24 - 27     binary group 7
00109 //          28 - 31     binary group 8
00110 //
00111 //-----------------------------------------------------------------------------
00112 
00113 namespace Imf {
00114 
00115    
00116 class TimeCode
00117 {
00118   public:
00119 
00120     //---------------------
00121     // Bit packing variants
00122     //---------------------
00123 
00124     enum Packing
00125     {
00126         TV60_PACKING,           // packing for 60-field television
00127         TV50_PACKING,           // packing for 50-field television
00128         FILM24_PACKING          // packing for 24-frame film
00129     };
00130 
00131 
00132     //-------------------------------------
00133     // Constructors and assignment operator
00134     //-------------------------------------
00135 
00136     TimeCode ();  // all fields set to 0 or false
00137 
00138     TimeCode (int hours,
00139               int minutes,
00140               int seconds,
00141               int frame,
00142               bool dropFrame = false,
00143               bool colorFrame = false,
00144               bool fieldPhase = false,
00145               bool bgf0 = false,
00146               bool bgf1 = false,
00147               bool bgf2 = false,
00148               int binaryGroup1 = 0,
00149               int binaryGroup2 = 0,
00150               int binaryGroup3 = 0,
00151               int binaryGroup4 = 0,
00152               int binaryGroup5 = 0,
00153               int binaryGroup6 = 0,
00154               int binaryGroup7 = 0,
00155               int binaryGroup8 = 0);
00156 
00157     TimeCode (unsigned int timeAndFlags,
00158               unsigned int userData = 0,
00159               Packing packing = TV60_PACKING);
00160 
00161     TimeCode (const TimeCode &other);
00162 
00163     TimeCode & operator = (const TimeCode &other);
00164 
00165 
00166     //----------------------------
00167     // Access to individual fields
00168     //----------------------------
00169 
00170     int         hours () const;
00171     void        setHours (int value);
00172 
00173     int         minutes () const;
00174     void        setMinutes (int value);
00175 
00176     int         seconds () const;
00177     void        setSeconds (int value);
00178 
00179     int         frame () const;
00180     void        setFrame (int value);
00181 
00182     bool        dropFrame () const;
00183     void        setDropFrame (bool value);
00184 
00185     bool        colorFrame () const;
00186     void        setColorFrame (bool value);
00187 
00188     bool        fieldPhase () const;
00189     void        setFieldPhase (bool value);
00190 
00191     bool        bgf0 () const;
00192     void        setBgf0 (bool value);
00193 
00194     bool        bgf1 () const;
00195     void        setBgf1 (bool value);
00196 
00197     bool        bgf2 () const;
00198     void        setBgf2 (bool value);
00199 
00200     int         binaryGroup (int group) const; // group must be between 1 and 8
00201     void        setBinaryGroup (int group, int value);
00202 
00203     
00204     //---------------------------------
00205     // Access to packed representations
00206     //---------------------------------
00207 
00208     unsigned int        timeAndFlags (Packing packing = TV60_PACKING) const;
00209 
00210     void                setTimeAndFlags (unsigned int value,
00211                                          Packing packing = TV60_PACKING);
00212 
00213     unsigned int        userData () const;
00214 
00215     void                setUserData (unsigned int value);
00216 
00217   private:
00218 
00219     unsigned int        _time;
00220     unsigned int        _user;
00221 };
00222 
00223 
00224 } // namespace Imf
00225 
00226 #endif