Blame IlmImf/ImfTimeCode.h

Packit Service 6754ca
///////////////////////////////////////////////////////////////////////////
Packit Service 6754ca
//
Packit Service 6754ca
// Copyright (c) 2004, Industrial Light & Magic, a division of Lucas
Packit Service 6754ca
// Digital Ltd. LLC
Packit Service 6754ca
// 
Packit Service 6754ca
// All rights reserved.
Packit Service 6754ca
// 
Packit Service 6754ca
// Redistribution and use in source and binary forms, with or without
Packit Service 6754ca
// modification, are permitted provided that the following conditions are
Packit Service 6754ca
// met:
Packit Service 6754ca
// *       Redistributions of source code must retain the above copyright
Packit Service 6754ca
// notice, this list of conditions and the following disclaimer.
Packit Service 6754ca
// *       Redistributions in binary form must reproduce the above
Packit Service 6754ca
// copyright notice, this list of conditions and the following disclaimer
Packit Service 6754ca
// in the documentation and/or other materials provided with the
Packit Service 6754ca
// distribution.
Packit Service 6754ca
// *       Neither the name of Industrial Light & Magic nor the names of
Packit Service 6754ca
// its contributors may be used to endorse or promote products derived
Packit Service 6754ca
// from this software without specific prior written permission. 
Packit Service 6754ca
// 
Packit Service 6754ca
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
Packit Service 6754ca
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
Packit Service 6754ca
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
Packit Service 6754ca
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
Packit Service 6754ca
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
Packit Service 6754ca
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
Packit Service 6754ca
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
Packit Service 6754ca
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
Packit Service 6754ca
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
Packit Service 6754ca
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
Packit Service 6754ca
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Packit Service 6754ca
//
Packit Service 6754ca
///////////////////////////////////////////////////////////////////////////
Packit Service 6754ca
Packit Service 6754ca
Packit Service 6754ca
#ifndef INCLUDED_IMF_TIME_CODE_H
Packit Service 6754ca
#define INCLUDED_IMF_TIME_CODE_H
Packit Service 6754ca
Packit Service 6754ca
#include "ImfExport.h"
Packit Service 6754ca
#include "ImfNamespace.h"
Packit Service 6754ca
Packit Service 6754ca
//-----------------------------------------------------------------------------
Packit Service 6754ca
//
Packit Service 6754ca
//	class TimeCode
Packit Service 6754ca
// 	
Packit Service 6754ca
// 	A TimeCode object stores time and control codes as described
Packit Service 6754ca
// 	in SMPTE standard 12M-1999.  A TimeCode object contains the
Packit Service 6754ca
// 	following fields:
Packit Service 6754ca
//
Packit Service 6754ca
// 	    Time Address:
Packit Service 6754ca
//
Packit Service 6754ca
//		hours			integer, range 0 - 23
Packit Service 6754ca
//		minutes			integer, range 0 - 59
Packit Service 6754ca
//		seconds			integer, range 0 - 59
Packit Service 6754ca
//		frame 			integer, range 0 - 29
Packit Service 6754ca
//
Packit Service 6754ca
// 	    Flags:
Packit Service 6754ca
//
Packit Service 6754ca
// 		drop frame flag		boolean
Packit Service 6754ca
//		color frame flag	boolean
Packit Service 6754ca
//		field/phase flag	boolean
Packit Service 6754ca
//		bgf0			boolean
Packit Service 6754ca
//		bgf1			boolean
Packit Service 6754ca
//		bgf2			boolean
Packit Service 6754ca
//
Packit Service 6754ca
// 	    Binary groups for user-defined data and control codes:
Packit Service 6754ca
//
Packit Service 6754ca
//		binary group 1		integer, range 0 - 15
Packit Service 6754ca
//		binary group 2		integer, range 0 - 15
Packit Service 6754ca
//		...
Packit Service 6754ca
//		binary group 8		integer, range 0 - 15
Packit Service 6754ca
//
Packit Service 6754ca
//	Class TimeCode contains methods to convert between the fields
Packit Service 6754ca
//	listed above and a more compact representation where the fields
Packit Service 6754ca
//	are packed into two unsigned 32-bit integers.  In the packed
Packit Service 6754ca
//	integer representations, bit 0 is the least significant bit,
Packit Service 6754ca
//	and bit 31 is the most significant bit of the integer value.
Packit Service 6754ca
//
Packit Service 6754ca
//	The time address and flags fields can be packed in three
Packit Service 6754ca
//	different ways:
Packit Service 6754ca
//
Packit Service 6754ca
//	      bits	packing for	  packing for	    packing for
Packit Service 6754ca
//	    		24-frame 	  60-field 	    50-field
Packit Service 6754ca
//	    		film		  television	    television
Packit Service 6754ca
//
Packit Service 6754ca
//	     0 -  3	frame units	  frame units	    frame units
Packit Service 6754ca
//	     4 -  5	frame tens	  frame tens	    frame tens
Packit Service 6754ca
//	     6		unused, set to 0  drop frame flag   unused, set to 0
Packit Service 6754ca
//	     7		unused, set to 0  color frame flag  color frame flag
Packit Service 6754ca
//	     8 - 11	seconds units	  seconds units	    seconds units
Packit Service 6754ca
//	    12 - 14	seconds tens	  seconds tens	    seconds tens
Packit Service 6754ca
//	    15		phase flag	  field/phase flag  bgf0
Packit Service 6754ca
//	    16 - 19	minutes units	  minutes units	    minutes units
Packit Service 6754ca
//	    20 - 22	minutes tens	  minutes tens	    minutes tens
Packit Service 6754ca
//	    23		bgf0		  bgf0		    bgf2
Packit Service 6754ca
//	    24 - 27	hours units	  hours units	    hours units
Packit Service 6754ca
//	    28 - 29	hours tens	  hours tens	    hours tens
Packit Service 6754ca
//	    30		bgf1		  bgf1		    bgf1
Packit Service 6754ca
//	    31		bgf2		  bgf2		    field/phase flag
Packit Service 6754ca
//
Packit Service 6754ca
//	User-defined data and control codes are packed as follows:
Packit Service 6754ca
//
Packit Service 6754ca
//	      bits	field
Packit Service 6754ca
//
Packit Service 6754ca
//	     0 -  3	binary group 1
Packit Service 6754ca
//	     4 -  7	binary group 2
Packit Service 6754ca
//	     8 - 11	binary group 3
Packit Service 6754ca
//	    12 - 15	binary group 4
Packit Service 6754ca
//	    16 - 19	binary group 5
Packit Service 6754ca
//	    20 - 23	binary group 6
Packit Service 6754ca
//	    24 - 27	binary group 7
Packit Service 6754ca
//	    28 - 31	binary group 8
Packit Service 6754ca
//
Packit Service 6754ca
//-----------------------------------------------------------------------------
Packit Service 6754ca
Packit Service 6754ca
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_ENTER
Packit Service 6754ca
Packit Service 6754ca
   
Packit Service 6754ca
class IMF_EXPORT TimeCode
Packit Service 6754ca
{
Packit Service 6754ca
  public:
Packit Service 6754ca
Packit Service 6754ca
    //---------------------
Packit Service 6754ca
    // Bit packing variants
Packit Service 6754ca
    //---------------------
Packit Service 6754ca
Packit Service 6754ca
    enum Packing
Packit Service 6754ca
    {
Packit Service 6754ca
	TV60_PACKING,		// packing for 60-field television
Packit Service 6754ca
	TV50_PACKING,		// packing for 50-field television
Packit Service 6754ca
	FILM24_PACKING		// packing for 24-frame film
Packit Service 6754ca
    };
Packit Service 6754ca
Packit Service 6754ca
Packit Service 6754ca
    //-------------------------------------
Packit Service 6754ca
    // Constructors and assignment operator
Packit Service 6754ca
    //-------------------------------------
Packit Service 6754ca
Packit Service 6754ca
    TimeCode ();  // all fields set to 0 or false
Packit Service 6754ca
Packit Service 6754ca
    TimeCode (int hours,
Packit Service 6754ca
	      int minutes,
Packit Service 6754ca
	      int seconds,
Packit Service 6754ca
	      int frame,
Packit Service 6754ca
	      bool dropFrame = false,
Packit Service 6754ca
	      bool colorFrame = false,
Packit Service 6754ca
	      bool fieldPhase = false,
Packit Service 6754ca
	      bool bgf0 = false,
Packit Service 6754ca
	      bool bgf1 = false,
Packit Service 6754ca
	      bool bgf2 = false,
Packit Service 6754ca
	      int binaryGroup1 = 0,
Packit Service 6754ca
	      int binaryGroup2 = 0,
Packit Service 6754ca
	      int binaryGroup3 = 0,
Packit Service 6754ca
	      int binaryGroup4 = 0,
Packit Service 6754ca
	      int binaryGroup5 = 0,
Packit Service 6754ca
	      int binaryGroup6 = 0,
Packit Service 6754ca
	      int binaryGroup7 = 0,
Packit Service 6754ca
	      int binaryGroup8 = 0);
Packit Service 6754ca
Packit Service 6754ca
    TimeCode (unsigned int timeAndFlags,
Packit Service 6754ca
	      unsigned int userData = 0,
Packit Service 6754ca
	      Packing packing = TV60_PACKING);
Packit Service 6754ca
Packit Service 6754ca
    TimeCode (const TimeCode &other);
Packit Service 6754ca
Packit Service 6754ca
    TimeCode & operator = (const TimeCode &other);
Packit Service 6754ca
Packit Service 6754ca
Packit Service 6754ca
    //----------------------------
Packit Service 6754ca
    // Access to individual fields
Packit Service 6754ca
    //----------------------------
Packit Service 6754ca
Packit Service 6754ca
    int		hours () const;
Packit Service 6754ca
    void	setHours (int value);
Packit Service 6754ca
Packit Service 6754ca
    int		minutes () const;
Packit Service 6754ca
    void	setMinutes (int value);
Packit Service 6754ca
Packit Service 6754ca
    int		seconds () const;
Packit Service 6754ca
    void	setSeconds (int value);
Packit Service 6754ca
Packit Service 6754ca
    int		frame () const;
Packit Service 6754ca
    void	setFrame (int value);
Packit Service 6754ca
Packit Service 6754ca
    bool	dropFrame () const;
Packit Service 6754ca
    void	setDropFrame (bool value);
Packit Service 6754ca
Packit Service 6754ca
    bool	colorFrame () const;
Packit Service 6754ca
    void	setColorFrame (bool value);
Packit Service 6754ca
Packit Service 6754ca
    bool	fieldPhase () const;
Packit Service 6754ca
    void	setFieldPhase (bool value);
Packit Service 6754ca
Packit Service 6754ca
    bool	bgf0 () const;
Packit Service 6754ca
    void	setBgf0 (bool value);
Packit Service 6754ca
Packit Service 6754ca
    bool	bgf1 () const;
Packit Service 6754ca
    void	setBgf1 (bool value);
Packit Service 6754ca
Packit Service 6754ca
    bool	bgf2 () const;
Packit Service 6754ca
    void	setBgf2 (bool value);
Packit Service 6754ca
Packit Service 6754ca
    int		binaryGroup (int group) const; // group must be between 1 and 8
Packit Service 6754ca
    void	setBinaryGroup (int group, int value);
Packit Service 6754ca
Packit Service 6754ca
    
Packit Service 6754ca
    //---------------------------------
Packit Service 6754ca
    // Access to packed representations
Packit Service 6754ca
    //---------------------------------
Packit Service 6754ca
Packit Service 6754ca
    unsigned int	timeAndFlags (Packing packing = TV60_PACKING) const;
Packit Service 6754ca
Packit Service 6754ca
    void		setTimeAndFlags (unsigned int value,
Packit Service 6754ca
					 Packing packing = TV60_PACKING);
Packit Service 6754ca
Packit Service 6754ca
    unsigned int	userData () const;
Packit Service 6754ca
Packit Service 6754ca
    void		setUserData (unsigned int value);
Packit Service 6754ca
    
Packit Service 6754ca
    
Packit Service 6754ca
    //---------
Packit Service 6754ca
    // Equality
Packit Service 6754ca
    //---------
Packit Service 6754ca
    
Packit Service 6754ca
    bool		operator == (const TimeCode &v) const;    
Packit Service 6754ca
    bool		operator != (const TimeCode &v) const;
Packit Service 6754ca
    
Packit Service 6754ca
  private:
Packit Service 6754ca
Packit Service 6754ca
    unsigned int	_time;
Packit Service 6754ca
    unsigned int	_user;
Packit Service 6754ca
};
Packit Service 6754ca
Packit Service 6754ca
Packit Service 6754ca
Packit Service 6754ca
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_EXIT
Packit Service 6754ca
Packit Service 6754ca
Packit Service 6754ca
Packit Service 6754ca
Packit Service 6754ca
Packit Service 6754ca
#endif