1/****************************************************************************************
2
3 Copyright (C) 2015 Autodesk, Inc.
4 All rights reserved.
5
6 Use of this software is subject to the terms of the Autodesk license agreement
7 provided at the time of installation or download, or which otherwise accompanies
8 this software in either electronic or hard copy form.
9
10****************************************************************************************/
11
12//! \file fbxtimecode.h
13#ifndef _FBXSDK_CORE_BASE_TIMECODE_H_
14#define _FBXSDK_CORE_BASE_TIMECODE_H_
15
16#include <fbxsdk/fbxsdk_def.h>
17
18#include <fbxsdk/fbxsdk_nsbegin.h>
19
20#define FBXSDK_TC_ZERO FBXSDK_LONGLONG(0)
21#define FBXSDK_TC_EPSILON FBXSDK_LONGLONG(1)
22#define FBXSDK_TC_MINFINITY FBXSDK_LONGLONG(-0x7fffffffffffffff)
23#define FBXSDK_TC_INFINITY FBXSDK_LONGLONG(0x7fffffffffffffff)
24#define FBXSDK_TC_FIX_DEN FBXSDK_LONGLONG(100000000)
25
26#define FBXSDK_TC_MILLISECOND FBXSDK_LONGLONG(46186158)
27#define FBXSDK_TC_SECOND FbxLongLong(FBXSDK_TC_MILLISECOND*1000)
28#define FBXSDK_TC_MINUTE FbxLongLong(FBXSDK_TC_SECOND*60)
29#define FBXSDK_TC_HOUR FbxLongLong(FBXSDK_TC_MINUTE*60)
30#define FBXSDK_TC_DAY FbxLongLong(FBXSDK_TC_HOUR*24)
31
32// Frame @ 30 Hz
33#define FBXSDK_TC_NTSC_FIELD FbxLongLong(FBXSDK_TC_SECOND/30/2)
34#define FBXSDK_TC_NTSC_FRAME FbxLongLong(FBXSDK_TC_SECOND/30)
35
36// Frame @ 29.9700299700 Hz
37#define FBXSDK_TC_MNTSC_FIELD FbxLongLong(FBXSDK_TC_MNTSC_FRAME/2)
38#define FBXSDK_TC_MNTSC_FRAME FbxLongLong(FBXSDK_TC_SECOND/30*1001/1000)
39#define FBXSDK_TC_MNTSC_2_FRAMES FbxLongLong(FBXSDK_TC_MNTSC_FRAME*2)
40#define FBXSDK_TC_MNTSC_30_FRAMES FbxLongLong(FBXSDK_TC_MNTSC_FRAME*30)
41#define FBXSDK_TC_MNTSC_1798_FRAMES FbxLongLong(FBXSDK_TC_MNTSC_FRAME*1798) // leap minute
42#define FBXSDK_TC_MNTSC_1800_FRAMES FbxLongLong(FBXSDK_TC_MNTSC_FRAME*1800) // ~1 minute
43#define FBXSDK_TC_MNTSC_17982_FRAMES FbxLongLong(FBXSDK_TC_MNTSC_FRAME*17982) // ~10 minutes
44#define FBXSDK_TC_MNTSC_107892_FRAMES FbxLongLong(FBXSDK_TC_MNTSC_FRAME*107892) // ~1 hour
45#define FBXSDK_TC_MNTSC_108000_FRAMES FbxLongLong(FBXSDK_TC_MNTSC_FRAME*108000)
46
47// For 29.9700299700 non-drop, btw : same values as with 23.976
48#define FBXSDK_TC_MNTSC_1_SECOND FbxLongLong(FBXSDK_TC_MNTSC_FRAME*30) // 1 frame * 30
49#define FBXSDK_TC_MNTSC_1_MINUTE FbxLongLong(FBXSDK_TC_MNTSC_1_SECOND*60) // 1 minute (1800 frames)
50#define FBXSDK_TC_MNTSC_1_HOUR FbxLongLong(FBXSDK_TC_MNTSC_1_SECOND*3600) // 1 hour
51
52#define FBXSDK_TC_MNTSC_NUM FbxULong(FBXSDK_TC_FIX_DEN*1000*30/1001)
53#define FBXSDK_TC_MNTSC_DEN FBXSDK_TC_FIX_DEN
54
55// Frame @ 25 Hz
56#define FBXSDK_TC_PAL_FIELD FbxLongLong(FBXSDK_TC_SECOND/25/2)
57#define FBXSDK_TC_PAL_FRAME FbxLongLong(FBXSDK_TC_SECOND/25)
58
59// Frame @ 24 Hz
60#define FBXSDK_TC_FILM_FRAME FbxLongLong(FBXSDK_TC_SECOND/24)
61
62// Frame @ 23.9760239760 Hz
63#define FBXSDK_TC_MFILM_FIELD FbxLongLong(FBXSDK_TC_MFILM_FRAME/2)
64#define FBXSDK_TC_MFILM_FRAME FbxLongLong(FBXSDK_TC_SECOND/24*1001/1000)
65#define FBXSDK_TC_MFILM_1_SECOND FbxLongLong(FBXSDK_TC_MFILM_FRAME*24) // 1 frame * 24
66#define FBXSDK_TC_MFILM_1_MINUTE FbxLongLong(FBXSDK_TC_MFILM_1_SECOND*60) // 1 minute (1440 frames)
67#define FBXSDK_TC_MFILM_1_HOUR FbxLongLong(FBXSDK_TC_MFILM_1_SECOND*3600) // 1 hour
68
69#define FBXSDK_TC_MFILM_NUM FbxULong(FBXSDK_TC_FIX_DEN*1000*24/1001)
70#define FBXSDK_TC_MFILM_DEN FBXSDK_TC_FIX_DEN
71
72//////////////////////////////////////////////////////////////////////////////////////////
73
74#define FBXSDK_TC_REM(quot, num, den) ((quot) = (num) / (den), (quot) * (den))
75#define FBXSDK_TC_HOUR_REM(quot, num, den) ((quot) = ((num - (-FbxLongLong(num < 0) & (den - 1))) / (den)), (quot) * (den))
76
77FBXSDK_DLL FbxLongLong FbxTCSeconds(FbxLongLong pTime);
78FBXSDK_DLL FbxLongLong FbxTCMinutes(FbxLongLong pTime);
79FBXSDK_DLL FbxLongLong FbxTCHours(FbxLongLong pTime);
80FBXSDK_DLL FbxLongLong FbxTCSetRate(int pHour, int pMinute, int pSecond, FbxLongLong pFrame, FbxLongLong pPeriod);
81FBXSDK_DLL FbxLongLong FbxTCGetRate(FbxLongLong pTime, int& pHour, int& pMinute, int& pSecond, int& pFrame, FbxLongLong pPeriod);
82FBXSDK_DLL FbxLongLong FbxTCSetNTSC(int pHour, int pMinute, int pSecond, FbxLongLong pFrame, int pField);
83FBXSDK_DLL FbxLongLong FbxTCGetNTSC(FbxLongLong pTime, int& pHour, int& pMinute, int& pSecond, int& pFrame, int& pField);
84FBXSDK_DLL FbxLongLong FbxTCSetMNTSCnd(int pHour, int pMinute, int pSecond, FbxLongLong pFrame, int pField);
85FBXSDK_DLL FbxLongLong FbxTCGetMNTSCnd(FbxLongLong pTime, int& pHour, int& pMinute, int& pSecond, int& pFrame, int& pField);
86FBXSDK_DLL FbxLongLong FbxTCSetMNTSC_2Xnd(int pHour, int pMinute, int pSecond, FbxLongLong pFrame, int pField);
87FBXSDK_DLL FbxLongLong FbxTCGetMNTSC_2Xnd(FbxLongLong pTime, int& pHour, int& pMinute, int& pSecond, int& pFrame, int& pField);
88FBXSDK_DLL FbxLongLong FbxTCSetMNTSC(int pHour, int pMinute, int pSecond, FbxLongLong pFrame, int pField);
89FBXSDK_DLL FbxLongLong FbxTCGetMNTSC(FbxLongLong pTime, int& pHour, int& pMinute, int& pSecond, int& pFrame, int& pField);
90FBXSDK_DLL FbxLongLong FbxTCSetPAL(int pHour, int pMinute, int pSecond, FbxLongLong pFrame, int pField);
91FBXSDK_DLL FbxLongLong FbxTCGetPAL(FbxLongLong pTime, int& pHour, int& pMinute, int& pSecond, int& pFrame, int& pField);
92FBXSDK_DLL FbxLongLong FbxTCSetFILM(int pHour, int pMinute, int pSecond, FbxLongLong pFrame);
93FBXSDK_DLL FbxLongLong FbxTCGetFILM(FbxLongLong pTime, int& pHour, int& pMinute, int& pSecond, int& pFrame);
94FBXSDK_DLL FbxLongLong FbxTCSetFILMND(int pHour, int pMinute, int pSecond, FbxLongLong pFrame, int pField);
95FBXSDK_DLL FbxLongLong FbxTCGetFILMND(FbxLongLong pTime, int& pHour, int& pMinute, int& pSecond, int& pFrame, int& pField);
96
97#include <fbxsdk/fbxsdk_nsend.h>
98
99#endif /* _FBXSDK_CORE_BASE_TIMECODE_H_ */
100