AJA NTV2 SDK  17.1.1.1245
NTV2 SDK 17.1.1.1245
ntv2rp188.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: MIT */
8 #ifndef __NTV2_RP188_
9 #define __NTV2_RP188_
10 
11 #include <string>
12 #include <sstream>
13 
14 #include "ajaexport.h"
15 #include "ajatypes.h"
16 #include "ntv2enums.h"
17 #include "ntv2publicinterface.h"
18 
19 
20 
21 #if defined(AJALinux)
22 # include <stdlib.h> /* malloc/free */
23 # include <string.h> /* memset, memcpy */
24 #endif
25 
26 
27 typedef enum
28 {
39 
40 typedef enum
41 {
42  kTCBurnTimecode, // display current timecode
43  kTCBurnUserBits, // display current user bits
44  kTCBurnFrameCount, // display current frame count
45  kTCBurnBlank // display --:--:--:--
47 
48 
49 const int64_t kDefaultFrameCount = 0x80000000;
50 
51 
52 //--------------------------------------------------------------------------------------------------------------------
53 // class CRP188
54 //--------------------------------------------------------------------------------------------------------------------
56 {
57 public:
58  // Constructors
59  CRP188 ();
60  CRP188 (const RP188_STRUCT & rp188, const TimecodeFormat tcFormat = kTCFormat30fps);
61  CRP188 (const NTV2_RP188 & rp188, const TimecodeFormat tcFormat = kTCFormat30fps);
62  CRP188 (const std::string & sRP188, const TimecodeFormat tcFormat = kTCFormat30fps);
63  CRP188 (ULWord ulFrms, ULWord ulSecs, ULWord ulMins, ULWord ulHrs, const TimecodeFormat tcFormat = kTCFormat30fps);
64  CRP188 (ULWord frames, const TimecodeFormat tcFormat = kTCFormat30fps);
65  virtual ~CRP188();
66  void Init ();
67  bool operator==( const CRP188& s);
68 
69  // Setters
70  void SetRP188 (ULWord ulFrms, ULWord ulSecs, ULWord ulMins, ULWord ulHrs,
71  NTV2FrameRate frameRate, const bool bDropFrame = false, const bool bSMPTE372 = false);
72  void SetRP188 (const RP188_STRUCT & rp188, const TimecodeFormat tcFormat = kTCFormatUnknown);
73  void SetRP188 (const NTV2_RP188 & rp188, const TimecodeFormat tcFormat = kTCFormatUnknown);
74  void SetRP188 (const std::string &sRP188, const TimecodeFormat tcFormat = kTCFormatUnknown);
75  void SetRP188 (ULWord ulFrms, ULWord ulSecs, ULWord ulMins, ULWord ulHrs, const TimecodeFormat tcFormat = kTCFormatUnknown);
76  void SetRP188 (ULWord frames, const TimecodeFormat tcFormat = kTCFormatUnknown);
77 
78  void SetDropFrame (bool bDropFrameFlag);
79  void SetColorFrame (bool bColorFrameFlag);
80  void SetVaricamFrameActive (bool bVaricamActive, ULWord frame);
81  void SetVaricamRate (NTV2FrameRate frameRate);
82  void SetFieldID (ULWord fieldID);
83  bool GetFieldID (void);
84  void SetBFGBits (bool bBFG0, bool bBFG1, bool bBFG2);
85  void SetSource (UByte src);
86  void SetOutputFilter (UByte src);
87 
88  // Getters
89  bool GetRP188Str (std::string & sRP188) const;
90  const char * GetRP188CString () const;
91  bool GetRP188Secs (ULWord & ulSecs) const;
92  bool GetRP188Frms (ULWord & ulFrms) const;
93  bool GetRP188Mins (ULWord & ulMins) const;
94  bool GetRP188Hrs (ULWord & ulHrs) const;
95  bool GetRP188Reg (RP188_STRUCT & outRP188) const;
96  bool GetRP188Reg (NTV2_RP188 & outRP188) const;
97  bool GetFrameCount (ULWord & frameCount);
98  ULWord MaxFramesPerDay (TimecodeFormat format = kTCFormatUnknown) const;
99  void ConvertTimecode (ULWord & frameCount, TimecodeFormat format, ULWord hours, ULWord minutes, ULWord seconds, ULWord frames);
100  void ConvertFrameCount (ULWord frameCount, TimecodeFormat format, ULWord & hours, ULWord & minutes, ULWord & seconds, ULWord & frames);
101  ULWord AddFrames (ULWord frameCount);
102  ULWord SubtractFrames (ULWord frameCount);
103  bool GetRP188UserBitsStr (std::string & sRP188UB);
104  const char * GetRP188UserBitsCString ();
105  UByte GetSource () const ;
106  UByte GetOutputFilter () const ;
107  TimecodeFormat GetTimecodeFormat() { return _tcFormat; }
108 
109  // these tests are ONLY valid if the CRP188 object is instantiated or set with an RP188_STRUCT
110  bool IsFreshRP188 (void)
111  { return(_bFresh); } // true if RP188 data is fresh this past frame
112  bool VaricamFrame0 (void)
113  { return(_bVaricamActiveF0); } // true if Varicam "Frame0 Active" bit is set
114  bool VaricamFrame1 (void)
115  { return(_bVaricamActiveF1); } // true if Varicam "Frame1 Active" bit is set
116  ULWord VaricamFrameRate (void);
117  NTV2FrameRate defaultFrameRateForTimecodeFormat (TimecodeFormat format = kTCFormatUnknown) const;
118  bool FormatIsDropFrame (TimecodeFormat format = kTCFormatUnknown) const;
119  bool FormatIs60_50fps (TimecodeFormat format = kTCFormatUnknown) const;
120  bool FormatIsPAL (TimecodeFormat format = kTCFormatUnknown) const;
121 
123  { return(_fieldID); } // fieldID bit
124  bool DropFrame (void)
125  { return(_bDropFrameFlag); } // drop frame bit
126  bool ColorFrame (void)
127  { return(_bColorFrameFlag); } // color frame bit
128  ULWord BinaryGroup (ULWord smpteNum);
129 
130  // For historical reasons, calling SetRP188 clears the user bits, so a call to either of these two functions
131  // should be done after the timecode value is set
132  bool SetBinaryGroup (ULWord smpteNum, ULWord bits);
133  bool SetUserBits (ULWord bits); // eight groups of four bits each
134 
135  ULWord UDW (ULWord smpteUDW);
136  ULWord FramesPerSecond (TimecodeFormat format = kTCFormatUnknown) const;
137  NTV2FrameRate DefaultFrameRateForTimecodeFormat (TimecodeFormat format = kTCFormatUnknown) const;
138 
139  // Modifiers
140  bool InitBurnIn (NTV2FrameBufferFormat frameBufferFormat, NTV2FrameDimensions frameDimensions, LWord percentY = 0);
141  void writeV210Pixel (char **pBytePtr, int x, int c, int y);
142  bool BurnTC (char *pBaseVideoAddress, int rowBytes, TimecodeBurnMode burnMode, int64_t frameCount = kDefaultFrameCount, bool bDisplay60_50fpsAs30_25 = false);
143  void CopyDigit (char *pDigit, int digitWidth, int digitHeight, char *pFrameBuff, int fbRowBytes);
144  std::string GetTimeCodeString(bool bDisplay60_50fpsAs30_25 = false);
145 
146 private:
147  void ConvertTcStrToVal (void); // converts _sHMSF to _ulVal
148  void ConvertTcStrToReg (void); // converts _sHMSF to _rp188
149  void RP188ToUserBits (void); // derives _ulUserBits and _sUserBits from RP188 struct
150 
151 
152 private:
153  TimecodeFormat _tcFormat; // fps, drop- or non-drop frame
154  bool _bInitialized; // if constructed with no args, set to false
155  bool _bFresh; // true if hardware told us this was new ANC data (not just what was lying around in the registers)
156  //bool _bDropFrame; // we have to be told whether we are df or ndf
157  //bool _b50Hz; // if true, interpret FieldID and Binary Group Flags per 50 Hz spec
158 
159  // RP188 user bits
160  bool _bVaricamActiveF0; // Varicam "Active Frame 0" user bit flag
161  bool _bVaricamActiveF1; // Varicam "Active Frame 1" user bit flag
162  ULWord _fieldID; // FieldID bit: '0' or '1'
163  bool _bDropFrameFlag; // Drop Frame bit: '0' or '1'
164  bool _bColorFrameFlag; // Color Frame bit: '0' or '1'
165  ULWord _varicamRate; // Varicam rate expressed as bits [0..3] 1 units, bits [4..7] tens unit.
166 
167  std::string _sHMSF; // hour:minute:second:frame in string format
168  std::string _sUserBits; // Binary Groups 8-1 in string format
169  ULWord _ulVal[4]; // [0]=frame, [1]=seconds, etc.
170  ULWord _ulUserBits[8]; // [0] = Binary Group 1, [1] = Binary Group 2, etc. (note: SMPTE labels them 1 - 8)
171  RP188_STRUCT _rp188; // AJA native format
172 
173  bool _bRendered; // set 'true' when Burn-In character map has been rendered
174  char * _pCharRenderMap; // ptr to rendered Burn-In character set
175  NTV2FrameBufferFormat _charRenderFBF; // frame buffer format of rendered characters
176  ULWord _charRenderHeight; // frame height for which rendered characters were rendered
177  ULWord _charRenderWidth; // frame width for which rendered characters were rendered
178  int _charWidthBytes; // rendered character width in bytes
179  int _charHeightLines; // rendered character height in frame lines
180  int _charPositionX; // offset (in bytes) from left side of screen to first burn-in character
181  int _charPositionY; // offset (in lines) from top of screen to top of burn-in characters
182 }; // CRP188
183 
190 AJAExport std::ostream & operator << (std::ostream & outputStream, const CRP188 & inObj);
191 
192 #endif // __NTV2_RP188_
CRP188::ColorFrame
bool ColorFrame(void)
Definition: ntv2rp188.h:126
LWord
int32_t LWord
Definition: ajatypes.h:252
ajaexport.h
Defines the import/export macros for producing DLLs or LIBs.
CRP188::VaricamFrame0
bool VaricamFrame0(void)
Definition: ntv2rp188.h:112
kTCFormat24fps
@ kTCFormat24fps
Definition: ntv2rp188.h:30
NTV2FrameDimensions
Describes the horizontal and vertical size dimensions of a raster, bitmap, frame or image.
Definition: ntv2publicinterface.h:5658
kTCFormat30fpsDF
@ kTCFormat30fpsDF
Definition: ntv2rp188.h:33
NTV2FrameBufferFormat
NTV2FrameBufferFormat
Identifies a particular video frame buffer format. See Device Frame Buffer Formats for details.
Definition: ntv2enums.h:207
nlohmann::json_abiNLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON_v3_11_NLOHMANN_JSON_VERSION_PATCH::operator==
bool operator==(const json_pointer< RefStringTypeLhs > &lhs, const json_pointer< RefStringTypeRhs > &rhs) noexcept
Definition: json.hpp:14737
kTCFormat30fps
@ kTCFormat30fps
Definition: ntv2rp188.h:32
TimecodeFormat
TimecodeFormat
Definition: ntv2rp188.h:27
kTCFormat48fps
@ kTCFormat48fps
Definition: ntv2rp188.h:34
operator<<
std::ostream & operator<<(std::ostream &outputStream, const CRP188 &inObj)
Prints the given CRP188's contents into the given output stream.
Definition: ntv2rp188.cpp:2081
NTV2FrameRate
NTV2FrameRate
Identifies a particular video frame rate.
Definition: ntv2enums.h:396
ajatypes.h
Declares the most fundamental data types used by NTV2. Since Windows NT was the first principal devel...
CRP188::DropFrame
bool DropFrame(void)
Definition: ntv2rp188.h:124
kTCFormat60fps
@ kTCFormat60fps
Definition: ntv2rp188.h:36
kDefaultFrameCount
const int64_t kDefaultFrameCount
Definition: ntv2rp188.h:49
CRP188::VaricamFrame1
bool VaricamFrame1(void)
Definition: ntv2rp188.h:114
kTCFormat50fps
@ kTCFormat50fps
Definition: ntv2rp188.h:35
kTCBurnTimecode
@ kTCBurnTimecode
Definition: ntv2rp188.h:42
kTCFormat25fps
@ kTCFormat25fps
Definition: ntv2rp188.h:31
ULWord
uint32_t ULWord
Definition: ajatypes.h:253
ntv2enums.h
Enumerations for controlling NTV2 devices.
CRP188::FieldID
ULWord FieldID(void)
Definition: ntv2rp188.h:122
kTCFormat60fpsDF
@ kTCFormat60fpsDF
Definition: ntv2rp188.h:37
RP188_STRUCT
Definition: ntv2publicinterface.h:4083
CRP188
Definition: ntv2rp188.h:55
UByte
uint8_t UByte
Definition: ajatypes.h:248
TimecodeBurnMode
TimecodeBurnMode
Definition: ntv2rp188.h:40
CRP188::GetTimecodeFormat
TimecodeFormat GetTimecodeFormat()
Definition: ntv2rp188.h:107
NTV2_RP188
This struct replaces the old RP188_STRUCT.
Definition: ntv2publicinterface.h:6760
AJAExport
#define AJAExport
Definition: export.h:33
CRP188::IsFreshRP188
bool IsFreshRP188(void)
Definition: ntv2rp188.h:110
kTCBurnUserBits
@ kTCBurnUserBits
Definition: ntv2rp188.h:43
kTCBurnBlank
@ kTCBurnBlank
Definition: ntv2rp188.h:45
kTCBurnFrameCount
@ kTCBurnFrameCount
Definition: ntv2rp188.h:44
ntv2publicinterface.h
Declares enums and structs used by all platform drivers and the SDK.
kTCFormatUnknown
@ kTCFormatUnknown
Definition: ntv2rp188.h:29