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