AJA NTV2 SDK  17.5.0.1492
NTV2 SDK 17.5.0.1492
ntv2framegrabber.cpp
Go to the documentation of this file.
1 /* SPDX-License-Identifier: MIT */
7 #include <ostream>
8 #include "ntv2framegrabber.h"
9 #include "ntv2democommon.h"
10 #include "ntv2utils.h"
11 #if defined (INCLUDE_AJACC)
14  using namespace std;
15 #endif
16 
17 #define NTV2_NUM_IMAGES (10)
18 
19 // Convenience macros for EZ logging:
20 #define FGFAIL(_expr_) AJA_sERROR (AJA_DebugUnit_DemoCapture, AJAFUNC << ": " << _expr_)
21 #define FGWARN(_expr_) AJA_sWARNING(AJA_DebugUnit_DemoCapture, AJAFUNC << ": " << _expr_)
22 #define FGDBG(_expr_) AJA_sDEBUG (AJA_DebugUnit_DemoCapture, AJAFUNC << ": " << _expr_)
23 #define FGNOTE(_expr_) AJA_sNOTICE (AJA_DebugUnit_DemoCapture, AJAFUNC << ": " << _expr_)
24 #define FGINFO(_expr_) AJA_sINFO (AJA_DebugUnit_DemoCapture, AJAFUNC << ": " << _expr_)
25 
26 static QMutex gMutex;
27 
28 
30  : QThread (parent),
31  mRestart (true),
32  mAbort (false),
33  mCheckFor4K (false),
34  mDeinterlace (true),
35  mbFixedReference (false),
36  mBoardNumber (0),
37  mDeviceID (DEVICE_ID_NOTFOUND),
38  mChannel (NTV2_MAX_NUM_CHANNELS),
39  mNumChannels (0),
40  mTsi (false),
41  mCurrentVideoFormat (NTV2_FORMAT_UNKNOWN),
42  mCurrentColorSpace (NTV2_LHIHDMIColorSpaceYCbCr),
43  mLastVideoFormat (NTV2_FORMAT_UNKNOWN),
44  mDebounceCounter (0),
45  mFormatIsProgressive (true),
46  mInputSource (NTV2_NUM_INPUTSOURCES),
47  mFrameBufferFormat (NTV2_FBF_ARGB),
48  mDoMultiChannel (false),
49  mbWithAudio (false),
50  mAudioOutput (AJA_NULL),
51  mAudioDevice (AJA_NULL),
52  mNumAudioChannels (0),
53  mAudioSystem (NTV2_AUDIOSYSTEM_1),
54  mTimeCodeSource (NTV2_TCINDEX_INVALID)
55 {
57 } // constructor
58 
59 
61 {
62  mAbort = true;
63  while (isRunning())
64  ; // Wait for grabber thread to finish
65 
67 
68  if (mAudioOutput)
69  delete mAudioOutput;
70 
71 } // destructor
72 
73 
75 {
76  if (inInputSource != mInputSource)
77  {
78  FGDBG("From " << ::NTV2InputSourceToString (mInputSource) << " to " << ::NTV2InputSourceToString (inInputSource));
79  gMutex.lock();
80  mInputSource = inInputSource;
81  mRestart = true;
82  gMutex.unlock();
83  }
84 
85 } // SetInputSource
86 
87 
88 void NTV2FrameGrabber::SetDeviceIndex (const UWord inDeviceIndex)
89 {
90  if (inDeviceIndex != mBoardNumber)
91  {
92  gMutex.lock();
93  mBoardNumber = inDeviceIndex;
94  mRestart = true;
95  gMutex.unlock();
96  }
97 } // SetDeviceIndex
98 
99 
101 {
102  if (inTCIndex != mTimeCodeSource)
103  {
104  gMutex.lock();
105  mTimeCodeSource = inTCIndex;
106  mRestart = true;
107  gMutex.unlock();
108  }
109 } // SetTimeCodeSource
110 
111 
113 {
114  gMutex.lock();
115  const UWord result (mBoardNumber);
116  gMutex.unlock();
117  return result;
118 }
119 
120 
121 #if defined (INCLUDE_AJACC)
122  #if 0
123  static const UWord gTest [15][32] =
124  // 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16
125  // 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
126  /*01*/ {{0x250C, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014,
127  0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2510},
128  /*02*/ {0x007C, 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037, 0x0038, 0x0039, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E,
129  0x003F, 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047, 0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x007C},
130  /*03*/ {0x007C, 0x004E, 0x004F, 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057, 0x0058, 0x0059, 0x005A, 0x005B, 0x005D,
131  0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067, 0x0068, 0x0069, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F, 0x007C},
132  /*04*/ {0x007C, 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077, 0x0078, 0x0079, 0x007A, 0x0020, 0x00E1, 0x00E9, 0x00ED,
133  0x00F3, 0x00FA, 0x00E7, 0x00F7, 0x00D1, 0x00E1, 0x00F1, 0x2588, 0x00AE, 0x00B0, 0x00BD, 0x00BF, 0x2122, 0x00A2, 0x00A3, 0x007C},
134  /*05*/ {0x007C, 0x266A, 0x00E0, 0x00A0, 0x00E8, 0x00E2, 0x00EA, 0x00EE, 0x00F4, 0x00FB, 0x00C1, 0x00C9, 0x00D3, 0x00DA, 0x00DC, 0x00FC,
135  0x2018, 0x00A1, 0x002A, 0x2019, 0x2014, 0x00A9, 0x2120, 0x2022, 0x201C, 0x201D, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x007C},
136  /*06*/ {0x007C, 0x00C0, 0x00C2, 0x00C7, 0x00C8, 0x00CA, 0x00CB, 0x00EB, 0x00CE, 0x00CF, 0x00EF, 0x00D4, 0x00D9, 0x00F9, 0x00DB, 0x00AB,
137  0x00BB, 0x0020, 0x0020, 0x00C3, 0x00E3, 0x00CD, 0x00CC, 0x00EC, 0x00D2, 0x00F2, 0x00D5, 0x00F5, 0x007B, 0x007D, 0x005C, 0x007C},
138  /*07*/ {0x007C, 0x005E, 0x005F, 0x007C, 0x007E, 0x0020, 0x0020, 0x00C4, 0x00E4, 0x00D6, 0x00F6, 0x00DF, 0x00A5, 0x00A4, 0x007C, 0x00C5,
139  0x00E5, 0x00D8, 0x00F8, 0x00C4, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x007C},
140  /*08*/ {0x007C, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020,
141  0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x007C},
142  /*09*/ {0x007C, 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037, 0x0038, 0x0039, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E,
143  0x003F, 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047, 0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x007C},
144  /*10*/ {0x007C, 0x004E, 0x004F, 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057, 0x0058, 0x0059, 0x005A, 0x005B, 0x005D,
145  0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067, 0x0068, 0x0069, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F, 0x007C},
146  /*11*/ {0x007C, 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077, 0x0078, 0x0079, 0x007A, 0x0020, 0x00E1, 0x00E9, 0x00ED,
147  0x00F3, 0x00FA, 0x00E7, 0x00F7, 0x00D1, 0x00E1, 0x00F1, 0x2588, 0x00AE, 0x00B0, 0x00BD, 0x00BF, 0x2122, 0x00A2, 0x00A3, 0x007C},
148  /*12*/ {0x007C, 0x266A, 0x00E0, 0x00A0, 0x00E8, 0x00E2, 0x00EA, 0x00EE, 0x00F4, 0x00FB, 0x00C1, 0x00C9, 0x00D3, 0x00DA, 0x00DC, 0x00FC,
149  0x2018, 0x00A1, 0x002A, 0x2019, 0x2014, 0x00A9, 0x2120, 0x2022, 0x201C, 0x201D, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x007C},
150  /*13*/ {0x007C, 0x00C0, 0x00C2, 0x00C7, 0x00C8, 0x00CA, 0x00CB, 0x00EB, 0x00CE, 0x00CF, 0x00EF, 0x00D4, 0x00D9, 0x00F9, 0x00DB, 0x00AB,
151  0x00BB, 0x0020, 0x0020, 0x00C3, 0x00E3, 0x00CD, 0x00CC, 0x00EC, 0x00D2, 0x00F2, 0x00D5, 0x00F5, 0x007B, 0x007D, 0x005C, 0x007C},
152  /*14*/ {0x007C, 0x005E, 0x005F, 0x007C, 0x007E, 0x0020, 0x0020, 0x00C4, 0x00E4, 0x00D6, 0x00F6, 0x00DF, 0x00A5, 0x00A4, 0x007C, 0x00C5,
153  0x00E5, 0x00D8, 0x00F8, 0x00C4, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x007C},
154  /*15*/ {0x2514, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014,
155  0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2518}};
156  #endif // 0
157 #endif // defined (INCLUDE_AJACC)
158 
159 
160 void NTV2FrameGrabber::ClearCaptionBuffer (const bool inNotifyClients)
161 {
162  #if defined (INCLUDE_AJACC)
163  for (UWord row (NTV2_CC608_MinRow); row <= NTV2_CC608_MaxRow; row++)
164  for (UWord col (NTV2_CC608_MinCol); col <= NTV2_CC608_MaxCol; col++)
165  mScreenBuffer [row-1][col-1] = 0x0020; // gTest[row-1][col-1];
166  if (inNotifyClients)
167  emit captionScreenChanged (&mScreenBuffer[0][0]);
168  #else
169  (void) inNotifyClients;
170  #endif
171 }
172 
173 
175 {
176  #if defined (INCLUDE_AJACC)
177  NTV2_ASSERT (mNTV2Card.IsOpen ());
178  NTV2_ASSERT (mDeviceID != DEVICE_ID_NOTFOUND);
179 
180  if (mNTV2Card.features().CanDoCustomAnc())
181  {
182  bool gotCaptionPacket (false);
183  CaptionData captionData; // The two byte pairs (one pair per field) our 608 decoder is looking for
184  ostringstream oss; // DEBUG
185 
186  // See what's in the AUTOCIRCULATE_TRANSFER's F1 & F2 anc buffers...
187  AJAAncillaryList ancPacketsF1, ancPacketsF2;
188  ancPacketsF1.AddReceivedAncillaryData ((uint8_t *) mTransferStruct.acANCBuffer.GetHostPointer (), mTransferStruct.acANCBuffer.GetByteCount ());
189  ancPacketsF2.AddReceivedAncillaryData ((uint8_t *) mTransferStruct.acANCField2Buffer.GetHostPointer (), mTransferStruct.acANCField2Buffer.GetByteCount ());
190  ancPacketsF1.ParseAllAncillaryData ();
191  ancPacketsF2.ParseAllAncillaryData ();
192 
194  {
196  if (ancCEA708DataIn.GetPayloadData () && ancCEA708DataIn.GetPayloadByteCount ())
197  gotCaptionPacket = m708Decoder ? m708Decoder->SetSMPTE334AncData (ancCEA708DataIn.GetPayloadData (), ancCEA708DataIn.GetPayloadByteCount ()) : false;
198  //if (gotCaptionPacket) oss << "Using F1 AJAAnc CEA708 packet(s)";
199  }
201  {
203  if (ancCEA608DataIn.GetPayloadData () && ancCEA608DataIn.GetPayloadByteCount ())
204  gotCaptionPacket = m708Decoder ? m708Decoder->SetSMPTE334AncData (ancCEA608DataIn.GetPayloadData (), ancCEA608DataIn.GetPayloadByteCount ()) : false;
205  //if (gotCaptionPacket) oss << "Using F1 AJAAnc CEA608 packet(s)";
206  }
208  {
210  if (AJA_SUCCESS (ancEIA608DataIn.ParsePayloadData ()))
211  if (AJA_SUCCESS (ancEIA608DataIn.GetCEA608Bytes (captionData.f1_char1, captionData.f1_char2, captionData.bGotField1Data)))
212  gotCaptionPacket = true;
213  //if (gotCaptionPacket) oss << "Using F1 AJAAnc EIA608 packet(s)";
214  }
216  {
218  if (AJA_SUCCESS (ancEIA608DataIn.ParsePayloadData ()))
219  if (AJA_SUCCESS (ancEIA608DataIn.GetCEA608Bytes (captionData.f2_char1, captionData.f2_char2, captionData.bGotField2Data)))
220  gotCaptionPacket = true;
221  //if (gotCaptionPacket) oss << "Using F2 AJAAnc EIA608 packet(s)";
222  }
223 
224  if (NTV2_IS_HD_VIDEO_FORMAT (mCurrentVideoFormat))
225  {
226  if (gotCaptionPacket && m708Decoder && m708Decoder->ParseSMPTE334AncPacket ())
227  captionData = m708Decoder->GetCC608CaptionData (); // Extract the 608 caption byte pairs
228  } // else if HD
229 
230  // Sorry, we only handle 608 captions -- nothing else.
231  // The 608 decoder does the rest. It expects to be called once per frame (to implement flashing characters and roll-up).
232  // Pass the caption byte pairs to it for processing (even if captionData.HasData returns false)...
233  if (m608Decoder)
234  m608Decoder->ProcessNew608FrameData (captionData);
235  //if (!oss.str ().empty ()) cerr << oss.str () << endl; // DEBUG DEBUG DEBUG DEBUG
236  //if (captionData.HasData ()) cerr << captionData << endl;
237  } // if able to use Anc buffers
238  #endif // defined (INCLUDE_AJACC)
239 } // GrabCaptions
240 
241 
242 void NTV2FrameGrabber::changeCaptionChannel (int inNewCaptionChannelId)
243 {
244  #if defined (INCLUDE_AJACC)
245  const NTV2Line21Channel chosenCaptionChannel (static_cast <NTV2Line21Channel> (inNewCaptionChannelId));
246 
247  if (!m608Decoder && IsValidLine21Channel (chosenCaptionChannel))
248  {
249  NTV2_ASSERT (!m708Decoder);
250  if (CNTV2CaptionDecoder608::Create (m608Decoder) && CNTV2CaptionDecoder708::Create (m708Decoder))
251  {
252  m608Decoder->SubscribeChangeNotification (Caption608Changed, this);
253  m608Decoder->SetDisplayChannel (chosenCaptionChannel);
254  ClearCaptionBuffer (true);
255  }
256  else
257  {m608Decoder = AJA_NULL; m708Decoder = AJA_NULL;}
258  }
259  else if (m608Decoder)
260  {
261  NTV2_ASSERT (m708Decoder);
262  if (!IsValidLine21Channel (chosenCaptionChannel))
263  {m608Decoder = AJA_NULL; m708Decoder = AJA_NULL;}
264  else if (m608Decoder->GetDisplayChannel () != chosenCaptionChannel)
265  m608Decoder->SetDisplayChannel (chosenCaptionChannel);
266  ClearCaptionBuffer (true);
267  }
268  #else
269  (void) inNewCaptionChannelId;
270  #endif // defined (INCLUDE_AJACC)
271 } // changeCaptionChannel
272 
273 
275 {
276  // Set up 2 images to ping-pong between capture and display...
277  QImage * images [NTV2_NUM_IMAGES];
278  ULWord framesCaptured (0);
279  FGNOTE("Thread started");
280 
281  // Initialize images
282  for (int i(0); i < NTV2_NUM_IMAGES; i++)
283  images[i] = new QImage(QTPREVIEW_WIDGET_X, QTPREVIEW_WIDGET_Y, QImage::Format_RGB32);
284 
285  // Make sure all Bidirectionals are set to Inputs.
286  if (mNTV2Card.Open(mBoardNumber))
287  {
288  if (!mDoMultiChannel && !mNTV2Card.AcquireStreamForApplicationWithReference (kDemoAppSignature, int32_t(AJAProcess::GetPid())))
289  {
290  // We have not acquired the board continue until something changes...
291  FGWARN("Could not acquire " << mNTV2Card.GetDescription());
292  mNTV2Card.Close ();
293  mDeviceID = DEVICE_ID_NOTFOUND;
294  }
295  else
296  {
297  mNTV2Card.GetEveryFrameServices (mSavedTaskMode); // Save the current state before we change it
298  mNTV2Card.SetEveryFrameServices (NTV2_OEM_TASKS); // Since this is an OEM demo we will set the OEM service level
299 
300  if (mNTV2Card.features().HasBiDirectionalSDI()) // If device has bidirectional SDI connectors...
301  {
302  bool waitForInput = false;
303  for (unsigned offset(0); offset < 8; offset++)
304  {
305  mNTV2Card.EnableChannel (NTV2Channel(offset));
306  bool outputEnabled;
307  mNTV2Card.GetSDITransmitEnable (NTV2Channel(offset), outputEnabled);
308  if (outputEnabled)
309  {
310  waitForInput = true;
311  mNTV2Card.SetSDITransmitEnable (NTV2Channel(offset), false);
312  }
313  }
314  // Only if we had to change an output to input do we need to wait.
315  if (waitForInput)
316  mNTV2Card.WaitForInputVerticalInterrupt (mChannel, 10); // ...and give the device some time to lock to a signal
317  }
318  }
319  }
320 
321  while (true)
322  {
323  if (mAbort)
324  break;
325 
326  if (!NTV2_IS_VALID_INPUT_SOURCE(mInputSource))
327  {
328  // No input chosen, so display banner...
329  if (NTV2_IS_VALID_CHANNEL(mChannel))
331  QImage * currentImage (images[framesCaptured % NTV2_NUM_IMAGES]);
332  currentImage->load (":/resources/splash.png");
333  emit newStatusString ("");
334  emit newFrame (*currentImage, true);
335  AJATime::Sleep(200);
336  continue;
337  }
338 
339  if (mRestart)
340  {
341  gMutex.lock();
343  if (mNTV2Card.IsOpen())
344  {
345  if (!mDoMultiChannel)
346  {
348  mNTV2Card.SetEveryFrameServices (mSavedTaskMode);
349  }
350  mNTV2Card.Close();
351  mDeviceID = DEVICE_ID_NOTFOUND;
352  }
353  gMutex.unlock();
354 
355  if (mNTV2Card.Open(mBoardNumber))
356  {
357  if (!mDoMultiChannel && !mNTV2Card.AcquireStreamForApplicationWithReference (kDemoAppSignature, int32_t(AJAProcess::GetPid())))
358  {
359  // Haven't acquired the device --- continue til other app releases it...
360  FGWARN(mNTV2Card.GetDisplayName() << " is busy");
361  QImage * currentImage (images[framesCaptured % NTV2_NUM_IMAGES]);
362  currentImage->fill(Qt::lightGray);
363  QString status (QString("%1 is busy").arg(mNTV2Card.GetDisplayName().c_str()));
364  emit newStatusString(status);
365  emit newFrame(*currentImage, true);
366  mNTV2Card.Close();
367  mDeviceID = DEVICE_ID_NOTFOUND;
368  AJATime::Sleep(500);
369  continue;
370  }
371 
372  mNTV2Card.GetEveryFrameServices(mSavedTaskMode); // Save the current state before we change it
373  mNTV2Card.SetEveryFrameServices(NTV2_OEM_TASKS); // Since this is an OEM demo we will set the OEM service level
374 
375  mDeviceID = mNTV2Card.GetDeviceID();
376  if (mNTV2Card.features().CanDoMultiFormat())
377  mNTV2Card.SetMultiFormatMode(true);
378 
379  if (!mNTV2Card.IsDeviceReady(false))
380  {
381  FGWARN(mNTV2Card.GetDisplayName() << " not ready");
382  QImage * currentImage (images[framesCaptured % NTV2_NUM_IMAGES]);
383  currentImage->fill(Qt::lightGray);
384  QString status (QString("%1 is not ready").arg(mNTV2Card.GetDisplayName().c_str()));
385  emit newStatusString(status);
386  emit newFrame(*currentImage, true);
387  AJATime::Sleep(1000); // Keep the UI responsive while waiting for device to become ready
388  }
389  else if (!mNTV2Card.features().CanDoCapture())
390  {
391  FGWARN(mNTV2Card.GetDisplayName() << " is output-only device");
392  QImage * currentImage (images[framesCaptured % NTV2_NUM_IMAGES]);
393  currentImage->fill(qRgba(40, 40, 40, 255));
394  QString status (QString("%1 is output-only device").arg(mNTV2Card.GetDisplayName().c_str()));
395  emit newStatusString(status);
396  emit newFrame(*currentImage, true);
397  AJATime::Sleep(1000); // Keep the UI responsive
398  }
399  else if (!mNTV2Card.features().GetNumCSCs())
400  {
401  FGWARN(mNTV2Card.GetDisplayName() << " has no CSCs, won't work with NTV2FrameGrabber");
402  QImage * currentImage (images[framesCaptured % NTV2_NUM_IMAGES]);
403  currentImage->fill(qRgba(40, 40, 40, 255));
404  QString status (QString("%1 has no CSCs, won't work for this demo").arg(mNTV2Card.GetDisplayName().c_str()));
405  emit newStatusString(status);
406  emit newFrame(*currentImage, true);
407  AJATime::Sleep(1000); // Keep the UI responsive
408  }
409  else if (SetupInput())
410  {
411  mTransferStruct.acANCBuffer.Allocate (mNTV2Card.features().CanDoCustomAnc() ? NTV2_ANCSIZE_MAX : 0); // Reserve space for anc data
412  mTransferStruct.acANCField2Buffer.Allocate(mNTV2Card.features().CanDoCustomAnc() ? NTV2_ANCSIZE_MAX : 0); // Reserve space for anc data
413  const ULWord acOptions(AUTOCIRCULATE_WITH_RP188 | (mTransferStruct.acANCBuffer.IsNULL() && mTransferStruct.acANCField2Buffer.IsNULL() ? 0 : AUTOCIRCULATE_WITH_ANC));
414  gMutex.lock();
416  ULWord numFrameBuffersAvailable = (mNTV2Card.DeviceGetNumberFrameBuffers() - mNTV2Card.features().GetNumAudioSystems());
417  ULWord startFrameBuffer = (numFrameBuffersAvailable / mNTV2Card.features().GetNumFrameStores()) * ULWord(mChannel);
418  mNTV2Card.AutoCirculateInitForInput (mChannel, 0, ::NTV2ChannelToAudioSystem(mChannel),
419  acOptions, 1, startFrameBuffer, startFrameBuffer+7);
420  gMutex.unlock();
421  SetupAudio();
422  if (mAudioOutput)
423  mAudioDevice = mAudioOutput->start();
424 
425  // Start AutoCirculate...
426  mNTV2Card.SetLTCInputEnable(true);
427  mNTV2Card.SetRP188SourceFilter (mChannel, 0); // 0=LTC 1=VITC1 2=VITC2
428  mNTV2Card.AutoCirculateStart(mChannel);
429 
430  for (int i(0); i < NTV2_NUM_IMAGES; i++)
431  {
432  delete images[i];
433  images[i] = new QImage (mFrameDimensions.Width(), mFrameDimensions.Height(), QImage::Format_RGB32);
434  }
435 
436  framesCaptured = 0;
437  mRestart = false;
438  } // if board set up ok
439  else
440  AJATime::Sleep(1000); // This keeps the UI responsive if/while this channel has no input
441  } // if board opened ok
442  else
443  {
444  FGWARN("Open failed for device " << DEC(GetDeviceIndex()));
445  AJATime::Sleep(200);
446  continue;
447  }
448 
449  emit newStatusString(::NTV2InputSourceToString (mInputSource, true).c_str());
450  } // if mRestart
451 
452  if (!CheckForValidInput() && NTV2_IS_VALID_INPUT_SOURCE(mInputSource))
453  {
454  QImage * currentImage (images[framesCaptured % NTV2_NUM_IMAGES]);
455  currentImage->fill(qRgba(40, 40, 40, 255));
456  QString status (QString("%1: No Detected Input").arg(::NTV2InputSourceToString(mInputSource, true).c_str()));
457  emit newStatusString(status);
458  emit newFrame(*currentImage, true);
459  AJATime::Sleep(200);
460  continue;
461  }
462 
463  AUTOCIRCULATE_STATUS acStatus;
464  mNTV2Card.AutoCirculateGetStatus (mChannel, acStatus);
465  if (acStatus.acState == NTV2_AUTOCIRCULATE_RUNNING && acStatus.acBufferLevel > 1)
466  {
467  QImage * currentImage (images [framesCaptured % NTV2_NUM_IMAGES]);
468  NTV2TimeCodeList tcValues;
469 
470  #if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
471  mTransferStruct.SetVideoBuffer (reinterpret_cast<PULWord>(currentImage->bits()), ULWord(currentImage->sizeInBytes()));
472  #else
473  mTransferStruct.SetVideoBuffer (reinterpret_cast<PULWord>(currentImage->bits()), ULWord(currentImage->byteCount()));
474  #endif
475  mNTV2Card.AutoCirculateTransfer (mChannel, mTransferStruct);
476  if (!mFormatIsProgressive && mDeinterlace)
477  {
478  // Eliminate field flicker by copying even lines to odd lines...
479  // (a very lame de-interlace technique)
480  if (currentImage->height() == int(mFrameDimensions.Height()) && currentImage->width() == int(mFrameDimensions.Width()))
481  for (ULWord line (0); line < mFrameDimensions.Height(); line += 2)
482  ::memcpy (currentImage->scanLine (int(line) + 1), currentImage->scanLine(int(line)), mFrameDimensions.Width() * 4);
483  }
484  GrabCaptions();
485  mTimeCode.clear ();
486  if (mTransferStruct.acTransferStatus.acFrameStamp.GetInputTimeCodes(tcValues) && size_t(mTimeCodeSource) < tcValues.size())
487  {
488  CRP188 tc (tcValues.at(mTimeCodeSource));
489  if (!tcValues.at (mTimeCodeSource).IsValid())
490  {
491  // If the requested timecode was invalid, check for embedded LTC
492  if (NTV2_IS_VALID_INPUT_SOURCE(mInputSource))
493  tc.SetRP188 (tcValues.at (::NTV2InputSourceToTimecodeIndex (mInputSource, true)));
494  }
495  tc.GetRP188Str (mTimeCode);
496  }
497 
498  QString outString (::NTV2InputSourceToString (mInputSource, true).c_str());
499  outString.append (" ");
500  outString.append (::NTV2VideoFormatToString (mCurrentVideoFormat).c_str ());
501  outString.append (" ");
502  outString.append (mTimeCode.c_str());
503 
504  emit newStatusString (outString);
505 
506  emit newFrame (*currentImage, (framesCaptured == 0) ? true : false);
507  if (mbWithAudio && mTransferStruct.acAudioBuffer)
508  OutputAudio (mTransferStruct.acAudioBuffer, mTransferStruct.acTransferStatus.acAudioTransferSize);
509 
510  framesCaptured++;
511  } // if running and at least one frame ready to transfer
512  else
513  mNTV2Card.WaitForInputVerticalInterrupt (mChannel);
514  } // loop til break
515 
516  if (mNTV2Card.IsOpen ())
517  {
518  gMutex.lock();
520  if (!mDoMultiChannel)
521  {
522  mNTV2Card.ReleaseStreamForApplicationWithReference (kDemoAppSignature, int32_t(AJAProcess::GetPid())); // Release the device
523  mNTV2Card.SetEveryFrameServices(mSavedTaskMode); // Restore prior task mode
524  }
525  gMutex.unlock();
526  }
527 
528  for (int i(0); i < NTV2_NUM_IMAGES; i++)
529  delete images[i];
530 
531  FGNOTE("Thread completed, will exit for " << mNTV2Card.GetDisplayName() << " input " << ::NTV2InputSourceToString(mInputSource));
532 
533 } // run
534 
535 
537 {
538  if (!mNTV2Card.IsOpen())
539  return false;
540  if (mDeviceID == DEVICE_ID_NOTFOUND)
541  return false;
542 
543  mChannel = ::NTV2InputSourceToChannel(mInputSource);
544  if (mChannel == NTV2_CHANNEL_INVALID)
545  mChannel = NTV2_CHANNEL1;
546  mTimeCodeSource = ::NTV2InputSourceToTimecodeIndex(mInputSource);
547 
548  bool waitForInput(false);
549  if (mNTV2Card.features().HasBiDirectionalSDI()) // If device has bidirectional SDIs...
550  for (unsigned offset(0); offset < 4; offset++)
551  {
552  mNTV2Card.EnableChannel(NTV2Channel(mChannel + offset));
553  bool outputEnabled;
554  mNTV2Card.GetSDITransmitEnable (NTV2Channel(mChannel + offset), outputEnabled);
555  if (outputEnabled)
556  {
557  waitForInput = true;
558  mNTV2Card.SetSDITransmitEnable (NTV2Channel(mChannel + offset), false);
559  }
560  }
561 
562  // Only if we had to change an output to input do we need to wait.
563  if (waitForInput)
564  mNTV2Card.WaitForInputVerticalInterrupt (mChannel, 10); // Give the device ~10 fields/frames to lock to a signal
565 
566  mCurrentVideoFormat = GetVideoFormatFromInputSource();
567  mCurrentColorSpace = GetColorSpaceFromInputSource();
568  mFrameDimensions.Set (QTPREVIEW_WIDGET_X, QTPREVIEW_WIDGET_Y);
569  if (!NTV2_IS_VALID_VIDEO_FORMAT(mCurrentVideoFormat))
570  return false; // No video!
571 
572  mNTV2Card.SetVideoFormat (mCurrentVideoFormat, false, false, mChannel);
574  mNTV2Card.GetVANCMode (vm, mChannel);
575  const NTV2FormatDescriptor fd (mCurrentVideoFormat, mFrameBufferFormat, vm);
576  mFrameDimensions.Set (fd.GetRasterWidth(), fd.GetRasterHeight());
577  const QString vfString (::NTV2VideoFormatToString(mCurrentVideoFormat).c_str());
578  FGDBG("mInputSource=" << mChannel << " mCurrentVideoFormat=" << vfString.toStdString()
579  << " wdth=" << mFrameDimensions.Width() << " hght=" << mFrameDimensions.Height());
580 
581  mFormatIsProgressive = IsProgressivePicture(mCurrentVideoFormat);
582  if (!mbFixedReference)
584 
585  if (NTV2_INPUT_SOURCE_IS_SDI(mInputSource))
586  {
587  mNumChannels = 0;
588  mTsi = false;
589 
590  bool is6g(false), is12g(false);
591  mNTV2Card.GetSDIInput6GPresent(is6g, mChannel);
592  mNTV2Card.GetSDIInput12GPresent(is12g, mChannel);
593 
594  if (mNTV2Card.features().CanDo12gRouting() && (is6g || is12g))
595  {
596  mNTV2Card.Connect (::GetCSCInputXptFromChannel(mChannel), ::GetSDIInputOutputXptFromChannel(mChannel));
597  mNTV2Card.Connect (::GetFrameBufferInputXptFromChannel(mChannel), ::GetCSCOutputXptFromChannel (mChannel, false/*isKey*/, true/*isRGB*/));
598  mNTV2Card.SetFrameBufferFormat (mChannel, mFrameBufferFormat);
599  mNTV2Card.EnableChannel(mChannel);
600  mNTV2Card.SetSDIInLevelBtoLevelAConversion (mChannel, IsInput3Gb(mInputSource) ? true : false);
601  }
602  else for (unsigned offset(0); offset < 4; offset++)
603  {
604  mNumChannels++;
605  mNTV2Card.Connect (::GetCSCInputXptFromChannel (NTV2Channel(mChannel + offset)), ::GetSDIInputOutputXptFromChannel(NTV2Channel(mChannel + offset)));
606  mNTV2Card.Connect (::GetFrameBufferInputXptFromChannel (NTV2Channel(mChannel + offset)), ::GetCSCOutputXptFromChannel(NTV2Channel(mChannel + offset), false/*isKey*/, true/*isRGB*/));
607  mNTV2Card.SetFrameBufferFormat (NTV2Channel(mChannel + offset), mFrameBufferFormat);
608  mNTV2Card.EnableChannel (NTV2Channel(mChannel + offset));
609  mNTV2Card.SetSDIInLevelBtoLevelAConversion (mChannel + offset, IsInput3Gb(mInputSource) ? true : false);
610  if (!NTV2_IS_4K_VIDEO_FORMAT(mCurrentVideoFormat))
611  break;
612  mNTV2Card.Set4kSquaresEnable(true, NTV2_CHANNEL1);
613  }
614  }
615  else if (mInputSource == NTV2_INPUTSOURCE_ANALOG1)
616  {
617  mNumChannels = 0;
618  mTsi = false;
619  //mNTV2Card.SetTsiFrameEnable(false, NTV2_CHANNEL1);
620 
622  mNTV2Card.Connect (::GetFrameBufferInputXptFromChannel(NTV2_CHANNEL1), ::GetCSCOutputXptFromChannel(NTV2_CHANNEL1, false/*isKey*/, true/*isRGB*/));
623  mNTV2Card.SetFrameBufferFormat(NTV2_CHANNEL1, mFrameBufferFormat);
624  if (!mbFixedReference)
626  mChannel = NTV2_CHANNEL1;
627  mNumChannels = 1;
628  }
629  else if (NTV2_INPUT_SOURCE_IS_HDMI(mInputSource))
630  {
631  mNumChannels = 0;
632  mTsi = false;
633 
634  if (!mbFixedReference)
635  mNTV2Card.SetReference(::NTV2InputSourceToReferenceSource(mInputSource));
636 
637  // configure hdmi with 2.0 support
638  if (mNTV2Card.features().CanDo12gRouting())
639  {
640  mNumChannels = 1;
641  mNTV2Card.EnableChannel(mChannel);
642  mNTV2Card.SetMode (mChannel, NTV2_MODE_CAPTURE);
643  mNTV2Card.SetFrameBufferFormat (mChannel, mFrameBufferFormat);
644  if (mCurrentColorSpace == NTV2_LHIHDMIColorSpaceYCbCr)
645  {
646  mNTV2Card.Connect (::GetCSCInputXptFromChannel(mChannel),
647  ::GetInputSourceOutputXpt (mInputSource, false/*isSDI_DS2*/, false/*isHDMI_RGB*/, 0/*hdmiQuadrant*/));
648  mNTV2Card.Connect (::GetFrameBufferInputXptFromChannel(mChannel),
649  ::GetCSCOutputXptFromChannel (mChannel, false/*isKey*/, true/*isRGB*/));
650  }
651  else
652  mNTV2Card.Connect (::GetFrameBufferInputXptFromChannel(mChannel),
653  ::GetInputSourceOutputXpt (mInputSource, false/*isSDI_DS2*/, true/*isHDMI_RGB*/, 0/*hdmiQuadrant*/));
654  }
655  else if (NTV2_IS_4K_VIDEO_FORMAT(mCurrentVideoFormat) && !mNTV2Card.features().CanDoHDMIQuadRasterConversion())
656  {
657  // Set two sample interleave
658  mChannel = NTV2_CHANNEL1;
659  mNTV2Card.SetTsiFrameEnable(true, NTV2_CHANNEL1);
660 
661  for (NTV2Channel channel (NTV2_CHANNEL1); channel < NTV2_CHANNEL3; channel = NTV2Channel(channel+1))
662  {
663  mNTV2Card.EnableChannel(channel);
664  mNTV2Card.SetMode (channel, NTV2_MODE_CAPTURE);
665  mNTV2Card.SetFrameBufferFormat (channel, mFrameBufferFormat);
666  }
667 
668  if (mCurrentColorSpace == NTV2_LHIHDMIColorSpaceYCbCr)
669  {
670  mNTV2Card.Connect (NTV2_XptCSC1VidInput,
671  ::GetInputSourceOutputXpt (mInputSource, false/*isSDI_DS2*/, false/*isHDMI_RGB*/, NTV2_CHANNEL1/*hdmiQuadrant*/));
672  mNTV2Card.Connect (NTV2_XptCSC2VidInput,
673  ::GetInputSourceOutputXpt (mInputSource, false/*isSDI_DS2*/, false/*isHDMI_RGB*/, NTV2_CHANNEL2/*hdmiQuadrant*/));
674  mNTV2Card.Connect (NTV2_XptCSC3VidInput,
675  ::GetInputSourceOutputXpt (mInputSource, false/*isSDI_DS2*/, false/*isHDMI_RGB*/, NTV2_CHANNEL3/*hdmiQuadrant*/));
676  mNTV2Card.Connect (NTV2_XptCSC4VidInput,
677  ::GetInputSourceOutputXpt (mInputSource, false/*isSDI_DS2*/, false/*isHDMI_RGB*/, NTV2_CHANNEL4/*hdmiQuadrant*/));
678 
683  }
684  else
685  {
686  mNTV2Card.Connect (NTV2_Xpt425Mux1AInput, ::GetInputSourceOutputXpt (mInputSource, false/*isSDI_DS2*/, true/*isHDMI_RGB*/, NTV2_CHANNEL1/*hdmiQuadrant*/));
687  mNTV2Card.Connect (NTV2_Xpt425Mux1BInput, ::GetInputSourceOutputXpt (mInputSource, false/*isSDI_DS2*/, true/*isHDMI_RGB*/, NTV2_CHANNEL2/*hdmiQuadrant*/));
688  mNTV2Card.Connect (NTV2_Xpt425Mux2AInput, ::GetInputSourceOutputXpt (mInputSource, false/*isSDI_DS2*/, true/*isHDMI_RGB*/, NTV2_CHANNEL3/*hdmiQuadrant*/));
689  mNTV2Card.Connect (NTV2_Xpt425Mux2BInput, ::GetInputSourceOutputXpt (mInputSource, false/*isSDI_DS2*/, true/*isHDMI_RGB*/, NTV2_CHANNEL4/*hdmiQuadrant*/));
690  }
691 
696 
697  mNumChannels = 2;
698  mTsi = true;
699  } // if 4K and can't do HDMI quad raster conversion
700  else if (NTV2_IS_4K_VIDEO_FORMAT(mCurrentVideoFormat) && mNTV2Card.features().CanDoHDMIQuadRasterConversion())
701  {
702  mNumChannels = 0;
703  mNTV2Card.SetTsiFrameEnable(false, NTV2_CHANNEL1);
704  for (NTV2Channel channel(NTV2_CHANNEL1); channel < NTV2_CHANNEL5; channel = NTV2Channel(channel+1))
705  {
706  mNumChannels++;
707  mNTV2Card.EnableChannel(channel);
708  mNTV2Card.SetMode (channel, NTV2_MODE_CAPTURE);
709  mNTV2Card.SetFrameBufferFormat (channel, mFrameBufferFormat);
710  if (mCurrentColorSpace == NTV2_LHIHDMIColorSpaceYCbCr)
711  {
712  mNTV2Card.Connect (::GetCSCInputXptFromChannel(channel),
713  ::GetInputSourceOutputXpt (mInputSource, false/*isSDI_DS2*/, false/*isHDMI_RGB*/, channel/*hdmiQuadrant*/));
714  mNTV2Card.Connect (::GetFrameBufferInputXptFromChannel(channel),
715  ::GetCSCOutputXptFromChannel (channel, false/*isKey*/, true/*isRGB*/));
716  }
717  else
718  mNTV2Card.Connect (::GetFrameBufferInputXptFromChannel(channel),
719  ::GetInputSourceOutputXpt (mInputSource, false/*isSDI_DS2*/, true/*isHDMI_RGB*/, channel/*hdmiQuadrant*/));
720  } // loop once for each channel (4 times for 4K/UHD)
721  } // else if 4K and can do HDMI quad raster conversion
722  else
723  {
724  mNumChannels = 1;
725  mNTV2Card.EnableChannel(mChannel);
726  mNTV2Card.SetMode (mChannel, NTV2_MODE_CAPTURE);
727  mNTV2Card.SetFrameBufferFormat (mChannel, mFrameBufferFormat);
728  if (mCurrentColorSpace == NTV2_LHIHDMIColorSpaceYCbCr)
729  {
730  mNTV2Card.Connect (::GetCSCInputXptFromChannel(mChannel),
731  ::GetInputSourceOutputXpt (mInputSource, false/*isSDI_DS2*/, false/*isHDMI_RGB*/, 0/*hdmiQuadrant*/));
732  mNTV2Card.Connect (::GetFrameBufferInputXptFromChannel(mChannel),
733  ::GetCSCOutputXptFromChannel (mChannel, false/*isKey*/, true/*isRGB*/));
734  }
735  else
736  mNTV2Card.Connect (::GetFrameBufferInputXptFromChannel(mChannel),
737  ::GetInputSourceOutputXpt (mInputSource, false/*isSDI_DS2*/, true/*isHDMI_RGB*/, 0/*hdmiQuadrant*/));
738  } // else not 4K
739 
740  // configure the qrc if present
741  if (mNTV2Card.features().GetHDMIVersion() == 2)
743  }
744  else
745  FGWARN("Bad mInputSource value " << DEC(mInputSource));
746 
747  return true;
748 
749 } // SetupInput
750 
751 
753 {
754  if (mNTV2Card.IsOpen())
755  {
756  mNTV2Card.AutoCirculateStop(mChannel);
757 
758  bool tsiEnable(false);
759  mNTV2Card.GetTsiFrameEnable (tsiEnable, NTV2_CHANNEL1);
760  for (ULWord i(0); i < (tsiEnable ? 2 : mNumChannels); i++)
761  mNTV2Card.SetMode (NTV2Channel(mChannel + i), NTV2_MODE_DISPLAY);
762  }
763  ClearCaptionBuffer(true);
764 
765 } // StopAutoCirculate
766 
767 
769 {
772 
773  if (videoFormat == NTV2_FORMAT_UNKNOWN)
774  {
775  mCurrentVideoFormat = videoFormat;
776  return false;
777  } // if no video or unknown format
778 
779  if ((mCurrentVideoFormat != videoFormat) || (mCurrentColorSpace != colorSpace))
780  {
781  if (mDebounceCounter == 0)
782  {
783  // Check to see if the video input has stabilized...
784  mLastVideoFormat = videoFormat;
785  mDebounceCounter++;
786  }
787  else if (mDebounceCounter == 6)
788  {
789  // The new format is stable -- restart autocirculate...
790  mRestart = true;
791  mCurrentVideoFormat = videoFormat;
792  mDebounceCounter = 0;
793  }
794  else
795  {
796  if (mLastVideoFormat == videoFormat)
797  mDebounceCounter++; // New format still stable -- keep counting
798  else
799  mDebounceCounter = 0; // Input changed again -- start over
800  }
801  return true;
802  } // if video format changed
803 
804  return true;
805 
806 } // CheckForValidInput
807 
808 
810 {
811  if (!mNTV2Card.IsOpen())
812  return NTV2_FORMAT_UNKNOWN;
813  if (mDeviceID == DEVICE_ID_NOTFOUND)
814  return NTV2_FORMAT_UNKNOWN;
815 
817  if (NTV2_INPUT_SOURCE_IS_SDI(mInputSource))
818  {
819  bool is6g (false), is12g(false);
820  NTV2Channel channel (::NTV2InputSourceToChannel(mInputSource));
821  mNTV2Card.GetSDIInput6GPresent(is6g, channel);
822  mNTV2Card.GetSDIInput12GPresent(is12g, channel);
823  if (mNTV2Card.features().CanDo12gRouting() && (is6g || is12g))
824  {
825  videoFormat = mNTV2Card.GetInputVideoFormat(mInputSource);
826  return videoFormat;
827  }
828  }
829 
830  switch (mInputSource)
831  {
834  {
835  const ULWord ndx (::GetIndexForNTV2InputSource(mInputSource));
836  videoFormat = mNTV2Card.GetInputVideoFormat(::GetNTV2InputSourceForIndex(ndx + 0));
837  NTV2Standard videoStandard (::GetNTV2StandardFromVideoFormat(videoFormat));
838  if (mCheckFor4K && (videoStandard == NTV2_STANDARD_1080p))
839  {
840  NTV2VideoFormat videoFormatNext (mNTV2Card.GetInputVideoFormat(::GetNTV2InputSourceForIndex(ndx + 1)));
841  if (videoFormatNext == videoFormat)
842  {
843  videoFormatNext = mNTV2Card.GetInputVideoFormat(::GetNTV2InputSourceForIndex(ndx + 2));
844  if (videoFormatNext == videoFormat)
845  {
846  videoFormatNext = mNTV2Card.GetInputVideoFormat(::GetNTV2InputSourceForIndex(ndx + 3));
847  if (videoFormatNext == videoFormat)
849  }
850  }
851  }
852  }
853  break;
854 
856  break; // indicates no source is currently selected
857 
858  default:
859  videoFormat = mNTV2Card.GetInputVideoFormat(mInputSource);
860  break;
861  }
862  return videoFormat;
863 
864 } // GetVideoFormatFromInputSource
865 
866 
868 {
869  if (NTV2_INPUT_SOURCE_IS_HDMI(mInputSource))
870  {
872  mNTV2Card.GetHDMIInputColor (hdmiColor, mChannel);
873  return hdmiColor;
874  }
876 }
877 
878 
880 {
881  bool is3Gb(false);
882  mNTV2Card.GetSDIInput3GbPresent (is3Gb, ::NTV2InputSourceToChannel(inputSource));
883  return is3Gb;
884 } // IsInput3Gb
885 
886 
888 {
889  if (!mNTV2Card.IsOpen())
890  return;
891  if (mDeviceID == DEVICE_ID_NOTFOUND)
892  return;
893 
894  mTransferStruct.acAudioBuffer.Allocate(NTV2_AUDIOSIZE_MAX); // Reserve space for largest audio packet/frame
895  if (mAudioOutput)
896  {
897  delete mAudioOutput;
898  mAudioOutput = AJA_NULL;
899  }
900 
901  NTV2AudioSource audioSource (NTV2_AUDIO_EMBEDDED);
902  if (NTV2_INPUT_SOURCE_IS_HDMI(mInputSource))
903  audioSource = NTV2_AUDIO_HDMI;
904  else if (NTV2_INPUT_SOURCE_IS_ANALOG(mInputSource))
905  audioSource = NTV2_AUDIO_ANALOG;
906 
907  // Set up AJA device audio...
908  mNumAudioChannels = mNTV2Card.features().GetMaxAudioChannels();
909  mAudioSystem = ::NTV2ChannelToAudioSystem(mChannel);
910  mNTV2Card.SetAudioSystemInputSource (mAudioSystem, audioSource, ::NTV2InputSourceToEmbeddedAudioInput(mInputSource));
911  mNTV2Card.SetNumberAudioChannels (mNumAudioChannels, mAudioSystem);
912  mNTV2Card.SetAudioRate (NTV2_AUDIO_48K, mAudioSystem);
913  mNTV2Card.SetAudioBufferSize (NTV2_AUDIO_BUFFER_BIG, mAudioSystem);
914 
915  // Set up Qt's audio output...
916 #if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
917  mFormat.setSampleRate(48000);
918  mFormat.setChannelCount(2);
919  mFormat.setSampleSize(16);
920  mFormat.setCodec("audio/pcm");
921  mFormat.setByteOrder(QAudioFormat::LittleEndian);
922  mFormat.setSampleType(QAudioFormat::SignedInt);
923 #else
924  mFormat.setSampleRate(48000);
925  mFormat.setChannelCount(2);
926  mFormat.setSampleFormat(QAudioFormat::Int16);
927 #endif
928 
929 #if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
930  QAudioDeviceInfo audioDeviceInfo (QAudioDeviceInfo::defaultOutputDevice());
931  if (audioDeviceInfo.isFormatSupported(mFormat))
932  mAudioOutput = new QAudioOutput (mFormat, AJA_NULL);
933 #else
934  QAudioDevice deviceInfo (QMediaDevices::defaultAudioOutput());
935  if (deviceInfo.isFormatSupported(mFormat))
936  mAudioOutput = new QAudioSink(deviceInfo, mFormat, AJA_NULL);
937 #endif
938 } // SetupAudio
939 
940 
941 void NTV2FrameGrabber::OutputAudio (ULWord * pInOutBuffer, const ULWord inNumValidBytes)
942 {
943  const ULWord nBytesPerAJASample (4); // AJA devices provide four bytes per channel per sample
944  unsigned channel (0); // Current channel being processed
945  UWord qtSampleNdx (0); // Which Qt audio sample is being processed
946  const ULWord totalSamples (inNumValidBytes / mNumAudioChannels); // Total number of audio samples to process, regardless of channel count
947  const ULWord totalAjaSamples (inNumValidBytes / nBytesPerAJASample); // Total number of AJA-device-provided audio samples, one sample per channel
948  UWord * pQtAudioBuffer (reinterpret_cast<UWord*>(pInOutBuffer)); // Qt-centric pointer to the audio buffer (2-bytes per channel per sample)
949 
950  //
951  // Walk through the audio buffer channel by channel:
952  // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 0 1 2 3 4 5 ...etc...
953  // and copy samples from channels 0 and 1 up to the front of the buffer...
954  // 0 1 0 1 0 1 0 1 0 1 0 1 ...etc..
955  //
956  for (unsigned ajaSampleNdx(0); ajaSampleNdx < totalAjaSamples; ajaSampleNdx++)
957  {
958  if (channel < 2)
959  {
960  pQtAudioBuffer [qtSampleNdx] = pInOutBuffer [ajaSampleNdx] >> 16; // Also discard the least significant 16 bits of each sample
961  qtSampleNdx++;
962  } // if channel 0 or 1
963 
964  channel++;
965  if (channel == mNumAudioChannels)
966  channel = 0;
967  } // for each channel for each sample
968 
969  if (mAudioDevice)
970  mAudioDevice->write (reinterpret_cast<const char*>(pQtAudioBuffer), totalSamples);
971 
972 } // OutputAudio
973 
974 
975 #if defined (INCLUDE_AJACC)
976  void NTV2FrameGrabber::Caption608Changed (void * pInstance, const NTV2Caption608ChangeInfo & inChangeInfo)
977  {
978  NTV2FrameGrabber * pFG (reinterpret_cast <NTV2FrameGrabber *> (pInstance));
979  if (pFG)
980  pFG->caption608Changed (inChangeInfo);
981  }
982 
983  void NTV2FrameGrabber::caption608Changed (const NTV2Caption608ChangeInfo & inChangeInfo)
984  {
985  NTV2Line21Attributes attrs;
986  bool changed (false);
987  for (UWord row (NTV2_CC608_MinRow); row <= NTV2_CC608_MaxRow; row++)
988  for (UWord col (NTV2_CC608_MinCol); col <= NTV2_CC608_MaxCol; col++)
989  {
990  ushort utf16Char (m608Decoder ? m608Decoder->GetOnAirUTF16CharacterWithAttributes (row, col, attrs) : 0x0020);
991  if (!utf16Char)
992  utf16Char = 0x0020;
993  if (utf16Char != mScreenBuffer [row-1][col-1])
994  {
995  mScreenBuffer [row-1][col-1] = utf16Char;
996  changed = true;
997  }
998  }
999  if (changed)
1000  emit captionScreenChanged (&mScreenBuffer[0][0]);
1001  }
1002 #endif // defined (INCLUDE_AJACC)
CNTV2Card::SetSDIInLevelBtoLevelAConversion
virtual bool SetSDIInLevelBtoLevelAConversion(const NTV2ChannelSet &inSDIInputs, const bool inEnable)
Enables or disables 3G level B to 3G level A conversion at the SDI input(s).
Definition: ntv2register.cpp:4269
NTV2InputSourceToReferenceSource
NTV2ReferenceSource NTV2InputSourceToReferenceSource(const NTV2InputSource inInputSource)
Converts a given NTV2InputSource to its equivalent NTV2ReferenceSource value.
Definition: ntv2utils.cpp:5088
CNTV2Card::SetMultiFormatMode
virtual bool SetMultiFormatMode(const bool inEnable)
Enables or disables multi-format (per channel) device operation. If enabled, each device channel can ...
Definition: ntv2register.cpp:4365
NTV2_Xpt425Mux1AInput
@ NTV2_Xpt425Mux1AInput
Definition: ntv2enums.h:2850
NTV2InputSourceToChannel
NTV2Channel NTV2InputSourceToChannel(const NTV2InputSource inInputSource)
Converts a given NTV2InputSource to its equivalent NTV2Channel value.
Definition: ntv2utils.cpp:5112
NTV2FrameGrabber::GetDeviceIndex
UWord GetDeviceIndex(void) const
Definition: ntv2framegrabber.cpp:112
NTV2_FBF_ARGB
@ NTV2_FBF_ARGB
See 8-Bit ARGB, RGBA, ABGR Formats.
Definition: ntv2enums.h:215
GetSDIInputOutputXptFromChannel
NTV2OutputXptID GetSDIInputOutputXptFromChannel(const NTV2Channel inSDIInput, const bool inIsDS2=false)
Definition: ntv2signalrouter.cpp:921
FGWARN
#define FGWARN(_expr_)
Definition: ntv2framegrabber.cpp:21
NTV2_CHANNEL2
@ NTV2_CHANNEL2
Specifies channel or FrameStore 2 (or the 2nd item).
Definition: ntv2enums.h:1346
CNTV2CaptionDecoder708::Create
static bool Create(CNTV2CaptionDecoder708Ptr &outDecoder)
Creates a new CNTV2CaptionEncoder708 instance.
CNTV2Card::SetVideoFormat
virtual bool SetVideoFormat(const NTV2VideoFormat inVideoFormat, const bool inIsAJARetail=(!(0)), const bool inKeepVancSettings=(0), const NTV2Channel inChannel=NTV2_CHANNEL1)
Configures the AJA device to handle a specific video format.
Definition: ntv2register.cpp:204
ancillarydata_cea608_line21.h
Declares the AJAAncillaryData_Cea608_line21 class.
CNTV2Card::Set4kSquaresEnable
virtual bool Set4kSquaresEnable(const bool inIsEnabled, const NTV2Channel inChannel)
Enables or disables SMPTE 425 "2K quadrants" mode for the given FrameStore bank on the device....
Definition: ntv2register.cpp:1238
NTV2_CC608_MinCol
const UWord NTV2_CC608_MinCol(1)
The minimum column index number (located at the left edge of the screen).
CaptionData::f2_char1
UByte f2_char1
Caption Byte 1 of Field 2.
Definition: ntv2caption608types.h:662
NTV2LHIHDMIColorSpace
NTV2LHIHDMIColorSpace
Definition: ntv2enums.h:3648
NTV2_AUDIO_BUFFER_BIG
@ NTV2_AUDIO_BUFFER_BIG
Definition: ntv2enums.h:1905
AJAAncillaryData_Cea608::GetCEA608Bytes
virtual AJAStatus GetCEA608Bytes(uint8_t &outByte1, uint8_t &outByte2, bool &outIsValid) const
Answers with the CEA608 payload bytes.
Definition: ancillarydata_cea608.cpp:89
NTV2FormatDescriptor
Describes a video frame for a given video standard or format and pixel format, including the total nu...
Definition: ntv2formatdescriptor.h:41
NTV2InputSourceToTimecodeIndex
NTV2TimecodeIndex NTV2InputSourceToTimecodeIndex(const NTV2InputSource inInputSource, const bool inEmbeddedLTC=false)
Converts a given NTV2InputSource to its equivalent NTV2TimecodeIndex value.
Definition: ntv2utils.cpp:5160
NTV2FrameGrabber::SetupInput
bool SetupInput(void)
Configures my AJA device for capture.
Definition: ntv2framegrabber.cpp:536
NTV2Channel
NTV2Channel
These enum values are mostly used to identify a specific widget_framestore. They're also commonly use...
Definition: ntv2enums.h:1343
NTV2Buffer::GetByteCount
ULWord GetByteCount(void) const
Definition: ntv2publicinterface.h:6168
NTV2_ASSERT
#define NTV2_ASSERT(_expr_)
Definition: ajatypes.h:508
NTV2_XptCSC4VidInput
@ NTV2_XptCSC4VidInput
Definition: ntv2enums.h:2763
AJAAncillaryData_Cea608_Line21
This class handles "analog" (Line 21) based CEA-608 caption data packets.
Definition: ancillarydata_cea608_line21.h:27
CNTV2Card::WaitForInputVerticalInterrupt
virtual bool WaitForInputVerticalInterrupt(const NTV2Channel inChannel=NTV2_CHANNEL1, UWord inRepeatCount=1)
Efficiently sleeps the calling thread/process until the next one or more field (interlaced video) or ...
Definition: ntv2subscriptions.cpp:149
NTV2_AUDIO_48K
@ NTV2_AUDIO_48K
Definition: ntv2enums.h:1916
NTV2FrameGrabber::GetVideoFormatFromInputSource
NTV2VideoFormat GetVideoFormatFromInputSource(void)
Definition: ntv2framegrabber.cpp:809
ancillarylist.h
Declares the AJAAncillaryList class.
NTV2_Xpt425Mux2AYUV
@ NTV2_Xpt425Mux2AYUV
Definition: ntv2enums.h:2639
NTV2_AUDIOSYSTEM_1
@ NTV2_AUDIOSYSTEM_1
This identifies the first Audio System.
Definition: ntv2enums.h:3867
NTV2InputSourceToEmbeddedAudioInput
NTV2EmbeddedAudioInput NTV2InputSourceToEmbeddedAudioInput(const NTV2InputSource inInputSource)
Converts a given NTV2InputSource to its equivalent NTV2EmbeddedAudioInput value.
Definition: ntv2utils.cpp:4942
AUTOCIRCULATE_TRANSFER::acAudioBuffer
NTV2Buffer acAudioBuffer
The host audio buffer. This field is owned by the client application, and thus is responsible for all...
Definition: ntv2publicinterface.h:8176
AJAAncillaryList::CountAncillaryDataWithType
virtual uint32_t CountAncillaryDataWithType(const AJAAncDataType inMatchType) const
Answers with the number of AJAAncillaryData objects having the given type.
Definition: ancillarylist.cpp:264
CNTV2Card::GetSDIInput12GPresent
virtual bool GetSDIInput12GPresent(bool &outValue, const NTV2Channel channel)
Definition: ntv2register.cpp:3638
CNTV2Card::AutoCirculateInitForInput
virtual bool AutoCirculateInitForInput(const NTV2Channel inChannel, const UWord inFrameCount=7, const NTV2AudioSystem inAudioSystem=NTV2_AUDIOSYSTEM_INVALID, const ULWord inOptionFlags=0, const UByte inNumChannels=1, const UWord inStartFrameNumber=0, const UWord inEndFrameNumber=0)
Prepares for subsequent AutoCirculate ingest, designating a contiguous block of frame buffers on the ...
Definition: ntv2autocirculate.cpp:221
AJAAncillaryList::ParseAllAncillaryData
virtual AJAStatus ParseAllAncillaryData(void)
Sends a "ParsePayloadData" command to all of my AJAAncillaryData objects.
Definition: ancillarylist.cpp:247
NTV2_Xpt425Mux2BYUV
@ NTV2_Xpt425Mux2BYUV
Definition: ntv2enums.h:2641
NTV2FormatDescriptor::GetRasterHeight
ULWord GetRasterHeight(const bool inVisibleOnly=false) const
Definition: ntv2formatdescriptor.h:188
NTV2_REFERENCE_ANALOG_INPUT1
@ NTV2_REFERENCE_ANALOG_INPUT1
Specifies the Analog In 1 connector.
Definition: ntv2enums.h:1446
gMutex
static QMutex gMutex
Definition: ntv2framegrabber.cpp:26
NTV2Buffer::Allocate
bool Allocate(const size_t inByteCount, const bool inPageAligned=false)
Allocates (or re-allocates) my user-space storage using the given byte count. I assume full responsib...
Definition: ntv2publicinterface.cpp:1769
NTV2_LHIHDMIColorSpaceRGB
@ NTV2_LHIHDMIColorSpaceRGB
Definition: ntv2enums.h:3651
CNTV2Card::GetVANCMode
virtual bool GetVANCMode(NTV2VANCMode &outVancMode, const NTV2Channel inChannel=NTV2_CHANNEL1)
Retrieves the current VANC mode for the given FrameStore.
Definition: ntv2register.cpp:2728
PULWord
uint32_t * PULWord
Definition: ajatypes.h:256
FGNOTE
#define FGNOTE(_expr_)
Definition: ntv2framegrabber.cpp:23
NTV2_CHANNEL1
@ NTV2_CHANNEL1
Specifies channel or FrameStore 1 (or the first item).
Definition: ntv2enums.h:1345
CNTV2Card::SetFrameBufferFormat
virtual bool SetFrameBufferFormat(NTV2Channel inChannel, NTV2FrameBufferFormat inNewFormat, bool inIsAJARetail=(!(0)), NTV2HDRXferChars inXferChars=NTV2_VPID_TC_SDR_TV, NTV2HDRColorimetry inColorimetry=NTV2_VPID_Color_Rec709, NTV2HDRLuminance inLuminance=NTV2_VPID_Luminance_YCbCr)
Sets the frame buffer format for the given FrameStore on the AJA device.
Definition: ntv2register.cpp:1812
CNTV2Card::SetSDITransmitEnable
virtual bool SetSDITransmitEnable(const NTV2Channel inChannel, const bool inEnable)
Sets the specified bidirectional SDI connector to act as an input or an output.
Definition: ntv2register.cpp:3796
CaptionData::f1_char2
UByte f1_char2
Caption Byte 2 of Field 1.
Definition: ntv2caption608types.h:659
NTV2_XptCSC1VidInput
@ NTV2_XptCSC1VidInput
Definition: ntv2enums.h:2757
CNTV2Card::GetSDITransmitEnable
virtual bool GetSDITransmitEnable(const NTV2Channel inChannel, bool &outEnabled)
Answers whether or not the specified SDI connector is currently acting as a transmitter (i....
Definition: ntv2register.cpp:3817
AJAAncillaryList::GetAncillaryDataWithType
virtual AJAAncillaryData * GetAncillaryDataWithType(const AJAAncDataType inMatchType, const uint32_t inIndex=0) const
Answers with the AJAAncillaryData object having the given type and index.
Definition: ancillarylist.cpp:280
nlohmann::json_abiNLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON_v3_11_NLOHMANN_JSON_VERSION_PATCH::detail::void
j template void())
Definition: json.hpp:4893
NTV2FrameGrabber::CheckForValidInput
bool CheckForValidInput(void)
Definition: ntv2framegrabber.cpp:768
NTV2_HDMI_V2_HDSD_BIDIRECTIONAL
@ NTV2_HDMI_V2_HDSD_BIDIRECTIONAL
Definition: ntv2enums.h:3972
CNTV2DemoCommon::Get4KInputFormat
static bool Get4KInputFormat(NTV2VideoFormat &inOutVideoFormat)
Given a video format, if all 4 inputs are the same and promotable to 4K, this function does the promo...
Definition: ntv2democommon.cpp:1157
AJAAncillaryList
I am an ordered collection of AJAAncillaryData instances which represent one or more SMPTE 291 data p...
Definition: ancillarylist.h:64
NTV2_Xpt425Mux2BInput
@ NTV2_Xpt425Mux2BInput
Definition: ntv2enums.h:2853
NTV2_CHANNEL_INVALID
@ NTV2_CHANNEL_INVALID
Definition: ntv2enums.h:1354
CNTV2Card::SetAudioSystemInputSource
virtual bool SetAudioSystemInputSource(const NTV2AudioSystem inAudioSystem, const NTV2AudioSource inAudioSource, const NTV2EmbeddedAudioInput inEmbeddedInput)
Sets the audio source for the given NTV2AudioSystem on the device.
Definition: ntv2audio.cpp:485
FGDBG
#define FGDBG(_expr_)
Definition: ntv2framegrabber.cpp:22
NTV2_IS_4K_VIDEO_FORMAT
#define NTV2_IS_4K_VIDEO_FORMAT(__f__)
Definition: ntv2enums.h:774
IsProgressivePicture
bool IsProgressivePicture(const NTV2VideoFormat format)
Definition: ntv2utils.cpp:5456
NTV2_CHANNEL4
@ NTV2_CHANNEL4
Specifies channel or FrameStore 4 (or the 4th item).
Definition: ntv2enums.h:1348
AUTOCIRCULATE_STATUS::acState
NTV2AutoCirculateState acState
Current AutoCirculate state.
Definition: ntv2publicinterface.h:7277
NTV2_CHANNEL5
@ NTV2_CHANNEL5
Specifies channel or FrameStore 5 (or the 5th item).
Definition: ntv2enums.h:1349
GetIndexForNTV2InputSource
ULWord GetIndexForNTV2InputSource(const NTV2InputSource inValue)
Definition: ntv2utils.cpp:5339
CNTV2Card::GetSDIInput6GPresent
virtual bool GetSDIInput6GPresent(bool &outValue, const NTV2Channel channel)
Definition: ntv2register.cpp:3626
CNTV2Card::features
virtual class DeviceCapabilities & features(void)
Definition: ntv2card.h:141
NTV2_INPUTSOURCE_ANALOG1
@ NTV2_INPUTSOURCE_ANALOG1
Identifies the first analog video input.
Definition: ntv2enums.h:1255
AUTOCIRCULATE_WITH_ANC
#define AUTOCIRCULATE_WITH_ANC
Use this to AutoCirculate with ancillary data.
Definition: ntv2publicinterface.h:5587
NTV2Caption608ChangeInfo
This class is used to respond to dynamic events that occur during CEA-608 caption decoding.
Definition: ntv2caption608types.h:779
NTV2_INPUTSOURCE_SDI1
@ NTV2_INPUTSOURCE_SDI1
Identifies the 1st SDI video input.
Definition: ntv2enums.h:1260
CNTV2Card::GetDisplayName
virtual std::string GetDisplayName(void)
Answers with this device's display name.
Definition: ntv2card.cpp:86
CNTV2Card::DeviceGetNumberFrameBuffers
virtual ULWord DeviceGetNumberFrameBuffers(const NTV2FrameGeometry inFrameGeometry, const NTV2FrameBufferFormat inFBFormat)
Definition: ntv2card.cpp:470
NTV2_XptCSC3VidRGB
@ NTV2_XptCSC3VidRGB
Definition: ntv2enums.h:2581
NTV2InputSourceToString
std::string NTV2InputSourceToString(const NTV2InputSource inValue, const bool inForRetailDisplay=false)
Definition: ntv2utils.cpp:7263
CNTV2Card::SetRP188SourceFilter
virtual bool SetRP188SourceFilter(const NTV2Channel inSDIInput, const UWord inFilterValue)
Sets the RP188 DBB filter for the given SDI input.
Definition: ntv2register.cpp:2533
NTV2_XptFrameBuffer1Input
@ NTV2_XptFrameBuffer1Input
Definition: ntv2enums.h:2741
NTV2FrameGrabber::ClearCaptionBuffer
void ClearCaptionBuffer(const bool inSignalClients=(0))
Definition: ntv2framegrabber.cpp:160
AJATime::Sleep
static void Sleep(const int32_t inMilliseconds)
Suspends execution of the current thread for a given number of milliseconds.
Definition: systemtime.cpp:284
NTV2Standard
NTV2Standard
Identifies a particular video standard.
Definition: ntv2enums.h:156
NTV2_XptCSC4VidRGB
@ NTV2_XptCSC4VidRGB
Definition: ntv2enums.h:2584
NTV2_MAX_NUM_CHANNELS
@ NTV2_MAX_NUM_CHANNELS
Definition: ntv2enums.h:1353
NTV2Buffer::IsNULL
bool IsNULL(void) const
Definition: ntv2publicinterface.h:6190
ULWord
uint32_t ULWord
Definition: ajatypes.h:255
CNTV2Card::GetDescription
virtual std::string GetDescription(void) const
Definition: ntv2card.cpp:143
AUTOCIRCULATE_STATUS
This is returned from the CNTV2Card::AutoCirculateGetStatus function.
Definition: ntv2publicinterface.h:7274
NTV2FrameGrabber::SetupAudio
void SetupAudio(void)
Performs audio configuration.
Definition: ntv2framegrabber.cpp:887
AJAAncillaryData
I am the principal class that stores a single SMPTE-291 SDI ancillary data packet OR the digitized co...
Definition: ancillarydata.h:552
NTV2FrameGrabber::captionScreenChanged
void captionScreenChanged(const ushort *pInScreen)
This is signaled (called) when my caption screen buffer changes.
NTV2_NUM_IMAGES
#define NTV2_NUM_IMAGES
Definition: ntv2framegrabber.cpp:17
AJAAncillaryData::GetPayloadData
virtual const uint8_t * GetPayloadData(void) const
Definition: ancillarydata.h:801
CNTV2Card::SetMode
virtual bool SetMode(const NTV2Channel inChannel, const NTV2Mode inNewValue, const bool inIsRetail=(!(0)))
Determines if a given FrameStore on the AJA device will be used to capture or playout video.
Definition: ntv2register.cpp:1607
FRAME_STAMP::GetInputTimeCodes
bool GetInputTimeCodes(NTV2TimeCodeList &outValues) const
Returns all RP188 timecodes associated with the frame in NTV2TCIndex order.
Definition: ntv2publicinterface.cpp:2238
NTV2_INPUTSOURCE_INVALID
@ NTV2_INPUTSOURCE_INVALID
The invalid video input.
Definition: ntv2enums.h:1268
AJAAncillaryData_Cea608_Line21::ParsePayloadData
virtual AJAStatus ParsePayloadData(void)
Parses out (interprets) the "local" ancillary data from my payload data.
Definition: ancillarydata_cea608_line21.cpp:83
NTV2TCIndex
NTV2TCIndex
These enum values are indexes into the capture/playout AutoCirculate timecode arrays.
Definition: ntv2enums.h:3921
IsValidLine21Channel
#define IsValidLine21Channel(_chan_)
Definition: ntv2caption608types.h:102
GetCSCOutputXptFromChannel
NTV2OutputXptID GetCSCOutputXptFromChannel(const NTV2Channel inCSC, const bool inIsKey=false, const bool inIsRGB=false)
Definition: ntv2signalrouter.cpp:847
GetFrameBufferInputXptFromChannel
#define GetFrameBufferInputXptFromChannel
Definition: ntv2signalrouter.h:732
AJAProcess::GetPid
static uint64_t GetPid()
Definition: process.cpp:35
NTV2_INPUTSOURCE_SDI5
@ NTV2_INPUTSOURCE_SDI5
Identifies the 5th SDI video input.
Definition: ntv2enums.h:1264
CNTV2Card::SetLTCInputEnable
virtual bool SetLTCInputEnable(const bool inEnable)
Enables or disables the ability for the device to read analog LTC on the reference input connector.
Definition: ntv2register.cpp:3651
NTV2_CHANNEL3
@ NTV2_CHANNEL3
Specifies channel or FrameStore 3 (or the 3rd item).
Definition: ntv2enums.h:1347
NTV2_STANDARD_1080p
@ NTV2_STANDARD_1080p
Identifies SMPTE HD 1080p.
Definition: ntv2enums.h:162
UWord
uint16_t UWord
Definition: ajatypes.h:253
CNTV2Card::AutoCirculateGetStatus
virtual bool AutoCirculateGetStatus(const NTV2Channel inChannel, AUTOCIRCULATE_STATUS &outStatus)
Returns the current AutoCirculate status for the given channel.
Definition: ntv2autocirculate.cpp:646
CRP188::SetRP188
void SetRP188(ULWord ulFrms, ULWord ulSecs, ULWord ulMins, ULWord ulHrs, NTV2FrameRate frameRate, const bool bDropFrame=false, const bool bSMPTE372=false)
Definition: ntv2rp188.cpp:586
NTV2_IS_VALID_INPUT_SOURCE
#define NTV2_IS_VALID_INPUT_SOURCE(_inpSrc_)
Definition: ntv2enums.h:1275
NTV2_REFERENCE_FREERUN
@ NTV2_REFERENCE_FREERUN
Specifies the device's internal clock.
Definition: ntv2enums.h:1445
GetNTV2InputSourceForIndex
NTV2InputSource GetNTV2InputSourceForIndex(const ULWord inIndex0, const NTV2IOKinds inKinds=NTV2_IOKINDS_SDI)
Definition: ntv2utils.cpp:5289
NTV2_XptCSC3VidInput
@ NTV2_XptCSC3VidInput
Definition: ntv2enums.h:2761
ntv2utils.h
Declares numerous NTV2 utility functions.
NTV2FrameGrabber::NTV2FrameGrabber
NTV2FrameGrabber(QObject *pInParentObject=NULL)
Constructs me.
Definition: ntv2framegrabber.cpp:29
NTV2VideoFormatToString
std::string NTV2VideoFormatToString(const NTV2VideoFormat inValue, const bool inUseFrameRate=false)
Definition: ntv2utils.cpp:6798
NTV2_INPUT_SOURCE_IS_HDMI
#define NTV2_INPUT_SOURCE_IS_HDMI(_inpSrc_)
Definition: ntv2enums.h:1272
QTPREVIEW_WIDGET_Y
#define QTPREVIEW_WIDGET_Y
Definition: ntv2framegrabber.h:36
AJAAncillaryDataType_Cea608_Vanc
#define AJAAncillaryDataType_Cea608_Vanc
Definition: ancillarydata.h:1640
AUTOCIRCULATE_TRANSFER::SetVideoBuffer
bool SetVideoBuffer(ULWord *pInVideoBuffer, const ULWord inVideoByteCount)
Sets my video buffer for use in a subsequent call to CNTV2Card::AutoCirculateTransfer.
Definition: ntv2publicinterface.cpp:2851
AJA_SUCCESS
#define AJA_SUCCESS(_status_)
Definition: types.h:370
GetCSCInputXptFromChannel
NTV2InputXptID GetCSCInputXptFromChannel(const NTV2Channel inCSC, const bool inIsKeyInput=false)
Definition: ntv2signalrouter.cpp:803
NTV2_IS_HD_VIDEO_FORMAT
#define NTV2_IS_HD_VIDEO_FORMAT(__f__)
Definition: ntv2enums.h:728
NTV2_XptAnalogIn
@ NTV2_XptAnalogIn
Definition: ntv2enums.h:2544
CNTV2CaptionDecoder608::Create
static bool Create(CNTV2CaptionDecoder608Ptr &outEncoder)
Creates a new CNTV2CaptionEncoder608 instance.
NTV2_XptFrameBuffer1DS2Input
@ NTV2_XptFrameBuffer1DS2Input
Definition: ntv2enums.h:2742
CNTV2DriverInterface::IsDeviceReady
virtual bool IsDeviceReady(const bool inCheckValid=(0))
Definition: ntv2driverinterface.cpp:1316
CaptionData::bGotField2Data
bool bGotField2Data
True if Field 2 bytes have been set; otherwise false.
Definition: ntv2caption608types.h:661
NTV2_NUM_INPUTSOURCES
@ NTV2_NUM_INPUTSOURCES
Definition: ntv2enums.h:1269
kDemoAppSignature
static const ULWord kDemoAppSignature((((uint32_t)( 'D'))<< 24)|(((uint32_t)( 'E'))<< 16)|(((uint32_t)( 'M'))<< 8)|(((uint32_t)( 'O'))<< 0))
NTV2_Xpt425Mux1AYUV
@ NTV2_Xpt425Mux1AYUV
Definition: ntv2enums.h:2635
NTV2_Xpt425Mux1BYUV
@ NTV2_Xpt425Mux1BYUV
Definition: ntv2enums.h:2637
AUTOCIRCULATE_TRANSFER_STATUS::acFrameStamp
FRAME_STAMP acFrameStamp
Frame stamp for the transferred frame.
Definition: ntv2publicinterface.h:8079
AUTOCIRCULATE_TRANSFER::acANCField2Buffer
NTV2Buffer acANCField2Buffer
The host "Field 2" ancillary data buffer. This field is owned by the client application,...
Definition: ntv2publicinterface.h:8198
CNTV2Card::SetTsiFrameEnable
virtual bool SetTsiFrameEnable(const bool inIsEnabled, const NTV2Channel inChannel)
Enables or disables SMPTE 425 two-sample interleave (Tsi) frame mode on the device.
Definition: ntv2register.cpp:1311
CNTV2Card::GetInputVideoFormat
virtual NTV2VideoFormat GetInputVideoFormat(const NTV2InputSource inVideoSource=NTV2_INPUTSOURCE_SDI1, const bool inIsProgressive=(0))
Returns the video format of the signal that is present on the given input source.
Definition: ntv2register.cpp:3365
CRP188
Definition: ntv2rp188.h:55
AUTOCIRCULATE_STATUS::acBufferLevel
ULWord acBufferLevel
Number of buffered frames in driver ready to capture or play.
Definition: ntv2publicinterface.h:7287
NTV2_AUDIOSIZE_MAX
#define NTV2_AUDIOSIZE_MAX
Definition: ntv2democommon.h:46
CNTV2Card::SetEveryFrameServices
virtual bool SetEveryFrameServices(const NTV2EveryFrameTaskMode inMode)
Sets the device's task mode.
Definition: ntv2register.cpp:179
NTV2FrameGrabber::newStatusString
void newStatusString(const QString &inStatus)
This is signaled (called) when my status string changes.
NTV2VANCMode
NTV2VANCMode
These enum values identify the available VANC modes.
Definition: ntv2enums.h:3767
AJA_NULL
#define AJA_NULL
Definition: ajatypes.h:199
AUTOCIRCULATE_TRANSFER::acTransferStatus
AUTOCIRCULATE_TRANSFER_STATUS acTransferStatus
Contains status information that's valid after CNTV2Card::AutoCirculateTransfer returns,...
Definition: ntv2publicinterface.h:8213
NTV2_IS_VALID_CHANNEL
#define NTV2_IS_VALID_CHANNEL(__x__)
Definition: ntv2enums.h:1357
NTV2_VANCMODE_INVALID
@ NTV2_VANCMODE_INVALID
This identifies the invalid (unspecified, uninitialized) VANC mode.
Definition: ntv2enums.h:3772
NTV2_CC608_MaxCol
const UWord NTV2_CC608_MaxCol(32)
The maximum column index number (located at the right edge of the screen).
NTV2FrameGrabber::OutputAudio
void OutputAudio(ULWord *pInOutAudioBuffer, const ULWord inNumValidBytes)
Writes audio samples for channels 1 and 2 that are in the given audio buffer to my QAudioOutput devic...
Definition: ntv2framegrabber.cpp:941
NTV2Buffer::GetHostPointer
void * GetHostPointer(void) const
Definition: ntv2publicinterface.h:6151
NTV2InputSource
NTV2InputSource
Identifies a specific video input source.
Definition: ntv2enums.h:1253
NTV2_FORMAT_UNKNOWN
@ NTV2_FORMAT_UNKNOWN
Definition: ntv2enums.h:525
NTV2_AUDIO_HDMI
@ NTV2_AUDIO_HDMI
Obtain audio samples from the device HDMI input, if available.
Definition: ntv2enums.h:1996
CNTV2Card::Connect
virtual bool Connect(const NTV2InputCrosspointID inInputXpt, const NTV2OutputCrosspointID inOutputXpt, const bool inValidate=(0))
Connects the given widget signal input (sink) to the given widget signal output (source).
Definition: ntv2regroute.cpp:87
NTV2FrameGrabber::run
virtual void run(void)
My thread function.
Definition: ntv2framegrabber.cpp:274
NTV2_LHIHDMIColorSpaceYCbCr
@ NTV2_LHIHDMIColorSpaceYCbCr
Definition: ntv2enums.h:3650
DEC
#define DEC(__x__)
Definition: ntv2publicinterface.h:5647
AJAAncillaryDataType_Cea708
#define AJAAncillaryDataType_Cea708
Definition: ancillarydata.h:1639
NTV2_XptFrameBuffer2Input
@ NTV2_XptFrameBuffer2Input
Definition: ntv2enums.h:2743
NTV2FrameGrabber
A QThread that captures audio/video from NTV2-compatible AJA devices and uses Qt signals to emit ARGB...
Definition: ntv2framegrabber.h:46
false
#define false
Definition: ntv2devicefeatures.h:25
ntv2democommon.h
This file contains some structures, constants, classes and functions that are used in some of the dem...
AUTOCIRCULATE_WITH_RP188
#define AUTOCIRCULATE_WITH_RP188
Use this to AutoCirculate with RP188.
Definition: ntv2publicinterface.h:5581
AJAAncillaryList::AddReceivedAncillaryData
virtual AJAStatus AddReceivedAncillaryData(const NTV2Buffer &inReceivedData, const uint32_t inFrameNum=0)
Parse "raw" ancillary data bytes received from hardware (ingest) – see SDI Anc Buffer Data Format – i...
Definition: ancillarylist.cpp:584
NTV2_MODE_CAPTURE
@ NTV2_MODE_CAPTURE
Capture (input) mode, which writes into device SDRAM.
Definition: ntv2enums.h:1234
NTV2FrameGrabber::GrabCaptions
void GrabCaptions(void)
Performs caption data extraction & decoding.
Definition: ntv2framegrabber.cpp:174
NTV2FrameGrabber::SetInputSource
void SetInputSource(const NTV2InputSource inInputSource)
Sets the input to be used for capture on the AJA device being used.
Definition: ntv2framegrabber.cpp:74
NTV2Line21Channel
NTV2Line21Channel
The CEA-608 caption channels: CC1 thru CC4, TX1 thru TX4, plus XDS.
Definition: ntv2caption608types.h:82
NTV2FrameGrabber::newFrame
void newFrame(const QImage &inImage, const bool inClear)
This is signaled (called) when a new frame has been captured and is available for display.
std
Definition: json.hpp:5362
NTV2_CC608_MinRow
const UWord NTV2_CC608_MinRow(1)
The minimum row index number (located at the top of the screen).
NTV2FrameGrabber::IsInput3Gb
bool IsInput3Gb(const NTV2InputSource inputSource)
Definition: ntv2framegrabber.cpp:879
NTV2_AUDIO_EMBEDDED
@ NTV2_AUDIO_EMBEDDED
Obtain audio samples from the audio that's embedded in the video HANC.
Definition: ntv2enums.h:1993
CNTV2Card::AutoCirculateTransfer
virtual bool AutoCirculateTransfer(const NTV2Channel inChannel, AUTOCIRCULATE_TRANSFER &transferInfo)
Transfers all or part of a frame as specified in the given AUTOCIRCULATE_TRANSFER object to/from the ...
Definition: ntv2autocirculate.cpp:695
CNTV2MacDriverInterface::AcquireStreamForApplicationWithReference
virtual bool AcquireStreamForApplicationWithReference(ULWord inApplicationType, int32_t inProcessID)
A reference-counted version of CNTV2DriverInterface::AcquireStreamForApplication useful for process g...
Definition: ntv2macdriverinterface.cpp:551
NTV2VideoFormat
enum _NTV2VideoFormat NTV2VideoFormat
Identifies a particular video format.
CNTV2Card::GetHDMIInputColor
virtual bool GetHDMIInputColor(NTV2LHIHDMIColorSpace &outValue, const NTV2Channel inChannel=NTV2_CHANNEL1)
Answers with the current colorspace for the given HDMI input.
Definition: ntv2hdmi.cpp:52
NTV2TimeCodeList
std::vector< NTV2_RP188 > NTV2TimeCodeList
An ordered sequence of zero or more NTV2_RP188 structures. An NTV2TCIndex enum value can be used as a...
Definition: ntv2publicinterface.h:6952
NTV2_XptCSC2VidRGB
@ NTV2_XptCSC2VidRGB
Definition: ntv2enums.h:2537
NTV2_AUTOCIRCULATE_RUNNING
@ NTV2_AUTOCIRCULATE_RUNNING
The AutoCirculate channel is running.
Definition: ntv2publicinterface.h:4335
true
#define true
Definition: ntv2devicefeatures.h:26
NTV2_TCINDEX_INVALID
@ NTV2_TCINDEX_INVALID
Definition: ntv2enums.h:3951
CNTV2DriverInterface::GetDeviceID
virtual NTV2DeviceID GetDeviceID(void)
Definition: ntv2driverinterface.cpp:411
ntv2framegrabber.h
Header file for the NTV2FrameGrabber class.
CNTV2Card::GetEveryFrameServices
virtual bool GetEveryFrameServices(NTV2EveryFrameTaskMode &outMode)
Retrieves the device's current "retail service" task mode.
Definition: ntv2register.cpp:184
GetInputSourceOutputXpt
NTV2OutputXptID GetInputSourceOutputXpt(const NTV2InputSource inInputSource, const bool inIsSDI_DS2=false, const bool inIsHDMI_RGB=false, const UWord inHDMI_Quadrant=0)
Definition: ntv2signalrouter.cpp:893
NTV2FrameGrabber::StopAutoCirculate
void StopAutoCirculate(void)
Stops capturing.
Definition: ntv2framegrabber.cpp:752
CNTV2Card::SetHDMIV2Mode
virtual bool SetHDMIV2Mode(const NTV2HDMIV2Mode inMode)
Sets HDMI V2 mode for the device.
Definition: ntv2hdmi.cpp:592
NTV2FrameGrabber::SetDeviceIndex
void SetDeviceIndex(const UWord inDeviceIndex)
Sets the AJA device to be used for capture.
Definition: ntv2framegrabber.cpp:88
NTV2_XptCSC1VidRGB
@ NTV2_XptCSC1VidRGB
Definition: ntv2enums.h:2522
AJAAncillaryDataType_Cea608_Line21
#define AJAAncillaryDataType_Cea608_Line21
Definition: ancillarydata.h:1641
NTV2_INPUT_SOURCE_IS_SDI
#define NTV2_INPUT_SOURCE_IS_SDI(_inpSrc_)
Definition: ntv2enums.h:1274
GetNTV2StandardFromVideoFormat
NTV2Standard GetNTV2StandardFromVideoFormat(const NTV2VideoFormat inVideoFormat)
Definition: ntv2utils.cpp:2279
CNTV2Card::AutoCirculateStart
virtual bool AutoCirculateStart(const NTV2Channel inChannel, const ULWord64 inStartTime=0)
Starts AutoCirculating the specified channel that was previously initialized by CNTV2Card::AutoCircul...
Definition: ntv2autocirculate.cpp:503
CaptionData::bGotField1Data
bool bGotField1Data
True if Field 1 bytes have been set; otherwise false.
Definition: ntv2caption608types.h:657
CNTV2Card::SetReference
virtual bool SetReference(const NTV2ReferenceSource inRefSource, const bool inKeepFramePulseSelect=(0))
Sets the device's clock reference source. See Video Output Clocking & Synchronization for more inform...
Definition: ntv2register.cpp:1484
AUTOCIRCULATE_TRANSFER_STATUS::acAudioTransferSize
ULWord acAudioTransferSize
Number of bytes captured into the audio buffer.
Definition: ntv2publicinterface.h:8080
NTV2Line21Attributes
CEA-608 Character Attributes.
Definition: ntv2caption608types.h:357
NTV2_AUDIO_ANALOG
@ NTV2_AUDIO_ANALOG
Obtain audio samples from the device analog input(s), if available.
Definition: ntv2enums.h:1995
CaptionData
This structure encapsulates all possible CEA-608 caption data bytes that may be associated with a giv...
Definition: ntv2caption608types.h:655
CNTV2Card::SetNumberAudioChannels
virtual bool SetNumberAudioChannels(const ULWord inNumChannels, const NTV2AudioSystem inAudioSystem=NTV2_AUDIOSYSTEM_1)
Sets the number of audio channels to be concurrently captured or played for a given Audio System on t...
Definition: ntv2audio.cpp:146
CNTV2Card::SetAudioBufferSize
virtual bool SetAudioBufferSize(const NTV2AudioBufferSize inValue, const NTV2AudioSystem inAudioSystem=NTV2_AUDIOSYSTEM_1)
Changes the size of the audio buffer that is used for a given Audio System in the AJA device.
Definition: ntv2audio.cpp:249
CaptionData::f2_char2
UByte f2_char2
Caption Byte 2 of Field 2.
Definition: ntv2caption608types.h:663
NTV2_HDMI_V2_4K_CAPTURE
@ NTV2_HDMI_V2_4K_CAPTURE
Definition: ntv2enums.h:3973
CNTV2MacDriverInterface::ReleaseStreamForApplicationWithReference
virtual bool ReleaseStreamForApplicationWithReference(ULWord inApplicationType, int32_t inProcessID)
A reference-counted version of CNTV2DriverInterface::ReleaseStreamForApplication useful for process g...
Definition: ntv2macdriverinterface.cpp:589
NTV2_INPUT_SOURCE_IS_ANALOG
#define NTV2_INPUT_SOURCE_IS_ANALOG(_inpSrc_)
Definition: ntv2enums.h:1273
CNTV2Card::EnableChannel
virtual bool EnableChannel(const NTV2Channel inChannel)
Enables the given FrameStore.
Definition: ntv2register.cpp:2097
NTV2_MODE_DISPLAY
@ NTV2_MODE_DISPLAY
Playout (output) mode, which reads from device SDRAM.
Definition: ntv2enums.h:1232
NTV2FrameGrabber::SetTimeCodeSource
void SetTimeCodeSource(const NTV2TCIndex inTCSource)
Definition: ntv2framegrabber.cpp:100
NTV2_XptFrameBuffer2DS2Input
@ NTV2_XptFrameBuffer2DS2Input
Definition: ntv2enums.h:2744
NTV2AudioSource
NTV2AudioSource
This enum value determines/states where an audio system will obtain its audio samples.
Definition: ntv2enums.h:1991
CNTV2Card::GetTsiFrameEnable
virtual bool GetTsiFrameEnable(bool &outIsEnabled, const NTV2Channel inChannel)
Returns the current SMPTE 425 two-sample-interleave frame mode on the device, whether it's enabled or...
Definition: ntv2register.cpp:1404
NTV2ChannelToAudioSystem
NTV2AudioSystem NTV2ChannelToAudioSystem(const NTV2Channel inChannel)
Converts the given NTV2Channel value into its equivalent NTV2AudioSystem.
Definition: ntv2utils.cpp:4934
AUTOCIRCULATE_TRANSFER::acANCBuffer
NTV2Buffer acANCBuffer
The host ancillary data buffer. This field is owned by the client application, and thus is responsibl...
Definition: ntv2publicinterface.h:8187
NTV2_XptCSC2VidInput
@ NTV2_XptCSC2VidInput
Definition: ntv2enums.h:2759
CNTV2DriverInterface::Open
virtual bool Open(const UWord inDeviceIndex)
Opens a local/physical AJA device so it can be monitored/controlled.
Definition: ntv2driverinterface.cpp:131
CNTV2Card::AutoCirculateStop
virtual bool AutoCirculateStop(const NTV2Channel inChannel, const bool inAbort=(0))
Stops AutoCirculate for the given channel, and releases the on-device frame buffers that were allocat...
Definition: ntv2autocirculate.cpp:519
DEVICE_ID_NOTFOUND
@ DEVICE_ID_NOTFOUND
Invalid or "not found".
Definition: ntv2enums.h:92
CNTV2Card::GetSDIInput3GbPresent
virtual bool GetSDIInput3GbPresent(bool &outValue, const NTV2Channel channel)
Definition: ntv2register.cpp:3614
NTV2_ANCSIZE_MAX
#define NTV2_ANCSIZE_MAX
Definition: ntv2democommon.h:47
NTV2_Xpt425Mux1BInput
@ NTV2_Xpt425Mux1BInput
Definition: ntv2enums.h:2851
CaptionData::f1_char1
UByte f1_char1
Caption Byte 1 of Field 1.
Definition: ntv2caption608types.h:658
NTV2_IS_VALID_VIDEO_FORMAT
#define NTV2_IS_VALID_VIDEO_FORMAT(__f__)
Definition: ntv2enums.h:716
CRP188::GetRP188Str
bool GetRP188Str(std::string &sRP188) const
Definition: ntv2rp188.cpp:917
CNTV2DriverInterface::Close
virtual bool Close(void)
Closes me, releasing host resources that may have been allocated in a previous Open call.
Definition: ntv2driverinterface.cpp:227
NTV2_OEM_TASKS
@ NTV2_OEM_TASKS
2: OEM (recommended): device configured by client application(s) with some driver involvement.
Definition: ntv2publicinterface.h:4350
QTPREVIEW_WIDGET_X
#define QTPREVIEW_WIDGET_X
Definition: ntv2framegrabber.h:35
NTV2_Xpt425Mux2AInput
@ NTV2_Xpt425Mux2AInput
Definition: ntv2enums.h:2852
NTV2FrameGrabber::GetColorSpaceFromInputSource
NTV2LHIHDMIColorSpace GetColorSpaceFromInputSource(void)
Definition: ntv2framegrabber.cpp:867
NTV2_CC608_MaxRow
const UWord NTV2_CC608_MaxRow(15)
The maximum permissible row index number (located at the bottom of the screen).
CNTV2Card::SetAudioRate
virtual bool SetAudioRate(const NTV2AudioRate inRate, const NTV2AudioSystem inAudioSystem=NTV2_AUDIOSYSTEM_1)
Sets the NTV2AudioRate for the given Audio System.
Definition: ntv2audio.cpp:205
NTV2FrameGrabber::~NTV2FrameGrabber
virtual ~NTV2FrameGrabber()
My destructor.
Definition: ntv2framegrabber.cpp:60