AJA NTV2 SDK  18.1.0.2505
NTV2 SDK 18.1.0.2505
ntv2publicinterface.cpp
Go to the documentation of this file.
1 /* SPDX-License-Identifier: MIT */
7 #include "ntv2publicinterface.h"
8 #include "ntv2devicefeatures.h"
9 #include "ntv2utils.h"
10 #include "ntv2endian.h"
11 #include "ajabase/system/memory.h"
12 #include "ajabase/system/debug.h"
13 #include "ajabase/system/process.h"
14 #include "ajabase/system/thread.h"
15 #include "ajabase/common/common.h"
16 #include "ntv2registerexpert.h"
17 #include "ntv2nubtypes.h"
18 #include "ntv2version.h"
19 #include "ntv2debug.h"
20 #include <iomanip>
21 #include <locale> // For std::locale, std::numpunct, std::use_facet
22 #include <string.h> // For memset, et al.
23 #include <algorithm> // For set_difference
24 #include <iterator> // For std::inserter
25 #include "ntv2rp188.h"
26 #if !defined(MSWindows)
27  #include <unistd.h>
28 #endif
29 using namespace std;
30 
31 //#define NTV2BUFFER_NO_MEMCMP
32 
33 
35 
36 ostream & operator << (ostream & inOutStream, const NTV2StringList & inData)
37 {
38  for (NTV2StringListConstIter it(inData.begin()); it != inData.end(); )
39  {
40  inOutStream << *it;
41  if (++it != inData.end())
42  inOutStream << ", ";
43  }
44  return inOutStream;
45 }
46 
47 ostream & operator << (ostream & inOutStream, const NTV2StringSet & inData)
48 {
49  for (NTV2StringSetConstIter it(inData.begin()); it != inData.end(); )
50  {
51  inOutStream << *it;
52  if (++it != inData.end())
53  inOutStream << ", ";
54  }
55  return inOutStream;
56 }
57 
58 ostream & operator << (ostream & inOutStr, const NTV2AudioChannelPairs & inSet)
59 {
60  if (inSet.empty())
61  inOutStr << "(none)";
62  else
63  for (NTV2AudioChannelPairsConstIter iter (inSet.begin ()); iter != inSet.end (); ++iter)
64  inOutStr << (iter != inSet.begin() ? ", " : "") << ::NTV2AudioChannelPairToString (*iter, true);
65  return inOutStr;
66 }
67 
68 ostream & operator << (ostream & inOutStr, const NTV2AudioChannelQuads & inSet)
69 {
70  for (NTV2AudioChannelQuadsConstIter iter (inSet.begin ()); iter != inSet.end (); ++iter)
71  inOutStr << (iter != inSet.begin () ? ", " : "") << ::NTV2AudioChannelQuadToString (*iter, true);
72  return inOutStr;
73 }
74 
75 ostream & operator << (ostream & inOutStr, const NTV2AudioChannelOctets & inSet)
76 {
77  for (NTV2AudioChannelOctetsConstIter iter (inSet.begin ()); iter != inSet.end (); ++iter)
78  inOutStr << (iter != inSet.begin () ? ", " : "") << ::NTV2AudioChannelOctetToString (*iter, true);
79  return inOutStr;
80 }
81 
82 ostream & operator << (ostream & inOutStr, const NTV2DoubleArray & inVector)
83 {
84  for (NTV2DoubleArrayConstIter iter (inVector.begin ()); iter != inVector.end (); ++iter)
85  inOutStr << *iter << endl;
86  return inOutStr;
87 }
88 
89 ostream & operator << (ostream & inOutStr, const NTV2DIDSet & inDIDs)
90 {
91  for (NTV2DIDSetConstIter it (inDIDs.begin()); it != inDIDs.end(); )
92  {
93  inOutStr << xHEX0N(uint16_t(*it),2);
94  if (++it != inDIDs.end())
95  inOutStr << ", ";
96  }
97  return inOutStr;
98 }
99 
100 ostream & operator << (ostream & inOutStream, const UWordSequence & inData)
101 {
102  inOutStream << DEC(inData.size()) << " UWords: ";
103  for (UWordSequenceConstIter iter(inData.begin()); iter != inData.end(); )
104  {
105  inOutStream << HEX0N(*iter,4);
106  if (++iter != inData.end())
107  inOutStream << " ";
108  }
109  return inOutStream;
110 }
111 
112 ostream & operator << (ostream & inOutStream, const ULWordSequence & inData)
113 {
114  inOutStream << DEC(inData.size()) << " ULWords: ";
115  for (ULWordSequenceConstIter iter(inData.begin()); iter != inData.end(); )
116  {
117  inOutStream << HEX0N(*iter,8);
118  if (++iter != inData.end())
119  inOutStream << " ";
120  }
121  return inOutStream;
122 }
123 
124 ostream & operator << (ostream & inOutStream, const ULWord64Sequence & inData)
125 {
126  inOutStream << DEC(inData.size()) << " ULWord64s: ";
127  for (ULWord64SequenceConstIter iter(inData.begin()); iter != inData.end(); )
128  {
129  inOutStream << HEX0N(*iter,16);
130  if (++iter != inData.end())
131  inOutStream << " ";
132  }
133  return inOutStream;
134 }
135 
136 
138 {
139  Clear ();
140 }
141 
142 
144 {
145  mCRCTallyA = 0;
146  mCRCTallyB = 0;
147  mUnlockTally = 0;
148  mFrameRefClockCount = 0;
149  mGlobalClockCount = 0;
150  mFrameTRSError = false;
151  mLocked = false;
152  mVPIDValidA = false;
153  mVPIDValidB = false;
154 }
155 
156 
157 ostream & NTV2SDIInputStatus::Print (ostream & inOutStream) const
158 {
159  inOutStream << "[CRCA=" << DEC(mCRCTallyA)
160  << " CRCB=" << DEC(mCRCTallyB)
161  << " unlk=" << xHEX0N(mUnlockTally,8)
162  << " frmRefClkCnt=" << xHEX0N(mFrameRefClockCount,16)
163  << " globalClkCnt=" << xHEX0N(mGlobalClockCount,16)
164  << " frmTRS=" << YesNo(mFrameTRSError)
165  << " locked=" << YesNo(mLocked)
166  << " VPIDA=" << YesNo(mVPIDValidA)
167  << " VPIDB=" << YesNo(mVPIDValidB)
168  << "]";
169  return inOutStream;
170 }
171 
172 
174 {
175  mEnabled = false;
176  mPixel420 = false;
177  mColorSpace = NTV2_INVALID_HDMI_COLORSPACE;
178  mRGBRange = NTV2_INVALID_HDMI_RANGE;
179  mProtocol = NTV2_INVALID_HDMI_PROTOCOL;
180  mVideoStandard = NTV2_STANDARD_INVALID;
181  mVideoRate = NTV2_FRAMERATE_UNKNOWN;
182  mVideoBitDepth = NTV2_INVALID_HDMIBitDepth;
183  mAudioFormat = NTV2_AUDIO_FORMAT_INVALID;
184  mAudioRate = NTV2_AUDIO_RATE_INVALID;
185  mAudioChannels = NTV2_INVALID_HDMI_AUDIO_CHANNELS;
186 }
187 
189 {
190  Clear();
192  if (mVideoRate == NTV2_FRAMERATE_UNKNOWN)
193  return true; // Not enabled -- success
194  mEnabled = true;
195  mPixel420 = ((inData & kVRegMaskHDMOutPixel420) >> kVRegShiftHDMOutPixel420) == 1;
200  mVideoBitDepth = NTV2HDMIBitDepth((inData & kVRegMaskHDMOutBitDepth) >> kVRegShiftHDMOutBitDepth);
204  return true;
205 }
206 
207 ostream & NTV2HDMIOutputStatus::Print (ostream & inOutStream) const
208 {
209  inOutStream << "Enabled: " << YesNo(mEnabled);
210  if (mEnabled)
211  inOutStream << endl
212  << "Is 4:2:0: " << YesNo(mPixel420) << endl
213  << "Color Space: " << ::NTV2HDMIColorSpaceToString(mColorSpace,true) << endl;
214  if (mColorSpace == NTV2_HDMIColorSpaceRGB)
215  inOutStream << "RGB Range: " << ::NTV2HDMIRangeToString(mRGBRange,true) << endl;
216  inOutStream << "Protocol: " << ::NTV2HDMIProtocolToString(mProtocol,true) << endl
217  << "Video Standard: " << ::NTV2StandardToString(mVideoStandard,true) << endl
218  << "Frame Rate: " << ::NTV2FrameRateToString(mVideoRate,true) << endl
219  << "Bit Depth: " << ::NTV2HDMIBitDepthToString(mVideoBitDepth,true) << endl
220  << "Audio Format: " << ::NTV2AudioFormatToString(mAudioFormat,true) << endl
221  << "Audio Rate: " << ::NTV2AudioRateToString(mAudioRate,true) << endl
222  << "Audio Channels: " << ::NTV2HDMIAudioChannelsToString(mAudioChannels,true);
223  return inOutStream;
224 }
225 
226 
228  : mode (AUTOCIRCVIDPROCMODE_MIX),
229  foregroundVideoCrosspoint (NTV2CROSSPOINT_CHANNEL1),
230  backgroundVideoCrosspoint (NTV2CROSSPOINT_CHANNEL1),
231  foregroundKeyCrosspoint (NTV2CROSSPOINT_CHANNEL1),
232  backgroundKeyCrosspoint (NTV2CROSSPOINT_CHANNEL1),
233  transitionCoefficient (0),
234  transitionSoftness (0)
235 {
236 }
237 
238 
240  : eCommand (inCommand),
241  channelSpec (inCrosspoint),
242  lVal1 (0),
243  lVal2 (0),
244  lVal3 (0),
245  lVal4 (0),
246  lVal5 (0),
247  lVal6 (0),
248  bVal1 (false),
249  bVal2 (false),
250  bVal3 (false),
251  bVal4 (false),
252  bVal5 (false),
253  bVal6 (false),
254  bVal7 (false),
255  bVal8 (false),
256  pvVal1 (AJA_NULL),
257  pvVal2 (AJA_NULL),
258  pvVal3 (AJA_NULL),
259  pvVal4 (AJA_NULL)
260 {
261 }
262 
263 ostream & AUTOCIRCULATE_DATA::Print (ostream & oss) const
264 {
265  static const string sCmds [] = {"ACInit","ACStart","ACStop","ACPause","GetAC","ACFrmStmp",
266  "ACFlush","ACPreRoll","ACXfer","ACAbort","ACStartAt",
267  "ACXfer1","ACXfer2","ACFrmStmp2","ACTask","ACSetActFrm"};
268  if (size_t(eCommand) < sizeof(sCmds))
269  { oss << sCmds[eCommand];
270  switch (eCommand)
271  {
272  case eInitAutoCirc:
273  oss << " " << ::NTV2CrosspointToString(channelSpec);
274  oss << " frms " << DEC(lVal1) << "-" << DEC(lVal2);
275  if (lVal4 > 1) oss << " +" << DEC(lVal4) << " chls";
276  if (lVal6 & AUTOCIRCULATE_WITH_FIELDS) oss << " +FieldMode";
277  if (lVal6 & AUTOCIRCULATE_WITH_HDMIAUX) oss << " +HDMIAux";
278  if (bVal2) oss << " +RP188";
279  if (bVal3) oss << " +FBFChg";
280  if (bVal4) oss << " +FBOChg";
281  if (bVal5) oss << " +ColCorr";
282  if (bVal6) oss << " +VidProc";
283  if (bVal7) oss << " +Anc";
284  if (bVal8) oss << " +LTC";
285  oss << " " << ::NTV2AudioSystemToString(NTV2AudioSystem(lVal3 & 0xF), true);
286  if (!bVal1 && ((lVal3 & 0xF) == NTV2_MAX_NUM_AudioSystemEnums)) oss << " +AudCtrl";
287  if (lVal3 & NTV2_AUDIOSYSTEM_Plus1) oss << " +MLAud1";
288  if (lVal3 & NTV2_AUDIOSYSTEM_Plus2) oss << " +MLAud2";
289  if (lVal3 & NTV2_AUDIOSYSTEM_Plus3) oss << " +MLAud3";
290  break;
291  case eStartAutoCirc:
292  break;
294  if (lVal1 || lVal2)
295  oss << " at " << xHEX0N((uint64_t(lVal1) << 32) | uint64_t(lVal2),16);
296  break;
297  case eStopAutoCirc:
298  oss << " " << ::NTV2CrosspointToString(channelSpec);
299  break;
300  case eAbortAutoCirc:
301  oss << " " << ::NTV2CrosspointToString(channelSpec);
302  break;
303  case ePauseAutoCirc:
304  oss << " " << ::NTV2CrosspointToString(channelSpec);
305  if (!bVal1 && lVal6) oss << " at frame " << DEC(lVal6);
306  if (bVal1) oss << " +resume";
307  if (bVal1 && bVal2) oss << " +clearDropCount";
308  break;
309  case eFlushAutoCirculate:
310  oss << " " << ::NTV2CrosspointToString(channelSpec);
311  if (bVal1) oss << " +clearDropCount";
312  break;
314  oss << " " << ::NTV2CrosspointToString(channelSpec) << " " << DEC(ULWord(lVal1)) << " frame(s)";
315  break;
316  case eGetAutoCirc:
317  oss << " " << ::NTV2CrosspointToString(channelSpec);
318  break;
319  case eSetActiveFrame:
320  case eGetFrameStamp:
321  oss << " " << ::NTV2CrosspointToString(channelSpec) << " frm " << DEC(ULWord(lVal1));
322  break;
323  default:
324  break;
325  }
326  }
327  return oss;
328 }
329 
330 
331 NTV2_HEADER::NTV2_HEADER (const ULWord inStructureType, const ULWord inStructSizeInBytes)
332  : fHeaderTag (NTV2_HEADER_TAG),
333  fType (inStructureType),
334  fHeaderVersion (NTV2_CURRENT_HEADER_VERSION),
335  fVersion (AUTOCIRCULATE_STRUCT_VERSION),
336  fSizeInBytes (inStructSizeInBytes),
337  fPointerSize (sizeof(int*)),
338  fOperation (0),
339  fResultStatus (0)
340 {
341 }
342 
344 {
345  if (!IsValid())
346  return nullptr;
347  const NTV2_TRAILER * pTrailer = reinterpret_cast<const NTV2_TRAILER*>(uint64_t(&fHeaderTag) + GetSizeInBytes() - sizeof(NTV2_TRAILER));
348  return pTrailer->IsValid() ? pTrailer : nullptr;
349 }
350 
351 ostream & operator << (ostream & inOutStream, const NTV2_HEADER & inObj)
352 {
353  return inObj.Print (inOutStream);
354 }
355 
356 
357 ostream & NTV2_HEADER::Print (ostream & oss) const
358 {
359  return oss << "[" << FourCCToString(fHeaderTag) << "|" << FourCCToString(fType) << " v" << fHeaderVersion
360  << " vers=" << fVersion << " sz=" << fSizeInBytes << "]";
361 }
362 
363 string NTV2_HEADER::FourCCToString (const ULWord in4CC, char nonPrintable)
364 {
365  const char * pU32 (reinterpret_cast<const char *>(&in4CC));
366  ostringstream result, fourCC;
367  size_t badTally(0);
368  if (nonPrintable && (nonPrintable < 32 || nonPrintable > 126)) // !::isprint(nonPrintable)
369  nonPrintable = 0; // specified non-printable character to use is itself non-printable: don't use it
370  for (size_t charPos(0); charPos < 4; charPos++)
371  {
372  #if AJATargetBigEndian
373  const char ch (pU32[charPos]);
374  #else // little-endian:
375  const char ch (pU32[3 - charPos]);
376  #endif
377  if (ch > 31 && ch < 127) // ::isprint(ch)
378  fourCC << ch;
379  else
380  {
381  if (nonPrintable)
382  fourCC << nonPrintable;
383  badTally++; // not printable
384  }
385  }
386  if (badTally == 4)
387  result << xHEX0N(in4CC,8); // nothing printable, just show hex value
388  else if (badTally)
389  result << "'" << fourCC.str() << "' (" << xHEX0N(in4CC,8) << ")"; // at least one printable, show 4CC & hex value
390  else
391  result << "'" << fourCC.str() << "'"; // all printable, show 4CC exclusively (no hex value)
392  return result.str();
393 }
394 
395 bool NTV2_HEADER::IsFourCC (const ULWord in4CC)
396 {
397  if (!in4CC)
398  return false; // Zero -- not a valid 4CC
399  const uint8_t * pU32 (reinterpret_cast<const uint8_t *>(&in4CC));
400  const uint8_t ch0(pU32[0] >> 5), ch1(pU32[1] >> 5), ch2(pU32[2] >> 5), ch3(pU32[3] >> 5);
401  // BUG: FIX THIS: This algorithm allows unprintable character 0x7F!!
402  return ch0 && ch0 < 4 && ch1 && ch1 < 4 && ch2 && ch2 < 4 && ch3 && ch3 < 4;
403 }
404 
405 
406 
409  fTrailerTag (NTV2_TRAILER_TAG)
410 {
411 }
412 
413 ostream & NTV2_TRAILER::Print (ostream & oss) const
414 {
415  return oss << "[" << VersionString() << " " << NTV2_HEADER::FourCCToString(fTrailerTag) << "]";
416 }
417 
419 {
421  return vers == fTrailerVersion;
422 }
423 
425 {
426  const ULWord vers(fTrailerVersion), major(NTV2SDKVersionDecode_Major(vers)), minor(NTV2SDKVersionDecode_Minor(vers)),
427  point(NTV2SDKVersionDecode_Point(vers));
428  if (!vers)
429  return false; // entire field is zero
430  if (major < 15)
431  return false; // major version less than 15
432  if (minor > 15)
433  return false; // minor version exceeds 15
434  if (point > 15)
435  return false; // point version exceeds 15
436  return true;
437 }
438 
439 string NTV2_TRAILER::VersionString (void) const
440 {
441  ostringstream oss;
442  if (IsValidVersion())
445  else
446  oss << xHEX0N(fTrailerVersion,8);
447  return oss.str();
448 }
449 
450 bool NTV2_TRAILER::VersionComponents (ULWord & outMajor, ULWord & outMinor, ULWord & outPoint, ULWord & outBuild) const
451 {
452  if (IsValidVersion())
453  {
458  return true;
459  }
460  outMajor = outMinor = outPoint = outBuild = 0;
461  return false;
462 }
463 
464 
465 ostream & operator << (ostream & oss, const NTV2_TRAILER & inObj)
466 {
467  return inObj.Print(oss);
468 }
469 
470 
471 ostream & operator << (ostream & inOutStream, const NTV2Buffer & inObj)
472 {
473  return inObj.Print (inOutStream);
474 }
475 
476 
477 ostream & NTV2Buffer::Print (ostream & oss) const
478 {
479  oss << DECN(GetByteCount(),10) << " @ x";
480  if (IsAllocatedBySDK())
481  oss << Hex(GetRawHostPointer());
482  else
483  oss << HEX(GetRawHostPointer());
484  return oss;
485 }
486 
487 
488 string NTV2Buffer::AsString (UWord inDumpMaxBytes) const
489 {
490  ostringstream oss;
491  oss << xHEX0N(GetRawHostPointer(),16) << ":" << DEC(GetByteCount()) << " bytes";
492  if (inDumpMaxBytes && GetHostPointer())
493  {
494  oss << ":";
495  if (inDumpMaxBytes > 256)
496  inDumpMaxBytes = 256;
497  if (ULWord(inDumpMaxBytes) > GetByteCount())
498  inDumpMaxBytes = UWord(GetByteCount());
499  const UByte * pBytes (reinterpret_cast<const UByte *>(GetHostPointer()));
500  for (UWord ndx(0); ndx < inDumpMaxBytes; ndx++)
501  oss << HEX0N(uint16_t(pBytes[ndx]),2);
502  }
503  return oss.str();
504 }
505 
506 string NTV2Buffer::AsCode (const size_t inBytesPerWord, const std::string & inVarName, const bool inUseSTL, const bool inByteSwap) const
507 {
508  ostringstream oss;
509  if (inBytesPerWord != 1 && inBytesPerWord != 2 && inBytesPerWord != 4 && inBytesPerWord != 8) return string();
510  NTV2Buffer tmp;
511  if (inBytesPerWord > 1)
512  { // Use a copy for U16s, U32s, or U64s...
513  tmp = *this;
514  if (!tmp)
515  return string();
516  }
517  const string cType (inBytesPerWord == 1 ? "uint8_t" : (inBytesPerWord == 2 ? "uint16_t" : (inBytesPerWord == 4 ? "uint32_t" : "uint64_t")));
518  const size_t numWords (GetByteCount() / inBytesPerWord);
519  const string vecType = "std::vector<" + cType + ">";
520  const string varName (inVarName.empty() ? (inUseSTL ? "tmpVector" : "tmpArray") : inVarName);
521  oss << "const " << (inUseSTL ? vecType : cType) << " " << varName << (inUseSTL ? "" : "[]") << " = {" << endl;
522  if (inByteSwap && inBytesPerWord > 1)
523  switch (inBytesPerWord)
524  {
525  case 2: tmp.ByteSwap16(); break;
526  case 4: tmp.ByteSwap32(); break;
527  case 8: tmp.ByteSwap64(); break;
528  }
529  for (size_t ndx(0); ndx < numWords; )
530  {
531  switch (inBytesPerWord)
532  {
533  case 1: oss << xHEX0N(UWord(U8(int(ndx))),2); break;
534  case 2: oss << xHEX0N(tmp.U16(int(ndx)),4); break;
535  case 4: oss << xHEX0N(tmp.U32(int(ndx)),8); break;
536  case 8: oss << xHEX0N(tmp.U64(int(ndx)),16); break;
537  }
538  if (++ndx < numWords)
539  oss << ",";
540  if (ndx % 128 == 0)
541  oss << endl;
542  }
543  oss << "};" << endl;
544  return oss.str();
545 }
546 
547 bool NTV2Buffer::toHexString (std::string & outStr, const size_t inLineBreakInterval) const
548 {
549  outStr.clear();
550  ostringstream oss;
551  if (GetHostPointer() && GetByteCount())
552  for (int ndx(0); ndx < int(GetByteCount()); )
553  {
554  oss << HEX0N(uint16_t(U8(ndx++)),2);
555  if (inLineBreakInterval && ndx < int(GetByteCount()) && ((size_t(ndx) % inLineBreakInterval) == 0))
556  oss << endl;
557  }
558  outStr = oss.str();
559  return !outStr.empty();
560 }
561 
562 static string print_address_offset (const size_t inRadix, const ULWord64 inOffset)
563 {
564  const streamsize maxAddrWidth (sizeof(ULWord64) * 2);
565  ostringstream oss;
566  if (inRadix == 8)
567  oss << OCT0N(inOffset,maxAddrWidth) << ": ";
568  else if (inRadix == 10)
569  oss << DEC0N(inOffset,maxAddrWidth) << ": ";
570  else
571  oss << xHEX0N(inOffset,maxAddrWidth) << ": ";
572  return oss.str();
573 }
574 
575 ostream & NTV2Buffer::Dump (ostream & inOStream,
576  const size_t inStartOffset,
577  const size_t inByteCount,
578  const size_t inRadix,
579  const size_t inBytesPerGroup,
580  const size_t inGroupsPerRow,
581  const size_t inAddressRadix,
582  const bool inShowAscii,
583  const size_t inAddrOffset) const
584 {
585  if (IsNULL())
586  return inOStream;
587  if (inRadix != 8 && inRadix != 10 && inRadix != 16 && inRadix != 2)
588  return inOStream;
589  if (inAddressRadix != 0 && inAddressRadix != 8 && inAddressRadix != 10 && inAddressRadix != 16)
590  return inOStream;
591  if (inBytesPerGroup == 0) // || inGroupsPerRow == 0)
592  return inOStream;
593 
594  {
595  const void * pInStartAddress (GetHostAddress(ULWord(inStartOffset)));
596  size_t bytesRemaining (inByteCount ? inByteCount : GetByteCount());
597  size_t bytesInThisGroup (0);
598  size_t groupsInThisRow (0);
599  const unsigned maxByteWidth (inRadix == 8 ? 4 : (inRadix == 10 ? 3 : (inRadix == 2 ? 8 : 2)));
600  const UByte * pBuffer (reinterpret_cast <const UByte *> (pInStartAddress));
601  const size_t asciiBufferSize (inShowAscii && inGroupsPerRow ? (inBytesPerGroup * inGroupsPerRow + 1) * sizeof (UByte) : 0); // Size in bytes, not chars
602 
603  if (!pInStartAddress)
604  return inOStream;
605 
606  UByte * pAsciiBuffer (asciiBufferSize ? new UByte[asciiBufferSize / sizeof(UByte)] : AJA_NULL);
607  if (pAsciiBuffer)
608  ::memset (pAsciiBuffer, 0, asciiBufferSize);
609 
610  if (inGroupsPerRow && inAddressRadix)
611  inOStream << print_address_offset (inAddressRadix, ULWord64(pBuffer) - ULWord64(pInStartAddress) + ULWord64(inAddrOffset));
612  while (bytesRemaining)
613  {
614  if (inRadix == 2)
615  inOStream << BIN08(*pBuffer);
616  else if (inRadix == 8)
617  inOStream << oOCT(uint16_t(*pBuffer));
618  else if (inRadix == 10)
619  inOStream << DEC0N(uint16_t(*pBuffer),maxByteWidth);
620  else if (inRadix == 16)
621  inOStream << HEX0N(uint16_t(*pBuffer),2);
622 
623  if (pAsciiBuffer)
624  pAsciiBuffer[groupsInThisRow * inBytesPerGroup + bytesInThisGroup] = isprint(*pBuffer) ? *pBuffer : '.';
625  pBuffer++;
626  bytesRemaining--;
627 
628  bytesInThisGroup++;
629  if (bytesInThisGroup >= inBytesPerGroup)
630  {
631  groupsInThisRow++;
632  if (inGroupsPerRow && groupsInThisRow >= inGroupsPerRow)
633  {
634  if (pAsciiBuffer)
635  {
636  inOStream << " " << pAsciiBuffer;
637  ::memset (pAsciiBuffer, 0, asciiBufferSize);
638  }
639  inOStream << endl;
640  if (inAddressRadix && bytesRemaining)
641  inOStream << print_address_offset (inAddressRadix, reinterpret_cast <ULWord64> (pBuffer) - reinterpret_cast <ULWord64> (pInStartAddress) + ULWord64 (inAddrOffset));
642  groupsInThisRow = 0;
643  } // if time for new row
644  else
645  inOStream << " ";
646  bytesInThisGroup = 0;
647  } // if time for new group
648  } // loop til no bytes remaining
649 
650  if (bytesInThisGroup && bytesInThisGroup < inBytesPerGroup && pAsciiBuffer)
651  {
652  groupsInThisRow++;
653  inOStream << string ((inBytesPerGroup - bytesInThisGroup) * maxByteWidth + 1, ' ');
654  }
655 
656  if (groupsInThisRow)
657  {
658  if (groupsInThisRow < inGroupsPerRow && pAsciiBuffer)
659  inOStream << string (((inGroupsPerRow - groupsInThisRow) * inBytesPerGroup * maxByteWidth + (inGroupsPerRow - groupsInThisRow)), ' ');
660  if (pAsciiBuffer)
661  inOStream << pAsciiBuffer;
662  inOStream << endl;
663  }
664  else if (bytesInThisGroup && bytesInThisGroup < inBytesPerGroup)
665  inOStream << endl;
666 
667  if (pAsciiBuffer)
668  delete [] pAsciiBuffer;
669  } // else radix is 16, 10, 8 or 2
670 
671  return inOStream;
672 } // Dump
673 
674 string & NTV2Buffer::Dump ( string & inOutputString,
675  const size_t inStartOffset,
676  const size_t inByteCount,
677  const size_t inRadix,
678  const size_t inBytesPerGroup,
679  const size_t inGroupsPerRow,
680  const size_t inAddressRadix,
681  const bool inShowAscii,
682  const size_t inAddrOffset) const
683 {
684  ostringstream oss;
685  Dump (oss, inStartOffset, inByteCount, inRadix, inBytesPerGroup, inGroupsPerRow, inAddressRadix, inShowAscii, inAddrOffset);
686  inOutputString = oss.str();
687  return inOutputString;
688 }
689 
690 NTV2Buffer & NTV2Buffer::Segment (NTV2Buffer & outPtr, const ULWord inByteOffset, const ULWord inByteCount) const
691 {
692  outPtr.Set(AJA_NULL, 0); // Make invalid
693  if (inByteOffset >= GetByteCount())
694  return outPtr; // Offset past end
695  if (inByteOffset+inByteCount > GetByteCount())
696  return outPtr; // Segment too long
697  outPtr.Set(GetHostAddress(inByteOffset), inByteCount);
698  return outPtr;
699 }
700 
701 
702 bool NTV2Buffer::GetU64s (ULWord64Sequence & outUint64s, const size_t inU64Offset, const size_t inMaxSize, const bool inByteSwap) const
703 {
704  outUint64s.clear();
705  if (IsNULL())
706  return false;
707 
708  size_t maxSize (size_t(GetByteCount()) / sizeof(uint64_t));
709  if (maxSize < inU64Offset)
710  return false; // Past end
711  maxSize -= inU64Offset; // Remove starting offset
712 
713  const uint64_t * pU64 (reinterpret_cast <const uint64_t *> (GetHostAddress(ULWord(inU64Offset * sizeof(uint64_t)))));
714  if (!pU64)
715  return false; // Past end
716 
717  if (inMaxSize && inMaxSize < maxSize)
718  maxSize = inMaxSize;
719 
720  try
721  {
722  outUint64s.reserve(maxSize);
723  for (size_t ndx(0); ndx < maxSize; ndx++)
724  {
725  const uint64_t u64 (*pU64++);
726  outUint64s.push_back(inByteSwap ? NTV2EndianSwap64(u64) : u64);
727  }
728  }
729  catch (...)
730  {
731  outUint64s.clear();
732  outUint64s.reserve(0);
733  return false;
734  }
735  return true;
736 }
737 
738 
739 bool NTV2Buffer::GetU32s (ULWordSequence & outUint32s, const size_t inU32Offset, const size_t inMaxSize, const bool inByteSwap) const
740 {
741  outUint32s.clear();
742  if (IsNULL())
743  return false;
744 
745  size_t maxNumU32s (size_t(GetByteCount()) / sizeof(uint32_t));
746  if (maxNumU32s < inU32Offset)
747  return false; // Past end
748  maxNumU32s -= inU32Offset; // Remove starting offset
749 
750  const uint32_t * pU32 (reinterpret_cast<const uint32_t*>(GetHostAddress(ULWord(inU32Offset * sizeof(uint32_t)))));
751  if (!pU32)
752  return false; // Past end
753 
754  if (inMaxSize && inMaxSize < maxNumU32s)
755  maxNumU32s = inMaxSize;
756 
757  try
758  {
759  outUint32s.reserve(maxNumU32s);
760  for (size_t ndx(0); ndx < maxNumU32s; ndx++)
761  {
762  const uint32_t u32 (*pU32++);
763  outUint32s.push_back(inByteSwap ? NTV2EndianSwap32(u32) : u32);
764  }
765  }
766  catch (...)
767  {
768  outUint32s.clear();
769  outUint32s.reserve(0);
770  return false;
771  }
772  return true;
773 }
774 
775 
776 bool NTV2Buffer::GetU16s (UWordSequence & outUint16s, const size_t inU16Offset, const size_t inMaxSize, const bool inByteSwap) const
777 {
778  outUint16s.clear();
779  if (IsNULL())
780  return false;
781 
782  size_t maxSize (size_t(GetByteCount()) / sizeof(uint16_t));
783  if (maxSize < inU16Offset)
784  return false; // Past end
785  maxSize -= inU16Offset; // Remove starting offset
786 
787  const uint16_t * pU16 (reinterpret_cast <const uint16_t *> (GetHostAddress(ULWord(inU16Offset * sizeof(uint16_t)))));
788  if (!pU16)
789  return false; // Past end
790 
791  if (inMaxSize && inMaxSize < maxSize)
792  maxSize = inMaxSize;
793 
794  try
795  {
796  outUint16s.reserve(maxSize);
797  for (size_t ndx(0); ndx < maxSize; ndx++)
798  {
799  const uint16_t u16 (*pU16++);
800  outUint16s.push_back(inByteSwap ? NTV2EndianSwap16(u16) : u16);
801  }
802  }
803  catch (...)
804  {
805  outUint16s.clear();
806  outUint16s.reserve(0);
807  return false;
808  }
809  return true;
810 }
811 
812 
813 bool NTV2Buffer::GetU8s (UByteSequence & outUint8s, const size_t inU8Offset, const size_t inMaxSize) const
814 {
815  outUint8s.clear();
816  if (IsNULL())
817  return false;
818 
819  size_t maxSize (GetByteCount());
820  if (maxSize < inU8Offset)
821  return false; // Past end
822  maxSize -= inU8Offset; // Remove starting offset
823 
824  const uint8_t * pU8 (reinterpret_cast <const uint8_t *> (GetHostAddress(ULWord(inU8Offset))));
825  if (!pU8)
826  return false; // Past end
827 
828  if (inMaxSize && inMaxSize < maxSize)
829  maxSize = inMaxSize;
830 
831  try
832  {
833  outUint8s.reserve(maxSize);
834  for (size_t ndx(0); ndx < maxSize; ndx++)
835  outUint8s.push_back(*pU8++);
836  }
837  catch (...)
838  {
839  outUint8s.clear();
840  outUint8s.reserve(0);
841  return false;
842  }
843  return true;
844 }
845 
847 {
848  const uint8_t * pU8 (reinterpret_cast<const uint8_t*> (GetHostPointer()));
849  if (!pU8)
850  return false; // Past end
851  const size_t maxSize (GetByteCount());
852  try
853  {
854  outU8s.reserve(outU8s.size() + maxSize);
855  outU8s.insert(outU8s.end(),pU8, pU8 + maxSize);
856  }
857  catch (...)
858  {
859  return false;
860  }
861  return true;
862 }
863 
864 
865 bool NTV2Buffer::GetString (std::string & outString, const size_t inU8Offset, const size_t inMaxSize) const
866 {
867  outString.clear();
868  if (IsNULL())
869  return false;
870 
871  size_t maxSize(GetByteCount());
872  if (maxSize < inU8Offset)
873  return false; // Past end
874  maxSize -= inU8Offset; // Remove starting offset
875 
876  const uint8_t * pU8 (reinterpret_cast <const uint8_t *> (GetHostAddress(ULWord(inU8Offset))));
877  if (!pU8)
878  return false; // Past end
879 
880  if (inMaxSize && inMaxSize < maxSize)
881  maxSize = inMaxSize;
882 
883  try
884  {
885  outString.reserve(maxSize);
886  for (size_t ndx(0); ndx < maxSize; ndx++)
887  {
888  const char c = *pU8++;
889  if (c)
890  outString += c;
891  else
892  break;
893  }
894  }
895  catch (...)
896  {
897  outString.clear();
898  outString.reserve(0);
899  return false;
900  }
901  return true;
902 }
903 
904 
905 bool NTV2Buffer::PutU64s (const ULWord64Sequence & inU64s, const size_t inU64Offset, const bool inByteSwap)
906 {
907  if (IsNULL())
908  return false; // No buffer or space
909  if (inU64s.empty())
910  return true; // Nothing to copy
911 
912  size_t maxU64s (GetByteCount() / sizeof(uint64_t));
913  uint64_t * pU64 (reinterpret_cast<uint64_t*>(GetHostAddress(ULWord(inU64Offset * sizeof(uint64_t)))));
914  if (!pU64)
915  return false; // Start offset is past end
916  if (maxU64s > inU64Offset)
917  maxU64s -= inU64Offset; // Don't go past end
918  if (maxU64s > inU64s.size())
919  maxU64s = inU64s.size(); // Truncate incoming vector to not go past my end
920  if (inU64s.size() > maxU64s)
921  return false; // Will write past end
922 
923  for (unsigned ndx(0); ndx < maxU64s; ndx++)
924 #if defined(_DEBUG)
925  *pU64++ = inByteSwap ? NTV2EndianSwap64(inU64s.at(ndx)) : inU64s.at(ndx);
926 #else
927  *pU64++ = inByteSwap ? NTV2EndianSwap64(inU64s[ndx]) : inU64s[ndx];
928 #endif
929  return true;
930 }
931 
932 
933 bool NTV2Buffer::PutU32s (const ULWordSequence & inU32s, const size_t inU32Offset, const bool inByteSwap)
934 {
935  if (IsNULL())
936  return false; // No buffer or space
937  if (inU32s.empty())
938  return true; // Nothing to copy
939 
940  size_t maxU32s (GetByteCount() / sizeof(uint32_t));
941  uint32_t * pU32 (reinterpret_cast<uint32_t*>(GetHostAddress(ULWord(inU32Offset * sizeof(uint32_t)))));
942  if (!pU32)
943  return false; // Start offset is past end
944  if (maxU32s > inU32Offset)
945  maxU32s -= inU32Offset; // Don't go past end
946  if (maxU32s > inU32s.size())
947  maxU32s = inU32s.size(); // Truncate incoming vector to not go past my end
948  if (inU32s.size() > maxU32s)
949  return false; // Will write past end
950 
951  for (unsigned ndx(0); ndx < maxU32s; ndx++)
952 #if defined(_DEBUG)
953  *pU32++ = inByteSwap ? NTV2EndianSwap32(inU32s.at(ndx)) : inU32s.at(ndx);
954 #else
955  *pU32++ = inByteSwap ? NTV2EndianSwap32(inU32s[ndx]) : inU32s[ndx];
956 #endif
957  return true;
958 }
959 
960 
961 bool NTV2Buffer::PutU16s (const UWordSequence & inU16s, const size_t inU16Offset, const bool inByteSwap)
962 {
963  if (IsNULL())
964  return false; // No buffer or space
965  if (inU16s.empty())
966  return true; // Nothing to copy
967 
968  size_t maxU16s (GetByteCount() / sizeof(uint16_t));
969  uint16_t * pU16 (reinterpret_cast<uint16_t*>(GetHostAddress(ULWord(inU16Offset * sizeof(uint16_t)))));
970  if (!pU16)
971  return false; // Start offset is past end
972  if (maxU16s > inU16Offset)
973  maxU16s -= inU16Offset; // Don't go past end
974  if (maxU16s > inU16s.size())
975  maxU16s = inU16s.size(); // Truncate incoming vector to not go past my end
976  if (inU16s.size() > maxU16s)
977  return false; // Will write past end
978 
979  for (unsigned ndx(0); ndx < maxU16s; ndx++)
980 #if defined(_DEBUG)
981  *pU16++ = inByteSwap ? NTV2EndianSwap16(inU16s.at(ndx)) : inU16s.at(ndx);
982 #else
983  *pU16++ = inByteSwap ? NTV2EndianSwap16(inU16s[ndx]) : inU16s[ndx];
984 #endif
985  return true;
986 }
987 
988 
989 bool NTV2Buffer::PutU8s (const UByteSequence & inU8s, const size_t inU8Offset)
990 {
991  if (IsNULL())
992  return false; // No buffer or space
993  if (inU8s.empty())
994  return true; // Nothing to copy
995 
996  size_t maxU8s (GetByteCount());
997  uint8_t * pU8 (reinterpret_cast<uint8_t*>(GetHostAddress(ULWord(inU8Offset))));
998  if (!pU8)
999  return false; // Start offset is past end
1000  if (maxU8s > inU8Offset)
1001  maxU8s -= inU8Offset; // Don't go past end
1002  if (maxU8s > inU8s.size())
1003  maxU8s = inU8s.size(); // Truncate incoming vector to not go past end
1004  if (inU8s.size() > maxU8s)
1005  return false; // Will write past end
1006 #if 1
1007  ::memcpy(pU8, &inU8s[0], maxU8s);
1008 #else
1009  for (unsigned ndx(0); ndx < maxU8s; ndx++)
1010  #if defined(_DEBUG)
1011  *pU8++ = inU8s.at(ndx);
1012  #else
1013  *pU8++ = inU8s[ndx];
1014  #endif
1015 #endif
1016  return true;
1017 }
1018 
1019 
1020 ostream & operator << (ostream & inOutStream, const NTV2_RP188 & inObj)
1021 {
1022  if (inObj.IsValid ())
1023  return inOutStream << "{Dx" << HEX0N(inObj.fDBB,8) << "|Lx" << HEX0N(inObj.fLo,8) << "|Hx" << HEX0N(inObj.fHi,8) << "}";
1024  else
1025  return inOutStream << "{invalid}";
1026 }
1027 
1028 
1030 {
1031  inOutList.push_back (inRP188);
1032  return inOutList;
1033 }
1034 
1035 
1036 ostream & operator << (ostream & inOutStream, const NTV2TimeCodeList & inObj)
1037 {
1038  inOutStream << inObj.size () << ":[";
1039  for (NTV2TimeCodeListConstIter iter (inObj.begin ()); iter != inObj.end (); )
1040  {
1041  inOutStream << *iter;
1042  if (++iter != inObj.end ())
1043  inOutStream << ", ";
1044  }
1045  return inOutStream << "]";
1046 }
1047 
1048 
1049 ostream & operator << (std::ostream & inOutStream, const NTV2TimeCodes & inObj)
1050 {
1051  inOutStream << inObj.size () << ":[";
1052  for (NTV2TimeCodesConstIter iter (inObj.begin ()); iter != inObj.end (); )
1053  {
1054  inOutStream << ::NTV2TCIndexToString (iter->first,true) << "=" << iter->second;
1055  if (++iter != inObj.end ())
1056  inOutStream << ", ";
1057  }
1058  return inOutStream << "]";
1059 }
1060 
1061 
1062 ostream & operator << (std::ostream & inOutStream, const NTV2TCIndexes & inObj)
1063 {
1064  for (NTV2TCIndexesConstIter iter (inObj.begin ()); iter != inObj.end (); )
1065  {
1066  inOutStream << ::NTV2TCIndexToString (*iter);
1067  if (++iter != inObj.end ())
1068  inOutStream << ", ";
1069  }
1070  return inOutStream;
1071 }
1072 
1073 
1075 {
1076  for (NTV2TCIndexesConstIter iter (inSet.begin ()); iter != inSet.end (); ++iter)
1077  inOutSet.insert (*iter);
1078  return inOutSet;
1079 }
1080 
1081 
1082 ostream & operator << (ostream & inOutStream, const FRAME_STAMP & inObj)
1083 {
1084  return inOutStream << inObj.acHeader
1085  << " frmTime=" << inObj.acFrameTime
1086  << " reqFrm=" << inObj.acRequestedFrame
1087  << " audClkTS=" << inObj.acAudioClockTimeStamp
1088  << " audExpAdr=" << hex << inObj.acAudioExpectedAddress << dec
1089  << " audInStrtAdr=" << hex << inObj.acAudioInStartAddress << dec
1090  << " audInStopAdr=" << hex << inObj.acAudioInStopAddress << dec
1091  << " audOutStrtAdr=" << hex << inObj.acAudioOutStartAddress << dec
1092  << " audOutStopAdr=" << hex << inObj.acAudioOutStopAddress << dec
1093  << " totBytes=" << inObj.acTotalBytesTransferred
1094  << " strtSamp=" << inObj.acStartSample
1095  << " curTime=" << inObj.acCurrentTime
1096  << " curFrm=" << inObj.acCurrentFrame
1097  << " curFrmTime=" << inObj.acCurrentFrameTime
1098  << " audClkCurTime=" << inObj.acAudioClockCurrentTime
1099  << " curAudExpAdr=" << hex << inObj.acCurrentAudioExpectedAddress << dec
1100  << " curAudStrtAdr=" << hex << inObj.acCurrentAudioStartAddress << dec
1101  << " curFldCnt=" << inObj.acCurrentFieldCount
1102  << " curLnCnt=" << inObj.acCurrentLineCount
1103  << " curReps=" << inObj.acCurrentReps
1104  << " curUsrCookie=" << hex << inObj.acCurrentUserCookie << dec
1105  << " acFrame=" << inObj.acFrame
1106  << " acRP188=" << inObj.acRP188 // deprecated
1107  << " " << inObj.acTrailer;
1108 }
1109 
1110 
1111 ostream & operator << (ostream & inOutStream, const NTV2SegmentedDMAInfo & inObj)
1112 {
1113  if (inObj.acNumSegments > 1)
1114  inOutStream << "segs=" << inObj.acNumSegments << " numActBPR=" << inObj.acNumActiveBytesPerRow
1115  << " segHostPitc=" << inObj.acSegmentHostPitch << " segDevPitc=" << inObj.acSegmentDevicePitch;
1116  else
1117  inOutStream << "n/a";
1118  return inOutStream;
1119 }
1120 
1121 
1122 ostream & operator << (ostream & inOutStream, const AUTOCIRCULATE_TRANSFER & inObj)
1123 {
1124  #if defined (_DEBUG)
1125  NTV2_ASSERT (inObj.NTV2_IS_STRUCT_VALID ());
1126  #endif
1127  string str (::NTV2FrameBufferFormatToString (inObj.acFrameBufferFormat, true));
1128  while (str.find (' ') != string::npos)
1129  str.erase (str.find (' '), 1);
1130  inOutStream << inObj.acHeader << " vid=" << inObj.acVideoBuffer
1131  << " aud=" << inObj.acAudioBuffer
1132  << " ancF1=" << inObj.acANCBuffer
1133  << " ancF2=" << inObj.acANCField2Buffer
1134  << " outTC(" << inObj.acOutputTimeCodes << ")"
1135  << " cookie=" << inObj.acInUserCookie
1136  << " vidDMAoff=" << inObj.acInVideoDMAOffset
1137  << " segDMA=" << inObj.acInSegmentedDMAInfo
1138  << " colcor=" << inObj.acColorCorrection
1139  << " fbf=" << str
1140  << " fbo=" << (inObj.acFrameBufferOrientation == NTV2_FRAMEBUFFER_ORIENTATION_BOTTOMUP ? "flip" : "norm")
1141  << " vidProc=" << inObj.acVidProcInfo
1142  << " quartsz=" << inObj.acVideoQuarterSizeExpand
1143  << " p2p=" << inObj.acPeerToPeerFlags
1144  << " repCnt=" << inObj.acFrameRepeatCount
1145  << " desFrm=" << inObj.acDesiredFrame
1146  << " rp188=" << inObj.acRP188 // deprecated
1147  << " xpt=" << inObj.acCrosspoint
1148  << " status{" << inObj.acTransferStatus << "}"
1149  << " " << inObj.acTrailer;
1150  return inOutStream;
1151 }
1152 
1153 
1154 ostream & operator << (ostream & inOutStream, const AUTOCIRCULATE_TRANSFER_STATUS & inObj)
1155 {
1156  inOutStream << inObj.acHeader << " state=" << ::NTV2AutoCirculateStateToString (inObj.acState)
1157  << " xferFrm=" << inObj.acTransferFrame
1158  << " bufLvl=" << inObj.acBufferLevel
1159  << " frms=" << inObj.acFramesProcessed
1160  << " drops=" << inObj.acFramesDropped
1161  << " " << inObj.acFrameStamp
1162  << " audXfrSz=" << inObj.acAudioTransferSize
1163  << " audStrtSamp=" << inObj.acAudioStartSample
1164  << " ancF1Siz=" << inObj.acAncTransferSize
1165  << " ancF2Siz=" << inObj.acAncField2TransferSize
1166  << " " << inObj.acTrailer;
1167  return inOutStream;
1168 }
1169 
1170 
1171 ostream & operator << (ostream & inOutStream, const NTV2RegisterValueMap & inObj)
1172 {
1173  NTV2RegValueMapConstIter iter (inObj.begin ());
1174  inOutStream << "RegValues:" << inObj.size () << "[";
1175  while (iter != inObj.end ())
1176  {
1177  const NTV2RegisterNumber registerNumber (static_cast <NTV2RegisterNumber> (iter->first));
1178  const ULWord registerValue (iter->second);
1179  inOutStream << ::NTV2RegisterNumberToString (registerNumber) << "=0x" << hex << registerValue << dec;
1180  if (++iter != inObj.end ())
1181  inOutStream << ",";
1182  }
1183  return inOutStream << "]";
1184 }
1185 
1186 
1187 ostream & operator << (ostream & inOutStream, const AutoCircVidProcInfo & inObj)
1188 {
1189  return inOutStream << "{mode=" << ::AutoCircVidProcModeToString (inObj.mode, true)
1190  << ", FGvid=" << ::NTV2CrosspointToString (inObj.foregroundVideoCrosspoint)
1191  << ", BGvid=" << ::NTV2CrosspointToString (inObj.backgroundVideoCrosspoint)
1192  << ", FGkey=" << ::NTV2CrosspointToString (inObj.foregroundKeyCrosspoint)
1193  << ", BGkey=" << ::NTV2CrosspointToString (inObj.backgroundKeyCrosspoint)
1194  << ", transCoeff=" << inObj.transitionCoefficient
1195  << ", transSoftn=" << inObj.transitionSoftness << "}";
1196 }
1197 
1198 
1199 ostream & operator << (ostream & inOutStream, const NTV2ColorCorrectionData & inObj)
1200 {
1201  return inOutStream << "{ccMode=" << ::NTV2ColorCorrectionModeToString (inObj.ccMode)
1202  << ", ccSatVal=" << inObj.ccSaturationValue
1203  << ", ccTables=" << inObj.ccLookupTables << "}";
1204 }
1205 
1206 
1208 {
1209  for (NTV2VideoFormatSetConstIter iter(inSet.begin()); iter != inSet.end(); ++iter)
1210  if (inOutSet.find(*iter) == inOutSet.end())
1211  inOutSet.insert(*iter);
1212  return inOutSet;
1213 }
1214 
1215 
1216 // Implementation of NTV2VideoFormatSet's ostream writer...
1217 ostream & operator << (ostream & inOStream, const NTV2VideoFormatSet & inFormats)
1218 {
1219  NTV2VideoFormatSet::const_iterator iter (inFormats.begin ());
1220 
1221  inOStream << inFormats.size ()
1222  << (inFormats.size () == 1 ? " video format: " : " video format(s): ");
1223 
1224  while (iter != inFormats.end ())
1225  {
1226  inOStream << std::string (::NTV2VideoFormatToString (*iter));
1227  inOStream << (++iter == inFormats.end () ? "" : ", ");
1228  }
1229 
1230  return inOStream;
1231 
1232 } // operator <<
1233 
1234 
1235 // Implementation of NTV2FrameBufferFormatSet's ostream writer...
1236 ostream & operator << (ostream & inOStream, const NTV2PixelFormats & inFormats)
1237 {
1238  NTV2PixelFormatsConstIter iter(inFormats.begin());
1239  inOStream << inFormats.size()
1240  << (inFormats.size() == 1 ? " pixel format: " : " pixel formats: ");
1241 
1242  while (iter != inFormats.end())
1243  {
1244  inOStream << ::NTV2FrameBufferFormatToString(*iter);
1245  inOStream << (++iter == inFormats.end() ? "" : ", ");
1246  }
1247  return inOStream;
1248 
1249 } // operator <<
1250 
1251 
1253 {
1254  for (NTV2PixelFormatsConstIter iter(inFBFs.begin()); iter != inFBFs.end(); ++iter)
1255  inOutSet.insert(*iter);
1256  return inOutSet;
1257 }
1258 
1259 
1260 // Implementation of NTV2StandardSet's ostream writer...
1261 ostream & operator << (ostream & inOStream, const NTV2StandardSet & inStandards)
1262 {
1263  NTV2StandardSetConstIter iter (inStandards.begin ());
1264 
1265  inOStream << inStandards.size ()
1266  << (inStandards.size () == 1 ? " standard: " : " standards: ");
1267 
1268  while (iter != inStandards.end ())
1269  {
1270  inOStream << ::NTV2StandardToString(*iter);
1271  inOStream << (++iter == inStandards.end () ? "" : ", ");
1272  }
1273 
1274  return inOStream;
1275 }
1276 
1277 
1279 {
1280  for (NTV2StandardSetConstIter iter(inSet.begin ()); iter != inSet.end(); ++iter)
1281  inOutSet.insert(*iter);
1282  return inOutSet;
1283 }
1284 
1285 
1286 // Implementation of NTV2GeometrySet's ostream writer...
1287 ostream & operator << (ostream & inOStream, const NTV2GeometrySet & inGeometries)
1288 {
1289  NTV2GeometrySetConstIter iter (inGeometries.begin ());
1290  inOStream << inGeometries.size ()
1291  << (inGeometries.size () == 1 ? " geometry: " : " geometries: ");
1292  while (iter != inGeometries.end ())
1293  {
1294  inOStream << ::NTV2FrameGeometryToString(*iter);
1295  inOStream << (++iter == inGeometries.end () ? "" : ", ");
1296  }
1297  return inOStream;
1298 }
1299 
1300 
1302 {
1303  for (NTV2GeometrySetConstIter iter(inSet.begin ()); iter != inSet.end(); ++iter)
1304  inOutSet.insert(*iter);
1305  return inOutSet;
1306 }
1307 
1308 
1309 // Implementation of NTV2FrameBufferFormatSet's ostream writer...
1310 ostream & operator << (ostream & inOStream, const NTV2InputSourceSet & inSet)
1311 {
1312  NTV2InputSourceSetConstIter iter(inSet.begin());
1313  inOStream << inSet.size()
1314  << (inSet.size() == 1 ? " input: " : " inputs: ");
1315  while (iter != inSet.end())
1316  {
1317  inOStream << ::NTV2InputSourceToString (*iter);
1318  inOStream << (++iter == inSet.end() ? "" : ", ");
1319  }
1320  return inOStream;
1321 } // operator <<
1322 
1323 
1325 {
1326  for (NTV2InputSourceSetConstIter iter (inSet.begin ()); iter != inSet.end (); ++iter)
1327  inOutSet.insert (*iter);
1328  return inOutSet;
1329 }
1330 
1331 
1332 ostream & operator << (ostream & inOStream, const NTV2OutputDestinations & inSet)
1333 {
1334  NTV2OutputDestinationsConstIter iter(inSet.begin());
1335  inOStream << inSet.size()
1336  << (inSet.size() == 1 ? " output: " : " outputs: ");
1337  while (iter != inSet.end())
1338  {
1339  inOStream << ::NTV2OutputDestinationToString(*iter);
1340  inOStream << (++iter == inSet.end() ? "" : ", ");
1341  }
1342  return inOStream;
1343 }
1344 
1345 
1347 {
1348  for (NTV2OutputDestinationsConstIter iter(inSet.begin()); iter != inSet.end(); ++iter)
1349  inOutSet.insert(*iter);
1350  return inOutSet;
1351 }
1352 
1354 {
1355  outFormats.clear();
1356  const NTV2DeviceIDSet devIDs (::NTV2GetSupportedDevices());
1357  for (NTV2DeviceIDSetConstIter it(devIDs.begin()); it != devIDs.end(); ++it)
1358  {
1359  NTV2PixelFormats fmts;
1361  for (NTV2PixelFormatsConstIter fit(fmts.begin()); fit != fmts.end(); ++fit)
1362  if (outFormats.find(*fit) == outFormats.end())
1363  outFormats.insert(*fit);
1364  }
1365  return true;
1366 }
1367 
1369 {
1370  NTV2PixelFormats usedFormats;
1371  ::NTV2GetSupportedPixelFormats(usedFormats);
1372  for (NTV2PixelFormat pf(NTV2_FBF_FIRST); pf < NTV2_FBF_LAST; pf = NTV2PixelFormat(pf+1))
1373  if (usedFormats.find(pf) == usedFormats.end()) // if unused
1374  outFormats.insert(pf);
1375  return true;
1376 }
1377 
1379 {
1380  outStandards.clear();
1381  const NTV2DeviceIDSet devIDs (::NTV2GetSupportedDevices());
1382  for (NTV2DeviceIDSetConstIter it(devIDs.begin()); it != devIDs.end(); ++it)
1383  {
1384  NTV2StandardSet stds;
1386  for (NTV2StandardSetConstIter sit(stds.begin()); sit != stds.end(); ++sit)
1387  if (outStandards.find(*sit) == outStandards.end())
1388  outStandards.insert(*sit);
1389  }
1390  return true;
1391 }
1392 
1394 {
1395  NTV2StandardSet usedStandards;
1396  ::NTV2GetSupportedStandards(usedStandards);
1398  if (usedStandards.find(st) == usedStandards.end()) // if unused
1399  outStandards.insert(st);
1400  return true;
1401 }
1402 
1403 
1404 // This needs to be moved into a C++ compatible "device features" module:
1406 {
1407  bool isOkay(true);
1408  outFormats.clear();
1409 
1411  {
1412  if (inDeviceID != DEVICE_ID_INVALID && !::NTV2DeviceCanDoVideoFormat(inDeviceID, vf))
1413  continue; // Valid devID specified and VF not supported on that device
1414  if (inDeviceID == DEVICE_ID_INVALID && !NTV2_IS_VALID_VIDEO_FORMAT(vf))
1415  continue; // Invalid devID specified and invalid VF
1416  try
1417  {
1418  outFormats.insert(vf);
1419  }
1420  catch (const std::bad_alloc &)
1421  {
1422  isOkay = false;
1423  outFormats.clear();
1424  break;
1425  }
1426  } // for each video format
1427 
1428  NTV2_ASSERT ((isOkay && !outFormats.empty()) || (!isOkay && outFormats.empty()));
1429  return isOkay;
1430 
1431 } // NTV2DeviceGetSupportedVideoFormats
1432 
1433 // This needs to be moved into a C++ compatible "device features" module:
1435 {
1436  bool isOkay(true);
1437  outFormats.clear();
1438 
1439  for (NTV2PixelFormat pixelFormat(NTV2_FBF_FIRST); pixelFormat < NTV2_FBF_LAST; pixelFormat = NTV2PixelFormat(pixelFormat+1))
1440  if (::NTV2DeviceCanDoFrameBufferFormat (inDeviceID, pixelFormat))
1441  try
1442  {
1443  outFormats.insert(pixelFormat);
1444  }
1445  catch (const std::bad_alloc &)
1446  {
1447  isOkay = false;
1448  outFormats.clear();
1449  break;
1450  }
1451 
1453  if (supportedDevices.find(inDeviceID) != supportedDevices.end())
1454  {// NTV2_ASSERT ((isOkay && !outFormats.empty() ) || (!isOkay && outFormats.empty() ));
1455  return isOkay && !outFormats.empty();
1456  }
1457  return isOkay;
1458 
1459 } // NTV2DeviceGetSupportedPixelFormats
1460 
1461 // This needs to be moved into a C++ compatible "device features" module:
1462 bool NTV2DeviceGetSupportedStandards (const NTV2DeviceID inDeviceID, NTV2StandardSet & outStandards)
1463 {
1464  NTV2VideoFormatSet videoFormats;
1465  outStandards.clear();
1466  if (!::NTV2DeviceGetSupportedVideoFormats(inDeviceID, videoFormats))
1467  return false;
1468  for (NTV2VideoFormatSetConstIter it(videoFormats.begin()); it != videoFormats.end(); ++it)
1469  {
1471  if (NTV2_IS_VALID_STANDARD(std) && outStandards.find(std) == outStandards.end())
1472  outStandards.insert(std);
1473  }
1474  return true;
1475 }
1476 
1477 // This needs to be moved into a C++ compatible "device features" module:
1478 bool NTV2DeviceGetSupportedGeometries (const NTV2DeviceID inDeviceID, NTV2GeometrySet & outGeometries)
1479 {
1480  NTV2VideoFormatSet videoFormats;
1481  outGeometries.clear();
1482  if (!::NTV2DeviceGetSupportedVideoFormats(inDeviceID, videoFormats))
1483  return false;
1484  for (NTV2VideoFormatSetConstIter it(videoFormats.begin()); it != videoFormats.end(); ++it)
1485  {
1488  outGeometries += ::GetRelatedGeometries(fg);
1489  }
1490  return true;
1491 }
1492 
1493 bool NTV2DeviceGetSupportedInputSources (const NTV2DeviceID inDeviceID, NTV2InputSourceSet & outInputSources, const NTV2IOKinds inKinds)
1494 {
1495  outInputSources.clear();
1496  if (!NTV2_IS_VALID_IOKINDS(inKinds))
1497  return false;
1499  { const bool ok (inDeviceID == DEVICE_ID_INVALID ? true : ::NTV2DeviceCanDoInputSource(inDeviceID, src));
1500  if (ok)
1501  if ( (NTV2_INPUT_SOURCE_IS_SDI(src) && (inKinds & NTV2_IOKINDS_SDI))
1502  || (NTV2_INPUT_SOURCE_IS_HDMI(src) && (inKinds & NTV2_IOKINDS_HDMI))
1503  || (NTV2_INPUT_SOURCE_IS_ANALOG(src) && (inKinds & NTV2_IOKINDS_ANALOG)) )
1504  outInputSources.insert(src);
1505  }
1506  return true;
1507 }
1508 
1509 bool NTV2DeviceGetSupportedOutputDests (const NTV2DeviceID inDeviceID, NTV2OutputDestinations & outOutputDests, const NTV2IOKinds inKinds)
1510 {
1514  outOutputDests.clear();
1515  if (!NTV2_IS_VALID_IOKINDS(inKinds))
1516  return false;
1517  const UWord numSDI(inDeviceID == DEVICE_ID_INVALID ? 8 : ::NTV2DeviceGetNumVideoOutputs(inDeviceID)),
1518  numAnl(inDeviceID == DEVICE_ID_INVALID ? 1 : ::NTV2DeviceGetNumAnalogVideoOutputs(inDeviceID)),
1519  numHDM(inDeviceID == DEVICE_ID_INVALID ? 1 : ::NTV2DeviceGetNumHDMIVideoOutputs(inDeviceID));
1520  for (size_t ndx(0); ndx < 10; ndx++)
1521  {
1522  const NTV2OutputDest dst(sDsts[ndx]);
1523  if ( (NTV2_OUTPUT_DEST_IS_SDI(dst) && (inKinds & NTV2_IOKINDS_SDI) && (numSDI > ::NTV2OutputDestinationToChannel(dst)))
1524  || (NTV2_OUTPUT_DEST_IS_HDMI(dst) && (inKinds & NTV2_IOKINDS_HDMI) && (numHDM) )
1525  || (NTV2_OUTPUT_DEST_IS_ANALOG(dst) && (inKinds & NTV2_IOKINDS_ANALOG) && (numAnl) ) )
1526  outOutputDests.insert(dst);
1527  }
1528  return true;
1529 }
1530 
1531 ostream & operator << (ostream & oss, const NTV2FrameRateSet & inSet)
1532 {
1533  NTV2FrameRateSetConstIter it(inSet.begin());
1534  oss << inSet.size()
1535  << (inSet.size() == 1 ? " rate: " : " rates: ");
1536  while (it != inSet.end())
1537  {
1538  oss << ::NTV2FrameRateToString(*it);
1539  oss << (++it == inSet.end() ? "" : ", ");
1540  }
1541  return oss;
1542 }
1543 
1545 {
1546  for (NTV2FrameRateSetConstIter it(inSet.begin()); it != inSet.end(); ++it)
1547  if (inOutSet.find(*it) == inOutSet.end())
1548  inOutSet.insert(*it);
1549  return inOutSet;
1550 }
1551 
1553 {
1554  outRates.clear();
1555  NTV2VideoFormatSet vfs;
1556  if (!::NTV2DeviceGetSupportedVideoFormats (inDeviceID, vfs))
1557  return false;
1558  for (NTV2VideoFormatSetConstIter it(vfs.begin()); it != vfs.end(); ++it)
1559  { const NTV2FrameRate fr (::GetNTV2FrameRateFromVideoFormat(*it));
1561  outRates.insert(fr);
1562  }
1563  return true;
1564 }
1565 
1566 
1567 ostream & operator << (ostream & inOutStrm, const NTV2SegmentedXferInfo & inRun)
1568 {
1569  return inRun.Print(inOutStrm);
1570 }
1571 
1572 
1573 // Implementation of NTV2AutoCirculateStateToString...
1575 {
1576  static const char * sStateStrings [] = { "Disabled", "Initializing", "Starting", "Paused", "Stopping", "Running", "StartingAtTime", AJA_NULL};
1578  return string (sStateStrings [inState]);
1579  else
1580  return "<invalid>";
1581 }
1582 
1583 
1584 NTV2FrameSize::operator NTV2FrameGeometry() const // Cast to NTV2FrameGeometry
1585 {
1586  return isValid() ? ::GetGeometryFromFrameDimensions(*this) : NTV2_FG_INVALID;
1587 }
1588 
1590 { // Requires C++11:
1591  static const FGSizesMap sFGWdths = { {NTV2_FG_720x486, 720},
1592  {NTV2_FG_720x508, 720},
1593  {NTV2_FG_720x514, 720},
1594  {NTV2_FG_720x576, 720},
1595  {NTV2_FG_720x598, 720},
1596  {NTV2_FG_720x612, 720},
1597  {NTV2_FG_1280x720, 1280},
1598  {NTV2_FG_1280x740, 1280},
1599  {NTV2_FG_1920x1080, 1920},
1600  {NTV2_FG_1920x1114, 1920},
1601  {NTV2_FG_1920x1112, 1920},
1602  {NTV2_FG_2048x1080, 2048},
1603  {NTV2_FG_2048x1112, 2048},
1604  {NTV2_FG_2048x1114, 2048},
1605  {NTV2_FG_2048x1556, 2048},
1606  {NTV2_FG_2048x1588, 2048},
1607  {NTV2_FG_3840x2160, 3840},
1608  {NTV2_FG_4096x2160, 4096},
1609  {NTV2_FG_7680x4320, 7680},
1610  {NTV2_FG_8192x4320, 8192} };
1611  FGSizesMapCI it (sFGWdths.find(fg));
1612  return it != sFGWdths.end() ? it->second : 0;
1613 }
1614 
1616 { // Requires C++11:
1617  static const FGSizesMap sFGHghts = { {NTV2_FG_720x486, 486},
1618  {NTV2_FG_720x508, 508},
1619  {NTV2_FG_720x514, 514},
1620  {NTV2_FG_720x576, 576},
1621  {NTV2_FG_720x598, 598},
1622  {NTV2_FG_720x612, 612},
1623  {NTV2_FG_1280x720, 720},
1624  {NTV2_FG_1280x740, 740},
1625  {NTV2_FG_2048x1556, 1556},
1626  {NTV2_FG_2048x1588, 1588},
1627  {NTV2_FG_1920x1080, 1080},
1628  {NTV2_FG_2048x1080, 1080},
1629  {NTV2_FG_1920x1114, 1114},
1630  {NTV2_FG_2048x1114, 1114},
1631  {NTV2_FG_1920x1112, 1112},
1632  {NTV2_FG_2048x1112, 1112},
1633  {NTV2_FG_3840x2160, 2160},
1634  {NTV2_FG_4096x2160, 2160},
1635  {NTV2_FG_7680x4320, 4320},
1636  {NTV2_FG_8192x4320, 4320} };
1637  FGSizesMapCI it (sFGHghts.find(fg));
1638  return it != sFGHghts.end() ? it->second : 0;
1639 }
1640 
1641 
1642 static const string sSegXferUnits[] = {"", " U8", " U16", "", " U32", "", "", "", " U64", ""};
1643 
1644 ostream & NTV2SegmentedXferInfo::Print (ostream & inStrm, const bool inDumpSegments) const
1645 {
1646  if (!isValid())
1647  return inStrm << "(invalid)";
1648  if (inDumpSegments)
1649  {
1650  // TBD
1651  }
1652  else
1653  {
1654  inStrm << DEC(getSegmentCount()) << " x " << DEC(getSegmentLength())
1655  << sSegXferUnits[getElementLength()] << " segs";
1656  if (getSourceOffset())
1657  inStrm << " srcOff=" << xHEX0N(getSourceOffset(),8);
1658  if (getSegmentCount() > 1)
1659  inStrm << " srcSpan=" << xHEX0N(getSourcePitch(),8) << (isSourceBottomUp()?" VF":"");
1660  if (getDestOffset())
1661  inStrm << " dstOff=" << xHEX0N(getDestOffset(),8);
1662  if (getSegmentCount() > 1)
1663  inStrm << " dstSpan=" << xHEX0N(getDestPitch(),8) << (isDestBottomUp()?" VF":"");
1664  inStrm << " totElm=" << DEC(getTotalElements()) << " totByt=" << xHEX0N(getTotalBytes(),8);
1665  }
1666  return inStrm;
1667 }
1668 
1669 string NTV2SegmentedXferInfo::getSourceCode (const bool inInclDecl) const
1670 {
1671  static string var("segInfo");
1672  ostringstream oss;
1673  string units("\t// bytes");
1674  if (!isValid())
1675  return "";
1676  if (inInclDecl)
1677  oss << "NTV2SegmentedXferInfo " << var << ";" << endl;
1678  if (getElementLength() > 1)
1679  {
1680  units = "\t// " + sSegXferUnits[getElementLength()] + "s";
1681  oss << var << ".setElementLength(" << getElementLength() << ");" << endl;
1682  }
1683  oss << var << ".setSegmentCount(" << DEC(getSegmentCount()) << ");" << endl;
1684  oss << var << ".setSegmentLength(" << DEC(getSegmentLength()) << ");" << units << endl;
1685  if (getSourceOffset())
1686  oss << var << ".setSourceOffset(" << DEC(getSourceOffset()) << ");" << units << endl;
1687  oss << var << ".setSourcePitch(" << DEC(getSourcePitch()) << ");" << units << endl;
1688  if (isSourceBottomUp())
1689  oss << var << ".setSourceDirection(false);" << endl;
1690  if (getDestOffset())
1691  oss << var << ".setDestOffset(" << DEC(getDestOffset()) << ");" << units << endl;
1692  if (getDestPitch())
1693  oss << var << ".setDestPitch(" << DEC(getDestPitch()) << ");" << units << endl;
1694  if (isDestBottomUp())
1695  oss << var << ".setDestDirection(false);" << endl;
1696  return oss.str();
1697 }
1698 
1699 bool NTV2SegmentedXferInfo::containsElementAtOffset (const ULWord inElementOffset) const
1700 {
1701  if (!isValid())
1702  return false;
1703  if (getSegmentCount() == 1)
1704  {
1705  if (inElementOffset >= getSourceOffset())
1706  if (inElementOffset < getSourceOffset()+getSegmentLength())
1707  return true;
1708  return false;
1709  }
1710  ULWord offset(getSourceOffset());
1711  for (ULWord seg(0); seg < getSegmentCount(); seg++)
1712  {
1713  if (inElementOffset < offset)
1714  return false; // past element of interest already
1715  if (inElementOffset < offset+getSegmentLength())
1716  return true; // must be within this segment
1717  offset += getSourcePitch(); // skip to next segment
1718  }
1719  return false;
1720 }
1721 
1723 {
1724  if (getElementLength() != inRHS.getElementLength())
1725  // FUTURE TBD: Need to transform RHS to match ElementLength so as to make apples-to-apples comparison
1726  return true; // For now, fail
1727  if (getSegmentCount() != inRHS.getSegmentCount())
1728  return true;
1729  if (getSegmentLength() != inRHS.getSegmentLength())
1730  return true;
1731  if (getSourceOffset() != inRHS.getSourceOffset())
1732  return true;
1733  if (getSourcePitch() != inRHS.getSourcePitch())
1734  return true;
1735  if (getDestOffset() != inRHS.getDestOffset())
1736  return true;
1737  if (getDestPitch() != inRHS.getDestPitch())
1738  return true;
1739  return false;
1740 }
1741 
1743 {
1744  mFlags = 0;
1745  mNumSegments = 0;
1746  mElementsPerSegment = 0;
1747  mInitialSrcOffset = 0;
1748  mInitialDstOffset = 0;
1749  mSrcElementsPerRow = 0;
1750  mDstElementsPerRow = 0;
1751  setElementLength(1); // elements == bytes
1752  return *this;
1753 }
1754 
1756 {
1757  std::swap(mSrcElementsPerRow, mDstElementsPerRow);
1758  std::swap(mInitialSrcOffset, mInitialDstOffset);
1759  const bool srcNormal(this->isSourceTopDown()), dstNormal(this->isDestTopDown());
1760  setSourceDirection(dstNormal).setDestDirection(srcNormal);
1761  return *this;
1762 }
1763 
1764 
1765 NTV2Buffer::NTV2Buffer (const void * pInUserPointer, const size_t inByteCount)
1766  : fUserSpacePtr (inByteCount ? NTV2Buffer_TO_ULWORD64(pInUserPointer) : 0),
1767  fByteCount (ULWord(pInUserPointer ? inByteCount : 0)),
1768  fFlags (0),
1769  #if defined (AJAMac)
1770  fKernelSpacePtr (0),
1771  fIOMemoryDesc (0),
1772  fIOMemoryMap (0)
1773  #else
1774  //fKernelSpacePtr (0),
1775  fKernelHandle (0)
1776  #endif
1777 {
1778 }
1779 
1780 
1781 NTV2Buffer::NTV2Buffer (const size_t inByteCount)
1782  : fUserSpacePtr (0),
1783  fByteCount (0),
1784  fFlags (0),
1785  #if defined (AJAMac)
1786  fKernelSpacePtr (0),
1787  fIOMemoryDesc (0),
1788  fIOMemoryMap (0)
1789  #else
1790  //fKernelSpacePtr (0),
1791  fKernelHandle (0)
1792  #endif
1793 {
1794  if (inByteCount)
1795  Allocate(inByteCount);
1796 }
1797 
1798 
1800  : fUserSpacePtr (0),
1801  fByteCount (0),
1802  fFlags (0),
1803  #if defined (AJAMac)
1804  fKernelSpacePtr (0),
1805  fIOMemoryDesc (0),
1806  fIOMemoryMap (0)
1807  #else
1808  //fKernelSpacePtr (0),
1809  fKernelHandle (0)
1810  #endif
1811 {
1812  if (Allocate(inObj.GetByteCount()))
1813  SetFrom(inObj);
1814 }
1815 
1816 bool NTV2Buffer::Truncate (const size_t inNewByteCount)
1817 {
1818  if (inNewByteCount == GetByteCount())
1819  return true; // Same size -- done!
1820  if (inNewByteCount > GetByteCount())
1821  return false; // Cannot enlarge -- i.e. can't be greater than my current size
1822  if (!inNewByteCount && IsAllocatedBySDK())
1823  return Deallocate(); // A newByteCount of zero calls Deallocate
1824  fByteCount = ULWord(inNewByteCount);
1825  return true;
1826 }
1827 
1829 {
1830  if (&inRHS != this)
1831  {
1832  if (inRHS.IsNULL())
1833  Set (AJA_NULL, 0);
1834  else if (GetByteCount() == inRHS.GetByteCount())
1835  SetFrom(inRHS);
1836  else if (Allocate(inRHS.GetByteCount()))
1837  SetFrom(inRHS);
1838  //else; // Error
1839  }
1840  return *this;
1841 }
1842 
1843 
1845 {
1846  Set (AJA_NULL, 0); // Call 'Set' to delete the array (if I allocated it)
1847 }
1848 
1849 
1851 {
1852  uint64_t * pU64s(reinterpret_cast<uint64_t*>(GetHostPointer()));
1853  const size_t loopCount(GetByteCount() / sizeof(uint64_t));
1854  if (IsNULL())
1855  return false;
1856  for (size_t ndx(0); ndx < loopCount; ndx++)
1857  pU64s[ndx] = NTV2EndianSwap64(pU64s[ndx]);
1858  return true;
1859 }
1860 
1861 
1863 {
1864  uint32_t * pU32s(reinterpret_cast<uint32_t*>(GetHostPointer()));
1865  const size_t loopCount(GetByteCount() / sizeof(uint32_t));
1866  if (IsNULL())
1867  return false;
1868  for (size_t ndx(0); ndx < loopCount; ndx++)
1869  pU32s[ndx] = NTV2EndianSwap32(pU32s[ndx]);
1870  return true;
1871 }
1872 
1873 
1875 {
1876  uint16_t * pU16s(reinterpret_cast<uint16_t*>(GetHostPointer()));
1877  const size_t loopCount(GetByteCount() / sizeof(uint16_t));
1878  if (IsNULL())
1879  return false;
1880  for (size_t ndx(0); ndx < loopCount; ndx++)
1881  pU16s[ndx] = NTV2EndianSwap16(pU16s[ndx]);
1882  return true;
1883 }
1884 
1885 
1886 bool NTV2Buffer::Set (const void * pInUserPointer, const size_t inByteCount)
1887 {
1888  if (uint64_t(inByteCount) >= 0x0000000100000000) // inByteCount >= 4GB?
1889  return false; // Can't store 4GB or larger value in fByteCount
1890  Deallocate();
1891  fUserSpacePtr = inByteCount ? NTV2Buffer_TO_ULWORD64(pInUserPointer) : 0;
1892  fByteCount = ULWord(pInUserPointer ? inByteCount : 0);
1893  // Return true only if both UserPointer and ByteCount are non-zero, or both are zero.
1894  return (pInUserPointer && inByteCount) || (!pInUserPointer && !inByteCount);
1895 }
1896 
1897 
1898 bool NTV2Buffer::SetAndFill (const void * pInUserPointer, const size_t inByteCount, const UByte inValue)
1899 {
1900  return Set(pInUserPointer, inByteCount) && Fill(inValue);
1901 }
1902 
1903 
1904 bool NTV2Buffer::Allocate (const size_t inByteCount, const bool inPageAligned)
1905 {
1906  if (uint64_t(inByteCount) >= 0x0000000100000000) // inByteCount >= 4GB?
1907  return false; // Can't store 4GB or more in fByteCount
1908  if (GetByteCount() && IsAllocatedBySDK()) // If already was Allocated
1909  if (inByteCount == GetByteCount()) // If same byte count
1910  {
1911  Fill(UByte(0)); // Zero it...
1912  return true; // ...and return true
1913  }
1914 
1915  bool result(Set(AJA_NULL, 0)); // Jettison existing buffer (if any)
1916  if (inByteCount)
1917  { // Allocate the byte array, and call Set...
1918  UByte * pBuffer(AJA_NULL);
1919  result = false;
1920  if (inPageAligned)
1921  pBuffer = reinterpret_cast<UByte*>(AJAMemory::AllocateAligned(inByteCount, DefaultPageSize()));
1922  else
1923  try
1924  {pBuffer = new UByte[inByteCount];}
1925  catch (const std::bad_alloc &)
1926  {pBuffer = AJA_NULL;}
1927  if (pBuffer && Set(pBuffer, inByteCount))
1928  { // SDK owns this memory -- set NTV2Buffer_ALLOCATED bit -- I'm responsible for deleting
1929  result = true;
1930  fFlags |= NTV2Buffer_ALLOCATED;
1931  if (inPageAligned)
1932  fFlags |= NTV2Buffer_PAGE_ALIGNED; // Set "page aligned" flag
1933  Fill(UByte(0)); // Zero it
1934  }
1935  } // if requested size is non-zero
1936  return result;
1937 }
1938 
1939 
1941 {
1942  if (IsAllocatedBySDK())
1943  {
1944  if (!IsNULL())
1945  {
1946  if (IsPageAligned())
1947  {
1949  fFlags &= ~NTV2Buffer_PAGE_ALIGNED;
1950  }
1951  else
1952  delete [] reinterpret_cast<UByte*>(GetHostPointer());
1953  }
1954  fUserSpacePtr = 0;
1955  fByteCount = 0;
1956  fFlags &= ~NTV2Buffer_ALLOCATED;
1957  }
1958  return true;
1959 }
1960 
1961 
1962 void * NTV2Buffer::GetHostAddress (const ULWord inByteOffset, const bool inFromEnd) const
1963 {
1964  if (IsNULL())
1965  return AJA_NULL;
1966  if (inByteOffset >= GetByteCount())
1967  return AJA_NULL;
1968  UByte * pBytes (reinterpret_cast<UByte*>(GetHostPointer()));
1969  if (inFromEnd)
1970  pBytes += GetByteCount() - inByteOffset;
1971  else
1972  pBytes += inByteOffset;
1973  return pBytes;
1974 }
1975 
1976 
1977 bool NTV2Buffer::SetFrom (const NTV2Buffer & inBuffer)
1978 {
1979  if (inBuffer.IsNULL())
1980  return false; // NULL or empty
1981  if (IsNULL())
1982  return false; // I am NULL or empty
1983  if (inBuffer.GetByteCount() == GetByteCount() && inBuffer.GetHostPointer() == GetHostPointer())
1984  return true; // Same buffer
1985 
1986  size_t bytesToCopy(inBuffer.GetByteCount());
1987  if (bytesToCopy > GetByteCount())
1988  bytesToCopy = GetByteCount();
1989  ::memcpy (GetHostPointer(), inBuffer.GetHostPointer(), bytesToCopy);
1990  return true;
1991 }
1992 
1993 
1994 bool NTV2Buffer::CopyFrom (const void * pInSrcBuffer, const ULWord inByteCount)
1995 {
1996  if (!inByteCount)
1997  return Set (AJA_NULL, 0); // Zero bytes
1998  if (!pInSrcBuffer)
1999  return false; // NULL src ptr
2000  if (!Allocate (inByteCount))
2001  return false; // Resize failed
2002  ::memcpy (GetHostPointer(), pInSrcBuffer, inByteCount);
2003  return true;
2004 }
2005 
2006 
2007 bool NTV2Buffer::CopyFrom (const NTV2Buffer & inBuffer,
2008  const ULWord inSrcByteOffset, const ULWord inDstByteOffset, const ULWord inByteCount)
2009 {
2010  if (inBuffer.IsNULL() || IsNULL())
2011  return false; // NULL or empty
2012  if (inSrcByteOffset + inByteCount > inBuffer.GetByteCount())
2013  return false; // Past end of src
2014  if (inDstByteOffset + inByteCount > GetByteCount())
2015  return false; // Past end of me
2016 
2017  const UByte * pSrc (inBuffer);
2018  pSrc += inSrcByteOffset;
2019 
2020  UByte * pDst (*this);
2021  pDst += inDstByteOffset;
2022 
2023  ::memcpy (pDst, pSrc, inByteCount);
2024  return true;
2025 }
2026 
2027 
2028 bool NTV2Buffer::CopyFrom (const NTV2Buffer & inSrcBuffer, const NTV2SegmentedXferInfo & inXferInfo)
2029 {
2030  if (!inXferInfo.isValid() || inSrcBuffer.IsNULL() || IsNULL())
2031  return false;
2032 
2033  // Copy every segment...
2034  LWord srcOffset (LWord(inXferInfo.getSourceOffset() * inXferInfo.getElementLength()));
2035  LWord dstOffset (LWord(inXferInfo.getDestOffset() * inXferInfo.getElementLength()));
2036  LWord srcPitch (LWord(inXferInfo.getSourcePitch() * inXferInfo.getElementLength()));
2037  LWord dstPitch (LWord(inXferInfo.getDestPitch() * inXferInfo.getElementLength()));
2038  const LWord bytesPerSeg (inXferInfo.getSegmentLength() * inXferInfo.getElementLength());
2039  if (inXferInfo.isSourceBottomUp())
2040  srcPitch = 0 - srcPitch;
2041  if (inXferInfo.isDestBottomUp())
2042  dstPitch = 0 - dstPitch;
2043  for (ULWord segNdx(0); segNdx < inXferInfo.getSegmentCount(); segNdx++)
2044  {
2045  const void * pSrc (inSrcBuffer.GetHostAddress(srcOffset));
2046  void * pDst (GetHostAddress(dstOffset));
2047  if (!pSrc) return false;
2048  if (!pDst) return false;
2049  if (srcOffset + bytesPerSeg > LWord(inSrcBuffer.GetByteCount()))
2050  return false; // memcpy will read past end of srcBuffer
2051  if (dstOffset + bytesPerSeg > LWord(GetByteCount()))
2052  return false; // memcpy will write past end of me
2053  ::memcpy (pDst, pSrc, size_t(bytesPerSeg));
2054  srcOffset += srcPitch; // Bump src offset
2055  dstOffset += dstPitch; // Bump dst offset
2056  } // for each segment
2057  return true;
2058 }
2059 
2060 bool NTV2Buffer::SetFromHexString (const string & inStr)
2061 {
2062  string str(inStr);
2063 
2064  // Remove all whitespace...
2065  const string newline("\n"), tab("\t");
2066  aja::replace(str, newline, string());
2067  aja::replace(str, tab, string());
2068  aja::upper(str);
2069 
2070  // Fail if any non-hex found...
2071  for (size_t ndx(0); ndx < str.size(); ndx++)
2072  if (!aja::is_hex_digit(str.at(ndx)))
2073  return false;
2074 
2075  if (str.size() & 1)
2076  return false; // Remaining length must be even
2077  if (!Allocate(str.size() / 2))
2078  return false; // Resize failed
2079 
2080  // Decode and copy in the data...
2081  for (size_t srcNdx(0), dstNdx(0); srcNdx < str.size(); srcNdx += 2)
2082  U8(int(dstNdx++)) = uint8_t(aja::stoul (str.substr(srcNdx,2), AJA_NULL, 16));
2083 
2084  return true;
2085 }
2086 
2088 {
2089  if (inBuffer.IsNULL ())
2090  return false; // NULL or empty
2091  if (IsNULL ())
2092  return false; // I am NULL or empty
2093  if (inBuffer.GetByteCount () != GetByteCount ())
2094  return false; // Different sizes
2095  if (fFlags != inBuffer.fFlags)
2096  return false; // Flags mismatch
2097  if (inBuffer.GetHostPointer () == GetHostPointer ())
2098  return true; // Same buffer
2099 
2100  ULWord64 tmp = fUserSpacePtr;
2101  fUserSpacePtr = inBuffer.fUserSpacePtr;
2102  inBuffer.fUserSpacePtr = tmp;
2103  return true;
2104 }
2105 
2106 ULWordSet & NTV2Buffer::Find (ULWordSet & outOffsets, const NTV2Buffer & inValue, const size_t inLimit) const
2107 {
2108  outOffsets.clear();
2109  if (IsNULL())
2110  return outOffsets; // NULL buffer, return "no matches"
2111  if (inValue.IsNULL())
2112  return outOffsets; // NULL buffer, return "no matches"
2113  const ULWord srchByteCount(inValue.GetByteCount());
2114  if (GetByteCount() < srchByteCount)
2115  return outOffsets; // I'm smaller than the search data, return "no matches"
2116 
2117  const ULWord maxOffset(GetByteCount() - srchByteCount); // Don't search past here
2118  const uint8_t * pSrchData (inValue); // Pointer to search data
2119  const uint8_t * pMyData (*this); // Pointer to where search starts in me
2120  ULWord offset(0); // Search starts at this byte offset
2121  do
2122  {
2123  if (!::memcmp(pMyData, pSrchData, srchByteCount))
2124  {
2125  outOffsets.insert(offset); // Record byte offset of match
2126  if (inLimit && outOffsets.size() >= inLimit)
2127  break; // reached limit, early exit
2128  }
2129  pMyData++; // Bump search pointer
2130  offset++; // Bump search byte offset
2131  } while (offset < maxOffset);
2132  return outOffsets;
2133 }
2134 
2135 bool NTV2Buffer::IsContentEqual (const NTV2Buffer & inBuffer, const ULWord inByteOffset, const ULWord inByteCount) const
2136 {
2137  if (IsNULL() || inBuffer.IsNULL())
2138  return false; // Buffer(s) are NULL/empty
2139  if (inBuffer.GetByteCount() != GetByteCount())
2140  return false; // Buffers are different sizes
2141 
2142  ULWord totalBytes(GetByteCount());
2143  if (inByteOffset >= totalBytes)
2144  return false; // Bad offset
2145 
2146  totalBytes -= inByteOffset;
2147 
2148  ULWord byteCount(inByteCount);
2149  if (byteCount > totalBytes)
2150  byteCount = totalBytes;
2151 
2152  if (inBuffer.GetHostPointer() == GetHostPointer())
2153  return true; // Same buffer
2154 
2155  const UByte * pByte1 (*this);
2156  const UByte * pByte2 (inBuffer);
2157  pByte1 += inByteOffset;
2158  pByte2 += inByteOffset;
2159  #if !defined(NTV2BUFFER_NO_MEMCMP)
2160  return ::memcmp (pByte1, pByte2, byteCount) == 0;
2161  #else // NTV2BUFFER_NO_MEMCMP
2162  ULWord offset(inByteOffset);
2163  while (byteCount)
2164  {
2165  if (*pByte1 != *pByte2)
2166  {
2167  cerr << "## ERROR: IsContentEqual: miscompare at offset " << xHEX0N(offset,8)
2168  << " (" << DEC(offset) << "): " << xHEX0N(UWord(*pByte1),2) << " != "
2169  << xHEX0N(UWord(*pByte2),2) << ", " << xHEX0N(byteCount,8) << " ("
2170  << DEC(byteCount) << ") bytes left to compare" << endl;
2171  return false;
2172  }
2173  pByte1++; pByte2++;
2174  byteCount--;
2175  offset++;
2176  }
2177  return true;
2178  #endif // NTV2BUFFER_NO_MEMCMP
2179 }
2180 
2181 bool NTV2Buffer::NextDifference (const NTV2Buffer & inBuffer, ULWord & byteOffset) const
2182 {
2183  if (byteOffset == 0xFFFFFFFF)
2184  return false; // bad offset
2185  if (IsNULL() || inBuffer.IsNULL())
2186  return false; // NULL or empty buffers
2187  if (inBuffer.GetByteCount() != GetByteCount())
2188  return false; // Different byte counts
2189  if (inBuffer.GetHostPointer() == GetHostPointer())
2190  {byteOffset = 0xFFFFFFFF; return true;} // Same buffer
2191 
2192  ULWord totalBytesToCompare(GetByteCount());
2193  if (byteOffset >= totalBytesToCompare)
2194  return false; // Bad offset
2195  totalBytesToCompare -= byteOffset;
2196 
2197  const UByte * pByte1 (*this);
2198  const UByte * pByte2 (inBuffer);
2199  while (totalBytesToCompare)
2200  {
2201  if (pByte1[byteOffset] != pByte2[byteOffset])
2202  return true;
2203  totalBytesToCompare--;
2204  byteOffset++;
2205  }
2206  byteOffset = 0xFFFFFFFF;
2207  return true;
2208 }
2209 
2210 bool NTV2Buffer::GetRingChangedByteRange (const NTV2Buffer & inBuffer, ULWord & outByteOffsetFirst, ULWord & outByteOffsetLast) const
2211 {
2212  outByteOffsetFirst = outByteOffsetLast = GetByteCount ();
2213  if (IsNULL () || inBuffer.IsNULL ())
2214  return false; // NULL or empty
2215  if (inBuffer.GetByteCount () != GetByteCount ())
2216  return false; // Different byte counts
2217  if (inBuffer.GetHostPointer () == GetHostPointer ())
2218  return true; // Same buffer
2219  if (GetByteCount() < 3)
2220  return false; // Too small
2221 
2222  const UByte * pByte1 (reinterpret_cast <const UByte *> (GetHostPointer()));
2223  const UByte * pByte2 (reinterpret_cast <const UByte *> (inBuffer.GetHostPointer()));
2224 
2225  outByteOffsetFirst = 0;
2226  while (outByteOffsetFirst < GetByteCount())
2227  {
2228  if (*pByte1 != *pByte2)
2229  break;
2230  pByte1++;
2231  pByte2++;
2232  outByteOffsetFirst++;
2233  }
2234  if (outByteOffsetFirst == 0)
2235  {
2236  // Wrap case -- look for first match...
2237  while (outByteOffsetFirst < GetByteCount())
2238  {
2239  if (*pByte1 == *pByte2)
2240  break;
2241  pByte1++;
2242  pByte2++;
2243  outByteOffsetFirst++;
2244  }
2245  if (outByteOffsetFirst < GetByteCount())
2246  outByteOffsetFirst--;
2247  }
2248  if (outByteOffsetFirst == GetByteCount())
2249  return true; // Identical --- outByteOffsetFirst == outByteOffsetLast == GetByteCount()
2250 
2251  // Now scan from the end...
2252  pByte1 = reinterpret_cast <const UByte *> (GetHostPointer());
2253  pByte2 = reinterpret_cast <const UByte *> (inBuffer.GetHostPointer());
2254  pByte1 += GetByteCount () - 1; // Point to last byte
2255  pByte2 += GetByteCount () - 1;
2256  while (--outByteOffsetLast)
2257  {
2258  if (*pByte1 != *pByte2)
2259  break;
2260  pByte1--;
2261  pByte2--;
2262  }
2263  if (outByteOffsetLast == (GetByteCount() - 1))
2264  {
2265  // Wrap case -- look for first match...
2266  while (outByteOffsetLast)
2267  {
2268  if (*pByte1 == *pByte2)
2269  break;
2270  pByte1--;
2271  pByte2--;
2272  outByteOffsetLast--;
2273  }
2274  if (outByteOffsetLast < GetByteCount())
2275  outByteOffsetLast++;
2276  if (outByteOffsetLast <= outByteOffsetFirst)
2277  cerr << "## WARNING: GetRingChangedByteRange: last " << outByteOffsetLast << " <= first " << outByteOffsetFirst << " in wrap condition" << endl;
2278  const ULWord tmp (outByteOffsetLast);
2279  outByteOffsetLast = outByteOffsetFirst;
2280  outByteOffsetFirst = tmp;
2281  if (outByteOffsetLast >= outByteOffsetFirst)
2282  cerr << "## WARNING: GetRingChangedByteRange: last " << outByteOffsetLast << " >= first " << outByteOffsetFirst << " in wrap condition" << endl;
2283  }
2284  return true;
2285 
2286 } // GetRingChangedByteRange
2287 
2288 
2289 static size_t gDefaultPageSize (AJA_PAGE_SIZE);
2290 
2292 {
2293  return gDefaultPageSize;
2294 }
2295 
2296 bool NTV2Buffer::SetDefaultPageSize (const size_t inNewSize)
2297 {
2298  const bool result (inNewSize && (!(inNewSize & (inNewSize - 1))));
2299  if (result)
2300  gDefaultPageSize = inNewSize;
2301  return result;
2302 }
2303 
2305 {
2306 #if defined(MSWindows) || defined(AJABareMetal)
2307  return AJA_PAGE_SIZE;
2308 #else
2309  return size_t(::getpagesize());
2310 #endif
2311 }
2312 
2313 
2315  : acHeader (NTV2_TYPE_ACFRAMESTAMP, sizeof(FRAME_STAMP)),
2316  acFrameTime (0),
2317  acRequestedFrame (0),
2318  acAudioClockTimeStamp (0),
2319  acAudioExpectedAddress (0),
2320  acAudioInStartAddress (0),
2321  acAudioInStopAddress (0),
2322  acAudioOutStopAddress (0),
2323  acAudioOutStartAddress (0),
2324  acTotalBytesTransferred (0),
2325  acStartSample (0),
2326  acTimeCodes (NTV2_MAX_NUM_TIMECODE_INDEXES * sizeof (NTV2_RP188)),
2327  acCurrentTime (0),
2328  acCurrentFrame (0),
2329  acCurrentFrameTime (0),
2330  acAudioClockCurrentTime (0),
2331  acCurrentAudioExpectedAddress (0),
2332  acCurrentAudioStartAddress (0),
2333  acCurrentFieldCount (0),
2334  acCurrentLineCount (0),
2335  acCurrentReps (0),
2336  acCurrentUserCookie (0),
2337  acFrame (0),
2338  acRP188 ()
2339 {
2341 }
2342 
2343 
2345  : acHeader (inObj.acHeader),
2346  acFrameTime (inObj.acFrameTime),
2347  acRequestedFrame (inObj.acRequestedFrame),
2348  acAudioClockTimeStamp (inObj.acAudioClockTimeStamp),
2349  acAudioExpectedAddress (inObj.acAudioExpectedAddress),
2350  acAudioInStartAddress (inObj.acAudioInStartAddress),
2351  acAudioInStopAddress (inObj.acAudioInStopAddress),
2352  acAudioOutStopAddress (inObj.acAudioOutStopAddress),
2353  acAudioOutStartAddress (inObj.acAudioOutStartAddress),
2354  acTotalBytesTransferred (inObj.acTotalBytesTransferred),
2355  acStartSample (inObj.acStartSample),
2356  acCurrentTime (inObj.acCurrentTime),
2357  acCurrentFrame (inObj.acCurrentFrame),
2358  acCurrentFrameTime (inObj.acCurrentFrameTime),
2359  acAudioClockCurrentTime (inObj.acAudioClockCurrentTime),
2360  acCurrentAudioExpectedAddress (inObj.acCurrentAudioExpectedAddress),
2361  acCurrentAudioStartAddress (inObj.acCurrentAudioStartAddress),
2362  acCurrentFieldCount (inObj.acCurrentFieldCount),
2363  acCurrentLineCount (inObj.acCurrentLineCount),
2364  acCurrentReps (inObj.acCurrentReps),
2365  acCurrentUserCookie (inObj.acCurrentUserCookie),
2366  acFrame (inObj.acFrame),
2367  acRP188 (inObj.acRP188),
2368  acTrailer (inObj.acTrailer)
2369 {
2371 }
2372 
2373 
2375 {
2376 }
2377 
2378 
2380 {
2382  ULWord numRP188s (acTimeCodes.GetByteCount () / sizeof (NTV2_RP188));
2383  const NTV2_RP188 * pArray (reinterpret_cast <const NTV2_RP188 *> (acTimeCodes.GetHostPointer ()));
2384  outValues.clear ();
2385  if (!pArray)
2386  return false; // No 'acTimeCodes' array!
2387 
2388  if (numRP188s > NTV2_MAX_NUM_TIMECODE_INDEXES)
2389  numRP188s = NTV2_MAX_NUM_TIMECODE_INDEXES; // clamp to this max number
2390 
2391  for (ULWord ndx (0); ndx < numRP188s; ndx++)
2392  outValues << pArray [ndx];
2393 
2394  return true;
2395 }
2396 
2397 
2398 bool FRAME_STAMP::GetInputTimeCode (NTV2_RP188 & outTimeCode, const NTV2TCIndex inTCIndex) const
2399 {
2401  ULWord numRP188s (acTimeCodes.GetByteCount () / sizeof (NTV2_RP188));
2402  const NTV2_RP188 * pArray (reinterpret_cast <const NTV2_RP188 *> (acTimeCodes.GetHostPointer ()));
2403  outTimeCode.Set (); // invalidate
2404  if (!pArray)
2405  return false; // No 'acTimeCodes' array!
2406  if (numRP188s > NTV2_MAX_NUM_TIMECODE_INDEXES)
2407  numRP188s = NTV2_MAX_NUM_TIMECODE_INDEXES; // clamp to this max number
2408  if (!NTV2_IS_VALID_TIMECODE_INDEX (inTCIndex))
2409  return false;
2410 
2411  outTimeCode = pArray [inTCIndex];
2412  return true;
2413 }
2414 
2415 
2416 bool FRAME_STAMP::GetInputTimeCodes (NTV2TimeCodes & outTimeCodes, const NTV2Channel inSDIInput, const bool inValidOnly) const
2417 {
2419  outTimeCodes.clear();
2420 
2421  if (!NTV2_IS_VALID_CHANNEL(inSDIInput))
2422  return false; // Bad SDI input
2423 
2424  NTV2TimeCodeList allTCs;
2425  if (!GetInputTimeCodes(allTCs))
2426  return false; // GetInputTimeCodes failed
2427 
2428  const NTV2TCIndexes tcIndexes (GetTCIndexesForSDIInput(inSDIInput));
2429  for (NTV2TCIndexesConstIter iter(tcIndexes.begin()); iter != tcIndexes.end(); ++iter)
2430  {
2431  const NTV2TCIndex tcIndex(*iter);
2433  const NTV2_RP188 tc(allTCs.at(tcIndex));
2434  if (!inValidOnly)
2435  outTimeCodes[tcIndex] = tc;
2436  else if (tc.IsValid())
2437  outTimeCodes[tcIndex] = tc;
2438  }
2439  return true;
2440 }
2441 
2442 
2443 bool FRAME_STAMP::GetSDIInputStatus(NTV2SDIInputStatus & outStatus, const UWord inSDIInputIndex0) const
2444 {
2446  (void)outStatus;
2447  (void)inSDIInputIndex0;
2448  return true;
2449 }
2450 
2451 bool FRAME_STAMP::SetInputTimecode (const NTV2TCIndex inTCNdx, const NTV2_RP188 & inTimecode)
2452 {
2453  ULWord numRP188s (acTimeCodes.GetByteCount() / sizeof(NTV2_RP188));
2454  NTV2_RP188 * pArray (reinterpret_cast<NTV2_RP188*>(acTimeCodes.GetHostPointer()));
2455  if (!pArray || !numRP188s)
2456  return false; // No 'acTimeCodes' array!
2457 
2458  if (numRP188s > NTV2_MAX_NUM_TIMECODE_INDEXES)
2459  numRP188s = NTV2_MAX_NUM_TIMECODE_INDEXES; // clamp to this max number
2460  if (ULWord(inTCNdx) >= numRP188s)
2461  return false; // Past end
2462 
2463  pArray[inTCNdx] = inTimecode; // Write the new value
2464  return true; // Success!
2465 }
2466 
2467 
2469 {
2470  if (this != &inRHS)
2471  {
2472  acTimeCodes = inRHS.acTimeCodes;
2473  acHeader = inRHS.acHeader;
2474  acFrameTime = inRHS.acFrameTime;
2483  acStartSample = inRHS.acStartSample;
2484  acCurrentTime = inRHS.acCurrentTime;
2492  acCurrentReps = inRHS.acCurrentReps;
2494  acFrame = inRHS.acFrame;
2495  acRP188 = inRHS.acRP188;
2496  acTrailer = inRHS.acTrailer;
2497  }
2498  return *this;
2499 }
2500 
2501 
2502 bool FRAME_STAMP::SetFrom (const FRAME_STAMP_STRUCT & inOldStruct)
2503 {
2505  //acCrosspoint = inOldStruct.channelSpec;
2506  acFrameTime = inOldStruct.frameTime;
2507  acRequestedFrame = inOldStruct.frame;
2514  acTotalBytesTransferred = inOldStruct.bytesRead;
2515  acStartSample = inOldStruct.startSample;
2516  acCurrentTime = inOldStruct.currentTime;
2517  acCurrentFrame = inOldStruct.currentFrame;
2518  acCurrentFrameTime = inOldStruct.currentFrameTime;
2522  acCurrentFieldCount = inOldStruct.currentFieldCount;
2523  acCurrentLineCount = inOldStruct.currentLineCount;
2524  acCurrentReps = inOldStruct.currentReps;
2525  acCurrentUserCookie = inOldStruct.currenthUser;
2526  acRP188 = NTV2_RP188 (inOldStruct.currentRP188);
2527  if (!acTimeCodes.IsNULL() && acTimeCodes.GetByteCount () >= sizeof (NTV2_RP188))
2528  {
2529  NTV2_RP188 * pTimecodes (reinterpret_cast <NTV2_RP188 *> (acTimeCodes.GetHostPointer ()));
2530  NTV2_ASSERT (pTimecodes);
2532  pTimecodes [NTV2_TCINDEX_DEFAULT] = acRP188;
2533  }
2534  return true;
2535 }
2536 
2537 
2538 bool FRAME_STAMP::CopyTo (FRAME_STAMP_STRUCT & outOldStruct) const
2539 {
2541  outOldStruct.frameTime = acFrameTime;
2542  outOldStruct.frame = acRequestedFrame;
2549  outOldStruct.bytesRead = acTotalBytesTransferred;
2550  outOldStruct.startSample = acStartSample;
2551  outOldStruct.currentTime = acCurrentTime;
2552  outOldStruct.currentFrame = acCurrentFrame;
2553  outOldStruct.currentFrameTime = acCurrentFrameTime;
2557  outOldStruct.currentFieldCount = acCurrentFieldCount;
2558  outOldStruct.currentLineCount = acCurrentLineCount;
2559  outOldStruct.currentReps = acCurrentReps;
2560  outOldStruct.currenthUser = ULWord(acCurrentUserCookie);
2561  outOldStruct.currentRP188 = acRP188;
2562  // Ticket 3367 -- Mark Gilbert of Gallery UK reports that after updating from AJA Retail Software 10.5 to 14.0,
2563  // their QuickTime app stopped receiving timecode during capture. Turns out the QuickTime components use the new
2564  // AutoCirculate APIs, but internally still use the old FRAME_STAMP_STRUCT for frame info, including timecode...
2565  // ...and only use the "currentRP188" field for the "retail" timecode.
2566  // Sadly, this FRAME_STAMP-to-FRAME_STAMP_STRUCT function historically only set "currentRP188" from the deprecated
2567  // (and completely unused) "acRP188" field, when it really should've been using the acTimeCodes[NTV2_TCINDEX_DEFAULT]
2568  // value all along...
2569  if (!acTimeCodes.IsNULL()) // If there's an acTimeCodes buffer...
2570  if (acTimeCodes.GetByteCount() >= sizeof(NTV2_RP188)) // ...and it has at least one timecode value...
2571  {
2572  const NTV2_RP188 * pDefaultTC (reinterpret_cast<const NTV2_RP188*>(acTimeCodes.GetHostPointer()));
2573  if (pDefaultTC)
2574  outOldStruct.currentRP188 = pDefaultTC[NTV2_TCINDEX_DEFAULT]; // Stuff the "default" (retail) timecode into "currentRP188".
2575  }
2576  return true;
2577 }
2578 
2579 
2580 string FRAME_STAMP::operator [] (const unsigned inIndexNum) const
2581 {
2582  ostringstream oss;
2583  NTV2_RP188 rp188;
2584  if (GetInputTimeCode (rp188, NTV2TimecodeIndex (inIndexNum)))
2585  {
2586  if (rp188.IsValid())
2587  {
2588  CRP188 foo (rp188);
2589  oss << foo;
2590  }
2591  else
2592  oss << "---";
2593  }
2594  else if (NTV2_IS_VALID_TIMECODE_INDEX (inIndexNum))
2595  oss << "---";
2596  return oss.str();
2597 }
2598 
2599 
2601  : mHeader(NTV2_TYPE_SDISTATS, sizeof(NTV2SDIInStatistics)),
2602  mInStatistics(NTV2_MAX_NUM_CHANNELS * sizeof(NTV2SDIInputStatus))
2603 {
2604  Clear();
2606 }
2607 
2609 {
2611  if (mInStatistics.IsNULL())
2612  return;
2613  NTV2SDIInputStatus * pArray(mInStatistics);
2614  const ULWord numElements(mInStatistics.GetByteCount() / sizeof(NTV2SDIInputStatus));
2615  for (ULWord i = 0; i < numElements; i++)
2616  pArray[i].Clear();
2617 }
2618 
2619 bool NTV2SDIInStatistics::GetSDIInputStatus(NTV2SDIInputStatus & outStatus, const UWord inSDIInputIndex0)
2620 {
2622  if (!mInStatistics)
2623  return false;
2624  const ULWord numElements(mInStatistics.GetByteCount() / sizeof(NTV2SDIInputStatus));
2625  const NTV2SDIInputStatus * pArray(mInStatistics);
2626  outStatus.Clear();
2627  if (numElements != 8)
2628  return false;
2629  if (inSDIInputIndex0 >= numElements)
2630  return false;
2631  outStatus = pArray[inSDIInputIndex0];
2632  return true;
2633 }
2634 
2636 {
2638  static NTV2SDIInputStatus dummy;
2639  if (!mInStatistics)
2640  return dummy;
2641  NTV2SDIInputStatus * pArray(mInStatistics);
2642  const ULWord numElements(mInStatistics.GetByteCount() / sizeof(NTV2SDIInputStatus));
2643  if (numElements != 8)
2644  return dummy;
2645  if (inSDIInputIndex0 >= numElements)
2646  return dummy;
2647  return pArray[inSDIInputIndex0];
2648 }
2649 
2650 std::ostream & NTV2SDIInStatistics::Print(std::ostream & inOutStream) const
2651 {
2653  inOutStream << mHeader << ", " << mInStatistics << ", " << mTrailer; return inOutStream;
2654 }
2655 
2656 
2659  acState (NTV2_AUTOCIRCULATE_DISABLED),
2660  acTransferFrame (0),
2661  acBufferLevel (0),
2662  acFramesProcessed (0),
2663  acFramesDropped (0),
2664  acFrameStamp (),
2665  acAudioTransferSize (0),
2666  acAudioStartSample (0),
2667  acAncTransferSize (0),
2668  acAncField2TransferSize (0)
2669  //acTrailer ()
2670 {
2672 }
2673 
2674 
2676  : acHeader (NTV2_TYPE_ACSTATUS, sizeof (AUTOCIRCULATE_STATUS)),
2677  acCrosspoint (inCrosspoint),
2678  acState (NTV2_AUTOCIRCULATE_DISABLED),
2679  acStartFrame (0),
2680  acEndFrame (0),
2681  acActiveFrame (0),
2682  acRDTSCStartTime (0),
2683  acAudioClockStartTime (0),
2684  acRDTSCCurrentTime (0),
2685  acAudioClockCurrentTime (0),
2686  acFramesProcessed (0),
2687  acFramesDropped (0),
2688  acBufferLevel (0),
2689  acOptionFlags (0),
2690  acAudioSystem (NTV2_AUDIOSYSTEM_INVALID)
2691 {
2693 }
2694 
2695 
2697 {
2699  outOldStruct.channelSpec = acCrosspoint;
2700  outOldStruct.state = acState;
2701  outOldStruct.startFrame = acStartFrame;
2702  outOldStruct.endFrame = acEndFrame;
2703  outOldStruct.activeFrame = acActiveFrame;
2704  outOldStruct.rdtscStartTime = acRDTSCStartTime;
2706  outOldStruct.rdtscCurrentTime = acRDTSCCurrentTime;
2708  outOldStruct.framesProcessed = acFramesProcessed;
2709  outOldStruct.framesDropped = acFramesDropped;
2710  outOldStruct.bufferLevel = acBufferLevel;
2712  outOldStruct.bWithRP188 = acOptionFlags & AUTOCIRCULATE_WITH_RP188 ? 1 : 0;
2713  outOldStruct.bFbfChange = acOptionFlags & AUTOCIRCULATE_WITH_FBFCHANGE ? 1 : 0;
2714  outOldStruct.bFboChange = acOptionFlags & AUTOCIRCULATE_WITH_FBOCHANGE ? 1 : 0;
2716  outOldStruct.bWithVidProc = acOptionFlags & AUTOCIRCULATE_WITH_VIDPROC ? 1 : 0;
2717  outOldStruct.bWithCustomAncData = acOptionFlags & AUTOCIRCULATE_WITH_ANC ? 1 : 0;
2718  return true;
2719 }
2720 
2721 
2723 {
2725  acCrosspoint = inOldStruct.channelSpec;
2726  acState = inOldStruct.state;
2727  acStartFrame = inOldStruct.startFrame;
2728  acEndFrame = inOldStruct.endFrame;
2729  acActiveFrame = inOldStruct.activeFrame;
2730  acRDTSCStartTime = inOldStruct.rdtscStartTime;
2732  acRDTSCCurrentTime = inOldStruct.rdtscCurrentTime;
2734  acFramesProcessed = inOldStruct.framesProcessed;
2735  acFramesDropped = inOldStruct.framesDropped;
2736  acBufferLevel = inOldStruct.bufferLevel;
2737  acAudioSystem = NTV2_AUDIOSYSTEM_INVALID; // NTV2_AUDIOSYSTEM_1;
2738  acOptionFlags = (inOldStruct.bWithRP188 ? AUTOCIRCULATE_WITH_RP188 : 0) |
2739  (inOldStruct.bFbfChange ? AUTOCIRCULATE_WITH_FBFCHANGE : 0) |
2740  (inOldStruct.bFboChange ? AUTOCIRCULATE_WITH_FBOCHANGE : 0) |
2742  (inOldStruct.bWithVidProc ? AUTOCIRCULATE_WITH_VIDPROC : 0) |
2743  (inOldStruct.bWithCustomAncData ? AUTOCIRCULATE_WITH_ANC : 0);
2744  return true;
2745 }
2746 
2747 
2749 {
2753  acStartFrame = 0;
2754  acEndFrame = 0;
2755  acActiveFrame = 0;
2756  acRDTSCStartTime = 0;
2758  acRDTSCCurrentTime = 0;
2760  acFramesProcessed = 0;
2761  acFramesDropped = 0;
2762  acBufferLevel = 0;
2763  acOptionFlags = 0;
2765 }
2766 
2767 
2769 {
2771 }
2772 
2773 
2774 struct ThousandsSeparator : std::numpunct <char>
2775 {
2776  virtual inline char do_thousands_sep() const {return ',';}
2777  virtual inline std::string do_grouping() const {return "\03";}
2778 };
2779 
2780 
2781 template <class T> string CommaStr (const T & inNum)
2782 {
2783  ostringstream oss;
2784  const locale loc (oss.getloc(), new ThousandsSeparator);
2785  oss.imbue (loc);
2786  oss << inNum;
2787  return oss.str();
2788 } // CommaStr
2789 
2790 
2791 string AUTOCIRCULATE_STATUS::operator [] (const unsigned inIndexNum) const
2792 {
2793  ostringstream oss;
2794  if (inIndexNum == 0)
2796  else if (!IsStopped())
2797  switch (inIndexNum)
2798  {
2799  case 1: oss << DEC(GetStartFrame()); break;
2800  case 2: oss << DEC(GetEndFrame()); break;
2801  case 3: oss << DEC(GetFrameCount()); break;
2802  case 4: oss << DEC(GetActiveFrame()); break;
2803  case 5: oss << xHEX0N(acRDTSCStartTime,16); break;
2804  case 6: oss << xHEX0N(acAudioClockStartTime,16); break;
2805  case 7: oss << DEC(acRDTSCCurrentTime); break;
2806  case 8: oss << DEC(acAudioClockCurrentTime); break;
2807  case 9: oss << CommaStr(GetProcessedFrameCount()); break;
2808  case 10: oss << CommaStr(GetDroppedFrameCount()); break;
2809  case 11: oss << DEC(GetBufferLevel()); break;
2810  case 12: oss << ::NTV2AudioSystemToString(acAudioSystem, true); break;
2811  case 13: oss << (WithRP188() ? "Yes" : "No"); break;
2812  case 14: oss << (WithLTC() ? "Yes" : "No"); break;
2813  case 15: oss << (WithFBFChange() ? "Yes" : "No"); break;
2814  case 16: oss << (WithFBOChange() ? "Yes" : "No"); break;
2815  case 17: oss << (WithColorCorrect() ? "Yes" : "No"); break;
2816  case 18: oss << (WithVidProc() ? "Yes" : "No"); break;
2817  case 19: oss << (WithCustomAnc() ? "Yes" : "No"); break;
2818  case 20: oss << (WithHDMIAuxData() ? "Yes" : "No"); break;
2819  case 21: oss << (IsFieldMode() ? "Yes" : "No"); break;
2820  default: break;
2821  }
2822  else if (inIndexNum < 22)
2823  oss << "---";
2824  return oss.str();
2825 }
2826 
2827 
2828 ostream & operator << (ostream & oss, const AUTOCIRCULATE_STATUS & inObj)
2829 {
2830  if (!inObj.IsStopped())
2831  oss << ::NTV2ChannelToString(inObj.GetChannel(), true) << ": "
2832  << (inObj.IsInput() ? "Input " : (inObj.IsOutput() ? "Output" : "*BAD* "))
2833  << setw(12) << ::NTV2AutoCirculateStateToString(inObj.acState) << " "
2834  << setw( 5) << inObj.GetStartFrame()
2835  << setw( 6) << inObj.GetEndFrame()
2836  << setw( 6) << inObj.GetActiveFrame()
2837  << setw( 8) << inObj.GetProcessedFrameCount()
2838  << setw( 8) << inObj.GetDroppedFrameCount()
2839  << setw( 7) << inObj.GetBufferLevel()
2840  << setw(10) << ::NTV2AudioSystemToString(inObj.acAudioSystem, true)
2841  << setw(10) << (inObj.WithRP188() ? "+RP188" : "-RP188")
2842  << setw(10) << (inObj.WithLTC() ? "+LTC" : "-LTC")
2843  << setw(10) << (inObj.WithFBFChange() ? "+FBFchg" : "-FBFchg")
2844  << setw(10) << (inObj.WithFBOChange() ? "+FBOchg" : "-FBOchg")
2845  << setw(10) << (inObj.WithColorCorrect() ? "+ColCor" : "-ColCor")
2846  << setw(10) << (inObj.WithVidProc() ? "+VidProc" : "-VidProc")
2847  << setw(10) << (inObj.WithCustomAnc() ? "+AncData" : "-AncData")
2848  << setw(10) << (inObj.WithHDMIAuxData() ? "+HDMIAux" : "-HDMIAux")
2849  << setw(10) << (inObj.IsFieldMode() ? "+FldMode" : "-FldMode");
2850  return oss;
2851 }
2852 
2853 
2855 {
2856  Reset ();
2857 }
2858 
2859 
2860 NTV2SegmentedDMAInfo::NTV2SegmentedDMAInfo (const ULWord inNumSegments, const ULWord inNumActiveBytesPerRow, const ULWord inHostBytesPerRow, const ULWord inDeviceBytesPerRow)
2861 {
2862  Set (inNumSegments, inNumActiveBytesPerRow, inHostBytesPerRow, inDeviceBytesPerRow);
2863 }
2864 
2865 
2866 void NTV2SegmentedDMAInfo::Set (const ULWord inNumSegments, const ULWord inNumActiveBytesPerRow, const ULWord inHostBytesPerRow, const ULWord inDeviceBytesPerRow)
2867 {
2868  acNumSegments = inNumSegments;
2869  if (acNumSegments > 1)
2870  {
2871  acNumActiveBytesPerRow = inNumActiveBytesPerRow;
2872  acSegmentHostPitch = inHostBytesPerRow;
2873  acSegmentDevicePitch = inDeviceBytesPerRow;
2874  }
2875  else
2876  Reset ();
2877 }
2878 
2879 
2881 {
2883 }
2884 
2885 
2887  : ccMode (NTV2_CCMODE_INVALID),
2888  ccSaturationValue (0)
2889 {
2890 }
2891 
2892 
2894 {
2895  Clear ();
2896 }
2897 
2898 
2900 {
2902  ccSaturationValue = 0;
2904 }
2905 
2906 
2907 bool NTV2ColorCorrectionData::Set (const NTV2ColorCorrectionMode inMode, const ULWord inSaturation, const void * pInTableData)
2908 {
2909  Clear();
2911  return false;
2912 
2913  if (pInTableData)
2915  return false;
2916  ccMode = inMode;
2917  ccSaturationValue = (inMode == NTV2_CCMODE_3WAY) ? inSaturation : 0;
2918  return true;
2919 }
2920 
2921 
2923  : acHeader (NTV2_TYPE_ACXFER, sizeof(AUTOCIRCULATE_TRANSFER)),
2924  acOutputTimeCodes (NTV2_MAX_NUM_TIMECODE_INDEXES * sizeof (NTV2_RP188)),
2925  acTransferStatus (),
2926  acInUserCookie (0),
2927  acInVideoDMAOffset (0),
2928  acInSegmentedDMAInfo (),
2929  acColorCorrection (),
2930  acFrameBufferFormat (NTV2_FBF_10BIT_YCBCR),
2931  acFrameBufferOrientation (NTV2_FRAMEBUFFER_ORIENTATION_TOPDOWN),
2932  acVidProcInfo (),
2933  acVideoQuarterSizeExpand (NTV2_QuarterSizeExpandOff),
2934  acPeerToPeerFlags (0),
2935  acFrameRepeatCount (1),
2936  acDesiredFrame (-1),
2937  acRP188 (),
2938  acCrosspoint (NTV2CROSSPOINT_INVALID)
2939 {
2943 }
2944 
2945 
2946 AUTOCIRCULATE_TRANSFER::AUTOCIRCULATE_TRANSFER (ULWord * pInVideoBuffer, const ULWord inVideoByteCount, ULWord * pInAudioBuffer,
2947  const ULWord inAudioByteCount, ULWord * pInANCBuffer, const ULWord inANCByteCount,
2948  ULWord * pInANCF2Buffer, const ULWord inANCF2ByteCount)
2949  : acHeader (NTV2_TYPE_ACXFER, sizeof(AUTOCIRCULATE_TRANSFER)),
2950  acVideoBuffer (pInVideoBuffer, inVideoByteCount),
2951  acAudioBuffer (pInAudioBuffer, inAudioByteCount),
2952  acANCBuffer (pInANCBuffer, inANCByteCount),
2953  acANCField2Buffer (pInANCF2Buffer, inANCF2ByteCount),
2954  acOutputTimeCodes (NTV2_MAX_NUM_TIMECODE_INDEXES * sizeof (NTV2_RP188)),
2955  acTransferStatus (),
2956  acInUserCookie (0),
2957  acInVideoDMAOffset (0),
2958  acInSegmentedDMAInfo (),
2959  acColorCorrection (),
2960  acFrameBufferFormat (NTV2_FBF_10BIT_YCBCR),
2961  acFrameBufferOrientation (NTV2_FRAMEBUFFER_ORIENTATION_TOPDOWN),
2962  acVidProcInfo (),
2963  acVideoQuarterSizeExpand (NTV2_QuarterSizeExpandOff),
2964  acPeerToPeerFlags (0),
2965  acFrameRepeatCount (1),
2966  acDesiredFrame (-1),
2967  acRP188 (),
2968  acCrosspoint (NTV2CROSSPOINT_INVALID)
2969 {
2973 }
2974 
2975 
2977 {
2978 }
2979 
2980 
2981 bool AUTOCIRCULATE_TRANSFER::SetBuffers (ULWord * pInVideoBuffer, const ULWord inVideoByteCount,
2982  ULWord * pInAudioBuffer, const ULWord inAudioByteCount,
2983  ULWord * pInANCBuffer, const ULWord inANCByteCount,
2984  ULWord * pInANCF2Buffer, const ULWord inANCF2ByteCount)
2985 {
2987  return SetVideoBuffer (pInVideoBuffer, inVideoByteCount)
2988  && SetAudioBuffer (pInAudioBuffer, inAudioByteCount)
2989  && SetAncBuffers (pInANCBuffer, inANCByteCount, pInANCF2Buffer, inANCF2ByteCount);
2990 }
2991 
2992 
2993 bool AUTOCIRCULATE_TRANSFER::SetVideoBuffer (ULWord * pInVideoBuffer, const ULWord inVideoByteCount)
2994 {
2996  acVideoBuffer.Set (pInVideoBuffer, inVideoByteCount);
2997  return true;
2998 }
2999 
3000 
3001 bool AUTOCIRCULATE_TRANSFER::SetAudioBuffer (ULWord * pInAudioBuffer, const ULWord inAudioByteCount)
3002 {
3004  acAudioBuffer.Set (pInAudioBuffer, inAudioByteCount);
3005  return true;
3006 }
3007 
3008 
3009 bool AUTOCIRCULATE_TRANSFER::SetAncBuffers (ULWord * pInANCBuffer, const ULWord inANCByteCount, ULWord * pInANCF2Buffer, const ULWord inANCF2ByteCount)
3010 {
3012  acANCBuffer.Set (pInANCBuffer, inANCByteCount);
3013  acANCField2Buffer.Set (pInANCF2Buffer, inANCF2ByteCount);
3014  return true;
3015 }
3016 
3018 
3019 
3021 {
3023  ULWord maxNumValues (acOutputTimeCodes.GetByteCount() / sizeof(NTV2_RP188));
3024  NTV2_RP188 * pArray (reinterpret_cast<NTV2_RP188*>(acOutputTimeCodes.GetHostPointer()));
3025  if (!pArray)
3026  return false;
3027  if (maxNumValues > NTV2_MAX_NUM_TIMECODE_INDEXES)
3028  maxNumValues = NTV2_MAX_NUM_TIMECODE_INDEXES;
3029 
3030  for (UWord ndx (0); ndx < UWord(maxNumValues); ndx++)
3031  {
3032  const NTV2TCIndex tcIndex (static_cast<NTV2TCIndex>(ndx));
3033  NTV2TimeCodesConstIter iter (inValues.find(tcIndex));
3034  pArray[ndx] = (iter != inValues.end()) ? iter->second : INVALID_TIMECODE_VALUE;
3035  } // for each possible NTV2TCSource value
3036  return true;
3037 }
3038 
3039 
3040 bool AUTOCIRCULATE_TRANSFER::SetOutputTimeCode (const NTV2_RP188 & inTimeCode, const NTV2TCIndex inTCIndex)
3041 {
3043  ULWord maxNumValues (acOutputTimeCodes.GetByteCount() / sizeof(NTV2_RP188));
3044  NTV2_RP188 * pArray (reinterpret_cast<NTV2_RP188*>(acOutputTimeCodes.GetHostPointer()));
3045  if (!pArray)
3046  return false;
3047  if (maxNumValues > NTV2_MAX_NUM_TIMECODE_INDEXES)
3048  maxNumValues = NTV2_MAX_NUM_TIMECODE_INDEXES;
3049  if (!NTV2_IS_VALID_TIMECODE_INDEX(inTCIndex))
3050  return false;
3051 
3052  pArray[inTCIndex] = inTimeCode;
3053  return true;
3054 }
3055 
3056 bool AUTOCIRCULATE_TRANSFER::SetAllOutputTimeCodes (const NTV2_RP188 & inTimeCode, const bool inIncludeF2)
3057 {
3059  ULWord maxNumValues (acOutputTimeCodes.GetByteCount() / sizeof(NTV2_RP188));
3060  NTV2_RP188 * pArray (reinterpret_cast<NTV2_RP188*>(acOutputTimeCodes.GetHostPointer()));
3061  if (!pArray)
3062  return false;
3063  if (maxNumValues > NTV2_MAX_NUM_TIMECODE_INDEXES)
3064  maxNumValues = NTV2_MAX_NUM_TIMECODE_INDEXES;
3065 
3066  for (ULWord tcIndex(0); tcIndex < maxNumValues; tcIndex++)
3067  if (NTV2_IS_ATC_VITC2_TIMECODE_INDEX(tcIndex))
3068  pArray[tcIndex] = inIncludeF2 ? inTimeCode : INVALID_TIMECODE_VALUE;
3069  else
3070  pArray[tcIndex] = inTimeCode;
3071  return true;
3072 }
3073 
3074 
3076 {
3078  if (!NTV2_IS_VALID_FRAME_BUFFER_FORMAT (inNewFormat))
3079  return false;
3080  acFrameBufferFormat = inNewFormat;
3081  return true;
3082 }
3083 
3084 
3086 {
3088  SetBuffers (AJA_NULL, 0, AJA_NULL, 0, AJA_NULL, 0, AJA_NULL, 0);
3089 }
3090 
3091 
3092 bool AUTOCIRCULATE_TRANSFER::EnableSegmentedDMAs (const ULWord inNumSegments, const ULWord inNumActiveBytesPerRow,
3093  const ULWord inHostBytesPerRow, const ULWord inDeviceBytesPerRow)
3094 {
3096  // Cannot allow segmented DMAs if video buffer was self-allocated by the SDK, since the video buffer size holds the segment size (in bytes)...
3098  return false; // Disallow
3099  acInSegmentedDMAInfo.Set (inNumSegments, inNumActiveBytesPerRow, inHostBytesPerRow, inDeviceBytesPerRow);
3100  return true;
3101 }
3102 
3103 
3105 {
3108  return true;
3109 }
3110 
3111 
3113 {
3116 }
3117 
3118 
3120 {
3122  return acTransferStatus.acFrameStamp.GetInputTimeCodes (outValues);
3123 }
3124 
3125 
3126 bool AUTOCIRCULATE_TRANSFER::GetInputTimeCode (NTV2_RP188 & outTimeCode, const NTV2TCIndex inTCIndex) const
3127 {
3129  return acTransferStatus.acFrameStamp.GetInputTimeCode (outTimeCode, inTCIndex);
3130 }
3131 
3132 
3133 bool AUTOCIRCULATE_TRANSFER::GetInputTimeCodes (NTV2TimeCodes & outTimeCodes, const NTV2Channel inSDIInput, const bool inValidOnly) const
3134 {
3136  return acTransferStatus.acFrameStamp.GetInputTimeCodes (outTimeCodes, inSDIInput, inValidOnly);
3137 }
3138 
3139 
3141  : mHeader (NTV2_TYPE_AJADEBUGLOGGING, sizeof (NTV2DebugLogging)),
3142  mSharedMemory (inEnable ? AJADebug::GetPrivateDataLoc() : AJA_NULL, inEnable ? AJADebug::GetPrivateDataLen() : 0)
3143 {
3144 }
3145 
3146 
3147 ostream & NTV2DebugLogging::Print (ostream & inOutStream) const
3148 {
3150  inOutStream << mHeader << " shMem=" << mSharedMemory << " " << mTrailer;
3151  return inOutStream;
3152 }
3153 
3154 
3155 
3157  : mHeader (NTV2_TYPE_AJABUFFERLOCK, sizeof(NTV2BufferLock))
3158 {
3160  SetFlags(0);
3161  SetMaxLockSize(0);
3162 }
3163 
3164 NTV2BufferLock::NTV2BufferLock (const NTV2Buffer & inBuffer, const ULWord inFlags)
3165  : mHeader (NTV2_TYPE_AJABUFFERLOCK, sizeof(NTV2BufferLock))
3166 {
3168  SetBuffer(inBuffer);
3169  SetFlags(inFlags);
3170  SetMaxLockSize(0);
3171 }
3172 
3173 NTV2BufferLock::NTV2BufferLock(const ULWord * pInBuffer, const ULWord inByteCount, const ULWord inFlags)
3174  : mHeader (NTV2_TYPE_AJABUFFERLOCK, sizeof(NTV2BufferLock))
3175 {
3177  SetBuffer (NTV2Buffer(pInBuffer, inByteCount));
3178  SetFlags (inFlags);
3179  SetMaxLockSize(0);
3180 }
3181 
3182 NTV2BufferLock::NTV2BufferLock(const ULWord64 inMaxLockSize, const ULWord inFlags)
3183  : mHeader (NTV2_TYPE_AJABUFFERLOCK, sizeof(NTV2BufferLock))
3184 {
3186  SetBuffer (NTV2Buffer());
3187  SetFlags (inFlags);
3188  SetMaxLockSize(inMaxLockSize);
3189 }
3190 
3191 bool NTV2BufferLock::SetBuffer (const NTV2Buffer & inBuffer)
3192 { // Just use address & length (don't deep copy)...
3194  return mBuffer.Set (inBuffer.GetHostPointer(), inBuffer.GetByteCount());
3195 }
3196 
3197 ostream & NTV2BufferLock::Print (ostream & inOutStream) const
3198 {
3200  inOutStream << mHeader << mBuffer << " flags=" << xHEX0N(mFlags,8) << " " << mTrailer;
3201  return inOutStream;
3202 }
3203 
3204 
3206  : mHeader (NTV2_TYPE_AJABITSTREAM, sizeof(NTV2Bitstream))
3207 {
3209 }
3210 
3211 NTV2Bitstream::NTV2Bitstream (const NTV2Buffer & inBuffer, const ULWord inFlags)
3212  : mHeader (NTV2_TYPE_AJABITSTREAM, sizeof(NTV2Bitstream))
3213 {
3215  SetBuffer(inBuffer);
3216  SetFlags(inFlags);
3217 }
3218 
3219 NTV2Bitstream::NTV2Bitstream(const ULWord * pInBuffer, const ULWord inByteCount, const ULWord inFlags)
3220  : mHeader (NTV2_TYPE_AJABITSTREAM, sizeof(NTV2Bitstream))
3221 {
3223  SetBuffer (NTV2Buffer(pInBuffer, inByteCount));
3224  SetFlags (inFlags);
3225 }
3226 
3227 bool NTV2Bitstream::SetBuffer (const NTV2Buffer & inBuffer)
3228 { // Just use address & length (don't deep copy)...
3230  return mBuffer.Set (inBuffer.GetHostPointer(), inBuffer.GetByteCount());
3231 }
3232 
3233 ostream & NTV2Bitstream::Print (ostream & inOutStream) const
3234 {
3236  inOutStream << mHeader << mBuffer << " flags=" << xHEX0N(mFlags,8) << " " << mTrailer;
3237  return inOutStream;
3238 }
3239 
3241  : mHeader (NTV2_TYPE_AJASTREAMCHANNEL, sizeof(NTV2StreamChannel))
3242 {
3244 }
3245 
3246 ostream & NTV2StreamChannel::Print (ostream & inOutStream) const
3247 {
3249  inOutStream << mHeader << mChannel << " flags=" << xHEX0N(mFlags,8) << xHEX0N(mStatus, 8) << " " << mTrailer;
3250  return inOutStream;
3251 }
3252 
3254  : mHeader (NTV2_TYPE_AJASTREAMBUFFER, sizeof(NTV2StreamBuffer))
3255 {
3257 }
3258 
3259 ostream & NTV2StreamBuffer::Print (ostream & inOutStream) const
3260 {
3262  inOutStream << mHeader << mChannel << " flags=" << xHEX0N(mFlags,8) << xHEX0N(mStatus, 8) << " " << mTrailer;
3263  return inOutStream;
3264 }
3265 
3267  : mHeader (NTV2_TYPE_AJAMAILBUFFER, sizeof(NTV2MailBuffer))
3268 {
3270 }
3271 
3272 ostream & NTV2MailBuffer::Print (ostream & inOutStream) const
3273 {
3275  inOutStream << mHeader << mChannel << " flags=" << xHEX0N(mFlags,8) << xHEX0N(mStatus, 8) << " " << mTrailer;
3276  return inOutStream;
3277 }
3278 
3280  : mHeader (NTV2_TYPE_GETREGS, sizeof(NTV2GetRegisters)),
3281  mInNumRegisters (ULWord (inRegisterNumbers.size ())),
3282  mOutNumRegisters (0)
3283 {
3285  ResetUsing (inRegisterNumbers);
3286 }
3287 
3288 
3290  : mHeader (NTV2_TYPE_GETREGS, sizeof(NTV2GetRegisters)),
3291  mInNumRegisters (ULWord (inRegReads.size ())),
3292  mOutNumRegisters (0)
3293 {
3295  ResetUsing (inRegReads);
3296 }
3297 
3298 
3299 bool NTV2GetRegisters::ResetUsing (const NTV2RegNumSet & inRegisterNumbers)
3300 {
3302  mInNumRegisters = ULWord(inRegisterNumbers.size());
3303  mOutNumRegisters = 0;
3304  bool result ( mInRegisters.Allocate(mInNumRegisters * sizeof(ULWord))
3305  && mOutGoodRegisters.Allocate(mInNumRegisters * sizeof(ULWord))
3306  && mOutValues.Allocate(mInNumRegisters * sizeof(ULWord)));
3307  if (!result)
3308  return false;
3309  mInRegisters.Fill(ULWord(0)); mOutGoodRegisters.Fill(ULWord(0)); mOutValues.Fill(ULWord(0));
3310 
3311  ULWord * pRegArray(mInRegisters);
3312  if (!pRegArray)
3313  return false;
3314 
3315  ULWord ndx(0);
3316  for (NTV2RegNumSetConstIter iter(inRegisterNumbers.begin()); iter != inRegisterNumbers.end(); ++iter)
3317  pRegArray[ndx++] = *iter;
3318  return (ndx * sizeof(ULWord)) == mInRegisters.GetByteCount();
3319 }
3320 
3322 {
3323  outRegNums.clear();
3324  if (!mInNumRegisters)
3325  return true; // None requested
3326  if (!mInRegisters)
3327  return false; // Empty/NULL reg num buffer
3328  if (mInRegisters.GetByteCount()/4 < mInNumRegisters)
3329  return false; // Sanity check failed: Reg num buffer too small
3330 
3331  const ULWord * pRegNums(mInRegisters);
3332  for (ULWord ndx(0); ndx < mInNumRegisters; ndx++)
3333  if (outRegNums.find(pRegNums[ndx]) == outRegNums.end())
3334  outRegNums.insert(pRegNums[ndx]);
3335  return true;
3336 }
3337 
3338 
3340 {
3342  outGoodRegNums.clear();
3343  if (!mOutGoodRegisters)
3344  return false; // Empty/NULL 'mOutGoodRegisters' array!
3345  if (!mOutNumRegisters)
3346  return false; // The driver says zero successfully read!
3347  if (mOutNumRegisters > mInNumRegisters)
3348  return false; // Sanity check failed: mOutNumRegisters must be less than or equal to mInNumRegisters!
3349 
3350  const ULWord * pRegArray (mOutGoodRegisters);
3351  for (ULWord ndx(0); ndx < mOutNumRegisters; ndx++)
3352  outGoodRegNums.insert(pRegArray[ndx]);
3353  return true;
3354 }
3355 
3357 {
3359  outBadRegNums.clear();
3360  NTV2RegNumSet reqRegNums, goodRegNums;
3361  if (!GetRequestedRegisterNumbers(reqRegNums))
3362  return false;
3363  if (!GetGoodRegisters(goodRegNums))
3364  return false;
3365  if (reqRegNums == goodRegNums)
3366  return true; // Requested reg nums identical to those that were read successfully
3367 
3368  // Subtract goodRegNums from reqRegNums...
3369  std::set_difference (reqRegNums.begin(), reqRegNums.end(),
3370  goodRegNums.begin(), goodRegNums.end(),
3371  std::inserter(outBadRegNums, outBadRegNums.begin()));
3372  return true;
3373 }
3374 
3375 bool NTV2GetRegisters::PatchRegister (const ULWord inRegNum, const ULWord inValue)
3376 {
3377  if (!mOutGoodRegisters)
3378  return false; // Empty/null 'mOutGoodRegisters' array!
3379  if (!mOutNumRegisters)
3380  return false; // Driver says zero successfully read!
3381  if (mOutNumRegisters > mInNumRegisters)
3382  return false; // Sanity check failed: mOutNumRegisters must be less than or equal to mInNumRegisters!
3383  if (!mOutValues)
3384  return false; // Empty/null 'mOutValues' array!
3385  if (mOutGoodRegisters.GetByteCount() != mOutValues.GetByteCount())
3386  return false; // Sanity check failed: These sizes should match
3387  const ULWord * pRegArray (mOutGoodRegisters);
3388  ULWord * pValArray (mOutValues);
3389  for (ULWord ndx(0); ndx < mOutNumRegisters; ndx++)
3390  if (pRegArray[ndx] == inRegNum)
3391  {
3392  pValArray[ndx] = inValue;
3393  return true;
3394  }
3395  return false; // Not found
3396 }
3397 
3398 
3400 {
3402  outValues.clear ();
3403  if (!mOutGoodRegisters)
3404  return false; // Empty/null 'mOutGoodRegisters' array!
3405  if (!mOutNumRegisters)
3406  return false; // Driver says zero successfully read!
3407  if (mOutNumRegisters > mInNumRegisters)
3408  return false; // Sanity check failed: mOutNumRegisters must be less than or equal to mInNumRegisters!
3409  if (!mOutValues)
3410  return false; // Empty/null 'mOutValues' array!
3411  if (mOutGoodRegisters.GetByteCount() != mOutValues.GetByteCount())
3412  return false; // Sanity check failed: These sizes should match
3413 
3414  const ULWord * pRegArray (mOutGoodRegisters);
3415  const ULWord * pValArray (mOutValues);
3416  for (ULWord ndx(0); ndx < mOutNumRegisters; ndx++)
3417  {
3418  outValues [pRegArray[ndx]] = pValArray[ndx];
3419 #if defined(NTV2_PRETEND_DEVICE)
3420  if (pRegArray[ndx] == kRegBoardID && pValArray[ndx] == NTV2_PRETEND_DEVICE_FROM)
3421  outValues [pRegArray[ndx]] = NTV2_PRETEND_DEVICE_TO;
3422 // else if (pRegArray[ndx] == kRegReserved83 || pRegArray[ndx] == kRegLPRJ45IP)
3423 // outValues [pRegArray[ndx]] = 0x0A03FAD9; // Local IPv4 10.3.250.217
3424 #endif // NTV2_PRETEND_DEVICE
3425  }
3426  return true;
3427 }
3428 
3429 
3431 {
3432  NTV2RegisterValueMap regValMap;
3433  if (!GetRegisterValues(regValMap))
3434  return false;
3435 
3436  if (outValues.empty())
3437  {
3438  for (NTV2RegValueMapConstIter it(regValMap.begin()); it != regValMap.end(); ++it)
3439  {
3440  NTV2RegInfo regInfo(/*regNum*/it->first, /*regVal*/it->second);
3441 #if defined(NTV2_PRETEND_DEVICE)
3442  if (regInfo.regNum() == kRegBoardID && regInfo.value() == NTV2_PRETEND_DEVICE_FROM)
3443  regInfo.setValue(NTV2_PRETEND_DEVICE_TO);
3444 // else if (regInfo.regNum() == kRegReserved83 || regInfo.regNum() == kRegLPRJ45IP)
3445 // regInfo.setValue(0x0A03FAD9); // Local IPv4 10.3.250.217
3446 #endif // NTV2_PRETEND_DEVICE
3447  outValues.push_back(regInfo);
3448  }
3449  return true;
3450  }
3451  else
3452  {
3453  uint32_t missingTally(0);
3454  for (NTV2RegisterReadsIter it (outValues.begin()); it != outValues.end(); ++it)
3455  {
3456  NTV2RegValueMapConstIter mapIter(regValMap.find(it->registerNumber));
3457  if (mapIter != regValMap.end())
3458  it->registerValue = mapIter->second;
3459  else
3460  missingTally++; // Missing register
3461 
3462 #if defined(NTV2_PRETEND_DEVICE) // Fake KONAIP25G from C4412G (see also CNTV2XXXXDriverInterface::ReadRegister):
3463  if (it->registerNumber == kRegBoardID && it->registerValue == NTV2_PRETEND_DEVICE_FROM)
3464  it->registerValue = NTV2_PRETEND_DEVICE_TO;
3465 // else if (it->registerNumber == kRegReserved83 || it->registerNumber == kRegLPRJ45IP)
3466 // it->registerValue = 0x0A03FAD9; // Local IPv4 10.3.250.217
3467 #endif // NTV2_PRETEND_DEVICE
3468  }
3469  return !missingTally;
3470  }
3471 }
3472 
3473 
3474 ostream & NTV2GetRegisters::Print (ostream & inOutStream) const
3475 {
3476  inOutStream << mHeader << ", numRegs=" << mInNumRegisters << ", inRegs=" << mInRegisters << ", outNumGoodRegs=" << mOutNumRegisters
3477  << ", outGoodRegs=" << mOutGoodRegisters << ", outValues=" << mOutValues << ", " << mTrailer;
3478  return inOutStream;
3479 }
3480 
3481 
3483  : mHeader (NTV2_TYPE_SETREGS, sizeof(NTV2SetRegisters)),
3484  mInNumRegisters (ULWord(inRegWrites.size())),
3485  mOutNumFailures (0)
3486 {
3487  ResetUsing(inRegWrites);
3488 }
3489 
3490 
3492 {
3494  mInNumRegisters = ULWord(inRegWrites.size());
3495  mOutNumFailures = 0;
3496  const bool result (mInRegInfos.Allocate (mInNumRegisters * sizeof(NTV2RegInfo))
3498  if (!result)
3499  return false;
3500 
3501  ULWord ndx (0);
3502  NTV2RegInfo * pRegInfoArray (mInRegInfos);
3503  UWord * pBadRegIndexes (mOutBadRegIndexes);
3504 
3505  for (NTV2RegisterWritesConstIter it(inRegWrites.begin()); it != inRegWrites.end(); ++it)
3506  {
3507  if (pBadRegIndexes)
3508  pBadRegIndexes[ndx] = 0;
3509  if (pRegInfoArray)
3510  pRegInfoArray[ndx++] = *it;
3511  }
3512  NTV2_ASSERT((ndx * sizeof(NTV2RegInfo)) == mInRegInfos.GetByteCount());
3513  NTV2_ASSERT((ndx * sizeof(UWord)) == mOutBadRegIndexes.GetByteCount());
3514  return result;
3515 }
3516 
3517 
3519 {
3521  outFailedRegWrites.clear();
3522  return true;
3523 }
3524 
3526 {
3527  outRegWrites.clear();
3528  if (!mInNumRegisters)
3529  return false;
3530  if (!mInRegInfos)
3531  return false;
3532 
3533  outRegWrites.reserve(size_t(mInNumRegisters));
3534  const NTV2RegInfo * pRegInfos(mInRegInfos);
3535  for (ULWord ndx(0); ndx < mInNumRegisters; ndx++)
3536  outRegWrites.push_back(pRegInfos[ndx]);
3537  return true;
3538 }
3539 
3540 ostream & NTV2SetRegisters::Print (ostream & oss) const
3541 {
3543  oss << mHeader << ": numRegs=" << mInNumRegisters << " inRegInfos=" << mInRegInfos << " numFailures=" << DEC(mOutNumFailures)
3544  << " outBadRegIndexes=" << mOutBadRegIndexes << ": " << mTrailer;
3545  const UWord * pBadRegIndexes (mOutBadRegIndexes);
3546  const UWord maxNumBadRegIndexes (UWord(mOutBadRegIndexes.GetByteCount() / sizeof(UWord)));
3547  const NTV2RegInfo * pRegInfoArray (mInRegInfos);
3548  const UWord maxNumRegInfos (UWord(mInRegInfos.GetByteCount() / sizeof(NTV2RegInfo)));
3549  if (pBadRegIndexes && maxNumBadRegIndexes && pRegInfoArray && maxNumRegInfos && mOutNumFailures)
3550  {
3551  oss << endl;
3552  for (UWord num(0); num < maxNumBadRegIndexes; num++)
3553  {
3554  const UWord badRegIndex (pBadRegIndexes[num]);
3555  if (badRegIndex < maxNumRegInfos)
3556  {
3557  const NTV2RegInfo & badRegInfo (pRegInfoArray[badRegIndex]);
3558  oss << "Failure " << num << ": " << badRegInfo << endl;
3559  }
3560  }
3561  }
3562  return oss;
3563 }
3564 
3565 
3566 bool NTV2RegInfo::operator < (const NTV2RegInfo & inRHS) const
3567 {
3568  typedef std::pair <ULWord, ULWord> ULWordPair;
3569  typedef std::pair <ULWordPair, ULWordPair> ULWordPairs;
3570  const ULWordPairs rhs (ULWordPair (inRHS.registerNumber, inRHS.registerValue), ULWordPair (inRHS.registerMask, inRHS.registerShift));
3571  const ULWordPairs mine(ULWordPair (registerNumber, registerValue), ULWordPair (registerMask, registerShift));
3572  return mine < rhs;
3573 }
3574 
3575 ostream & NTV2RegInfo::Print (ostream & oss, const bool inAsCode) const
3576 {
3577  if (inAsCode)
3578  return PrintCode(oss);
3580  oss << "[" << regName << "|" << DEC(registerNumber) << ": val=" << xHEX0N(registerValue,8);
3581  if (registerMask != 0xFFFFFFFF)
3582  oss << " msk=" << xHEX0N(registerMask,8);
3583  if (registerShift)
3584  oss << " shf=" << DEC(registerShift);
3585  return oss << "]";
3586 }
3587 
3588 ostream & NTV2RegInfo::PrintCode (ostream & oss, const int inRadix, const NTV2DeviceID inDeviceID, const string & sCard) const
3589 {
3591  const bool readOnly (CNTV2RegisterExpert::IsReadOnly(registerNumber));
3592  const bool badName (regName.find(' ') != string::npos);
3593  if (readOnly)
3594  oss << "//\t";
3595  oss << sCard << ".WriteRegister (";
3596  if (badName)
3597  oss << DEC(registerNumber);
3598  else
3599  oss << regName;
3600  switch (inRadix)
3601  {
3602  case 2: oss << ", " << BIN032(registerValue); break;
3603  case 8: oss << ", " << OCT(registerValue); break;
3604  case 10: oss << ", " << DEC(registerValue); break;
3605  default: oss << ", " << xHEX0N(registerValue,8); break;
3606  }
3607  if (registerMask != 0xFFFFFFFF)
3608  switch (inRadix)
3609  {
3610  case 2: oss << ", " << BIN032(registerMask); break;
3611  case 8: oss << ", " << OCT(registerMask); break;
3612  case 10: oss << ", " << DEC(registerMask); break;
3613  default: oss << ", " << xHEX0N(registerMask,8); break;
3614  }
3615  if (registerShift)
3616  oss << ", " << DEC(registerShift);
3617  oss << "); // ";
3618  if (badName)
3619  oss << regName;
3620  else
3621  oss << "Reg " << DEC(registerNumber);
3622  // Decode the reg value...
3624  if (!info.empty()) // and add to end of comment
3625  oss << " // " << aja::replace(info, "\n", ", ");
3626  return oss;
3627 }
3628 
3629 ostream & NTV2RegInfo::PrintLog (ostream & oss, const NTV2DeviceID inDeviceID) const
3630 {
3631  const string name ((regNum() < VIRTUALREG_START) || (regNum() > kVRegLast) ? "Register" : "VReg");
3632  oss << name << " Name: " << CNTV2RegisterExpert::GetDisplayName(regNum()) << endl
3633  << name << " Number: " << regNum() << endl
3634  << name << " Value: " << value() << " : " << xHEX0N(value(),8);
3635  //<< "Register Classes: " << CNTV2RegisterExpert::GetRegisterClasses(regNum()) << endl
3636  const string sVal(CNTV2RegisterExpert::GetDisplayValue (regNum(), value(), inDeviceID));
3637 // if (!sVal.empty()) // stay compatible with older supportlogs
3638  oss << endl
3639  << sVal << endl;
3640  return oss;
3641 }
3642 
3644 {
3645  ULWord received(0), rcvdRegNum(0), rcvdRegVal(0); // what was received
3646  static const string sNumber (" Number: "), sValue (" Value: "), sHexPrefix(" : 0x");
3647  for (size_t ndx(0); ndx < inLogLines.size(); ndx++)
3648  {
3649  string line (inLogLines.at(ndx));
3650  size_t posNumber (line.find(sNumber));
3651  if (posNumber != string::npos)
3652  { // e.g. "VReg Number: 10394" pos=4, then 4+9=13
3653  if (received & 0x0001)
3654  continue; // uh-oh, already received "Number:"
3655  line.erase(0, posNumber + sNumber.length()); // only decimal number should remain
3656  if (!aja::is_legal_decimal_number (line, line.length()))
3657  continue; // missing decimal register number, keep looking
3658  rcvdRegNum = aja::stoull(line); // Read the reg number
3659  received |= 0x00000001; // received register number
3660  continue;
3661  } // if " Number: " found
3662  size_t posValue(inLogLines.at(ndx).find(sValue));
3663  if (posValue != string::npos)
3664  { // e.g. "VReg Value: 13966 : 0x0000368E"
3665  if (received & 0x0002)
3666  continue; // uh-oh, already received "Value:"
3667  posValue += sValue.length();
3668  line.erase(0, posValue + sValue.length()); // remainder: "13966 : 0x0000368E"
3669  aja::strip(line); aja::lower(line); // strip any remaining whitespace, then force lower case
3670  // Check for non-hex digits...
3671  size_t numHexDigits(0);
3672  for (size_t ndx(0); ndx < line.size(); ndx++)
3673  if (aja::is_hex_digit(line.at(ndx)))
3674  numHexDigits++;
3675  if (numHexDigits != line.length())
3676  continue; // mismatch indicates bad hex digit(s), keep looking
3677  // Read the value...
3678  istringstream iss(line);
3679  iss >> std::hex >> rcvdRegVal;
3680  received |= 0x0002; // received register value
3681  continue;
3682  } // if " Value: " found
3683  } // for each line
3684  if (received == 3)
3685  setRegNum(rcvdRegNum).setValue(rcvdRegVal).setMask(0xFFFFFFFF).setShift(0);
3686  return received == 3; // success if we got both " Number: " and " Value: "
3687 } // ImportFromLog
3688 
3689 
3690 ostream & NTV2PrintULWordVector (const NTV2ULWordVector & inObj, ostream & inOutStream)
3691 {
3692  for (NTV2ULWordVector::const_iterator it(inObj.begin()); it != inObj.end(); ++it)
3693  inOutStream << " " << HEX0N(*it,8);
3694  return inOutStream;
3695 }
3696 
3697 
3698 ostream & NTV2PrintChannelList (const NTV2ChannelList & inObj, const bool inCompact, ostream & inOutStream)
3699 {
3700  inOutStream << (inCompact ? "Ch[" : "[");
3701  for (NTV2ChannelListConstIter it(inObj.begin()); it != inObj.end(); )
3702  {
3703  if (inCompact)
3704  inOutStream << DEC(*it+1);
3705  else
3706  inOutStream << ::NTV2ChannelToString(*it);
3707  if (++it != inObj.end())
3708  inOutStream << (inCompact ? "|" : ",");
3709  }
3710  return inOutStream << "]";
3711 }
3712 
3713 string NTV2ChannelListToStr (const NTV2ChannelList & inObj, const bool inCompact)
3714 { ostringstream oss;
3715  ::NTV2PrintChannelList (inObj, inCompact, oss);
3716  return oss.str();
3717 }
3718 
3719 ostream & NTV2PrintChannelSet (const NTV2ChannelSet & inObj, const bool inCompact, ostream & inOutStream)
3720 {
3721  inOutStream << (inCompact ? "Ch{" : "{");
3722  for (NTV2ChannelSetConstIter it(inObj.begin()); it != inObj.end(); )
3723  {
3724  if (inCompact)
3725  inOutStream << DEC(*it+1);
3726  else
3727  inOutStream << ::NTV2ChannelToString(*it);
3728  if (++it != inObj.end())
3729  inOutStream << (inCompact ? "|" : ",");
3730  }
3731  return inOutStream << "}";
3732 }
3733 
3734 string NTV2ChannelSetToStr (const NTV2ChannelSet & inObj, const bool inCompact)
3735 { ostringstream oss;
3736  ::NTV2PrintChannelSet (inObj, inCompact, oss);
3737  return oss.str();
3738 }
3739 
3740 NTV2ChannelSet NTV2MakeChannelSet (const NTV2Channel inFirstChannel, const UWord inNumChannels)
3741 {
3742  NTV2ChannelSet result;
3743  for (UWord ch(inFirstChannel); ch < UWord(inFirstChannel+inNumChannels) && ch < NTV2_MAX_NUM_CHANNELS; ch++)
3744  if (NTV2_IS_VALID_CHANNEL(ch))
3745  result.insert(NTV2Channel(ch));
3746  return result;
3747 }
3748 
3750 {
3751  NTV2ChannelSet result;
3752  for (NTV2ChannelListConstIter it(inChannels.begin()); it != inChannels.end(); ++it)
3753  result.insert(*it);
3754  return result;
3755 }
3756 
3757 NTV2ChannelList NTV2MakeChannelList (const NTV2Channel inFirstChannel, const UWord inNumChannels)
3758 {
3759  NTV2ChannelList result;
3760  for (UWord ch(inFirstChannel); ch < (inFirstChannel+inNumChannels) && ch < NTV2_MAX_NUM_CHANNELS; ch++)
3761  if (NTV2_IS_VALID_CHANNEL(ch))
3762  result.push_back(NTV2Channel(ch));
3763  return result;
3764 }
3765 
3767 {
3768  NTV2ChannelList result;
3769  for (NTV2ChannelSetConstIter it(inChannels.begin()); it != inChannels.end(); ++it)
3770  result.push_back(*it);
3771  return result;
3772 }
3773 
3774 ostream & NTV2PrintAudioSystemSet (const NTV2AudioSystemSet & inObj, const bool inCompact, std::ostream & inOutStream)
3775 {
3776  inOutStream << (inCompact ? "AudSys{" : "{");
3777  for (NTV2AudioSystemSetConstIter it(inObj.begin()); it != inObj.end(); )
3778  {
3779  if (inCompact)
3780  inOutStream << DEC(*it+1);
3781  else
3782  inOutStream << ::NTV2AudioSystemToString(*it);
3783  if (++it != inObj.end())
3784  inOutStream << (inCompact ? "|" : ",");
3785  }
3786  return inOutStream << "}";
3787 }
3788 
3789 string NTV2AudioSystemSetToStr (const NTV2AudioSystemSet & inObj, const bool inCompact)
3790 { ostringstream oss;
3791  ::NTV2PrintAudioSystemSet (inObj, inCompact, oss);
3792  return oss.str();
3793 }
3794 
3795 NTV2AudioSystemSet NTV2MakeAudioSystemSet (const NTV2AudioSystem inFirstAudioSystem, const UWord inCount)
3796 {
3797  NTV2AudioSystemSet result;
3798  for (NTV2AudioSystem audSys(inFirstAudioSystem); audSys < NTV2AudioSystem(inFirstAudioSystem+inCount); audSys = NTV2AudioSystem(audSys+1))
3799  if (NTV2_IS_VALID_AUDIO_SYSTEM(audSys))
3800  result.insert(audSys);
3801  return result;
3802 }
3803 
3805 {
3806  NTV2RegNumSet result;
3807  for (NTV2RegisterReadsConstIter it(inRegInfos.begin()); it != inRegInfos.end(); ++it)
3808  if (result.find(it->registerNumber) == result.end())
3809  result.insert(it->registerNumber);
3810  return result;
3811 }
3812 
3814 {
3815  for (NTV2RegisterReadsConstIter iter(inRegInfos.begin()); iter != inRegInfos.end(); ++iter) // Ugh -- linear search
3816  if (iter->registerNumber == inRegNum)
3817  return iter;
3818  return inRegInfos.end();
3819 }
3820 
3821 
3822 ostream & operator << (std::ostream & inOutStream, const NTV2RegInfo & inObj)
3823 {
3824  return inObj.Print(inOutStream);
3825 }
3826 
3827 
3828 ostream & operator << (ostream & inOutStream, const NTV2RegisterWrites & inObj)
3829 {
3830  inOutStream << inObj.size () << " regs:" << endl;
3831  for (NTV2RegisterWritesConstIter iter (inObj.begin ()); iter != inObj.end (); ++iter)
3832  inOutStream << *iter << endl;
3833  return inOutStream;
3834 }
3835 
3836 
3837 NTV2BankSelGetSetRegs::NTV2BankSelGetSetRegs (const NTV2RegInfo & inBankSelect, const NTV2RegInfo & inOutRegInfo, const bool inDoWrite)
3838  : mHeader (NTV2_TYPE_BANKGETSET, sizeof (NTV2BankSelGetSetRegs)),
3839  mIsWriting (inDoWrite), // Default to reading
3840  mInBankInfos (sizeof(NTV2RegInfo)), // Room for one bank select
3841  mInRegInfos (sizeof(NTV2RegInfo)) // Room for one register read or write
3842 {
3843  NTV2RegInfo * pRegInfo (mInBankInfos);
3844  if (pRegInfo)
3845  *pRegInfo = inBankSelect; // Store bank select regInfo
3846  pRegInfo = mInRegInfos;
3847  if (pRegInfo)
3848  *pRegInfo = inOutRegInfo; // Store regInfo
3850 }
3851 
3852 
3854 {
3856  NTV2RegInfo result;
3857  if (mInRegInfos)
3858  {
3859  const NTV2RegInfo * pRegInfos (mInRegInfos);
3860  const ULWord maxNum (mInRegInfos.GetByteCount() / ULWord(sizeof(NTV2RegInfo)));
3861  if (ULWord(inIndex0) < maxNum)
3862  result = pRegInfos[inIndex0];
3863  }
3864  return result;
3865 }
3866 
3867 
3868 ostream & NTV2BankSelGetSetRegs::Print (ostream & oss) const
3869 {
3871  const NTV2RegInfo * pBankRegInfo (mInBankInfos);
3872  const NTV2RegInfo * pRegInfo (mInRegInfos);
3873  oss << mHeader << (mIsWriting ? " WRIT" : " READ") << " bankReg=";
3874  if (mInBankInfos) oss << *pBankRegInfo; else oss << "-";
3875  oss << " regInfos=";
3876  if (mInRegInfos) oss << *pRegInfo; else oss << "-";
3877  return oss;
3878 }
3879 
3880 
3882 {
3883  static NTV2StringList sOpStrs = {"(invalid)", /*1*/"Subscribe", /*2*/"Unsubscribe", /*3*/"Enable", /*4*/"Disable",
3884  /*5*/"GetSubscribed", /*6*/"GetEnabledIDs", /*7*/"GetIntCount", /*8*/"SetIntCount"};
3885  return op < sOpStrs.size() ? sOpStrs.at(op) : aja::to_string(op);
3886 }
3887 
3889 {
3890  if (id >= eNumInterruptTypes)
3891  return string();
3892  const char * pName (::NTV2InterruptEnumString(unsigned(id)));
3893  if (!pName)
3894  return aja::to_string(ULWord(id));
3895  return string(pName);
3896 }
3897 
3899 {
3900  NTV2StringList strs;
3901  for (ULWord id(0); id < eNumInterruptTypes; id++)
3902  if (mask & uint64_t(1ULL << id))
3903  strs.push_back(IntName(INTERRUPT_ENUMS(id)));
3904  return strs;
3905 }
3906 
3908  : mHeader (NTV2_TYPE_CONFIGINTERRUPT, sizeof(NTV2ConfigInterrupt)),
3909  mOperation (kOpINVALID),
3910  mFlags (0),
3911  mInterruptID (eNumInterruptTypes),
3912  mResult (0),
3913  mInterruptIDs (0),
3914  mEventHandle (0),
3915  mClientID (uint64_t(pClient)),
3916  mClientPID (0),
3917  mClientTID (0),
3918  mCount (0),
3919  mHandles (nullptr,0)
3920 {
3921  ::memset(mSpares, 0, sizeof(mSpares));
3923 }
3924 
3925 ostream & NTV2ConfigInterrupt::print (ostream & oss) const
3926 {
3927  oss << mHeader;
3928  if (isValid())
3929  {
3930  oss << " op=" << OpName(operation());
3931  oss << " id=" << IntName(interruptID());
3932  if (flags())
3933  oss << " flgs=" << xHEX0N(mFlags,8);
3934  if (clientID())
3935  oss << " " << HEX(clientID());
3936  if (clientPID())
3937  oss << " pid=" << HEX(clientPID());
3938  if (clientTID())
3939  oss << " tid=" << HEX(clientTID());
3940  oss << " res=" << DEC(mResult);
3941  if (interruptIDs())
3942  oss << " ids=" << aja::join(IntNames(interruptIDs()),",");
3943  if (count())
3944  oss << " num=" << DEC(count());
3945  if (mHandles)
3946  oss << " +" << maxHandleCapacity() << " hdls (max)";
3947  }
3948  oss << mTrailer;
3949  return oss;
3950 }
3951 
3953 {
3954  mOperation = op;
3957  return *this;
3958 }
3959 
3960 ostream & operator << (ostream & oss, const NTV2ConfigInterrupt & msg)
3961 {
3962  return msg.print(oss);
3963 }
3964 
3965 
3966 NTV2VirtualData::NTV2VirtualData (const ULWord inTag, const void* inVirtualData, const size_t inVirtualDataSize, const bool inDoWrite)
3967  : mHeader (NTV2_TYPE_VIRTUAL_DATA_RW, sizeof (NTV2VirtualData)),
3968  mTag (inTag), // setup tag
3969  mIsWriting (inDoWrite), // setup write/read
3970  mVirtualData (inVirtualData, inVirtualDataSize) // setup virtual data
3971 {
3973 }
3974 
3975 
3976 ostream & NTV2VirtualData::Print (ostream & inOutStream) const
3977 {
3979  inOutStream << mHeader << ", mTag=" << mTag << ", mIsWriting=" << mIsWriting;
3980  return inOutStream;
3981 }
3982 
3983 NTV2MessageData::NTV2MessageData (const void* inMessage, const size_t inMessageSize, const ULWord inFlags)
3984  : mHeader (NTV2_TYPE_MESSAGE_DATA, sizeof (NTV2MessageData)),
3985  mMessage (inMessage, inMessageSize),
3986  mFlags (inFlags),
3987  mStatus (0)
3988 {
3990 }
3991 
3992 
3993 ostream & NTV2MessageData::Print (ostream & inOutStream) const
3994 {
3996  inOutStream << mHeader;
3997  return inOutStream;
3998 }
3999 
4000 using namespace ntv2nub;
4001 
4002  /*********************************************************************************************************************
4003  RPC ENCODE/DECODE FUNCTIONS
4004  Each class/struct type that can be marshalled to go over-the-wire must have an RPCEncode and RPCDecode member function.
4005  For convenience, these Encode/Decode implementations have been consolidated together in this section.
4006 
4007  RPCEncode FUNCTION -- Calls PUSHU8, PUSHU16, PUSHU32, or PUSHU64 to add 8/16/32/64-bit data members to the RPCBlob.
4008 
4009  bool class::RPCEncode (RPCBlob & outBlob)
4010  Pushes each data member of the class or struct byte-by-byte onto the end of the provided byte sequence.
4011  outBlob A non-const reference to the byte sequence to be appended onto.
4012  Returns true if successful; otherwise false.
4013 
4014  RPCDecode FUNCTION -- Calls POPU8, POPU16, POPU32, or POPU64 to pull 8/16/32/64-bit data members out of the RPCBlob.
4015 
4016  bool class::RPCDecode (const RPCBlob & inBlob, size_t & inOutIndex)
4017  Pops each data member of the class or struct byte-by-byte from the provided byte sequence.
4018  inBlob The source byte sequence.
4019  inOutIndex A non-const reference to the zero-based byte index (offset) into the byte sequence.
4020  At entry: points to the first byte of the next field to be popped from the sequence.
4021  At exit: points to the byte that immediately follows the last field popped from the sequence.
4022  Returns true if successful; otherwise false.
4023  *********************************************************************************************************************/
4024  #define AsU8Ref(_x_) reinterpret_cast<uint8_t&>(_x_)
4025  #define AsU16Ref(_x_) reinterpret_cast<uint16_t&>(_x_)
4026  #define AsU32Ref(_x_) reinterpret_cast<uint32_t&>(_x_)
4027  #define AsU64Ref(_x_) reinterpret_cast<uint64_t&>(_x_)
4028 
4030  {
4031  PUSHU32(fHeaderTag, outBlob); // ULWord fHeaderTag
4032  PUSHU32(fType, outBlob); // ULWord fType
4033  PUSHU32(fHeaderVersion, outBlob); // ULWord fHeaderVersion
4034  PUSHU32(fVersion, outBlob); // ULWord fVersion
4035  PUSHU32(fSizeInBytes, outBlob); // ULWord fSizeInBytes
4036  PUSHU32(fPointerSize, outBlob); // ULWord fPointerSize
4037  PUSHU32(fOperation, outBlob); // ULWord fOperation
4038  PUSHU32(fResultStatus, outBlob); // ULWord fResultStatus
4039  return true;
4040  }
4041 
4042  bool NTV2_HEADER::RPCDecode (const RPCBlob & inBlob, size_t & inOutIndex)
4043  { uint32_t v32(0);
4044  POPU32(fHeaderTag, inBlob, inOutIndex); // ULWord fHeaderTag
4045  POPU32(fType, inBlob, inOutIndex); // ULWord fType
4046  POPU32(fHeaderVersion, inBlob, inOutIndex); // ULWord fHeaderVersion
4047  POPU32(fVersion, inBlob, inOutIndex); // ULWord fVersion
4048  // Do not decode fSizeInBytes, use native size because size can vary based on OS specific struct padding
4049  POPU32(v32, inBlob, inOutIndex); // ULWord fSizeInBytes - dummy read
4050  POPU32(fPointerSize, inBlob, inOutIndex); // ULWord fPointerSize
4051  POPU32(fOperation, inBlob, inOutIndex); // ULWord fOperation
4052  POPU32(fResultStatus, inBlob, inOutIndex); // ULWord fResultStatus
4053  return true;
4054  }
4055 
4057  {
4058  PUSHU32(fTrailerVersion, outBlob); // ULWord fTrailerVersion
4059  PUSHU32(fTrailerTag, outBlob); // ULWord fTrailerTag
4060  return true;
4061  }
4062 
4063  bool NTV2_TRAILER::RPCDecode (const RPCBlob & inBlob, size_t & inOutIndex)
4064  {
4065  POPU32(fTrailerVersion, inBlob, inOutIndex); // ULWord fTrailerVersion
4066  POPU32(fTrailerTag, inBlob, inOutIndex); // ULWord fTrailerTag
4067  return true;
4068  }
4069 
4070 
4071  bool NTV2Buffer::RPCEncode (RPCBlob & outBlob, bool fillBuffer)
4072  {
4073  PUSHU32(fByteCount, outBlob); // ULWord fByteCount
4074  PUSHU32(fFlags, outBlob); // ULWord fFlags
4075  if (!IsNULL() && fillBuffer)
4076  AppendU8s(outBlob); // NOTE: My buffer content should already have been made BigEndian, if necessary
4077  return true;
4078  }
4079 
4080  bool NTV2Buffer::RPCDecode (const RPCBlob & inBlob, size_t & inOutIndex, bool fillBuffer)
4081  {
4082  ULWord byteCount(0), flags(0);
4083  POPU32(byteCount, inBlob, inOutIndex); // ULWord fByteCount
4084  POPU32(flags, inBlob, inOutIndex); // ULWord fFlags
4085  if (!Allocate(byteCount, flags & NTV2Buffer_PAGE_ALIGNED))
4086  return false;
4087  if (fillBuffer)
4088  {
4089  if ((inOutIndex + byteCount) > inBlob.size())
4090  return false; // past end of inBlob
4091  ::memcpy(GetHostPointer(), inBlob.data() + inOutIndex, byteCount); // Caller is responsible for byte-swapping if needed
4092  inOutIndex += byteCount;
4093  }
4094  return true;
4095  }
4096 
4097  // Created for DMATransfer, removed Allocate().
4098  bool NTV2Buffer::RPCDecodeNoAllocate (const RPCBlob & inBlob, size_t & inOutIndex)
4099  {
4100  ULWord byteCount(0), flags(0);
4101  POPU32(byteCount, inBlob, inOutIndex); // ULWord fByteCount
4102  POPU32(flags, inBlob, inOutIndex); // ULWord fFlags
4103  if ((inOutIndex + byteCount) > inBlob.size())
4104  return false; // past end of inBlob
4105 
4106  ::memcpy(GetHostPointer(), inBlob.data() + inOutIndex, byteCount); // Caller is responsible for byte-swapping if needed
4107  inOutIndex += byteCount;
4108  return true;
4109  }
4110 
4112  {
4113  const size_t totBytes (mHeader.GetSizeInBytes() // Header + natural size of all structs/fields inbetween + Trailer
4114  + mInRegisters.GetByteCount() + mOutGoodRegisters.GetByteCount() + mOutValues.GetByteCount()); // NTV2Buffer fields
4115  if (outBlob.capacity() < totBytes)
4116  outBlob.reserve(totBytes);
4117  if (!NTV2HostIsBigEndian)
4118  { // All of my NTV2Buffers store arrays of ULWords that must be BigEndian BEFORE encoding into outBlob...
4119  mInRegisters.ByteSwap32();
4120  }
4121  bool ok = mHeader.RPCEncode(outBlob); // NTV2_HEADER mHeader
4122  PUSHU32(mInNumRegisters, outBlob); // ULWord mInNumRegisters
4123  ok &= mInRegisters.RPCEncode(outBlob, /*fillbuffer=*/true); // NTV2Buffer mInRegisters
4124  PUSHU32(mOutNumRegisters, outBlob); // ULWord mOutNumRegisters
4125  ok &= mOutGoodRegisters.RPCEncode(outBlob, /*fillbuffer=*/false) // NTV2Buffer mOutGoodRegisters
4126  && mOutValues.RPCEncode(outBlob, /*fillbuffer=*/false) // NTV2Buffer mOutValues
4127  && mTrailer.RPCEncode(outBlob); // NTV2_TRAILER mTrailer
4128  if (!NTV2HostIsBigEndian && !ok)
4129  { // FAILED: Un-byteswap NTV2Buffer data...
4130  mInRegisters.ByteSwap32();
4131  }
4132  return ok;
4133  }
4134 
4135  bool NTV2GetRegisters::RPCDecodeServer (const RPCBlob & inBlob, size_t & inOutIndex)
4136  {
4137  bool ok = mHeader.RPCDecode(inBlob, inOutIndex); // NTV2_HEADER mHeader
4138  if (!ok) return false;
4139  POPU32(mInNumRegisters, inBlob, inOutIndex); // ULWord mInNumRegisters
4140  ok &= mInRegisters.RPCDecode(inBlob, inOutIndex, /*fillbuffer=*/true); // NTV2Buffer mInRegisters
4141  POPU32(mOutNumRegisters, inBlob, inOutIndex); // ULWord mOutNumRegisters
4142  ok &= mOutGoodRegisters.RPCDecode(inBlob, inOutIndex, /*fillbuffer=*/false); // NTV2Buffer mOutGoodRegisters
4143  ok &= mOutValues.RPCDecode(inBlob, inOutIndex, /*fillbuffer=*/false); // NTV2Buffer mOutValues
4144  ok &= mTrailer.RPCDecode(inBlob, inOutIndex); // NTV2_TRAILER mTrailer
4145  if (!NTV2HostIsBigEndian)
4146  { // Re-byteswap NTV2Buffer data after decoding...
4147  mInRegisters.ByteSwap32();
4148  }
4149  return ok;
4150  }
4151 
4153  {
4154  const size_t totBytes (mHeader.GetSizeInBytes() // Header + natural size of all structs/fields inbetween + Trailer
4155  + mInRegisters.GetByteCount() + mOutGoodRegisters.GetByteCount() + mOutValues.GetByteCount()); // NTV2Buffer fields
4156  if (outBlob.capacity() < totBytes)
4157  outBlob.reserve(totBytes);
4158  if (!NTV2HostIsBigEndian)
4159  { // All of my NTV2Buffers store arrays of ULWords that must be BigEndian BEFORE encoding into outBlob...
4160  mOutGoodRegisters.ByteSwap32();
4161  mOutValues.ByteSwap32();
4162  }
4163  bool ok = mHeader.RPCEncode(outBlob); // NTV2_HEADER mHeader
4164  PUSHU32(mInNumRegisters, outBlob); // ULWord mInNumRegisters
4165  ok &= mInRegisters.RPCEncode(outBlob, /*fillbuffer=*/false); // NTV2Buffer mInRegisters
4166  PUSHU32(mOutNumRegisters, outBlob); // ULWord mOutNumRegisters
4167  ok &= mOutGoodRegisters.RPCEncode(outBlob, /*fillbuffer=*/true) // NTV2Buffer mOutGoodRegisters
4168  && mOutValues.RPCEncode(outBlob, /*fillbuffer=*/true) // NTV2Buffer mOutValues
4169  && mTrailer.RPCEncode(outBlob); // NTV2_TRAILER mTrailer
4170  if (!NTV2HostIsBigEndian && !ok)
4171  { // FAILED: Un-byteswap NTV2Buffer data...
4172  mOutGoodRegisters.ByteSwap32();
4173  mOutValues.ByteSwap32();
4174  }
4175  return ok;
4176  }
4177 
4178  bool NTV2GetRegisters::RPCDecodeClient (const RPCBlob & inBlob, size_t & inOutIndex)
4179  {
4180  bool ok = mHeader.RPCDecode(inBlob, inOutIndex); // NTV2_HEADER mHeader
4181  if (!ok) return false;
4182  POPU32(mInNumRegisters, inBlob, inOutIndex); // ULWord mInNumRegisters
4183  ok &= mInRegisters.RPCDecode(inBlob, inOutIndex, /*fillbuffer=*/false); // NTV2Buffer mInRegisters
4184  POPU32(mOutNumRegisters, inBlob, inOutIndex); // ULWord mOutNumRegisters
4185  ok &= mOutGoodRegisters.RPCDecode(inBlob, inOutIndex, /*fillbuffer=*/true); // NTV2Buffer mOutGoodRegisters
4186  ok &= mOutValues.RPCDecode(inBlob, inOutIndex, /*fillbuffer=*/true); // NTV2Buffer mOutValues
4187  ok &= mTrailer.RPCDecode(inBlob, inOutIndex); // NTV2_TRAILER mTrailer
4188  if (!NTV2HostIsBigEndian)
4189  { // Re-byteswap NTV2Buffer data after decoding...
4190  mOutGoodRegisters.ByteSwap32();
4191  mOutValues.ByteSwap32();
4192  }
4193  return ok;
4194  }
4195 
4197  {
4198  const size_t totBytes (mHeader.GetSizeInBytes() // Header + natural size of all structs/fields inbetween + Trailer
4199  + mInRegInfos.GetByteCount() + mOutBadRegIndexes.GetByteCount()); // NTV2Buffer fields
4200  if (outBlob.capacity() < totBytes)
4201  outBlob.reserve(totBytes);
4202  if (!NTV2HostIsBigEndian)
4203  { // All of my NTV2Buffers store arrays of ULWords that must be BigEndian BEFORE encoding into outBlob...
4204  mInRegInfos.ByteSwap32();
4205  mOutBadRegIndexes.ByteSwap32();
4206  }
4207  bool ok = mHeader.RPCEncode(outBlob); // NTV2_HEADER mHeader
4208  PUSHU32(mInNumRegisters, outBlob); // ULWord mInNumRegisters
4209  ok &= mInRegInfos.RPCEncode(outBlob); // NTV2Buffer mInRegInfos
4210  PUSHU32(mOutNumFailures, outBlob); // ULWord mOutNumFailures
4211  ok &= mOutBadRegIndexes.RPCEncode(outBlob) // NTV2Buffer mOutBadRegIndexes
4212  && mTrailer.RPCEncode(outBlob); // NTV2_TRAILER mTrailer
4213  if (!NTV2HostIsBigEndian && !ok)
4214  { // FAILED: Un-byteswap NTV2Buffer data...
4215  mInRegInfos.ByteSwap32();
4216  mOutBadRegIndexes.ByteSwap16();
4217  }
4218  return ok;
4219  }
4220 
4221  bool NTV2SetRegisters::RPCDecode (const RPCBlob & inBlob, size_t & inOutIndex)
4222  {
4223  bool ok = mHeader.RPCDecode(inBlob, inOutIndex); // NTV2_HEADER mHeader
4224  POPU32(mInNumRegisters, inBlob, inOutIndex); // ULWord mInNumRegisters
4225  ok &= mInRegInfos.RPCDecode(inBlob, inOutIndex); // NTV2Buffer mInRegInfos
4226  POPU32(mOutNumFailures, inBlob, inOutIndex); // ULWord mOutNumFailures
4227  ok &= mOutBadRegIndexes.RPCDecode(inBlob, inOutIndex); // NTV2Buffer mOutBadRegIndexes
4228  ok &= mTrailer.RPCDecode(inBlob, inOutIndex); // NTV2_TRAILER mTrailer
4229  if (!NTV2HostIsBigEndian)
4230  { // Re-byteswap NTV2Buffer data after decoding...
4231  mInRegInfos.ByteSwap32();
4232  mOutBadRegIndexes.ByteSwap16();
4233  }
4234  return ok;
4235  }
4236 
4238  {
4239  const size_t totBytes (mHeader.GetSizeInBytes() // Header + natural size of all structs/fields inbetween + Trailer
4240  + mInBankInfos.GetByteCount() + mInRegInfos.GetByteCount()); // NTV2Buffer fields
4241  if (outBlob.capacity() < totBytes)
4242  outBlob.reserve(totBytes);
4243  if (!NTV2HostIsBigEndian)
4244  { // All of my NTV2Buffers store arrays of ULWords that must be BigEndian BEFORE encoding into outBlob...
4245  mInBankInfos.ByteSwap32();
4246  mInRegInfos.ByteSwap32();
4247  }
4248  bool ok = mHeader.RPCEncode(outBlob); // NTV2_HEADER mHeader
4249  PUSHU32(mIsWriting, outBlob); // ULWord mIsWriting
4250  ok &= mInBankInfos.RPCEncode(outBlob); // NTV2Buffer mInBankInfos
4251  ok &= mInRegInfos.RPCEncode(outBlob) // NTV2Buffer mInRegInfos
4252  && mTrailer.RPCEncode(outBlob); // NTV2_TRAILER mTrailer
4253  if (!NTV2HostIsBigEndian && !ok)
4254  { // FAILED: Un-byteswap NTV2Buffer data...
4255  mInBankInfos.ByteSwap32();
4256  mInRegInfos.ByteSwap32();
4257  }
4258  return ok;
4259  }
4260 
4261  bool NTV2BankSelGetSetRegs::RPCDecode (const RPCBlob & inBlob, size_t & inOutIndex)
4262  {
4263  bool ok = mHeader.RPCDecode(inBlob, inOutIndex); // NTV2_HEADER mHeader
4264  POPU32(mIsWriting, inBlob, inOutIndex); // ULWord mIsWriting
4265  ok &= mInBankInfos.RPCDecode(inBlob, inOutIndex); // NTV2Buffer mInBankInfos
4266  ok &= mInRegInfos.RPCDecode(inBlob, inOutIndex); // NTV2Buffer mInRegInfos
4267  ok &= mTrailer.RPCDecode(inBlob, inOutIndex); // NTV2_TRAILER mTrailer
4268  if (!NTV2HostIsBigEndian)
4269  { // Re-byteswap NTV2Buffer data after decoding...
4270  mInBankInfos.ByteSwap32();
4271  mInRegInfos.ByteSwap32();
4272  }
4273  return ok;
4274  }
4275 
4277  {
4278  const size_t totBytes (mHeader.GetSizeInBytes() // Header + natural size of all structs/fields inbetween + Trailer
4279  + mHandles.GetByteCount()); // NTV2Buffer field
4280  if (outBlob.capacity() < totBytes)
4281  outBlob.reserve(totBytes);
4282  bool ok = true;
4283  if (!NTV2HostIsBigEndian && mHandles)
4284  ok &= mHandles.ByteSwap64(); // mHandles is array of ULWord64s that must be BigEndian BEFORE encoding into outBlob
4285  ok &= mHeader.RPCEncode(outBlob); // NTV2_HEADER mHeader
4286  PUSHU32(mOperation, outBlob); // ULWord mOperation
4287  PUSHU32(mFlags, outBlob); // ULWord mFlags
4288  PUSHU32(mInterruptID, outBlob); // ULWord mInterruptID
4289  PUSHU32(mResult, outBlob); // ULWord mResult
4290  PUSHU64(mInterruptIDs, outBlob); // ULWord64 mInterruptIDs
4291  PUSHU64(mEventHandle, outBlob); // ULWord64 mEventHandle
4292  PUSHU64(mClientID, outBlob); // ULWord64 mClientID
4293  PUSHU64(mClientPID, outBlob); // ULWord64 mClientPID
4294  PUSHU64(mClientTID, outBlob); // ULWord64 mClientTID
4295  PUSHU32(mCount, outBlob); // ULWord mCount
4296  ok &= mHandles.RPCEncode(outBlob); // NTV2Buffer mHandles
4297  ok &= mTrailer.RPCEncode(outBlob); // NTV2_TRAILER mTrailer
4298  if (!NTV2HostIsBigEndian && !ok && mHandles)
4299  ok &= mHandles.ByteSwap64(); // FAILED: Un-byteswap NTV2Buffer data
4300  return ok;
4301  }
4302 
4303  bool NTV2ConfigInterrupt::RPCDecode (const RPCBlob & inBlob, size_t & inOutIndex)
4304  {
4305  bool ok = mHeader.RPCDecode(inBlob, inOutIndex); // NTV2_HEADER mHeader
4306  ok &= POPU32(mOperation, inBlob, inOutIndex); // ULWord mOperation
4307  ok &= POPU32(mFlags, inBlob, inOutIndex); // ULWord mFlags
4308  ok &= POPU32(mInterruptID, inBlob, inOutIndex); // ULWord mInterruptID
4309  ok &= POPU32(mResult, inBlob, inOutIndex); // ULWord mResult
4310  ok &= POPU64(mInterruptIDs, inBlob, inOutIndex); // ULWord64 mInterruptIDs
4311  ok &= POPU64(mEventHandle, inBlob, inOutIndex); // ULWord64 mEventHandle
4312  ok &= POPU64(mClientID, inBlob, inOutIndex); // ULWord64 mClientID
4313  ok &= POPU64(mClientPID, inBlob, inOutIndex); // ULWord64 mClientPID
4314  ok &= POPU64(mClientTID, inBlob, inOutIndex); // ULWord64 mClientTID
4315  ok &= POPU32(mCount, inBlob, inOutIndex); // ULWord mCount
4316  ok &= mHandles.RPCDecode(inBlob, inOutIndex); // NTV2Buffer mHandles
4317  ok &= mTrailer.RPCDecode(inBlob, inOutIndex); // NTV2_TRAILER mTrailer
4318  if (!NTV2HostIsBigEndian)
4319  mHandles.ByteSwap64(); // Re-byteswap NTV2Buffer data after decoding
4320  return ok;
4321  }
4322 
4324  {
4325  const size_t totBytes (acHeader.GetSizeInBytes()); // Header + natural size of all structs/fields inbetween + Trailer
4326  if (outBlob.capacity() < totBytes)
4327  outBlob.reserve(totBytes);
4328  bool ok = acHeader.RPCEncode(outBlob); // NTV2_HEADER acHeader
4329  PUSHU16(UWord(acCrosspoint), outBlob); // NTV2Crosspoint acCrosspoint
4330  PUSHU16(UWord(acState), outBlob); // NTV2AutoCirculateState acState
4331  PUSHU32(ULWord(acStartFrame), outBlob); // LWord acStartFrame
4332  PUSHU32(ULWord(acEndFrame), outBlob); // LWord acEndFrame
4333  PUSHU32(ULWord(acActiveFrame), outBlob); // LWord acActiveFrame
4334  PUSHU64(acRDTSCStartTime, outBlob); // ULWord64 acRDTSCStartTime
4335  PUSHU64(acAudioClockStartTime, outBlob); // ULWord64 acAudioClockStartTime
4336  PUSHU64(acRDTSCCurrentTime, outBlob); // ULWord64 acRDTSCCurrentTime
4337  PUSHU64(acAudioClockCurrentTime, outBlob); // ULWord64 acAudioClockCurrentTime
4338  PUSHU32(acFramesProcessed, outBlob); // ULWord acFramesProcessed
4339  PUSHU32(acFramesDropped, outBlob); // ULWord acFramesDeopped
4340  PUSHU32(acBufferLevel, outBlob); // ULWord acBufferLevel
4341  PUSHU32(acOptionFlags, outBlob); // ULWord acOptionFlags
4342  PUSHU16(UWord(acAudioSystem), outBlob); // NTV2AudioSystem acAudioSystem
4343  ok &= acTrailer.RPCEncode(outBlob); // NTV2_TRAILER acTrailer
4344  return ok;
4345  }
4346 
4347  bool AUTOCIRCULATE_STATUS::RPCDecode (const RPCBlob & inBlob, size_t & inOutIndex)
4348  { uint16_t v16(0); uint32_t v32(0);
4349  bool ok = acHeader.RPCDecode(inBlob, inOutIndex); // NTV2_HEADER acHeader
4350  POPU16(v16, inBlob, inOutIndex); // NTV2Crosspoint acCrosspoint
4351  acCrosspoint = NTV2Crosspoint(v16);
4352  POPU16(v16, inBlob, inOutIndex); // NTV2AutoCirculateState acState
4353  acState = NTV2AutoCirculateState(v16);
4354  POPU32(v32, inBlob, inOutIndex); // LWord acStartFrame
4355  acStartFrame = LWord(v32);
4356  POPU32(v32, inBlob, inOutIndex); // LWord acEndFrame
4357  acEndFrame = LWord(v32);
4358  POPU32(v32, inBlob, inOutIndex); // LWord acActiveFrame
4359  acActiveFrame = LWord(v32);
4360  POPU64(acRDTSCStartTime, inBlob, inOutIndex); // ULWord64 acRDTSCStartTime
4361  POPU64(acAudioClockStartTime, inBlob, inOutIndex); // ULWord64 acAudioClockStartTime
4362  POPU64(acRDTSCCurrentTime, inBlob, inOutIndex); // ULWord64 acRDTSCCurrentTime
4363  POPU64(acAudioClockCurrentTime, inBlob, inOutIndex); // ULWord64 acAudioClockCurrentTime
4364  POPU32(acFramesProcessed, inBlob, inOutIndex); // ULWord acFramesProcessed
4365  POPU32(acFramesDropped, inBlob, inOutIndex); // ULWord acFramesDropped
4366  POPU32(acBufferLevel, inBlob, inOutIndex); // ULWord acBufferLevel
4367  POPU32(acOptionFlags, inBlob, inOutIndex); // ULWord acOptionFlags
4368  POPU16(v16, inBlob, inOutIndex); // NTV2AudioSystem acAudioSystem
4369  acAudioSystem = NTV2AudioSystem(v16);
4370  ok &= acTrailer.RPCDecode(inBlob, inOutIndex); // NTV2_TRAILER acTrailer
4371  return ok;
4372  }
4373 
4375  {
4376  const size_t totBytes (acHeader.GetSizeInBytes()); // Header + natural size of all structs/fields inbetween + Trailer
4377  if (outBlob.capacity() < totBytes)
4378  outBlob.reserve(totBytes);
4379  bool ok = acHeader.RPCEncode(outBlob); // NTV2_HEADER acHeader
4380  PUSHU64(ULWord64(acFrameTime), outBlob); // LWord64 acFrameTime
4381  PUSHU32(acRequestedFrame, outBlob); // ULWord acRequestedFrame
4382  PUSHU64(acAudioClockTimeStamp, outBlob); // ULWord64 acAudioClockTimeStamp
4383  PUSHU32(acAudioExpectedAddress, outBlob); // ULWord acAudioExpectedAddress
4384  PUSHU32(acAudioInStartAddress, outBlob); // ULWord acAudioInStartAddress
4385  PUSHU32(acAudioInStopAddress, outBlob); // ULWord acAudioInStopAddress
4386  PUSHU32(acAudioOutStopAddress, outBlob); // ULWord acAudioOutStopAddress
4387  PUSHU32(acAudioOutStartAddress, outBlob); // ULWord acAudioOutStartAddress
4388  PUSHU32(acTotalBytesTransferred, outBlob); // ULWord acTotalBytesTransferred
4389  PUSHU32(acStartSample, outBlob); // ULWord acStartSample
4390 
4391  ok &= acTimeCodes.RPCEncode(outBlob); // NTV2Buffer acTimeCodes
4392  PUSHU64(ULWord64(acCurrentTime), outBlob); // LWord64 acCurrentTime
4393  PUSHU32(acCurrentFrame, outBlob); // ULWord acCurrentFrame
4394  PUSHU64(ULWord64(acCurrentFrameTime), outBlob); // LWord64 acCurrentFrameTime
4395  PUSHU64(acAudioClockCurrentTime, outBlob); // ULWord64 acAudioClockCurrentTime
4396  PUSHU32(acCurrentAudioExpectedAddress, outBlob); // ULWord acCurrentAudioExpectedAddress
4397  PUSHU32(acCurrentAudioStartAddress, outBlob); // ULWord acCurrentAudioStartAddress
4398  PUSHU32(acCurrentFieldCount, outBlob); // ULWord acCurrentFieldCount
4399  PUSHU32(acCurrentLineCount, outBlob); // ULWord acCurrentLineCount
4400  PUSHU32(acCurrentReps, outBlob); // ULWord acCurrentReps
4401  PUSHU64(acCurrentUserCookie, outBlob); // ULWord64 acCurrentUserCookie
4402  PUSHU32(acFrame, outBlob); // ULWord acFrame
4403  PUSHU32(acRP188.fDBB, outBlob); // ULWord acRP188.fDBB
4404  PUSHU32(acRP188.fLo, outBlob); // ULWord acRP188.fLo
4405  PUSHU32(acRP188.fHi, outBlob); // ULWord acRP188.fHi
4406  ok &= acTrailer.RPCEncode(outBlob); // NTV2_TRAILER acTrailer
4407  return ok;
4408  }
4409 
4410  bool FRAME_STAMP::RPCDecode (const RPCBlob & inBlob, size_t & inOutIndex)
4411  { uint64_t v64(0);
4412  bool ok = acHeader.RPCDecode(inBlob, inOutIndex); // NTV2_HEADER acHeader
4413  POPU64(v64, inBlob, inOutIndex); // LWord64 acFrameTime
4414  acFrameTime = LWord64(v64);
4415  POPU32(acRequestedFrame, inBlob, inOutIndex); // ULWord acRequestedFrame
4416  POPU64(acAudioClockTimeStamp, inBlob, inOutIndex); // ULWord64 acAudioClockTimeStamp
4417  POPU32(acAudioExpectedAddress, inBlob, inOutIndex); // ULWord acAudioExpectedAddress
4418  POPU32(acAudioInStartAddress, inBlob, inOutIndex); // ULWord acAudioInStartAddress
4419  POPU32(acAudioInStopAddress, inBlob, inOutIndex); // ULWord acAudioInStopAddress
4420  POPU32(acAudioOutStopAddress, inBlob, inOutIndex); // ULWord acAudioOutStopAddress
4421  POPU32(acAudioOutStartAddress, inBlob, inOutIndex); // ULWord acAudioOutStartAddress
4422  POPU32(acTotalBytesTransferred, inBlob, inOutIndex); // ULWord acTotalBytesTransferred
4423  POPU32(acStartSample, inBlob, inOutIndex); // ULWord acStartSample
4424 
4425  ok &= acTimeCodes.RPCDecode(inBlob, inOutIndex); // NTV2Buffer acTimeCodes
4426  POPU64(v64, inBlob, inOutIndex); // LWord64 acCurrentTime
4427  acCurrentTime = LWord64(v64);
4428  POPU32(acCurrentFrame, inBlob, inOutIndex); // ULWord acCurrentFrame
4429  POPU64(v64, inBlob, inOutIndex); // LWord64 acCurrentFrameTime
4430  acCurrentFrameTime = LWord64(v64);
4431  POPU64(acAudioClockCurrentTime, inBlob, inOutIndex); // ULWord64 acAudioClockCurrentTime
4432  POPU32(acCurrentAudioExpectedAddress, inBlob, inOutIndex); // ULWord acCurrentAudioExpectedAddress
4433  POPU32(acCurrentAudioStartAddress, inBlob, inOutIndex); // ULWord acCurrentAudioStartAddress
4434  POPU32(acCurrentFieldCount, inBlob, inOutIndex); // ULWord acCurrentFieldCount
4435  POPU32(acCurrentLineCount, inBlob, inOutIndex); // ULWord acCurrentLineCount
4436  POPU32(acCurrentReps, inBlob, inOutIndex); // ULWord acCurrentReps
4437  POPU64(acCurrentUserCookie, inBlob, inOutIndex); // ULWord64 acCurrentUserCookie
4438  POPU32(acFrame, inBlob, inOutIndex); // ULWord acFrame
4439  POPU32(acRP188.fDBB, inBlob, inOutIndex); // ULWord acRP188.fDBB
4440  POPU32(acRP188.fLo, inBlob, inOutIndex); // ULWord acRP188.fLo
4441  POPU32(acRP188.fHi, inBlob, inOutIndex); // ULWord acRP188.fHi
4442  ok &= acTrailer.RPCDecode(inBlob, inOutIndex); // NTV2_TRAILER acTrailer
4443  return ok;
4444  }
4445 
4447  {
4448  const size_t totBytes (acHeader.GetSizeInBytes()); // Header + natural size of all structs/fields inbetween + Trailer
4449  if (outBlob.capacity() < totBytes)
4450  outBlob.reserve(totBytes);
4451  bool ok = acHeader.RPCEncode(outBlob); // NTV2_HEADER acHeader
4452  PUSHU16(acState, outBlob); // UWord acState
4453  PUSHU32(ULWord(acTransferFrame), outBlob); // LWord acTransferFrame
4454  PUSHU32(acBufferLevel, outBlob); // ULWord acBufferLevel
4455  PUSHU32(acFramesProcessed, outBlob); // ULWord acFramesProcessed
4456  PUSHU32(acFramesDropped, outBlob); // ULWord acFramesDropped
4457  ok &= acFrameStamp.RPCEncode(outBlob); // FRAME_STAMP acFrameStamp
4458  PUSHU32(acAudioTransferSize, outBlob); // ULWord acAudioTransferSize
4459  PUSHU32(acAudioStartSample, outBlob); // ULWord acAudioStartSample
4460  PUSHU32(acAncTransferSize, outBlob); // ULWord acAncTransferSize
4461  PUSHU32(acAncField2TransferSize, outBlob); // ULWord acAncField2TransferSize
4462  ok &= acTrailer.RPCEncode(outBlob); // NTV2_TRAILER acTrailer
4463  return ok;
4464  }
4465 
4466  bool AUTOCIRCULATE_TRANSFER_STATUS::RPCDecode (const RPCBlob & inBlob, size_t & inOutIndex)
4467  { uint16_t v16(0); uint32_t v32(0);
4468  bool ok = acHeader.RPCDecode(inBlob, inOutIndex); // NTV2_HEADER acHeader
4469  POPU16(v16, inBlob, inOutIndex); // NTV2AutoCirculateState acState
4470  acState = NTV2AutoCirculateState(v16);
4471  POPU32(v32, inBlob, inOutIndex); // LWord acTransferFrame
4472  acTransferFrame = LWord(v32);
4473  POPU32(acBufferLevel, inBlob, inOutIndex); // ULWord acBufferLevel
4474  POPU32(acFramesProcessed, inBlob, inOutIndex); // ULWord acFramesProcessed
4475  POPU32(acFramesDropped, inBlob, inOutIndex); // ULWord acFramesDropped
4476  ok &= acFrameStamp.RPCDecode(inBlob, inOutIndex); // FRAME_STAMP acFrameStamp
4477  POPU32(acAudioTransferSize, inBlob, inOutIndex); // ULWord acAudioTransferSize
4478  POPU32(acAudioStartSample, inBlob, inOutIndex); // ULWord acAudioStartSample
4479  POPU32(acAncTransferSize, inBlob, inOutIndex); // ULWord acAncTransferSize
4480  POPU32(acAncField2TransferSize, inBlob, inOutIndex); // ULWord acAncField2TransferSize
4481  ok &= acTrailer.RPCDecode(inBlob, inOutIndex); // NTV2_TRAILER acTrailer
4482  return ok;
4483  }
4484 
4486  {
4487  PUSHU32(acNumSegments, outBlob); // ULWord acNumSegments
4488  PUSHU32(acNumActiveBytesPerRow, outBlob); // ULWord acNumActiveBytesPerRow
4489  PUSHU32(acSegmentHostPitch, outBlob); // ULWord acSegmentHostPitch
4490  PUSHU32(acSegmentDevicePitch, outBlob); // ULWord acSegmentDevicePitch
4491  return true;
4492  }
4493 
4494  bool NTV2SegmentedDMAInfo::RPCDecode (const RPCBlob & inBlob, size_t & inOutIndex)
4495  {
4496  POPU32(acNumSegments, inBlob, inOutIndex); // ULWord acNumSegments
4497  POPU32(acNumActiveBytesPerRow, inBlob, inOutIndex); // ULWord acNumActiveBytesPerRow
4498  POPU32(acSegmentHostPitch, inBlob, inOutIndex); // ULWord acSegmentHostPitch
4499  POPU32(acSegmentDevicePitch, inBlob, inOutIndex); // ULWord acSegmentDevicePitch
4500  return true;
4501  }
4502 
4504  {
4505  PUSHU16(ccMode, outBlob); // NTV2ColorCorrectionMode ccMode
4506  PUSHU32(ccSaturationValue, outBlob); // ULWord ccSaturationValue
4507  return ccLookupTables.RPCEncode(outBlob); // NTV2Buffer ccLookupTables
4508  }
4509 
4510  bool NTV2ColorCorrectionData::RPCDecode (const RPCBlob & inBlob, size_t & inOutIndex)
4511  { uint16_t u16(0);
4512  POPU16(u16, inBlob, inOutIndex); // NTV2ColorCorrectionMode ccMode
4513  ccMode = NTV2ColorCorrectionMode(u16);
4514  POPU32(ccSaturationValue, inBlob, inOutIndex); // ULWord ccSaturationValue
4515  return ccLookupTables.RPCDecode(inBlob, inOutIndex); // NTV2Buffer ccLookupTables
4516  }
4517 
4519  {
4520  PUSHU16(mode, outBlob); // AutoCircVidProcMode mode
4521  PUSHU16(foregroundVideoCrosspoint, outBlob); // NTV2Crosspoint foregroundVideoCrosspoint
4522  PUSHU16(backgroundVideoCrosspoint, outBlob); // NTV2Crosspoint backgroundVideoCrosspoint
4523  PUSHU16(foregroundKeyCrosspoint, outBlob); // NTV2Crosspoint foregroundKeyCrosspoint
4524  PUSHU16(backgroundKeyCrosspoint, outBlob); // NTV2Crosspoint backgroundKeyCrosspoint
4525  PUSHU32(ULWord(transitionCoefficient), outBlob); // Fixed_ transitionCoefficient
4526  PUSHU32(ULWord(transitionSoftness), outBlob); // Fixed_ transitionSoftness
4527  return true;
4528  }
4529 
4530  bool AutoCircVidProcInfo::RPCDecode (const RPCBlob & inBlob, size_t & inOutIndex)
4531  { uint16_t v16(0); uint32_t v32(0);
4532  POPU16(v16, inBlob, inOutIndex); // AutoCircVidProcMode mode
4533  mode = AutoCircVidProcMode(v16);
4534  POPU16(v16, inBlob, inOutIndex); // NTV2Crosspoint foregroundVideoCrosspoint
4535  foregroundVideoCrosspoint = NTV2Crosspoint(v16);
4536  POPU16(v16, inBlob, inOutIndex); // NTV2Crosspoint backgroundVideoCrosspoint
4537  backgroundVideoCrosspoint = NTV2Crosspoint(v16);
4538  POPU16(v16, inBlob, inOutIndex); // NTV2Crosspoint foregroundKeyCrosspoint
4539  foregroundKeyCrosspoint = NTV2Crosspoint(v16);
4540  POPU16(v16, inBlob, inOutIndex); // NTV2Crosspoint backgroundKeyCrosspoint
4541  backgroundKeyCrosspoint = NTV2Crosspoint(v16);
4542  POPU32(v32, inBlob, inOutIndex); // Fixed_ transitionCoefficient
4543  transitionCoefficient = Fixed_(v32);
4544  POPU32(v32, inBlob, inOutIndex); // Fixed_ transitionSoftness
4545  transitionSoftness = Fixed_(v32);
4546  return true;
4547  }
4548 
4550  {
4551  PUSHU32(fDBB, outBlob); // ULWord fDBB
4552  PUSHU32(fLo, outBlob); // ULWord fLo
4553  PUSHU32(fHi, outBlob); // ULWord fHi
4554  return true;
4555  }
4556 
4557  bool NTV2_RP188::RPCDecode (const RPCBlob & inBlob, size_t & inOutIndex)
4558  {
4559  POPU32(fDBB, inBlob, inOutIndex); // ULWord fDBB
4560  POPU32(fLo, inBlob, inOutIndex); // ULWord fLo
4561  POPU32(fHi, inBlob, inOutIndex); // ULWord fHi
4562  return true;
4563  }
4564 
4566  {
4568  const size_t totBytes (acHeader.GetSizeInBytes() + acVideoBuffer.GetByteCount() + acAudioBuffer.GetByteCount()
4569  + acANCBuffer.GetByteCount() + acANCField2Buffer.GetByteCount() + acOutputTimeCodes.GetByteCount()
4570  + acHDMIAuxData.GetByteCount() + 64); // Header + natural size of all structs/fields inbetween + Trailer
4571  if (outBlob.capacity() < totBytes)
4572  outBlob.reserve(totBytes);
4573  bool ok = acHeader.RPCEncode(outBlob); // NTV2_HEADER acHeader
4574  ok &= acVideoBuffer.RPCEncode(outBlob); // NTV2Buffer acVideoBuffer
4575  ok &= acAudioBuffer.RPCEncode(outBlob); // NTV2Buffer acAudioBuffer
4576  ok &= acANCBuffer.RPCEncode(outBlob); // NTV2Buffer acANCBuffer
4577  ok &= acANCField2Buffer.RPCEncode(outBlob); // NTV2Buffer acANCField2Buffer
4578  ok &= acOutputTimeCodes.RPCEncode(outBlob); // NTV2Buffer acOutputTimeCodes
4579  ok &= acTransferStatus.RPCEncode(outBlob); // AUTOCIRCULATE_TRANSFER_STATUS acTransferStatus
4580  PUSHU64(acInUserCookie, outBlob); // ULWord64 acInUserCookie
4581  PUSHU32(acInVideoDMAOffset, outBlob); // ULWord acInVideoDMAOffset
4582  ok &= acInSegmentedDMAInfo.RPCEncode(outBlob); // NTV2SegmentedDMAInfo acInSegmentedDMAInfo
4583  ok &= acColorCorrection.RPCEncode(outBlob); // NTV2ColorCorrectionData acColorCorrection
4584  PUSHU16(acFrameBufferFormat, outBlob); // NTV2PixelFormat acFrameBufferFormat
4585  PUSHU16(acFrameBufferOrientation, outBlob); // NTV2FBOrientation acFrameBufferOrientation
4586  ok &= acVidProcInfo.RPCEncode(outBlob); // AutoCircVidProcInfo acVidProcInfo
4587  PUSHU16(acVideoQuarterSizeExpand, outBlob); // NTV2QtrSizeExpandMode acVideoQuarterSizeExpand
4588  ok &= acHDMIAuxData.RPCEncode(outBlob); // NTV2Buffer acHDMIAuxData
4589  PUSHU32(acPeerToPeerFlags, outBlob); // ULWord acPeerToPeerFlags
4590  PUSHU32(acFrameRepeatCount, outBlob); // ULWord acFrameRepeatCount
4591  PUSHU32(ULWord(acDesiredFrame), outBlob); // LWord acDesiredFrame
4592  ok &= acRP188.RPCEncode(outBlob); // NTV2_RP188 acRP188
4593  PUSHU16(acCrosspoint, outBlob); // NTV2Crosspoint acCrosspoint
4594  ok &= acTrailer.RPCEncode(outBlob); // NTV2_TRAILER acTrailer
4596  return ok;
4597  }
4598 
4599  bool AUTOCIRCULATE_TRANSFER::RPCDecode (const RPCBlob & inBlob, size_t & inOutIndex)
4600  { uint16_t v16(0); uint32_t v32(0);
4602  bool ok = acHeader.RPCDecode(inBlob, inOutIndex); // NTV2_HEADER acHeader
4603  ok &= acVideoBuffer.RPCDecode(inBlob, inOutIndex); // NTV2Buffer acVideoBuffer
4604  ok &= acAudioBuffer.RPCDecode(inBlob, inOutIndex); // NTV2Buffer acAudioBuffer
4605  ok &= acANCBuffer.RPCDecode(inBlob, inOutIndex); // NTV2Buffer acANCBuffer
4606  ok &= acANCField2Buffer.RPCDecode(inBlob, inOutIndex); // NTV2Buffer acANCField2Buffer
4607  ok &= acOutputTimeCodes.RPCDecode(inBlob, inOutIndex); // NTV2Buffer acOutputTimeCodes
4608  ok &= acTransferStatus.RPCDecode(inBlob, inOutIndex); // AUTOCIRCULATE_TRANSFER_STATUS acTransferStatus
4609  POPU64(acInUserCookie, inBlob, inOutIndex); // ULWord64 acInUserCookie
4610  POPU32(acInVideoDMAOffset, inBlob, inOutIndex); // ULWord acInVideoDMAOffset
4611  ok &= acInSegmentedDMAInfo.RPCDecode(inBlob, inOutIndex);// NTV2Buffer acInSegmentedDMAInfo
4612  ok &= acColorCorrection.RPCDecode(inBlob, inOutIndex); // NTV2Buffer acColorCorrection
4613  POPU16(v16, inBlob, inOutIndex); // NTV2PixelFormat acFrameBufferFormat
4614  acFrameBufferFormat = NTV2FrameBufferFormat(v16);
4615  POPU16(v16, inBlob, inOutIndex); // NTV2FBOrientation acFrameBufferOrientation
4616  acFrameBufferOrientation = NTV2FBOrientation(v16);
4617  ok &= acVidProcInfo.RPCDecode(inBlob, inOutIndex); // AutoCircVidProcInfo acVidProcInfo
4618  POPU16(v16, inBlob, inOutIndex); // NTV2QtrSizeExpandMode acVideoQuarterSizeExpand
4619  acVideoQuarterSizeExpand = NTV2QtrSizeExpandMode(v16);
4620  ok &= acHDMIAuxData.RPCDecode(inBlob, inOutIndex); // NTV2Buffer acHDMIAuxData
4621  POPU32(acPeerToPeerFlags, inBlob, inOutIndex); // ULWord acPeerToPeerFlags
4622  POPU32(acFrameRepeatCount, inBlob, inOutIndex); // ULWord acFrameRepeatCount
4623  POPU32(v32, inBlob, inOutIndex); // LWord acDesiredFrame
4624  acDesiredFrame = LWord(v32);
4625  ok &= acRP188.RPCDecode(inBlob, inOutIndex); // NTV2_RP188 acRP188
4626  POPU16(v16, inBlob, inOutIndex); // NTV2Crosspoint acCrosspoint
4627  acCrosspoint = NTV2Crosspoint(v16);
4628  ok &= acTrailer.RPCDecode(inBlob, inOutIndex); // NTV2_TRAILER acTrailer
4630  return ok;
4631  }
4632 
4634  {
4635  NTV2Buffer buff;
4636  PUSHU16(UWord(channelSpec), outBlob); // NTV2Crosspoint channelSpec
4637 // PUSHU64(ULWord64(videoBuffer), outBlob) // ULWord * videoBuffer
4638  PUSHU32(videoBufferSize, outBlob); // ULWord videoBufferSize
4639  if (videoBuffer && videoBufferSize)
4640  { buff.Set(videoBuffer, videoBufferSize);
4641  buff.AppendU8s(outBlob);
4642  }
4643  PUSHU32(videoDmaOffset, outBlob); // ULWord videoDmaOffset
4644 // PUSHU64(ULWord64(audioBuffer), outBlob) // ULWord * audioBuffer
4645  PUSHU32(audioBufferSize, outBlob); // ULWord audioBufferSize
4646  if (audioBuffer && audioBufferSize)
4647  { buff.Set(audioBuffer, audioBufferSize);
4648  buff.AppendU8s(outBlob);
4649  }
4650  PUSHU32(audioStartSample, outBlob); // ULWord audioStartSample
4651  PUSHU32(audioNumChannels, outBlob); // ULWord audioNumChannels
4652  PUSHU32(frameRepeatCount, outBlob); // ULWord frameRepeatCount
4653  rp188.RPCEncode(outBlob); // RP188_STRUCT rp188
4654  PUSHU32(ULWord(desiredFrame), outBlob); // LWord desiredFrame
4655  PUSHU32(hUser, outBlob); // ULWord hUser
4656  PUSHU32(transferFlags, outBlob); // ULWord transferFlags
4657  PUSHU8(bDisableExtraAudioInfo, outBlob); // BOOL_ bDisableExtraAudioInfo
4658  PUSHU16(UWord(frameBufferFormat), outBlob); // NTV2PixelFormat frameBufferFormat
4659  PUSHU16(UWord(frameBufferOrientation), outBlob); // NTV2FBOrientation frameBufferOrientation
4660  // Skip color correction for now // NTV2ColorCorrectionInfo colorCorrectionInfo
4661  vidProcInfo.RPCEncode(outBlob); // AutoCircVidProcInfo vidProcInfo
4662  PUSHU32(customAncInfo.Group1, outBlob); // CUSTOM_ANC_STRUCT customAncInfo
4663  PUSHU32(customAncInfo.Group2, outBlob);
4664  PUSHU32(customAncInfo.Group3, outBlob);
4665  PUSHU32(customAncInfo.Group4, outBlob);
4666  PUSHU32(videoNumSegments, outBlob); // ULWord videoNumSegments
4667  PUSHU32(videoSegmentHostPitch, outBlob); // ULWord videoSegmentHostPitch
4668  PUSHU32(videoSegmentCardPitch, outBlob); // ULWord videoSegmentCardPitch
4669  PUSHU16(UWord(videoQuarterSizeExpand), outBlob); // NTV2QtrSizeExpandMode videoQuarterSizeExpand
4670  return true;
4671  }
4672 
4673  bool AUTOCIRCULATE_TRANSFER_STRUCT::RPCDecode (const RPCBlob & inBlob, size_t & inOutIndex)
4674  { UWord v16(0); ULWord v32(0);
4675  POPU16(v16, inBlob, inOutIndex); // NTV2Crosspoint channelSpec
4676  channelSpec = NTV2Crosspoint(v16);
4677 // POPU64(u64, inBlob, inOutIndex); // ULWord * videoBuffer
4678 // videoBuffer = reinterpret_cast<ULWord*>(u64);
4679  POPU32(videoBufferSize, inBlob, inOutIndex); // ULWord videoBufferSize
4680  if (videoBufferSize && !videoBuffer)
4681  {
4682  videoBuffer = reinterpret_cast<ULWord*>(AJAMemory::AllocateAligned(videoBufferSize, NTV2Buffer::DefaultPageSize()));
4683  if (!videoBuffer)
4684  return false;
4685  if ((inOutIndex + videoBufferSize) >= inBlob.size())
4686  return false; // past end of inBlob
4687  UByte* pBuffer = reinterpret_cast<UByte*>(videoBuffer);
4688  for (ULWord cnt(0); cnt < videoBufferSize; cnt++)
4689  pBuffer[cnt] = inBlob.at(inOutIndex++); // Caller is responsible for byte-swapping if needed
4690  }
4691  POPU32(videoDmaOffset, inBlob, inOutIndex); // ULWord videoDmaOffset
4692 // POPU64(u64, inBlob, inOutIndex); // ULWord * audioBuffer
4693 // audioBuffer = reinterpret_cast<ULWord*>(u64);
4694  POPU32(audioBufferSize, inBlob, inOutIndex); // ULWord audioBufferSize
4695  if (audioBufferSize && !audioBuffer)
4696  {
4697  audioBuffer = reinterpret_cast<ULWord*>(AJAMemory::AllocateAligned(audioBufferSize, NTV2Buffer::DefaultPageSize()));
4698  if (!audioBuffer)
4699  return false;
4700  if ((inOutIndex + audioBufferSize) >= inBlob.size())
4701  return false; // past end of inBlob
4702  UByte* pBuffer = reinterpret_cast<UByte*>(audioBuffer);
4703  for (ULWord cnt(0); cnt < audioBufferSize; cnt++)
4704  pBuffer[cnt] = inBlob.at(inOutIndex++); // Caller is responsible for byte-swapping if needed
4705  }
4706  POPU32(audioStartSample, inBlob, inOutIndex); // ULWord audioStartSample
4707  POPU32(audioNumChannels, inBlob, inOutIndex); // ULWord audioNumChannels
4708  POPU32(frameRepeatCount, inBlob, inOutIndex); // ULWord frameRepeatCount
4709  rp188.RPCDecode(inBlob, inOutIndex); // RP188_STRUCT rp188
4710  POPU32(v32, inBlob, inOutIndex); // LWord desiredFrame
4711  desiredFrame = LWord(v32);
4712  POPU32(hUser, inBlob, inOutIndex); // ULWord hUser
4713  POPU32(transferFlags, inBlob, inOutIndex); // ULWord transferFlags
4714  POPU8(AsU8Ref(bDisableExtraAudioInfo), inBlob, inOutIndex); // BOOL_ bDisableExtraAudioInfo
4715  POPU16(v16, inBlob, inOutIndex); // NTV2PixelFormat frameBufferFormat
4716  frameBufferFormat = NTV2PixelFormat(v16);
4717  POPU16(v16, inBlob, inOutIndex); // NTV2FBOrientation frameBufferOrientation
4718  frameBufferOrientation = NTV2FBOrientation(v16);
4719  // Skip color correction for now // NTV2ColorCorrectionInfo colorCorrectionInfo
4720  vidProcInfo.RPCDecode(inBlob, inOutIndex); // AutoCircVidProcInfo vidProcInfo
4721  POPU32(customAncInfo.Group1, inBlob, inOutIndex); // CUSTOM_ANC_STRUCT customAncInfo
4722  POPU32(customAncInfo.Group2, inBlob, inOutIndex);
4723  POPU32(customAncInfo.Group3, inBlob, inOutIndex);
4724  POPU32(customAncInfo.Group4, inBlob, inOutIndex);
4725  POPU32(videoNumSegments, inBlob, inOutIndex); // ULWord videoNumSegments
4726  POPU32(videoSegmentHostPitch, inBlob, inOutIndex); // ULWord videoSegmentHostPitch
4727  POPU32(videoSegmentCardPitch, inBlob, inOutIndex); // ULWord videoSegmentCardPitch
4728  POPU16(v16, inBlob, inOutIndex); // NTV2QtrSizeExpandMode videoQuarterSizeExpand
4729  videoQuarterSizeExpand = NTV2QtrSizeExpandMode(v16);
4730  return true;
4731  }
4732 
4734  {
4735  const size_t totBytes (mHeader.GetSizeInBytes()); // Header + natural size of all structs/fields inbetween + Trailer
4736  if (outBlob.capacity() < totBytes)
4737  outBlob.reserve(totBytes);
4738  bool ok = mHeader.RPCEncode(outBlob); // NTV2_HEADER mHeader
4739  ok &= mBuffer.RPCEncode(outBlob); // NTV2Buffer mBuffer
4740  PUSHU32(mFlags, outBlob); // ULWord mFlags
4741  PUSHU32(mStatus, outBlob); // ULWord mStatus
4742  for (size_t ndx(0); ndx < 16; ndx++)
4743  PUSHU32(mRegisters[ndx], outBlob); // ULWord mRegisters[16]
4744  for (size_t ndx(0); ndx < 32; ndx++)
4745  PUSHU32(mReserved[ndx], outBlob); // ULWord mReserved[32]
4746  ok &= mTrailer.RPCEncode(outBlob); // NTV2_TRAILER mTrailer
4747  return ok;
4748  }
4749 
4750  bool NTV2Bitstream::RPCDecode (const RPCBlob & inBlob, size_t & inOutIndex)
4751  {
4752  bool ok = mHeader.RPCDecode(inBlob, inOutIndex); // NTV2_HEADER acHeader
4753  ok &= mBuffer.RPCDecode(inBlob, inOutIndex); // NTV2Buffer mBuffer
4754  POPU32(mFlags, inBlob, inOutIndex); // ULWord mFlags
4755  POPU32(mStatus, inBlob, inOutIndex); // ULWord mStatus
4756  for (size_t ndx(0); ndx < 16; ndx++)
4757  POPU32(mRegisters[ndx], inBlob, inOutIndex); // ULWord mRegisters[16]
4758  for (size_t ndx(0); ndx < 16; ndx++)
4759  POPU32(mReserved[ndx], inBlob, inOutIndex); // ULWord mReserved[16]
4760  ok &= mTrailer.RPCDecode(inBlob, inOutIndex); // NTV2_TRAILER mTrailer
4761  return ok;
4762  }
4763 
4765  {
4766  PUSHU16(UWord(channelSpec), outBlob); // NTV2Crosspoint channelSpec
4767  PUSHU16(UWord(state), outBlob); // NTV2AutoCirculateState state
4768  PUSHU32(ULWord(startFrame), outBlob); // LWord startFrame
4769  PUSHU32(ULWord(endFrame), outBlob); // LWord endFrame
4770  PUSHU32(ULWord(activeFrame), outBlob); // LWord activeFrame
4771  PUSHU64(rdtscStartTime, outBlob); // ULWord64 rdtscStartTime
4772  PUSHU64(audioClockStartTime, outBlob); // ULWord64 audioClockStartTime
4773  PUSHU64(rdtscCurrentTime, outBlob); // ULWord64 rdtscCurrentTime
4774  PUSHU64(audioClockCurrentTime, outBlob); // ULWord64 audioClockCurrentTime
4775  PUSHU32(framesProcessed, outBlob); // ULWord framesProcessed
4776  PUSHU32(framesDropped, outBlob); // ULWord framesDropped
4777  PUSHU32(bufferLevel, outBlob); // ULWord bufferLevel
4778  PUSHU8(bWithAudio, outBlob); // BOOL_ bWithAudio
4779  PUSHU8(bWithRP188, outBlob); // BOOL_ bWithRP188
4780  PUSHU8(bFbfChange, outBlob); // BOOL_ bFbfChange
4781  PUSHU8(bFboChange, outBlob); // BOOL_ bFboChange
4782  PUSHU8(bWithColorCorrection, outBlob); // BOOL_ bWithColorCorrection
4783  PUSHU8(bWithVidProc, outBlob); // BOOL_ bWithVidProc
4784  PUSHU8(bWithCustomAncData, outBlob); // BOOL_ bWithCustomAncData
4785  return true;
4786  }
4787 
4788  bool AUTOCIRCULATE_STATUS_STRUCT::RPCDecode (const RPCBlob & inBlob, size_t & inOutIndex)
4789  { uint16_t v16(0); uint32_t v32(0);
4790  POPU16(v16, inBlob, inOutIndex); // NTV2Crosspoint channelSpec
4791  channelSpec = NTV2Crosspoint(v16);
4792  POPU16(v16, inBlob, inOutIndex); // NTV2AutoCirculateState state
4793  state = NTV2AutoCirculateState(v16);
4794  POPU32(v32, inBlob, inOutIndex); // LWord startFrame
4795  startFrame = LWord(v32);
4796  POPU32(v32, inBlob, inOutIndex); // LWord endFrame
4797  endFrame = LWord(v32);
4798  POPU32(v32, inBlob, inOutIndex); // LWord activeFrame
4799  activeFrame = LWord(v32);
4800  POPU64(rdtscStartTime, inBlob, inOutIndex); // ULWord64 rdtscStartTime
4801  POPU64(audioClockStartTime, inBlob, inOutIndex); // ULWord64 audioClockStartTime
4802  POPU64(rdtscCurrentTime, inBlob, inOutIndex); // ULWord64 rdtscCurrentTime
4803  POPU64(audioClockCurrentTime, inBlob, inOutIndex); // ULWord64 audioClockCurrentTime
4804  POPU32(framesProcessed, inBlob, inOutIndex); // ULWord framesProcessed
4805  POPU32(framesDropped, inBlob, inOutIndex); // ULWord framesDropped
4806  POPU32(bufferLevel, inBlob, inOutIndex); // ULWord bufferLevel
4807  POPU8(AsU8Ref(bWithAudio), inBlob, inOutIndex); // BOOL_ bWithAudio
4808  POPU8(AsU8Ref(bWithRP188), inBlob, inOutIndex); // BOOL_ bWithRP188
4809  POPU8(AsU8Ref(bFbfChange), inBlob, inOutIndex); // BOOL_ bFbfChange
4810  POPU8(AsU8Ref(bFboChange), inBlob, inOutIndex); // BOOL_ bFboChange
4811  POPU8(AsU8Ref(bWithColorCorrection), inBlob, inOutIndex);// BOOL_ bWithColorCorrection
4812  POPU8(AsU8Ref(bWithVidProc), inBlob, inOutIndex); // BOOL_ bWithVidProc
4813  POPU8(AsU8Ref(bWithCustomAncData), inBlob, inOutIndex); // BOOL_ bWithCustomAncData
4814  return true;
4815  }
4816 
4818  {
4819  PUSHU32(DBB, outBlob); // ULWord DBB
4820  PUSHU32(Low, outBlob); // ULWord Low
4821  PUSHU32(High, outBlob); // ULWord High
4822  return true;
4823  }
4824 
4825  bool RP188_STRUCT::RPCDecode (const RPCBlob & inBlob, size_t & inOutIndex)
4826  {
4827  POPU32(DBB, inBlob, inOutIndex); // ULWord DBB
4828  POPU32(Low, inBlob, inOutIndex); // ULWord Low
4829  POPU32(High, inBlob, inOutIndex); // ULWord High
4830  return true;
4831  }
4832 
4833 
4835  {
4836  PUSHU32(taskVersion, outBlob); // ULWord taskVersion
4837  PUSHU32(taskSize, outBlob); // ULWord taskSize
4838  PUSHU32(numTasks, outBlob); // ULWord numTasks
4839  PUSHU32(maxTasks, outBlob); // ULWord maxTasks
4840  PUSHU64(ULWord64(taskArray), outBlob); // ULWord taskArray
4841  if (taskArray && numTasks)
4842  for (ULWord num(0); num < numTasks; num++)
4843  {
4844  const AutoCircGenericTask & task (taskArray[num]);
4845  PUSHU32(task.taskType, outBlob); // AutoCircTaskType taskType
4846  const ULWord * pULWords = reinterpret_cast<const ULWord*>(&task.u);
4847  ULWord numWords(0);
4848  if (NTV2_IS_REGISTER_TASK(task.taskType))
4849  numWords = sizeof(AutoCircRegisterTask)/sizeof(ULWord);
4850  else if (NTV2_IS_TIMECODE_TASK(task.taskType))
4851  numWords = sizeof(AutoCircTimeCodeTask)/sizeof(ULWord);
4852  for (ULWord word(0); word < numWords; word++)
4853  PUSHU32(pULWords[word], outBlob);
4854  }
4855  return true;
4856  }
4857 
4858  bool AUTOCIRCULATE_TASK_STRUCT::RPCDecode (const RPCBlob & inBlob, size_t & inOutIndex)
4859  { ULWord u32(0); ULWord64 u64(0);
4860  POPU32(taskVersion, inBlob, inOutIndex); // ULWord taskVersion
4861  POPU32(taskSize, inBlob, inOutIndex); // ULWord taskSize
4862  POPU32(numTasks, inBlob, inOutIndex); // ULWord numTasks
4863  POPU32(maxTasks, inBlob, inOutIndex); // ULWord maxTasks
4864  POPU64(u64, inBlob, inOutIndex); // ULWord taskArray
4865  taskArray = reinterpret_cast<AutoCircGenericTask*>(u64);
4866  if (taskArray && numTasks)
4867  for (ULWord num(0); num < numTasks; num++)
4868  {
4869  AutoCircGenericTask & task (taskArray[num]);
4870  POPU32(u32, inBlob, inOutIndex); // AutoCircTaskType taskType
4871  task.taskType = AutoCircTaskType(u32);
4872  ULWord * pULWords = reinterpret_cast<ULWord*>(&task.u);
4873  ULWord numWords(0);
4874  if (NTV2_IS_REGISTER_TASK(task.taskType))
4875  numWords = sizeof(AutoCircRegisterTask)/sizeof(ULWord);
4876  else if (NTV2_IS_TIMECODE_TASK(task.taskType))
4877  numWords = sizeof(AutoCircTimeCodeTask)/sizeof(ULWord);
4878  for (ULWord word(0); word < numWords; word++)
4879  POPU32(pULWords[word], inBlob, inOutIndex);
4880  }
4881  return true;
4882  }
4883 
4885  {
4886  PUSHU16(UWord(channelSpec), outBlob); // NTV2Crosspoint channelSpec
4887  PUSHU64(ULWord64(frameTime), outBlob); // LWord64 frameTime
4888  PUSHU32(frame, outBlob); // ULWord frame
4889  PUSHU64(audioClockTimeStamp, outBlob); // ULWord64 audioClockTimeStamp
4890  PUSHU32(audioExpectedAddress, outBlob); // ULWord audioExpectedAddress
4891  PUSHU32(audioInStartAddress, outBlob); // ULWord audioInStartAddress
4892  PUSHU32(audioInStopAddress, outBlob); // ULWord audioInStopAddress
4893  PUSHU32(audioOutStopAddress, outBlob); // ULWord audioOutStopAddress
4894  PUSHU32(audioOutStartAddress, outBlob); // ULWord audioOutStartAddress
4895  PUSHU32(bytesRead, outBlob); // ULWord bytesRead
4896  PUSHU32(startSample, outBlob); // ULWord startSample
4897  PUSHU64(ULWord64(currentTime), outBlob); // LWord64 currentTime
4898  PUSHU32(currentFrame, outBlob); // ULWord currentFrame
4899  currentRP188.RPCEncode(outBlob); // RP188_STRUCT currentRP188
4900  PUSHU64(ULWord64(currentFrameTime), outBlob); // LWord64 currentFrameTime
4901  PUSHU64(audioClockCurrentTime, outBlob); // ULWord64 audioClockCurrentTime
4902  PUSHU32(currentAudioExpectedAddress, outBlob); // ULWord currentAudioExpectedAddress
4903  PUSHU32(currentAudioStartAddress, outBlob); // ULWord currentAudioStartAddress
4904  PUSHU32(currentFieldCount, outBlob); // ULWord currentFieldCount
4905  PUSHU32(currentLineCount, outBlob); // ULWord currentLineCount
4906  PUSHU32(currentReps, outBlob); // ULWord currentReps
4907  PUSHU32(currenthUser, outBlob); // ULWord currenthUser
4908  return true;
4909  }
4910 
4911  bool FRAME_STAMP_STRUCT::RPCDecode (const RPCBlob & inBlob, size_t & inOutIndex)
4912  { uint16_t v16(0); uint64_t v64(0);
4913  POPU16(v16, inBlob, inOutIndex); // NTV2Crosspoint channelSpec
4914  channelSpec = NTV2Crosspoint(v16);
4915  POPU64(v64, inBlob, inOutIndex); // LWord64 frameTime
4916  frameTime = LWord64(v64);
4917  POPU32(frame, inBlob, inOutIndex); // ULWord frame
4918  POPU64(audioClockTimeStamp, inBlob, inOutIndex); // ULWord64 audioClockTimeStamp
4919  POPU32(audioExpectedAddress, inBlob, inOutIndex); // ULWord audioExpectedAddress
4920  POPU32(audioInStartAddress, inBlob, inOutIndex); // ULWord audioInStartAddress
4921  POPU32(audioInStopAddress, inBlob, inOutIndex); // ULWord audioInStopAddress
4922  POPU32(audioOutStopAddress, inBlob, inOutIndex); // ULWord audioOutStopAddress
4923  POPU32(audioOutStartAddress, inBlob, inOutIndex); // ULWord audioOutStartAddress
4924  POPU32(bytesRead, inBlob, inOutIndex); // ULWord bytesRead
4925  POPU32(startSample, inBlob, inOutIndex); // ULWord startSample
4926  POPU64(v64, inBlob, inOutIndex); // LWord64 currentTime
4927  currentTime = LWord64(v64);
4928  POPU32(currentFrame, inBlob, inOutIndex); // ULWord currentFrame
4929  currentRP188.RPCDecode(inBlob, inOutIndex); // RP188_STRUCT currentRP188
4930  POPU64(v64, inBlob, inOutIndex); // LWord64 currentFrameTime
4931  currentFrameTime = LWord64(v64);
4932  POPU64(audioClockCurrentTime, inBlob, inOutIndex); // ULWord64 audioClockCurrentTime
4933  POPU32(currentAudioExpectedAddress, inBlob, inOutIndex);// ULWord currentAudioExpectedAddress
4934  POPU32(currentAudioStartAddress, inBlob, inOutIndex); // ULWord currentAudioStartAddress
4935  POPU32(currentFieldCount, inBlob, inOutIndex); // ULWord currentFieldCount
4936  POPU32(currentLineCount, inBlob, inOutIndex); // ULWord currentLineCount
4937  POPU32(currentReps, inBlob, inOutIndex); // ULWord currentReps
4938  POPU32(currenthUser, inBlob, inOutIndex); // ULWord currenthUser
4939  return true;
4940  }
4941 
4943  {
4944  PUSHU16(UWord(eCommand), outBlob); // AUTO_CIRC_COMMAND eCommand
4945  PUSHU16(UWord(channelSpec), outBlob); // NTV2Crosspoint channelSpec
4946  PUSHU32(ULWord(lVal1), outBlob); // LWord lVal1
4947  PUSHU32(ULWord(lVal2), outBlob); // LWord lVal2
4948  PUSHU32(ULWord(lVal3), outBlob); // LWord lVal3
4949  PUSHU32(ULWord(lVal4), outBlob); // LWord lVal4
4950  PUSHU32(ULWord(lVal5), outBlob); // LWord lVal5
4951  PUSHU32(ULWord(lVal6), outBlob); // LWord lVal6
4952  PUSHU8(bVal1, outBlob); // BOOL_ bVal1
4953  PUSHU8(bVal2, outBlob); // BOOL_ bVal2
4954  PUSHU8(bVal3, outBlob); // BOOL_ bVal3
4955  PUSHU8(bVal4, outBlob); // BOOL_ bVal4
4956  PUSHU8(bVal5, outBlob); // BOOL_ bVal5
4957  PUSHU8(bVal6, outBlob); // BOOL_ bVal6
4958  PUSHU8(bVal7, outBlob); // BOOL_ bVal7
4959  PUSHU8(bVal8, outBlob); // BOOL_ bVal8
4960  PUSHU64(ULWord64(pvVal1), outBlob); // void* pvVal1
4961  PUSHU64(ULWord64(pvVal2), outBlob); // void* pvVal2
4962  PUSHU64(ULWord64(pvVal3), outBlob); // void* pvVal3
4963  PUSHU64(ULWord64(pvVal4), outBlob); // void* pvVal4
4964  if (eCommand == eGetAutoCirc && pvVal1)
4965  reinterpret_cast<AUTOCIRCULATE_STATUS_STRUCT*>(pvVal1)->RPCEncode(outBlob);
4966  if ((eCommand == eGetFrameStamp || eCommand == eGetFrameStampEx2) && pvVal1)
4967  reinterpret_cast<FRAME_STAMP_STRUCT*>(pvVal1)->RPCEncode(outBlob);
4968  if (eCommand == eGetFrameStampEx2 && pvVal2)
4969  reinterpret_cast<AUTOCIRCULATE_TASK_STRUCT*>(pvVal2)->RPCEncode(outBlob);
4970  if (eCommand == eTransferAutoCirculate && pvVal1)
4971  reinterpret_cast<AUTOCIRCULATE_TRANSFER_STRUCT*>(pvVal1)->RPCEncode(outBlob);
4972  return true;
4973  }
4974 
4975  bool AUTOCIRCULATE_DATA::RPCDecode (const RPCBlob & inBlob, size_t & inOutIndex)
4976  {
4977 #if defined(AJA_LINUX)
4978  #pragma GCC diagnostic push
4979  #pragma GCC diagnostic ignored "-Wstrict-aliasing"
4980 #endif
4981  uint16_t v16(0); uint32_t v32(0);
4982  POPU16(v16, inBlob, inOutIndex); // AUTO_CIRC_COMMAND eCommand
4983  eCommand = AUTO_CIRC_COMMAND(v16);
4984  POPU16(v16, inBlob, inOutIndex); // NTV2Crosspoint channelSpec
4985  channelSpec = NTV2Crosspoint(v16);
4986  POPU32(v32, inBlob, inOutIndex); lVal1 = LWord(v32); // LWord lVal1
4987  POPU32(v32, inBlob, inOutIndex); lVal2 = LWord(v32); // LWord lVal2
4988  POPU32(v32, inBlob, inOutIndex); lVal3 = LWord(v32); // LWord lVal3
4989  POPU32(v32, inBlob, inOutIndex); lVal4 = LWord(v32); // LWord lVal4
4990  POPU32(v32, inBlob, inOutIndex); lVal5 = LWord(v32); // LWord lVal5
4991  POPU32(v32, inBlob, inOutIndex); lVal6 = LWord(v32); // LWord lVal6
4992  POPU8(AsU8Ref(bVal1), inBlob, inOutIndex); // BOOL_ bVal1
4993  POPU8(AsU8Ref(bVal2), inBlob, inOutIndex); // BOOL_ bVal2
4994  POPU8(AsU8Ref(bVal3), inBlob, inOutIndex); // BOOL_ bVal3
4995  POPU8(AsU8Ref(bVal4), inBlob, inOutIndex); // BOOL_ bVal4
4996  POPU8(AsU8Ref(bVal5), inBlob, inOutIndex); // BOOL_ bVal5
4997  POPU8(AsU8Ref(bVal6), inBlob, inOutIndex); // BOOL_ bVal6
4998  POPU8(AsU8Ref(bVal7), inBlob, inOutIndex); // BOOL_ bVal7
4999  POPU8(AsU8Ref(bVal8), inBlob, inOutIndex); // BOOL_ bVal8
5000  POPU64(AsU64Ref(pvVal1), inBlob, inOutIndex); // void* pvVal1
5001  POPU64(AsU64Ref(pvVal2), inBlob, inOutIndex); // void* pvVal2
5002  POPU64(AsU64Ref(pvVal3), inBlob, inOutIndex); // void* pvVal3
5003  POPU64(AsU64Ref(pvVal4), inBlob, inOutIndex); // void* pvVal4
5004 #if defined(AJA_LINUX)
5005  #pragma GCC diagnostic pop
5006 #endif
5007  if (eCommand == eGetAutoCirc && pvVal1)
5008  reinterpret_cast<AUTOCIRCULATE_STATUS_STRUCT*>(pvVal1)->RPCDecode(inBlob, inOutIndex);
5009  if ((eCommand == eGetFrameStamp || eCommand == eGetFrameStampEx2) && pvVal1)
5010  reinterpret_cast<FRAME_STAMP_STRUCT*>(pvVal1)->RPCDecode(inBlob, inOutIndex);
5011  if (eCommand == eGetFrameStampEx2 && pvVal2)
5012  reinterpret_cast<AUTOCIRCULATE_TASK_STRUCT*>(pvVal2)->RPCDecode(inBlob, inOutIndex);
5013  if (eCommand == eTransferAutoCirculate && pvVal1)
5014  reinterpret_cast<AUTOCIRCULATE_TRANSFER_STRUCT*>(pvVal1)->RPCDecode(inBlob, inOutIndex);
5015  return true;
5016  }
NTV2_RP188 acRP188
Will be deprecated – use AUTOCIRCULATE_TRANSFER::SetOutputTimeCode instead.
bool AppendU8s(UByteSequence &outU8s) const
Appends my contents to an existing UByteSequence.
bool RPCEncode(NTV2_RPC_BLOB_TYPE &outBlob)
NTV2Channel mChannel
Stream channel.
bool SetOutputTimeCodes(const NTV2TimeCodes &inValues)
Intended for playout, replaces the contents of my acOutputTimeCodes member.
std::set< NTV2VideoFormat > NTV2VideoFormatSet
A set of distinct NTV2VideoFormat values.
NTV2SegmentedXferInfo & setSourceDirection(const bool inTopDown)
Sets the scan direction for the source.
NTV2AutoCirculateState state
ULWord acCurrentAudioStartAddress
As set by play.
NTV2Buffer acOutputTimeCodes
Intended for playout, this is an ordered sequence of NTV2_RP188 values to send to the device...
#define NTV2_TYPE_MESSAGE_DATA
Identifies NTV2MessageData struct.
const char * NTV2InterruptEnumString(const unsigned inInterruptEnum)
Definition: ntv2debug.cpp:1183
Everything needed to call CNTV2Card::ReadRegister or CNTV2Card::WriteRegister functions.
NTV2FrameRate GetNTV2FrameRateFromVideoFormat(const NTV2VideoFormat inVideoFormat)
Definition: ntv2utils.cpp:3630
bool GetBadRegisters(NTV2RegNumSet &outBadRegNums) const
Returns the set of register numbers that were not read successfully.
NTV2StandardSet::const_iterator NTV2StandardSetConstIter
A handy const iterator for iterating over an NTV2StandardSet.
#define NTV2_TYPE_AJABITSTREAM
Identifies NTV2Bitstream struct.
ULWord mFlags
Action flags.
ULWord audioInStopAddress
For record - end position (exclusive) in buffer of audio (includes base offset)
std::string NTV2FrameGeometryToString(const NTV2FrameGeometry inValue, const bool inForRetailDisplay=false)
Definition: ntv2utils.cpp:6982
bool GetRequestedRegisterNumbers(NTV2RegNumSet &outRegNums) const
Answers with the set of register numbers that were requested.
std::string NTV2AudioSystemToString(const NTV2AudioSystem inValue, const bool inCompactDisplay=false)
Definition: ntv2utils.cpp:5749
NTV2_TRAILER mTrailer
The common structure trailer – ALWAYS LAST!
ULWord frame
The frame requested or -1 if not available.
NTV2Buffer mHandles
Optional buffer to store subscribed HANDLEs.
#define NTV2EndianSwap64(__val__)
Definition: ntv2endian.h:25
bool RPCEncode(NTV2_RPC_BLOB_TYPE &outBlob)
std::string NTV2HDMIBitDepthToString(const NTV2HDMIBitDepth inValue, const bool inCompactDisplay=false)
Definition: ntv2utils.cpp:6649
std::ostream & Print(std::ostream &inOutStream) const
Prints a human-readable representation of me to the given output stream.
std::string operator[](const unsigned inIndexNum) const
NTV2AudioSystem
Used to identify an Audio System on an NTV2 device. See Audio System Operation for more information...
Definition: ntv2enums.h:3901
#define AJA_NTV2_SDK_BUILD_NUMBER
The SDK build number, an unsigned decimal integer.
Definition: ntv2version.h:16
#define NTV2_HEADER_TAG
Identifies the struct header.
ULWord acCurrentFrame
Last vertical blank frame for this autocirculate channel (when CNTV2Card::AutoCirculateGetFrameStamp ...
NTV2OutputDestinations::const_iterator NTV2OutputDestinationsConstIter
A handy const iterator for iterating over an NTV2OutputDestinations.
bool CopyTo(FRAME_STAMP_STRUCT &outOldStruct) const
Copies my fields into the given FRAME_STAMP_STRUCT.
YCbCr color space.
Definition: ntv2enums.h:3615
For devices that support it (see NTV2DeviceCanDoSDIErrorChecks ), this struct reports SDI input error...
bool IsValid(const bool chkTrailer=false) const
bool PutU16s(const UWordSequence &inU16s, const size_t inU16Offset=0, const bool inByteSwap=false)
Copies a vector of unsigned 16-bit values into me.
Specifies SDI input/output kinds.
Definition: ntv2enums.h:1296
std::set< NTV2TCIndex > NTV2TCIndexes
ULWord currentAudioStartAddress
As found by isr.
bool RPCDecode(const NTV2_RPC_BLOB_TYPE &inBlob, size_t &inOutIndex)
FRAME_STAMP()
Constructs a default FRAME_STAMP structure.
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...
ULWord64 acInUserCookie
Intended for playout, an optional app-specific cookie value that tags this frame, such that if this s...
void SetFlags(const ULWord inFlags)
Sets the action flags for use in a subsequent call to CNTV2Card::LoadBitstream.
#define NTV2HostIsBigEndian
Definition: ntv2endian.h:58
NTV2_HEADER mHeader
The common structure header – ALWAYS FIRST!
bool GetSDIInputStatus(NTV2SDIInputStatus &outStatus, const UWord inSDIInputIndex0=0) const
Answers with the NTV2SDIInputStatus for the given SDI input spigot.
NTV2Buffer & operator=(const NTV2Buffer &inRHS)
Assigns me from another NTV2Buffer instance.
LWord64 currentTime
Current processor time ... on Windows, this is derived from KeQueryPerformanceCounter.
NTV2SetRegisters(const NTV2RegWrites &inRegWrites=NTV2RegWrites())
Constructs an NTV2SetRegisters struct from the given NTV2RegisterWrites collection.
Declares the AJAMemory class.
std::set< NTV2FrameRate > NTV2FrameRateSet
A set of distinct NTV2FrameRate values. New in SDK 17.0.
NTV2StreamBuffer()
Constructs a default NTV2StreamBuffer struct.
NTV2Crosspoint
Logically, these are an NTV2Channel combined with an NTV2Mode.
Definition: ntv2enums.h:1705
mVideoBuffer Allocate(mFormatDesc.GetTotalRasterBytes())
std::ostream & Print(std::ostream &inStrm, const bool inDumpSegments=false) const
Writes a human-readable description of me into a given output stream.
void PUSHU32(const uint32_t val, RPCBlob &blob, const bool dontSwap=false)
Pushes a 32-bit value onto the given byte sequence.
Definition: ntv2nubtypes.h:63
bool CopyTo(AUTOCIRCULATE_STATUS_STRUCT &outOldStruct)
Copies my data into the given AUTOCIRCULATE_STATUS_STRUCT.
unsigned long long stoull(const std::string &str, std::size_t *idx, int base)
Definition: common.cpp:154
ULWord registerMask
My register mask value to use in a ReadRegister or WriteRegister call.
bool SetFrameBufferFormat(const NTV2FrameBufferFormat inNewFormat)
Sets my acFrameBufferFormat value to the given new value (if valid and circulating with AUTOCIRCULATE...
NTV2DeviceIDSet NTV2GetSupportedDevices(const NTV2DeviceKinds inKinds=NTV2_DEVICEKIND_ALL)
Returns an NTV2DeviceIDSet of devices supported by the SDK.
Definition: ntv2utils.cpp:7419
std::vector< double > NTV2DoubleArray
An array of double-precision floating-point values.
NTV2HDMIColorSpace
Indicates or specifies HDMI Color Space.
Definition: ntv2enums.h:3611
#define NTV2_IS_TIMECODE_TASK(_x_)
void Clear(void)
Resets the struct to its initialized state, with timecode capture disabled, freeing all buffers that ...
bool WithCustomAnc(void) const
bool IsNULL(void) const
NTV2Buffer mSharedMemory
Virtual address of AJADebug shared memory in calling process&#39; context,.
ULWord audioOutStartAddress
For play - end position (exclusive) in buffer of audio.
NTV2RegNumSet GetRegisterNumbers(const NTV2RegReads &inRegInfos)
std::ostream & Print(std::ostream &outputStream, const bool inAsCode=false) const
Renders me to the given output stream in a human-readable format.
CHAR * pName
Definition: amvideo.cpp:26
#define DEC0N(__x__, __n__)
ULWord getElementLength(void) const
NTV2RegInfo & setMask(const ULWord val)
string NTV2ChannelSetToStr(const NTV2ChannelSet &inObj, const bool inCompact)
1920x1080, for 1080i and 1080p, NTV2_VANCMODE_TALL
Definition: ntv2enums.h:363
ULWord mFlags
Action flags.
NTV2FrameBufferFormat
Identifies a particular video frame buffer pixel format. See Device Frame Buffer Formats for details...
Definition: ntv2enums.h:223
bool RPCDecode(const NTV2_RPC_BLOB_TYPE &inBlob, size_t &inOutIndex)
bool EnableSegmentedDMAs(const ULWord inNumSegments, const ULWord inNumActiveBytesPerLine, const ULWord inHostBytesPerLine, const ULWord inDeviceBytesPerLine)
Enables segmented DMAs given a segment count, a host pitch, and device pitch value.
NTV2ChannelSet::const_iterator NTV2ChannelSetConstIter
A handy const iterator into an NTV2ChannelSet.
ULWord getTotalBytes(void) const
bool SetBuffers(ULWord *pInVideoBuffer, const ULWord inVideoByteCount, ULWord *pInAudioBuffer, const ULWord inAudioByteCount, ULWord *pInANCBuffer, const ULWord inANCByteCount, ULWord *pInANCF2Buffer=NULL, const ULWord inANCF2ByteCount=0)
Sets my buffers for use in a subsequent call to CNTV2Card::AutoCirculateTransfer. ...
NTV2_HEADER acHeader
The common message header – ALWAYS FIRST!
bool RPCEncode(NTV2_RPC_BLOB_TYPE &outBlob)
bool RPCEncode(NTV2_RPC_BLOB_TYPE &outBlob)
NTV2StringSet::const_iterator NTV2StringSetConstIter
~AUTOCIRCULATE_TRANSFER()
My default destructor, which frees all allocatable fields that I own.
Declares the AJADebug class.
bool CopyFrom(const void *pInSrcBuffer, const ULWord inByteCount)
Replaces my contents from the given memory buffer, resizing me to the new byte count.
720x576, for PAL 625i, NTV2_VANCMODE_TALL
Definition: ntv2enums.h:362
See 10-Bit YCbCr Format.
Definition: ntv2enums.h:226
#define GetTCIndexesForSDIInput
Definition: ntv2utils.h:592
bool Set(const NTV2ColorCorrectionMode inMode, const ULWord inSaturation, const void *pInTableData)
Sets this struct from the given mode, saturation and table data, replacing any existing mode...
static ULWord FGWidth(const NTV2FrameGeometry fg)
std::set< NTV2InputSource > NTV2InputSourceSet
A set of distinct NTV2InputSource values.
ULWord acCurrentReps
Contains validCount (Playout: on repeated frames, number of reps remaining; Record: drops on frame) ...
bool NTV2GetUnsupportedStandards(NTV2StandardSet &outStandards)
Returns a set of NTV2Standard values not suported by any NTV2 device.
ULWord acAudioInStopAddress
(input/ingest/capture only) Ending audio record head position (exclusive) AFTER this frame was stampe...
1280x720, for 720p, NTV2_VANCMODE_OFF
Definition: ntv2enums.h:356
std::string NTV2OutputDestinationToString(const NTV2OutputDestination inValue, const bool inForRetailDisplay=false)
Definition: ntv2utils.cpp:7066
bool RPCEncode(NTV2_RPC_BLOB_TYPE &outBlob)
int Fixed_
Definition: ajatypes.h:302
enum _NTV2VideoFormat NTV2VideoFormat
Identifies a particular video format.
static bool SetDefaultPageSize(const size_t inNewSize)
Changes the default page size for use in future page-aligned allocations.
bool ByteSwap32(void)
Byte-swaps my contents 32-bits at a time.
NTV2_HEADER mHeader
The common structure header – ALWAYS FIRST!
static std::string OpName(const ULWord op)
static uint64_t GetPid()
Definition: process.cpp:35
ULWord GetBufferLevel(void) const
NTV2StringList::const_iterator NTV2StringListConstIter
enum NTV2VideoFrameBufferOrientation NTV2FBOrientation
bool WithFBOChange(void) const
bool IsContentEqual(const NTV2Buffer &inBuffer, const ULWord inByteOffset=0, const ULWord inByteCount=0xFFFFFFFF) const
AutoCircVidProcInfo acVidProcInfo
Specifies the mixer/keyer transition to make. Ignored if AUTOCIRCULATE_WITH_VIDPROC option is not set...
bool isSourceTopDown(void) const
NTV2SDIInStatistics()
Constructs an NTV2GetSDIStatistics struct and initializes it to its default state.
void SetMaxLockSize(const ULWord64 inNumBytes)
Sets the maximum lock size for use in a subsequent call to CNTV2Card::DMABufferLock.
NTV2ConfigInterrupt & setOperation(const ULWord op)
Sets my operation; also stores caller&#39;s PID & TID.
bool ResetUsing(const NTV2RegNumSet &inRegisterNumbers)
Resets me, starting over, now using the given NTV2RegisterNumberSet.
NTV2TimeCodeList::const_iterator NTV2TimeCodeListConstIter
A handy const interator for iterating over an NTV2TimeCodeList.
AutoCircTaskType
These are the available AutoCirculate task types.
uint32_t U32(const int inIndex) const
ULWord acAudioStartSample
Starting audio sample (valid for capture only).
AutoCircVidProcMode
ULWordSequence::const_iterator ULWordSequenceConstIter
A handy const iterator for iterating over a ULWordSequence.
bool RPCDecode(const NTV2_RPC_BLOB_TYPE &inBlob, size_t &inOutIndex)
AUTOCIRCULATE_TRANSFER_STATUS()
Constructs a default AUTOCIRCULATE_TRANSFER_STATUS structure.
ULWord bytesRead
Total audio and video bytes transfered.
bool IsValid(void) const
Answers true if I&#39;m valid, or false if I&#39;m not valid.
ULWord GetByteCount(void) const
NTV2_TRAILER acTrailer
The common structure trailer – ALWAYS LAST!
#define NTV2_TYPE_AJAMAILBUFFER
Identifies NTV2MailBuffer struct.
ULWord audioExpectedAddress
The address that was used to transfer.
Configure interrupt (subscribe/unsubscribe, enable/disable, query subscribed interrupts, query enabled interrupts, etc.).
NTV2RegWrites::const_iterator NTV2RegisterWritesConstIter
bool RPCDecode(const NTV2_RPC_BLOB_TYPE &inBlob, size_t &inOutIndex, bool fillBuffer=true)
LWord acStartFrame
First frame to circulate. FIXFIXFIX Why is this signed? CHANGE TO ULWord??
#define NTV2SDKVersionDecode_Minor
std::map< ULWord, ULWord > NTV2RegisterValueMap
A mapping of distinct NTV2RegisterNumbers to their corresponding ULWord values.
ULWord getDestPitch(void) const
ULWord mSpares[32]
Reserved for future use.
std::string NTV2RegisterNumberToString(const NTV2RegisterNumber inValue)
Definition: ntv2utils.cpp:7588
ULWordSetConstIter NTV2RegNumSetConstIter
A const iterator that iterates over a set of distinct NTV2RegisterNumbers.
bool PutU64s(const ULWord64Sequence &inU64s, const size_t inU64Offset=0, const bool inByteSwap=false)
Copies a vector of unsigned 64-bit values into me.
NTV2SegmentedDMAInfo()
Constructs a disabled NTV2SegmentedDMAInfo struct.
int32_t LWord
Definition: ajatypes.h:235
bool RPCEncode(NTV2_RPC_BLOB_TYPE &outBlob)
NTV2Buffer acVideoBuffer
The host video buffer. This field is owned by the client application, and thus is responsible for all...
#define AUTOCIRCULATE_WITH_FBFCHANGE
Use this to AutoCirculate with the possibility of frame buffer format changes.
ULWord mIsWriting
If non-zero, virtual data will be written; otherwise, virtual data will be read.
Specifies HDMI input/output kinds.
Definition: ntv2enums.h:1297
NTV2ConfigInterrupt(const void *pClient=nullptr)
Default ctor, optionally set clientID if needed.
LWord64 acFrameTime
(input/ingest/capture only) The absolute timestamp at the VBI when the frame started recording into d...
NTV2AudioSystemSet NTV2MakeAudioSystemSet(const NTV2AudioSystem inFirstAudioSystem, const UWord inCount)
NTV2ChannelSet NTV2MakeChannelSet(const NTV2Channel inFirstChannel, const UWord inNumChannels)
ULWord ccSaturationValue
My saturation value, used only in 3-way color correction mode.
bool RPCDecode(const NTV2_RPC_BLOB_TYPE &inBlob, size_t &inOutIndex)
if(!(riid==IID_IUnknown) &&!(riid==IID_IClassFactory))
Definition: dllentry.cpp:196
FRAME_STAMP acFrameStamp
Frame stamp for the transferred frame.
AUTOCIRCULATE_DATA(const AUTO_CIRC_COMMAND inCommand=AUTO_CIRC_COMMAND_INVALID, const NTV2Crosspoint inCrosspoint=NTV2CROSSPOINT_INVALID)
NTV2RegisterReadsConstIter FindFirstMatchingRegisterNumber(const uint32_t inRegNum, const NTV2RegisterReads &inRegInfos)
Returns a const iterator to the first entry in the NTV2RegInfo collection with a matching register nu...
std::string NTV2ColorCorrectionModeToString(const NTV2ColorCorrectionMode inValue, const bool inCompactDisplay=false)
Definition: ntv2utils.cpp:7608
NTV2_TRAILER mTrailer
The common structure trailer – ALWAYS LAST!
NTV2AudioChannelQuads::const_iterator NTV2AudioChannelQuadsConstIter
Handy const iterator to iterate over a set of distinct NTV2AudioChannelQuad values.
bool containsElementAtOffset(const ULWord inElementOffset) const
NTV2_TRAILER mTrailer
The common structure trailer – ALWAYS LAST!
bool DisableSegmentedDMAs(void)
Disables segmented DMAs, performing a Reset on my acInSegmentedDMAInfo.
LWord64 acCurrentTime
The absolute timestamp at the moment the CNTV2Card::AutoCirculateTransfer or CNTV2Card::AutoCirculate...
Defines a number of handy byte-swapping macros.
bool GetGoodRegisters(NTV2RegNumSet &outGoodRegNums) const
Returns an NTV2RegNumSet built from my mOutGoodRegisters field.
The "default" timecode (mostly used by the AJA "Retail" service and Control Panel) ...
Definition: ntv2enums.h:3959
bool SetOutputTimeCode(const NTV2_RP188 &inTimecode, const NTV2TCIndex inTCIndex=NTV2_TCINDEX_SDI1)
Intended for playout, sets one element of my acOutputTimeCodes member.
ULWord value(void) const
NTV2_HEADER mHeader
The common structure header – ALWAYS FIRST!
bool NTV2DeviceCanDoFrameBufferFormat(const NTV2DeviceID inDeviceID, const NTV2FrameBufferFormat inFBFormat)
bool RPCDecode(const NTV2_RPC_BLOB_TYPE &inBlob, size_t &inOutIndex)
NTV2FrameBufferFormatSet NTV2PixelFormats
#define NTV2_IS_VALID_TIMECODE_INDEX(__x__)
Definition: ntv2enums.h:3990
ULWord currentFrame
Last vertical blank frame for this channel&#39;s auto-circulate. (at the time of the IOCTL_NTV2_GET_FRAME...
ULWord mResult
Out: 0=false (fail), 1 or non-zero == true (success)
static string print_address_offset(const size_t inRadix, const ULWord64 inOffset)
bool POPU8(uint8_t &outVal, const RPCBlob &blob, std::size_t &inOutNdx)
Pops an 8-bit value off the given byte sequence at the given zero-based index position.
Definition: ntv2nubtypes.h:110
2048x1080, for 2Kx1080p, NTV2_VANCMODE_TALL
Definition: ntv2enums.h:368
Definition: json.hpp:5362
FGSizesMap::const_iterator FGSizesMapCI
NTV2HDMIAudioChannels
Indicates or specifies the HDMI audio channel count.
Definition: ntv2enums.h:3673
NTV2FBOrientation acFrameBufferOrientation
Specifies the frame buffer orientation to change to. Ignored if AUTOCIRCULATE_WITH_FBOCHANGE option i...
std::ostream & Print(std::ostream &inOutStream) const
Prints a human-readable representation of me into the given output stream.
std::set< NTV2OutputDestination > NTV2OutputDestinations
A set of distinct NTV2OutputDestination values.
ULWord count(void) const
bool isSourceBottomUp(void) const
ULWord acInVideoDMAOffset
Optional byte offset into the device frame buffer. Defaults to zero. If non-zero, should be a multipl...
#define NTV2_TYPE_GETREGS
Identifies NTV2GetRegisters struct.
#define NTV2_COLORCORRECTOR_TABLESIZE
#define false
ULWord mTag
Tag for virtual data. This value is used to recall saved data by tag.
LWord acActiveFrame
Current frame actually being captured/played when CNTV2Card::AutoCirculateGetStatus called...
bool GetFailedRegisterWrites(NTV2RegWrites &outFailedRegWrites) const
Returns an NTV2RegisterWrites built from my mOutBadRegInfos field.
#define NTV2_TYPE_ACSTATUS
Identifies AUTOCIRCULATE_STATUS struct.
#define AJA_NTV2_SDK_VERSION_POINT
The SDK "point" release version, an unsigned decimal integer.
Definition: ntv2version.h:15
NTV2HDMIRange
Indicates or specifies the HDMI RGB range.
Definition: ntv2enums.h:3641
uint32_t ULWord
Definition: ajatypes.h:236
NTV2SegmentedXferInfo & setElementLength(const ULWord inBytesPerElement)
Sets my element length.
NTV2AudioFormat
Definition: ntv2enums.h:1956
NTV2Channel
These enum values are mostly used to identify a specific widget_framestore. They&#39;re also commonly use...
Definition: ntv2enums.h:1361
bool toHexString(std::string &outStr, const size_t inLineBreakInterval=0) const
Converts my contents into a hex-encoded string.
std::string NTV2AudioFormatToString(const NTV2AudioFormat inValue, const bool inCompactDisplay=false)
Definition: ntv2utils.cpp:6706
Describes a segmented data transfer (copy or move) from a source memory location to a destination loc...
#define NTV2_TYPE_BANKGETSET
Identifies NTV2BankSelGetSetRegs struct.
std::vector< NTV2RegInfo > NTV2RegWrites
An ordered sequence of zero or more NTV2RegInfo structs intended for WriteRegister.
virtual char do_thousands_sep() const
NTV2_HEADER mHeader
The common structure header – ALWAYS FIRST!
Specifies devices that internally use NTV2.
Definition: ntv2enums.h:1402
NTV2FrameRateSet::const_iterator NTV2FrameRateSetConstIter
A handy const iterator for iterating over an NTV2FrameRateSet.
NTV2FrameGeometry GetGeometryFromFrameDimensions(const NTV2FrameSize &inFD)
Definition: ntv2utils.cpp:3957
std::set< NTV2AudioChannelPair > NTV2AudioChannelPairs
A set of distinct NTV2AudioChannelPair values.
NTV2SegmentedXferInfo & swapSourceAndDestination(void)
Swaps my source and destination offsets, pitches and scan directions.
NTV2_HEADER mHeader
The common structure header – ALWAYS FIRST!
#define NTV2_TYPE_ACXFER
Identifies AUTOCIRCULATE_TRANSFER struct.
std::set< NTV2AudioChannelQuad > NTV2AudioChannelQuads
A set of distinct NTV2AudioChannelQuad values.
#define NTV2_OUTPUT_DEST_IS_HDMI(_dest_)
Definition: ntv2enums.h:1348
string NTV2ChannelListToStr(const NTV2ChannelList &inObj, const bool inCompact)
std::set< NTV2Standard > NTV2StandardSet
A set of distinct NTV2Standard values.
NTV2Crosspoint acCrosspoint
Will be deprecated – used internally by the SDK. Will be removed when the driver changes to use NTV2...
bool CopyFrom(const AUTOCIRCULATE_STATUS_STRUCT &inOldStruct)
Copies the given AUTOCIRCULATE_STATUS_STRUCT into me.
#define BIN08(__x__)
ULWord GetProcessedFrameCount(void) const
#define NTV2_ASSERT(_expr_)
Definition: ajatypes.h:489
void PUSHU8(const uint8_t val, RPCBlob &blob)
Pushes an 8-bit value onto the given byte sequence.
Definition: ntv2nubtypes.h:37
std::string AsString(UWord inDumpMaxBytes=0) const
ULWord mFlags
Action flags (lock, unlock, etc)
bool GetInputTimeCodes(NTV2TimeCodeList &outValues) const
Returns all RP188 timecodes associated with the frame in NTV2TCIndex order.
Represents an unknown or invalid frame rate.
Definition: ntv2enums.h:418
std::string operator[](const unsigned inIndexNum) const
std::vector< uint8_t > UByteSequence
An ordered sequence of UByte (uint8_t) values.
NTV2AutoCirculateState acState
Current AutoCirculate state after the transfer.
static AJAStatus StatTimerStop(const uint32_t inKey)
Definition: debug.cpp:1161
bool NTV2DeviceGetSupportedStandards(const NTV2DeviceID inDeviceID, NTV2StandardSet &outStandards)
Returns a set of distinct NTV2Standard values supported on the given device.
NTV2RegWritesConstIter NTV2RegisterReadsConstIter
bool Truncate(const size_t inByteCount)
Truncates me to the given length. No reallocation takes place.
This struct replaces the old RP188_STRUCT.
NTV2GeometrySet::const_iterator NTV2GeometrySetConstIter
A handy const iterator for iterating over an NTV2GeometrySet.
NTV2FrameBufferFormat NTV2PixelFormat
An alias for NTV2FrameBufferFormat.
Definition: ntv2enums.h:264
NTV2_HEADER acHeader
The common structure header – ALWAYS FIRST!
NTV2ColorCorrectionMode ccMode
My mode (off, RGB, YCbCr, or 3-way)
Last virtual register slot.
NTV2_TRAILER acTrailer
The common message trailer – ALWAYS LAST!
static bool IsFourCC(const ULWord in4CC)
NTV2BankSelGetSetRegs(const NTV2RegInfo &inBankSelect, const NTV2RegInfo &inRegInfo, const bool inDoWrite=false)
Constructs an NTV2BankSelGetSetRegs struct for atomically reading or writing the given bank-selected ...
ULWord regNum(void) const
unsigned long stoul(const std::string &str, std::size_t *idx, int base)
Definition: common.cpp:143
NTV2RegInfo & setRegNum(const ULWord val)
2048x1556, for 2Kx1556psf film format, NTV2_VANCMODE_OFF
Definition: ntv2enums.h:366
NTV2TCIndex
These enum values are indexes into the capture/playout AutoCirculate timecode arrays.
Definition: ntv2enums.h:3957
bool Fill(const T &inValue)
Fills me with the given scalar value.
bool Find(const T &inValue, int &inOutIndex) const
Searches me for the given scalar value of type T starting at a given index position.
bool GetString(std::string &outString, const size_t inU8Offset=0, const size_t inMaxSize=128) const
Answers with my contents as a character string.
bool GetRegisterValues(NTV2RegisterValueMap &outValues) const
Returns an NTV2RegisterValueMap built from my mOutGoodRegisters and mOutValues fields.
std::string NTV2InputSourceToString(const NTV2InputSource inValue, const bool inForRetailDisplay=false)
Definition: ntv2utils.cpp:7043
bool Deallocate(void)
Deallocates my user-space storage (if I own it – i.e. from a prior call to Allocate).
bool RPCDecode(const NTV2_RPC_BLOB_TYPE &inBlob, size_t &inOutIndex)
void Clear(void)
Resets me to an invalid state.
ULWord currentReps
At Call Line# currently being OUTPUT (at the time of the IOCTL_NTV2_GET_FRAMESTAMP) ...
NTV2Channel NTV2OutputDestinationToChannel(const NTV2OutputDestination inOutputDest)
Converts a given NTV2OutputDestination to its equivalent NTV2Channel value.
Definition: ntv2utils.cpp:5159
bool IsValid(void) const
std::string AutoCircVidProcModeToString(const AutoCircVidProcMode inValue, const bool inCompactDisplay=false)
Definition: ntv2utils.cpp:7594
UWord NTV2DeviceGetNumHDMIVideoOutputs(const NTV2DeviceID inDeviceID)
ULWord mInNumRegisters
The number of NTV2RegInfo&#39;s to be set.
ULWord operation(void) const
static bool IsReadOnly(const uint32_t inRegNum)
AutoCircVidProcMode mode
NTV2FrameRate
Identifies a particular video frame rate.
Definition: ntv2enums.h:416
NTV2_TRAILER mTrailer
The common structure trailer – ALWAYS LAST!
std::ostream & Print(std::ostream &inOutStream) const
Prints a human-readable representation of me to the given output stream.
NTV2FrameBufferFormat acFrameBufferFormat
Specifies the frame buffer format to change to. Ignored if AUTOCIRCULATE_WITH_FBFCHANGE option is not...
std::string NTV2StandardToString(const NTV2Standard inValue, const bool inForRetailDisplay=false)
Definition: ntv2utils.cpp:6914
bool RPCEncode(NTV2_RPC_BLOB_TYPE &outBlob)
#define NTV2_TYPE_SDISTATS
Identifies NTV2SDIStatus struct.
std::string NTV2AudioChannelQuadToString(const NTV2Audio4ChannelSelect inValue, const bool inCompactDisplay=false)
Definition: ntv2utils.cpp:6447
2048x1080, NTV2_VANCMODE_TALLER
Definition: ntv2enums.h:360
#define BIN032(__x__)
NTV2Standard
Identifies a particular video standard.
Definition: ntv2enums.h:169
#define NTV2_TYPE_VIRTUAL_DATA_RW
Identifies NTV2VirtualData struct.
NTV2ColorCorrectionData acColorCorrection
Color correction data. This field is ignored if AUTOCIRCULATE_WITH_COLORCORRECT option is not set...
ULWord registerValue
My register value to use in a ReadRegister or WriteRegister call.
bool IsAllocatedBySDK(void) const
ULWord acOptionFlags
AutoCirculate options used when CNTV2Card::AutoCirculateInitForInput or CNTV2Card::AutoCirculateInitF...
ULWord GetSizeInBytes(void) const
My total size, in bytes, including header, body and trailer (but excluding embedded NTV2Buffer data) ...
NTV2DeviceID
Identifies a specific AJA NTV2 device model number. The NTV2DeviceID is actually the PROM part number...
Definition: ntv2enums.h:20
ULWord registerNumber
My register number to use in a ReadRegister or WriteRegister call.
NTV2Buffer mBuffer
Virtual address of a buffer to prelock, and its length.
bool NTV2DeviceCanDoVideoFormat(const NTV2DeviceID inDeviceID, const NTV2VideoFormat inVideoFormat)
bool NTV2DeviceGetSupportedOutputDests(const NTV2DeviceID inDeviceID, NTV2OutputDestinations &outOutputDests, const NTV2IOKinds inKinds)
Returns a set of distinct NTV2OutputDest values supported on the given device.
ULWord acAncTransferSize
Total ancillary data bytes for field 1 transferred (capture only).
ULWord64 mClientTID
In: client thread identifier.
#define YesNo(__x__)
This is used to perform virtual data reads or writes.
enum NTV2QuarterSizeExpandMode NTV2QtrSizeExpandMode
1920x1080, for 1080i and 1080p, NTV2_VANCMODE_OFF
Definition: ntv2enums.h:354
Declares the AJAThread class.
ULWord mStatus
Action status.
bool PatchRegister(const ULWord inRegNum, const ULWord inValue)
Patches the given register value.
ULWord64 acRDTSCCurrentTime
Timestamp when CNTV2Card::AutoCirculateGetStatus called, using the host OS system clock...
#define NTV2_TYPE_CONFIGINTERRUPT
Identifies NTV2ConfigInterrupt struct.
std::string to_string(bool val)
Definition: common.cpp:180
#define NTV2_IS_ATC_VITC2_TIMECODE_INDEX(__x__)
Definition: ntv2enums.h:3997
#define NTV2_TYPE_ACXFERSTATUS
Identifies AUTOCIRCULATE_TRANSFER_STATUS struct.
NTV2_HEADER mHeader
The common structure header – ALWAYS FIRST!
else
Definition: ntv2vcam.cpp:789
#define AJA_NTV2_SDK_VERSION_MAJOR
The SDK major version number, an unsigned decimal integer.
Definition: ntv2version.h:13
bool WithHDMIAuxData(void) const
NTV2DeviceIDSet::const_iterator NTV2DeviceIDSetConstIter
A convenient const iterator for NTV2DeviceIDSet.
Definition: ntv2utils.h:1100
std::set< std::string > NTV2StringSet
#define NTV2_TYPE_AJABUFFERLOCK
Identifies NTV2BufferLock struct.
std::ostream & Print(std::ostream &inOutStream) const
RGB color space.
Definition: ntv2enums.h:3614
std::string VersionString(void) const
#define NTV2_INPUT_SOURCE_IS_HDMI(_inpSrc_)
Definition: ntv2enums.h:1285
#define AsU8Ref(_x_)
NTV2VideoFormatSet::const_iterator NTV2VideoFormatSetConstIter
A handy const iterator for iterating over an NTV2VideoFormatSet.
bool RPCDecode(const NTV2_RPC_BLOB_TYPE &inBlob, size_t &inOutIndex)
Specifies analog input/output kinds.
Definition: ntv2enums.h:1298
NTV2Buffer & Segment(NTV2Buffer &outPtr, const ULWord inByteOffset, const ULWord inByteCount) const
Resets an NTV2Buffer instance to reference a contiguous segment (portion) of my memory buffer...
void SetFlags(const ULWord inFlags)
Sets the action flags for use in a subsequent call to CNTV2Card::DMABufferLock.
bool RPCDecode(const NTV2_RPC_BLOB_TYPE &inBlob, size_t &inOutIndex)
#define NTV2SDKVersionEncode
bool RPCEncode(NTV2_RPC_BLOB_TYPE &outBlob)
1280x720, for 720p, NTV2_VANCMODE_TALL
Definition: ntv2enums.h:364
NTV2Channel mChannel
Stream channel.
NTV2MailBuffer()
Constructs a default NTV2MailBuffer struct.
#define AJA_NULL
Definition: ajatypes.h:180
#define NTV2_IS_VALID_IOKINDS(_k_)
Definition: ntv2enums.h:1316
NTV2ChannelList NTV2MakeChannelList(const NTV2Channel inFirstChannel, const UWord inNumChannels)
Declares the CRP188 class. See SMPTE RP188 standard for details.
NTV2TimeCodes::const_iterator NTV2TimeCodesConstIter
A handy const interator for iterating over NTV2TCIndex/NTV2TimeCodeList pairs.
NTV2AutoCirculateState acState
Current AutoCirculate state.
bool RPCDecode(const NTV2_RPC_BLOB_TYPE &inBlob, size_t &inOutIndex)
bool RPCDecode(const NTV2_RPC_BLOB_TYPE &inBlob, size_t &inOutIndex)
std::vector< ULWord > NTV2ULWordVector
An ordered sequence of ULWords.
std::string NTV2HDMIProtocolToString(const NTV2HDMIProtocol inValue, const bool inCompactDisplay=false)
Definition: ntv2utils.cpp:6672
std::ostream & Print(std::ostream &inOutStream) const
Prints a human-readable representation of me to the given output stream.
bool SetBuffer(const NTV2Buffer &inBuffer)
Sets the buffer to lock for use in a subsequent call to CNTV2Card::LoadBitstream. ...
Defines for the NTV2 SDK version number, used by ajantv2/includes/ntv2enums.h. See the ajantv2/includ...
enum _INTERRUPT_ENUMS_ INTERRUPT_ENUMS
ULWord64 acAudioClockCurrentTime
The absolute timestamp at the moment the CNTV2Card::AutoCirculateTransfer or CNTV2Card::AutoCirculate...
bool SetFrom(const NTV2Buffer &inBuffer)
Replaces my contents from the given memory buffer without resizing me.
ULWord flags(void) const
NTV2ColorCorrectionMode
Definition: ntv2enums.h:2084
ULWord fTrailerVersion
Trailer version, set when created. Before SDK 15.1: always zero; 15.1 or later: set to calling SDK ve...
bool IsStopped(void) const
NTV2RegisterNumberSet NTV2RegNumSet
A set of distinct NTV2RegisterNumbers.
This is used to atomically perform bank-selected register reads or writes.
ULWord64 acRDTSCStartTime
Timestamp of the first VBI received after CNTV2Card::AutoCirculateStart called, using host OS system ...
std::set< ULWord > ULWordSet
A collection of unique ULWord (uint32_t) values.
ULWord acRequestedFrame
On entry for NTV2_TYPE_ACFRAMESTAMP message, the requested frame. Upon exit, 0xFFFFFFFF means "not ...
ULWord acFramesDropped
Total number of frames dropped since AutoCirculateStart.
bool ImportFromLog(const NTV2StringList &inLogLines)
Resets me using the given "Number:" and "Value:" lines from the support log.
Specifies any/all devices.
Definition: ntv2enums.h:1384
ULWord acAudioTransferSize
Number of bytes captured into the audio buffer.
#define NTV2_TYPE_AJADEBUGLOGGING
Identifies NTV2DebugLogging struct.
bool VersionComponents(ULWord &outMajor, ULWord &outMinor, ULWord &outPoint, ULWord &outBuild) const
bool RPCDecode(const NTV2_RPC_BLOB_TYPE &inBlob, size_t &inOutIndex)
bool RPCDecodeServer(const NTV2_RPC_BLOB_TYPE &inBlob, size_t &inOutIndex)
int64_t LWord64
Definition: ajatypes.h:238
All NTV2 messages start with this common header.
std::ostream & PrintLog(std::ostream &outputStream, const NTV2DeviceID inDeviceID=DEVICE_ID_INVALID) const
Renders me to the given output stream in "supportlog" format.
static size_t DefaultPageSize(void)
NTV2RegWrites NTV2RegisterReads
static std::string FourCCToString(const ULWord in4CC, const char nonPrintable='?')
ULWord registerShift
My register shift value to use in a ReadRegister or WriteRegister call.
ULWord acSegmentDevicePitch
Offset, in bytes, between the start of one device segment and the start of the next device segment (i...
bool operator<(const NTV2RegInfo &inRHS) const
bool SetFromHexString(const std::string &inStr)
Replaces my contents from the given hex-encoded string, resizing me if necessary. ...
std::vector< uint16_t > UWordSequence
An ordered sequence of UWord (uint16_t) values.
NTV2Buffer mInRegInfos
NTV2RegInfo array of registers be read/written. The SDK owns this memory.
std::set< NTV2FrameGeometry > NTV2GeometrySet
A set of distinct NTV2FrameGeometry values.
std::ostream & Print(std::ostream &inOutStream) const
Prints a human-readable representation of me to the given output stream.
ULWord acAncField2TransferSize
Total ancillary data bytes for field 2 transferred (capture only).
AUTOCIRCULATE_STATUS(const NTV2Crosspoint inCrosspoint=NTV2CROSSPOINT_CHANNEL1)
Constructs a default AUTOCIRCULATE_STATUS struct for the given NTV2Crosspoint.
string NTV2AudioSystemSetToStr(const NTV2AudioSystemSet &inObj, const bool inCompact)
bool RPCDecode(const NTV2_RPC_BLOB_TYPE &inBlob, size_t &inOutIndex)
ULWord64 acAudioClockCurrentTime
Timestamp when CNTV2Card::AutoCirculateGetStatus called, using "64-bit clean" value of the device&#39;s 4...
UWordSequence::const_iterator UWordSequenceConstIter
A handy const iterator for iterating over a UWordSequence.
std::string NTV2HDMIAudioChannelsToString(const NTV2HDMIAudioChannels inValue, const bool inCompactDisplay=false)
Definition: ntv2utils.cpp:6661
std::set< NTV2AudioSystem > NTV2AudioSystemSet
A set of distinct NTV2AudioSystem values. New in SDK 16.2.
std::string NTV2VideoFormatToString(const NTV2VideoFormat inValue, const bool inUseFrameRate=false)
Definition: ntv2utils.cpp:6750
~NTV2ColorCorrectionData()
My destructor, which frees my private color correction table buffer.
bool IsValidVersion(void) const
NTV2HDMIProtocol
Indicates or specifies the HDMI protocol.
Definition: ntv2enums.h:3627
The AutoCirculate channel is starting, waiting for the start time specified in the call to CNTV2Card:...
bool NTV2GetUnsupportedPixelFormats(NTV2PixelFormats &outFormats)
Returns a set of NTV2PixelFormat values not suported by any NTV2 device.
#define NTV2_IS_VALID_STANDARD(__s__)
Definition: ntv2enums.h:192
#define NTV2_TYPE_ACFRAMESTAMP
Identifies FRAME_STAMP struct.
ULWord acFrameRepeatCount
Intended for playout. The number of times to repeat the frame being transferred.
size_t maxHandleCapacity(void) const
ULWord GetDroppedFrameCount(void) const
Declares data types and structures used in NTV2 "nub" packets.
UWord NTV2DeviceGetNumAnalogVideoOutputs(const NTV2DeviceID inDeviceID)
LWord acTransferFrame
Frame buffer number the frame was transferred to/from. (-1 if failed)
std::string getSourceCode(const bool inInclDecl=true) const
bool isValid(void) const
bool SwapWith(NTV2Buffer &inBuffer)
Swaps my underlying buffer with another&#39;s.
bool RPCEncodeServer(NTV2_RPC_BLOB_TYPE &inBlob)
ULWord64 audioClockCurrentTime
48kHz clock in reg 28 extended to 64 bits
ULWord acCurrentFieldCount
As found by ISR at Call Field0 or Field1 currently being OUTPUT (when CNTV2Card::AutoCirculateGetFram...
void PUSHU16(const uint16_t val, RPCBlob &blob, const bool dontSwap=false)
Pushes a 16-bit value onto the given byte sequence.
Definition: ntv2nubtypes.h:49
#define oOCT(__x__)
The AutoCirculate channel is stopped.
ULWord64 acAudioClockStartTime
Timestamp of the first VBI received after CNTV2Card::AutoCirculateStart called, using "64-bit clean" ...
bool WithRP188(void) const
#define AUTOCIRCULATE_WITH_ANC
Use this to AutoCirculate with ancillary data.
LWord acEndFrame
Last frame to circulate. FIXFIXFIX Why is this signed? CHANGE TO ULWord??
uint64_t ULWord64
Definition: ajatypes.h:239
#define Hex(__x__)
std::string NTV2TCIndexToString(const NTV2TCIndex inValue, const bool inCompactDisplay=false)
Definition: ntv2utils.cpp:6398
bool RPCEncode(NTV2_RPC_BLOB_TYPE &outBlob)
void Clear(void)
Clears (zeroes) all of my member variables.
NTV2DIDSet::const_iterator NTV2DIDSetConstIter
Handy const iterator to iterate over an NTV2DIDSet.
LWord GetActiveFrame(void) const
std::string NTV2AudioChannelOctetToString(const NTV2Audio8ChannelSelect inValue, const bool inCompactDisplay=false)
Definition: ntv2utils.cpp:6459
ostream & NTV2PrintChannelSet(const NTV2ChannelSet &inObj, const bool inCompact, ostream &inOutStream)
ULWord getDestOffset(void) const
static NTV2StringList IntNames(const uint64_t mask)
bool NTV2DeviceGetSupportedVideoFormats(const NTV2DeviceID inDeviceID, NTV2VideoFormatSet &outFormats)
Returns a set of distinct NTV2VideoFormat values supported on the given device.
bool RPCEncode(NTV2_RPC_BLOB_TYPE &outBlob)
uint8_t UByte
Definition: ajatypes.h:231
NTV2Crosspoint channelSpec
bool IsPageAligned(void) const
This is used by the CNTV2Card::ReadRegisters function.
NTV2Buffer(const void *pInUserPointer, const size_t inByteCount)
Constructs me from a client-supplied address and size.
bool RPCDecodeClient(const NTV2_RPC_BLOB_TYPE &inBlob, size_t &inOutIndex)
1920x1080, NTV2_VANCMODE_TALLER
Definition: ntv2enums.h:359
NTV2_TRAILER mTrailer
The common structure trailer – ALWAYS LAST!
#define NTV2_OUTPUT_DEST_IS_ANALOG(_dest_)
Definition: ntv2enums.h:1349
720x486, for NTSC 525i, NTV2_VANCMODE_TALL
Definition: ntv2enums.h:361
std::string NTV2AudioChannelPairToString(const NTV2AudioChannelPair inValue, const bool inCompactDisplay=false)
Definition: ntv2utils.cpp:6435
ULWord64 acCurrentUserCookie
The frame&#39;s AUTOCIRCULATE_TRANSFER::acInUserCookie value that was set when CNTV2Card::AutoCirculateTr...
ULWord acCurrentLineCount
At Call Line# currently being OUTPUT (at the time of the IOCTL_NTV2_GET_FRAMESTAMP) ...
NTV2Crosspoint backgroundVideoCrosspoint
NTV2_HEADER mHeader
The common structure header – ALWAYS FIRST!
#define NTV2_CURRENT_HEADER_VERSION
Current version of NTV2_HEADER struct, originally 0.
NTV2_HEADER mHeader
The common structure header – ALWAYS FIRST!
const NTV2_TRAILER * GetTrailer(void) const
std::ostream & PrintCode(std::ostream &outputStream, const int inRadix=16, const NTV2DeviceID inDeviceID=DEVICE_ID_INVALID, const std::string &sCard="card") const
Renders me to the given output stream as source code using a "WriteRegister" function call...
ostream & operator<<(ostream &inOutStream, const NTV2StringList &inData)
void Clear(void)
Clears my data.
LWord acDesiredFrame
Used to specify a different frame in the circulate ring to transfer to/from.
bool NTV2GetSupportedPixelFormats(NTV2PixelFormats &outFormats)
Returns a set of all NTV2PixelFormat values supported (used) by any/all supported NTV2 devices...
void Set(const ULWord inNumSegments, const ULWord inNumActiveBytesPerRow, const ULWord inHostBytesPerRow, const ULWord inDeviceBytesPerRow)
Sets the NTV2SegmentedDMAInfo struct members.
This is used to prelock a video/audio/anc buffer used as the source or target of DMA transfers...
bool NTV2DeviceCanDoInputSource(const NTV2DeviceID inDeviceID, const NTV2InputSource inInputSource)
bool ByteSwap16(void)
Byte-swaps my contents 16-bits at a time.
#define NTV2_OUTPUT_DEST_IS_SDI(_dest_)
Definition: ntv2enums.h:1350
NTV2AutoCirculateState
Describes the state of an AutoCirculate channel. See AUTOCIRCULATE_STATUS.
bool RPCDecode(const NTV2_RPC_BLOB_TYPE &inBlob, size_t &inOutIndex)
#define VIRTUALREG_START
ULWord getTotalElements(void) const
std::ostream & Print(std::ostream &oss) const
#define NTV2_IS_VALID_CHANNEL(__x__)
Definition: ntv2enums.h:1375
Declares the AJAProcess class.
This is used for bitstream maintainance. (New in SDK 16.0)
Describes a user-space buffer on the host computer. I have an address and a length, plus some optional attributes (allocated by SDK?, page-aligned? etc.).
ULWord audioInStartAddress
For record - first position in buffer of audio (includes base offset)
ostream & NTV2PrintULWordVector(const NTV2ULWordVector &inObj, ostream &inOutStream)
NTV2BufferLock()
Constructs a default NTV2BufferLock struct.
std::map< NTV2TCIndex, NTV2_RP188 > NTV2TimeCodes
A mapping of NTV2TCIndex enum values to NTV2_RP188 structures.
bool RPCEncode(NTV2_RPC_BLOB_TYPE &outBlob)
bool RPCEncode(NTV2_RPC_BLOB_TYPE &outBlob)
Identifies SMPTE HD 1080i or 1080psf.
Definition: ntv2enums.h:171
NTV2_HEADER mHeader
The common structure header – ALWAYS FIRST!
std::string NTV2HDMIRangeToString(const NTV2HDMIRange inValue, const bool inCompactDisplay=false)
Definition: ntv2utils.cpp:6683
bool NTV2DeviceGetSupportedPixelFormats(const NTV2DeviceID inDeviceID, NTV2PixelFormats &outFormats)
Returns a set of distinct NTV2FrameBufferFormat values supported on the given device.
static AJAStatus StatTimerStart(const uint32_t inKey)
Definition: debug.cpp:1141
static size_t gDefaultPageSize(AJA_PAGE_SIZE)
uint16_t GetEndFrame(void) const
ULWord acAudioExpectedAddress
Audio transfer address.
NTV2InputSource
Identifies a specific video input source.
Definition: ntv2enums.h:1266
bool RPCEncode(NTV2_RPC_BLOB_TYPE &outBlob, bool fillBuffer=true)
NTV2MessageData(const void *inMessage, const size_t inMessageSize, const ULWord inFlags)
Constructs an NTV2VirtualData struct for reading or writing virtual data.
bool RPCEncode(NTV2_RPC_BLOB_TYPE &outBlob)
NTV2InputSourceSet::const_iterator NTV2InputSourceSetConstIter
A handy const iterator for iterating over an NTV2InputSourceSet.
ULWord acCurrentAudioExpectedAddress
bool PutU32s(const ULWordSequence &inU32s, const size_t inU32Offset=0, const bool inByteSwap=false)
Copies a vector of unsigned 32-bit values into me.
bool GetU8s(UByteSequence &outU8s, const size_t inU8Offset=0, const size_t inMaxSize=128) const
Answers with my contents as a vector of unsigned 8-bit values.
#define AUTOCIRCULATE_WITH_FBOCHANGE
Use this to AutoCirculate with the possibility of frame buffer orientation changes.
bool RPCDecode(const NTV2_RPC_BLOB_TYPE &inBlob, size_t &inOutIndex)
bool RPCDecodeNoAllocate(const NTV2_RPC_BLOB_TYPE &inBlob, size_t &inOutIndex)
bool RPCEncodeClient(NTV2_RPC_BLOB_TYPE &inBlob)
ostream & NTV2PrintAudioSystemSet(const NTV2AudioSystemSet &inObj, const bool inCompact, std::ostream &inOutStream)
Streams a human-readable dump of the given NTV2AudioSystemSet into the specified output stream...
This object specifies the information that will be transferred to or from the AJA device in the CNTV2...
std::string & strip(std::string &str, const std::string &ws)
Definition: common.cpp:461
bool GetSDIInputStatus(NTV2SDIInputStatus &outStatus, const UWord inSDIInputIndex0=0)
Answers with the NTV2SDIInputStatus for the given SDI input spigot.
bool RPCDecode(const NTV2_RPC_BLOB_TYPE &inBlob, size_t &inOutIndex)
2048x1080, for 2Kx1080p, NTV2_VANCMODE_OFF
Definition: ntv2enums.h:365
bool RPCDecode(const NTV2_RPC_BLOB_TYPE &inBlob, size_t &inOutIndex)
ULWord acFramesProcessed
Total number of frames successfully processed since AutoCirculateStart.
ULWord acStartSample
The actual audio start sample when this frame was started at the VBI, which may be used to check sync...
bool is_hex_digit(const char inChr)
Definition: common.cpp:511
NTV2_HEADER mHeader
The common structure header – ALWAYS FIRST!
bool RPCDecode(const NTV2_RPC_BLOB_TYPE &inBlob, size_t &inOutIndex)
void Clear(void)
Resets the struct to its initialized state.
static std::string GetDisplayValue(const uint32_t inRegNum, const uint32_t inRegValue, const NTV2DeviceID inDeviceID=DEVICE_ID_NOTFOUND)
static size_t HostPageSize(void)
#define DEC(__x__)
NTV2RegisterNumber
#define NTV2SDKVersionDecode_Point
std::ostream & Print(std::ostream &inOutStream) const
Prints a human-readable representation of me to the given output stream.
NTV2FrameGeometry
Identifies a particular video frame geometry.
Definition: ntv2enums.h:352
720x576, for PAL 625i, NTV2_VANCMODE_OFF
Definition: ntv2enums.h:358
bool RPCEncode(NTV2_RPC_BLOB_TYPE &outBlob)
User cookie at last vblank.
NTV2Buffer acANCField2Buffer
The host "Field 2" ancillary data buffer. This field is owned by the client application, and thus is responsible for allocating and/or freeing it. If the pointer is NULL or the size is zero, no "Field 2" ancillary data will be transferred. Use the AUTOCIRCULATE_TRANSFER::SetAncBuffers method to set or reset this field.
FRAME_STAMP & operator=(const FRAME_STAMP &inRHS)
uint64_t clientPID(void) const
std::set< NTV2Channel > NTV2ChannelSet
A set of distinct NTV2Channel values.
NTV2AudioChannelOctets::const_iterator NTV2AudioChannelOctetsConstIter
Handy const iterator to iterate over a set of distinct NTV2AudioChannelOctet values.
std::string NTV2HDMIColorSpaceToString(const NTV2HDMIColorSpace inValue, const bool inCompactDisplay=false)
Definition: ntv2utils.cpp:6694
ULWord mFlags
Action flags (lock, unlock, etc)
uint64_t interruptIDs(void) const
NTV2_TRAILER()
Constructs a default NTV2_TRAILER having the proper version and tag.
uint64_t clientID(void) const
#define NTV2_TYPE_AJASTREAMBUFFER
Identifies NTV2StreamBuffer struct.
void Set(const ULWord inDBB=0xFFFFFFFF, const ULWord inLow=0xFFFFFFFF, const ULWord inHigh=0xFFFFFFFF)
Sets my fields from the given DBB, low and high ULWord components.
std::ostream & Print(std::ostream &oss) const
Prints a human-readable representation of me into the given output stream.
Declares numerous NTV2 utility functions.
bool GetU16s(UWordSequence &outU16s, const size_t inU16Offset=0, const size_t inMaxSize=64, const bool inByteSwap=false) const
Answers with my contents as a vector of unsigned 16-bit values.
std::ostream & Print(std::ostream &inOutStream) const
Prints a human-readable representation of me into the given output stream.
NTV2_TRAILER mTrailer
The common structure trailer – ALWAYS LAST!
NTV2Buffer mOutBadRegIndexes
Array of UWords containing index numbers of the register writes that failed. The SDK owns this memory...
#define NTV2Buffer_TO_ULWORD64(__p__)
bool NTV2DeviceGetSupportedGeometries(const NTV2DeviceID inDeviceID, NTV2GeometrySet &outGeometries)
Returns a set of distinct NTV2FrameGeometry values supported on the given device. ...
NTV2Crosspoint foregroundKeyCrosspoint
void swap(nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer, BinaryType, CustomBaseClass > &j1, nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer, BinaryType, CustomBaseClass > &j2) noexcept(//NOLINT(readability-inconsistent-declaration-parameter-name, cert-dcl58-cpp) is_nothrow_move_constructible< nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer, BinaryType, CustomBaseClass > >::value &&//NOLINT(misc-redundant-expression, cppcoreguidelines-noexcept-swap, performance-noexcept-swap) is_nothrow_move_assignable< nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer, BinaryType, CustomBaseClass > >::value)
exchanges the values of two JSON objects
Definition: json.hpp:24538
std::string NTV2CrosspointToString(const NTV2Crosspoint inChannel)
Definition: ntv2utils.cpp:5809
bool Set(const void *pInUserPointer, const size_t inByteCount)
Sets (or resets) me from a client-supplied address and size.
union AutoCircGenericTask::@15 u
ULWord acBufferLevel
Number of buffered frames in driver ready to capture or play.
std::vector< uint64_t > ULWord64Sequence
An ordered sequence of ULWord64 (uint64_t) values.
#define NTV2Buffer_PAGE_ALIGNED
Allocated page-aligned?
NTV2GetRegisters(const NTV2RegNumSet &inRegisterNumbers=NTV2RegNumSet())
Constructs an NTV2GetRegisters struct from the given set of register numbers.
#define AsU64Ref(_x_)
bool operator!=(const NTV2SegmentedXferInfo &inRHS) const
bool NTV2GetSupportedStandards(NTV2StandardSet &outStandards)
Returns a set of all NTV2Standard values supported (used) by any/all supported NTV2 devices...
std::string AsCode(const size_t inBytesPerWord=4, const std::string &inVarName="", const bool inUseSTL=false, const bool inByteSwap=false) const
std::ostream & Print(std::ostream &inOutStream) const
Prints a human-readable representation of me to the given output stream.
string NTV2AutoCirculateStateToString(const NTV2AutoCirculateState inState)
NTV2RegInfo GetRegInfo(const UWord inIndex0=0) const
AUTO_CIRC_COMMAND eCommand
NTV2SDIInputStatus & operator[](const size_t inSDIInputIndex0)
This struct is used to augment the default full-frame AutoCirculate DMA transfer to accommodate multi...
bool GetInputTimeCodes(NTV2TimeCodeList &outValues) const
Intended for capture, answers with the timecodes captured in my acTransferStatus member&#39;s acFrameStam...
bool SetInputTimecode(const NTV2TCIndex inTCNdx, const NTV2_RP188 &inTimecode)
Sets one of my input timecodes.
ULWord acAudioOutStartAddress
(output/playback only) Audio play head position (exclusive) AFTER this frame was stamped.
720x486, for NTSC 525i and 525p60, NTV2_VANCMODE_OFF
Definition: ntv2enums.h:357
ULWord GetFrameCount(void) const
This is returned from the CNTV2Card::AutoCirculateGetStatus function.
NTV2SegmentedXferInfo & reset(void)
Resets me to an invalid (all zero) state.
ULWord mFlags
Action flags.
bool NextDifference(const NTV2Buffer &inBuffer, ULWord &byteOffset) const
Iterates over each byte that differs between myself and the given buffer.
#define AUTOCIRCULATE_WITH_COLORCORRECT
Use this to AutoCirculate with color correction.
bool RPCDecode(const NTV2_RPC_BLOB_TYPE &inBlob, size_t &inOutIndex)
std::vector< NTV2_RP188 > NTV2TimeCodeList
An ordered sequence of zero or more NTV2_RP188 structures. An NTV2TCIndex enum value can be used as a...
virtual std::string do_grouping() const
bool RPCDecode(const NTV2_RPC_BLOB_TYPE &inBlob, size_t &inOutIndex)
NTV2VirtualData(const ULWord inTag, const void *inVirtualData, const size_t inVirtualDataSize, const bool inDoWrite=false)
Constructs an NTV2VirtualData struct for reading or writing virtual data.
std::string NTV2AudioRateToString(const NTV2AudioRate inValue, const bool inForRetailDisplay=false)
Definition: ntv2utils.cpp:5760
NTV2RegisterValueMap::const_iterator NTV2RegValueMapConstIter
A const iterator that iterates over NTV2RegisterValueMap entries.
bool is_legal_decimal_number(const std::string &inStr, size_t inMaxLength)
Definition: common.cpp:526
ULWord acAudioOutStopAddress
(output/playback only) Audio play head position when this frame was stamped.
void Clear(void)
Frees my private color correction table buffer and resets my mode to "invalid".
LWord64 acCurrentFrameTime
The VBI timestamp of the current/active frame currently being ingested on the device (capture)...
uint16_t UWord
Definition: ajatypes.h:234
std::ostream & Print(std::ostream &oStream) const
Prints a human-readable representation of me into the given output stream.
bool SetAndFill(const void *pInUserPointer, const size_t inByteCount, const UByte inValue)
Sets (or resets) me from a client-supplied address and size.
uint16_t U16(const int inIndex) const
NTV2DoubleArray::const_iterator NTV2DoubleArrayConstIter
Handy const iterator to iterate over an NTV2DoubleArray.
std::ostream & Dump(std::ostream &inOutputStream=std::cout, const size_t inStartByteOffset=0, const size_t inByteCount=0, const size_t inRadix=16, const size_t inBytesPerGroup=4, const size_t inGroupsPerLine=8, const size_t inAddressRadix=0, const bool inShowAscii=false, const size_t inAddrOffset=0) const
Dumps me in hex/octal/decimal, with/without Ascii, to the given output stream.
#define OCT(__x__)
ULWord acFramesDropped
Total number of frames dropped since CNTV2Card::AutoCirculateStart called.
NTV2TCIndexes & operator+=(NTV2TCIndexes &inOutSet, const NTV2TCIndexes &inSet)
Appends the given NTV2TCIndexes contents into the given set.
static void FreeAligned(void *pMemory)
Definition: memory.cpp:145
NTV2Buffer acTimeCodes
Intended for capture, this is a sequence of NTV2_RP188 values received from the device (in NTV2TCInde...
std::ostream & Print(std::ostream &inOutStream) const
AUTOCIRCULATE_TRANSFER_STATUS acTransferStatus
Contains status information that&#39;s valid after CNTV2Card::AutoCirculateTransfer returns, including the driver buffer level, number of frames processed or dropped, audio and anc transfer byte counts, and a complete FRAME_STAMP that has even more detailed clocking information.
NTV2_HEADER(const ULWord inStructureType, const ULWord inSizeInBytes)
Constructs a default NTV2_HEADER having the proper tag, version, and the given type and size...
enum _AutoCircCommand_ AUTO_CIRC_COMMAND
NTV2Channel GetChannel(void) const
#define NTV2_ASSERT_STRUCT_VALID
NTV2Buffer mBuffer
Virtual address of a bitstream buffer and its length.
#define xHEX0N(__x__, __n__)
AUTOCIRCULATE_TRANSFER()
Constructs a default AUTOCIRCULATE_TRANSFER struct.
~NTV2Buffer()
My destructor. If I&#39;m responsible for the memory, I free it here.
static std::string GetDisplayName(const uint32_t inRegNum)
~FRAME_STAMP()
My destructor.
#define NTV2_IS_VALID_AUDIO_SYSTEM(__x__)
Definition: ntv2enums.h:3920
ULWord currenthUser
Contains validCount (Play - reps remaining, Record - drops on frame)
bool SetAncBuffers(ULWord *pInANCBuffer, const ULWord inANCByteCount, ULWord *pInANCF2Buffer=NULL, const ULWord inANCF2ByteCount=0)
Sets my ancillary data buffers for use in a subsequent call to CNTV2Card::AutoCirculateTransfer.
std::string NTV2FrameBufferFormatToString(const NTV2FrameBufferFormat inValue, const bool inForRetailDisplay=false)
Definition: ntv2utils.cpp:6940
std::vector< uint8_t > RPCBlob
Definition: ntv2nubtypes.h:19
bool RPCEncode(NTV2_RPC_BLOB_TYPE &outBlob)
uint64_t clientTID(void) const
ULWord getSourcePitch(void) const
NTV2_RP188 acRP188
Deprecated – call FRAME_STAMP::GetInputTimeCode instead.
NTV2GeometrySet GetRelatedGeometries(const NTV2FrameGeometry inFrameGeometry)
Definition: ntv2utils.cpp:4002
#define NTV2_INPUT_SOURCE_IS_ANALOG(_inpSrc_)
Definition: ntv2enums.h:1286
NTV2RegWritesIter NTV2RegisterReadsIter
NTV2RegInfo & setValue(const ULWord val)
bool GetInputTimeCode(NTV2_RP188 &outTimeCode, const NTV2TCIndex inTCIndex=NTV2_TCINDEX_SDI1) const
Intended for capture, answers with a specific timecode captured in my acTransferStatus member&#39;s acFra...
ULWord mIsWriting
If non-zero, register(s) will be written; otherwise, register(s) will be read.
NTV2AudioSystemSet::const_iterator NTV2AudioSystemSetConstIter
A handy const iterator into an NTV2AudioSystemSet. New in SDK 16.2.
NTV2Buffer mInBankInfos
Bank select NTV2RegInfo. The SDK owns this memory.
#define NTV2_TYPE_AJASTREAMCHANNEL
Identifies NTV2StreamChannel struct.
This object is embedded in the AUTOCIRCULATE_TRANSFER struct that&#39;s returned from the CNTV2Card::Auto...
bool SetFromRegValue(const ULWord inData)
Sets my fields from the given status register value.
NTV2_TRAILER mTrailer
The common structure trailer – ALWAYS LAST!
bool ResetUsing(const NTV2RegWrites &inRegWrites)
Resets me, starting over, now using the given NTV2RegisterNumberSet.
ULWord acBufferLevel
The number of frames ready to record/play after the transfer.
ULWord mStatus
Action status.
std::ostream & Print(std::ostream &inOutStream) const
Prints a human-readable representation of me into the given output stream.
bool RPCEncode(NTV2_RPC_BLOB_TYPE &outBlob)
enum NTV2OutputDestination NTV2OutputDest
bool RPCDecode(const NTV2_RPC_BLOB_TYPE &inBlob, size_t &inOutIndex)
bool POPU32(uint32_t &outVal, const RPCBlob &blob, std::size_t &inOutNdx, const bool dontSwap=false)
Pops a 32-bit value off the given byte sequence at the given zero-based index position.
Definition: ntv2nubtypes.h:149
#define AUTOCIRCULATE_STRUCT_VERSION
Version number of AutoCirculate structures, originally 0.
ULWord getSegmentLength(void) const
UWord NTV2DeviceGetNumVideoOutputs(const NTV2DeviceID inDeviceID)
NTV2QuarterSizeExpandMode acVideoQuarterSizeExpand
Turns on the "quarter-size expand" (2x H + 2x V) hardware. Defaults to off (1:1). ...
bool GetRequestedRegisterWrites(NTV2RegWrites &outRegWrites) const
bool isDestBottomUp(void) const
ULWord currentAudioExpectedAddress
As set by play.
Identifies the first analog video input.
Definition: ntv2enums.h:1268
Private include file for all ajabase sources.
This class/object reports information about the current and/or requested AutoCirculate frame...
NTV2Standard GetNTV2StandardFromVideoFormat(const NTV2VideoFormat inVideoFormat)
Definition: ntv2utils.cpp:2375
std::map< NTV2FrameGeometry, ULWord > FGSizesMap
ULWord getSourceOffset(void) const
NTV2ChannelList::const_iterator NTV2ChannelListConstIter
A handy const iterator into an NTV2ChannelList.
NTV2AudioRate
Definition: ntv2enums.h:1933
std::vector< uint32_t > ULWordSequence
An ordered sequence of ULWord (uint32_t) values.
RP188_STRUCT currentRP188
Last vertical blank timecode (RP-188)
ULWord mFlags
In: option flags.
static void * AllocateAligned(size_t size, size_t alignment)
Definition: memory.cpp:115
ULWord acAudioInStartAddress
(input/ingest/capture only) Starting audio record head position when this frame was stamped...
#define NTV2_IS_VALID_VIDEO_FORMAT(__f__)
Definition: ntv2enums.h:729
std::vector< NTV2Channel > NTV2ChannelList
An ordered sequence of NTV2Channel values.
std::string & upper(std::string &str)
Definition: common.cpp:442
std::string join(const std::vector< std::string > &parts, const std::string &delim)
Definition: common.cpp:468
#define AUTOCIRCULATE_WITH_VIDPROC
Use this to AutoCirculate with video processing.
NTV2_HEADER acHeader
The common structure header – ALWAYS FIRST!
#define NTV2_TYPE_SETREGS
Identifies NTV2SetRegisters struct.
bool GetU32s(ULWordSequence &outU32s, const size_t inU32Offset=0, const size_t inMaxSize=32, const bool inByteSwap=false) const
Answers with my contents as a vector of unsigned 32-bit values.
ULWord64Sequence::const_iterator ULWord64SequenceConstIter
A handy const iterator for iterating over a ULWord64Sequence.
static ULWord FGHeight(const NTV2FrameGeometry fg)
ULWord acSegmentHostPitch
Offset, in bytes, between the start of one host segment and the start of the next host segment (i...
ULWord fLo
| BG 4 | Secs10 | BG 3 | Secs 1 | BG 2 | Frms10 | BG 1 | Frms 1 |
std::set< NTV2DeviceID > NTV2DeviceIDSet
A set of NTV2DeviceIDs.
Definition: ntv2utils.h:1098
uint64_t U64(const int inIndex) const
bool RPCEncode(NTV2_RPC_BLOB_TYPE &outBlob)
void * GetHostPointer(void) const
NTV2ColorCorrectionData()
Constructs a default NTV2ColorCorrectionData struct.
bool WithColorCorrect(void) const
NTV2SegmentedXferInfo & setDestDirection(const bool inTopDown)
Sets the scan direction for the destination.
NTV2Bitstream()
Constructs a default NTV2Bitstream struct.
#define NTV2_IS_VALID_FRAME_BUFFER_FORMAT(__s__)
Definition: ntv2enums.h:267
void Reset(void)
Resets the NTV2SegmentedDMAInfo struct members to their default values (normal, non-segmented AutoCir...
bool GetRingChangedByteRange(const NTV2Buffer &inBuffer, ULWord &outByteOffsetFirst, ULWord &outByteOffsetLast) const
Assuming my contents and the contents of the given buffer comprise ring buffers that periodically get...
bool POPU64(uint64_t &outVal, const RPCBlob &blob, std::size_t &inOutNdx, const bool dontSwap=false)
Pops a 64-bit value off the given byte sequence at the given zero-based index position.
Definition: ntv2nubtypes.h:171
ULWord64 acAudioClockTimeStamp
(input/ingest/capture only) The absolute timestamp at the VBI when the frame started recording into d...
This is used by the CNTV2Card::ReadSDIStatistics function.
string CommaStr(const T &inNum)
2048x1556, for 2Kx1556psf film format, NTV2_VANCMODE_TALL
Definition: ntv2enums.h:367
NTV2Buffer acAudioBuffer
The host audio buffer. This field is owned by the client application, and thus is responsible for all...
static const NTV2_RP188 INVALID_TIMECODE_VALUE
static std::string IntName(const INTERRUPT_ENUMS id)
NTV2TCIndexes::const_iterator NTV2TCIndexesConstIter
Color correction data used with AUTOCIRCULATE_WITH_COLORCORRECT option.
static const string sSegXferUnits[]
std::vector< std::string > NTV2StringList
ULWord64 mClientPID
In: client process identifier.
bool SetFrom(const FRAME_STAMP_STRUCT &inOldStruct)
Sets my fields from the given FRAME_STAMP_STRUCT.
std::ostream & print(std::ostream &oss) const
prints a human-readable representation of me to the given output stream
std::set< NTV2AudioChannelOctet > NTV2AudioChannelOctets
A set of distinct NTV2AudioChannelOctet values.
bool GetInputTimeCode(NTV2_RP188 &outTimeCode, const NTV2TCIndex inTCIndex=NTV2_TCINDEX_SDI1) const
Answers with a specific timecode captured in my acTimeCodes member.
#define HEX0N(__x__, __n__)
Definition: debug.cpp:1181
#define NTV2Buffer_ALLOCATED
Allocated using Allocate function?
std::ostream & Print(std::ostream &inOutStream) const
bool GetU64s(ULWord64Sequence &outU64s, const size_t inU64Offset=0, const size_t inMaxSize=16, const bool inByteSwap=false) const
Answers with my contents as a vector of unsigned 16-bit values.
#define NTV2_IS_VALID_COLOR_CORRECTION_MODE(__x__)
Definition: ntv2enums.h:2094
#define NTV2SDKVersionDecode_Build
uint8_t U8(const int inIndex) const
ULWord audioOutStopAddress
For play - first position in buffer of audio.
std::vector< NTV2RegInfo > NTV2RegisterWrites
#define OCT0N(__x__, __n__)
#define AUTOCIRCULATE_WITH_RP188
Use this to AutoCirculate with RP188.
bool RPCEncode(NTV2_RPC_BLOB_TYPE &outBlob)
LWord64 currentFrameTime
Vertical blank start of current frame.
std::string NTV2ChannelToString(const NTV2Channel inValue, const bool inForRetailDisplay=false)
Definition: ntv2utils.cpp:5731
bool ByteSwap64(void)
Byte-swaps my contents 64-bits at a time.
#define NTV2_INPUT_SOURCE_IS_SDI(_inpSrc_)
Definition: ntv2enums.h:1287
std::string & lower(std::string &str)
Definition: common.cpp:436
NTV2StreamChannel()
Constructs a default NTV2StreamChannel struct.
std::ostream & Print(std::ostream &inOutStream) const
Prints a human-readable representation of me to the given output stream.
NTV2RegWrites NTV2RegReads
An ordered sequence of zero or more NTV2RegInfo structs intended for ReadRegister.
void * GetHostAddress(const ULWord inByteOffset, const bool inFromEnd=false) const
bool RPCEncode(NTV2_RPC_BLOB_TYPE &outBlob)
bool SetAudioBuffer(ULWord *pInAudioBuffer, const ULWord inAudioByteCount)
Sets my audio buffer for use in a subsequent call to CNTV2Card::AutoCirculateTransfer.
ULWord acNumSegments
Number of segments of size ::AUTOCIRCULATE_TRANSFER::acVideoBuffer.fByteCount to transfer. Zero or 1 means normal (unsegmented) transfer.
NTV2AudioChannelPairs::const_iterator NTV2AudioChannelPairsConstIter
Handy const iterator to iterate over a set of distinct NTV2AudioChannelPair values.
#define NTV2EndianSwap16(__val__)
Definition: ntv2endian.h:15
bool NTV2DeviceGetSupportedFrameRates(const NTV2DeviceID inDeviceID, NTV2FrameRateSet &outRates)
Returns a set of distinct NTV2FrameRate values supported on the given device.
NTV2Channel mChannel
Mail buffer channel.
ostream & NTV2PrintChannelList(const NTV2ChannelList &inObj, const bool inCompact, ostream &inOutStream)
720x576, for PAL 625i, NTV2_VANCMODE_TALLER
Definition: ntv2enums.h:370
Declares enums and structs used by all platform drivers and the SDK.
NTV2Crosspoint backgroundKeyCrosspoint
ULWord mOperation
In: requested operation.
NTV2AudioSystem acAudioSystem
The audio system being used for this channel (NTV2_AUDIOSYSTEM_INVALID if none)
#define NTV2SDKVersionDecode_Major
#define HEX(__x__)
NTV2Buffer acANCBuffer
The host ancillary data buffer. This field is owned by the client application, and thus is responsibl...
#define DECN(__x__, __n__)
AutoCircTaskType taskType
#define AUTOCIRCULATE_WITH_FIELDS
Use this to AutoCirculate with fields as frames for interlaced formats.
NTV2Buffer mInRegInfos
Read-only array of NTV2RegInfo structs to be set. The SDK owns this memory.
NTV2Buffer ccLookupTables
RGB lookup tables pre-formatted for AJA hardware as a contiguous block of NTV2_COLORCORRECTOR_TABLESI...
ULWord mStatus
Action status.
bool NTV2DeviceGetSupportedInputSources(const NTV2DeviceID inDeviceID, NTV2InputSourceSet &outInputSources, const NTV2IOKinds inKinds)
Returns a set of distinct NTV2InputSource values supported on the given device.
bool SetAllOutputTimeCodes(const NTV2_RP188 &inTimecode, const bool inIncludeF2=true)
Intended for playout, replaces all elements of my acOutputTimeCodes member with the given timecode va...
std::string & replace(std::string &str, const std::string &from, const std::string &to)
Definition: common.cpp:110
std::ostream & Print(std::ostream &inOutStream) const
Prints a human-readable representation of me to the given output stream.
#define AUTOCIRCULATE_WITH_HDMIAUX
Use this to AutoCirculate with HDMI auxiliary data.
bool IsFieldMode(void) const
#define NTV2_TRAILER_TAG
Identifies the struct trailer.
bool WithFBFChange(void) const
#define NTV2_IS_VALID_NTV2FrameGeometry(__s__)
Definition: ntv2enums.h:384
NTV2Crosspoint acCrosspoint
The crosspoint (channel number with direction)
ULWord fTrailerTag
A special FourCC to identify the tail end of an NTV2 structure.
NTV2SDIInputStatus()
Constructs a default NTV2SDIInputStatus.
This is used to enable or disable AJADebug logging in the driver.
bool MatchesThisSDK(void) const
ULWord mOutNumFailures
The number of registers unsuccessfully written.
NTV2Crosspoint foregroundVideoCrosspoint
ULWord fHi
| BG 8 | Hrs 10 | BG 7 | Hrs 1 | BG 6 | Mins10 | BG 5 | Mins 1 |
bool PutU8s(const UByteSequence &inU8s, const size_t inU8Offset=0)
Copies a vector of unsigned 8-bit values into me.
NTV2HDMIBitDepth
Indicates or specifies the HDMI video bit depth.
Definition: ntv2enums.h:3698
#define NTV2_IS_REGISTER_TASK(_x_)
#define NTV2EndianSwap32(__val__)
Definition: ntv2endian.h:19
ULWord acNumActiveBytesPerRow
Number of active bytes in a row of video.
bool POPU16(uint16_t &outVal, const RPCBlob &blob, std::size_t &inOutNdx, const bool dontSwap=false)
Pops a 16-bit value off the given byte sequence at the given zero-based index position.
Definition: ntv2nubtypes.h:128
NTV2RegInfo & setShift(const ULWord val)
bool SetBuffer(const NTV2Buffer &inBuffer)
Sets the buffer to lock for use in a subsequent call to CNTV2Card::DMABufferLock. ...
#define AJA_NTV2_SDK_VERSION_MINOR
The SDK minor version number, an unsigned decimal integer.
Definition: ntv2version.h:14
uint16_t GetStartFrame(void) const
Declares device capability functions.
#define NTV2_IS_VALID_NTV2FrameRate(__r__)
Definition: ntv2enums.h:448
bool WithVidProc(void) const
NTV2Channel NTV2CrosspointToNTV2Channel(const NTV2Crosspoint inCrosspointChannel)
Definition: ntv2utils.cpp:4712
ULWord acFramesProcessed
Total number of frames successfully processed since CNTV2Card::AutoCirculateStart called...
ULWord getSegmentCount(void) const
NTV2_HEADER mHeader
The common structure header – ALWAYS FIRST!
ULWord64 GetRawHostPointer(void) const
720x486, for NTSC 525i and 525p60, NTV2_VANCMODE_TALLER
Definition: ntv2enums.h:369
std::set< UByte > NTV2DIDSet
A set of distinct NTV2DID values.
std::ostream & Print(std::ostream &inOutStream) const
Prints a human-readable representation of me to the given output stream.
NTV2DebugLogging(const bool inEnable=false)
Constructs an NTV2DebugLogging struct.
This is used by the CNTV2Card::WriteRegisters function.
bool SetVideoBuffer(ULWord *pInVideoBuffer, const ULWord inVideoByteCount)
Sets my video buffer for use in a subsequent call to CNTV2Card::AutoCirculateTransfer.
std::string NTV2FrameRateToString(const NTV2FrameRate inValue, const bool inForRetailDisplay=false)
Definition: ntv2utils.cpp:7012
NTV2_TRAILER mTrailer
The common structure trailer – ALWAYS LAST!
ULWord64 audioClockTimeStamp
48kHz clock (in reg 28, extended to 64 bits) at time of play or record.
bool SegmentedDMAsEnabled(void) const
enum NTV2TCIndex NTV2TimecodeIndex
ULWord acTotalBytesTransferred
Total audio and video bytes transferred.
NTV2FrameBufferFormatSetConstIter NTV2PixelFormatsConstIter
ULWord NTV2IOKinds
Definition: ntv2enums.h:1314
bool RPCEncode(NTV2_RPC_BLOB_TYPE &outBlob)
Declares the CNTV2RegisterExpert class.
INTERRUPT_ENUMS interruptID(void) const
bool isDestTopDown(void) const
All NTV2 messages end with this common trailer.
static uint64_t GetThreadId()
Definition: thread.cpp:180
NTV2_TRAILER acTrailer
The common structure trailer – ALWAYS LAST!
ULWord acFrame
(input/ingest/capture only) Current/active frame number.
NTV2FrameGeometry GetNTV2FrameGeometryFromVideoFormat(const NTV2VideoFormat inVideoFormat)
Definition: ntv2utils.cpp:2644
ULWord currentFieldCount
At Call Field0 or Field1 currently being OUTPUT (at the time of the IOCTL_NTV2_GET_FRAMESTAMP) ...
void PUSHU64(const uint64_t val, RPCBlob &blob, const bool dontSwap=false)
Pushes a 64-bit value onto the given byte sequence.
Definition: ntv2nubtypes.h:78
NTV2SegmentedDMAInfo acInSegmentedDMAInfo
Optional segmented DMA info, for use with specialized data transfers.