AJA NTV2 SDK  17.0.1.1246
NTV2 SDK 17.0.1.1246
ntv2dolbycapture.cpp
Go to the documentation of this file.
1 /* SPDX-License-Identifier: MIT */
8 //#define AJA_RAW_AUDIO_RECORD // Uncomment to record raw audio file
9 //#define AJA_WAV_AUDIO_RECORD // Uncomment to record WAV audio file
10 #include "ntv2dolbycapture.h"
11 #include "ntv2utils.h"
12 #include "ntv2debug.h" // for NTV2DeviceString
13 #include "ntv2devicefeatures.h"
14 #include "ajabase/system/process.h"
16 #include <iterator> // for inserter
17 #include <fstream> // for ofstream
18 
19 using namespace std;
20 
21 #define NTV2_AUDIOSIZE_MAX (401 * 1024)
22 #define NTV2_ANCILLARYSIZE_MAX (256 * 1024)
23 //#define NTV2_BUFFER_LOCK
24 
25 
27 
29  : mConsumerThread (AJAThread()),
30  mProducerThread (AJAThread()),
31  mDeviceID (DEVICE_ID_NOTFOUND),
32  mConfig (inConfig),
33  mVideoFormat (NTV2_FORMAT_UNKNOWN),
34  mSavedTaskMode (NTV2_DISABLE_TASKS),
35  mAudioSystem (NTV2_AUDIOSYSTEM_1),
36  mGlobalQuit (false),
37  mHostBuffers (),
38  mAVCircularBuffer ()
39 {
40 } // constructor
41 
42 
44 {
45  // Stop my capture and consumer threads, then destroy them...
46  Quit();
47 
48  // Unsubscribe from input vertical event...
50 
51 } // destructor
52 
53 
55 {
56  // Set the global 'quit' flag, and wait for the threads to go inactive...
57  mGlobalQuit = true;
58 
59  while (mConsumerThread.Active())
60  AJATime::Sleep(10);
61 
62  while (mProducerThread.Active())
63  AJATime::Sleep(10);
64 
65  if (!mConfig.fDoMultiFormat)
66  {
67  mDevice.ReleaseStreamForApplication (kDemoAppSignature, static_cast<int32_t>(AJAProcess::GetPid()));
68  mDevice.SetEveryFrameServices(mSavedTaskMode); // Restore prior task mode
69  }
70 
71 } // Quit
72 
73 
75 {
77 
78  // Open the device...
80  {cerr << "## ERROR: Device '" << mConfig.fDeviceSpec << "' not found" << endl; return AJA_STATUS_OPEN;}
81 
82  if (!mDevice.IsDeviceReady(false))
83  {cerr << "## ERROR: Device '" << mConfig.fDeviceSpec << "' not ready" << endl; return AJA_STATUS_INITIALIZE;}
84 
85  mDeviceID = mDevice.GetDeviceID(); // Keep the device ID handy, as it's used frequently
86  if (!::NTV2DeviceCanDoCapture(mDeviceID))
87  {cerr << "## ERROR: Device '" << mConfig.fDeviceSpec << "' cannot capture" << endl; return AJA_STATUS_FEATURE;}
88 
89  ULWord appSignature (0);
90  int32_t appPID (0);
91  mDevice.GetStreamingApplication (appSignature, appPID); // Who currently "owns" the device?
92  mDevice.GetEveryFrameServices(mSavedTaskMode); // Save the current device state
93  if (!mConfig.fDoMultiFormat)
94  {
95  if (!mDevice.AcquireStreamForApplication (kDemoAppSignature, static_cast<int32_t>(AJAProcess::GetPid())))
96  {
97  cerr << "## ERROR: Unable to acquire device because another app (pid " << appPID << ") owns it" << endl;
98  return AJA_STATUS_BUSY; // Another app is using the device
99  }
100  mDevice.GetEveryFrameServices(mSavedTaskMode); // Save the current state before we change it
101  }
102  mDevice.SetEveryFrameServices(NTV2_OEM_TASKS); // Since this is an OEM demo, use the OEM service level
103 
104  if (::NTV2DeviceCanDoMultiFormat(mDeviceID))
105  mDevice.SetMultiFormatMode(mConfig.fDoMultiFormat);
106 
108  mConfig.fInputChannel = NTV2_CHANNEL1;
113  // On KonaHDMI, map specified SDI input to equivalent HDMI input...
116 
117  // Set up the video and audio...
118  status = SetupVideo();
119  if (AJA_FAILURE(status))
120  return status;
121 
122  status = SetupAudio();
123  if (AJA_FAILURE(status))
124  return status;
125 
126  // Set up the circular buffers, the device signal routing, and both playout and capture AutoCirculate...
129 
130  mDolbyState = 0;
131 
132  #if defined(_DEBUG)
133  cerr << mConfig;
134  if (mDevice.IsRemote())
135  cerr << "Device Description: " << mDevice.GetDescription() << endl;
136  cerr << endl;
137  #endif // defined(_DEBUG)
138  return AJA_STATUS_SUCCESS;
139 
140 } // Init
141 
142 
144 {
145  // Sometimes other applications disable some or all of the frame buffers, so turn on ours now...
146  mDevice.EnableChannel(mConfig.fInputChannel);
147 
148  // Enable and subscribe to the interrupts for the channel to be used...
149  mDevice.EnableInputInterrupt(mConfig.fInputChannel);
151 
152  // Determine the input video signal format...
153  mVideoFormat = mDevice.GetInputVideoFormat (mConfig.fInputSource);
154  if (mVideoFormat == NTV2_FORMAT_UNKNOWN)
155  {
156  cerr << "## ERROR: No input signal or unknown format" << endl;
157  return AJA_STATUS_NOINPUT; // Sorry, can't handle this format
158  }
159  mProgressive = NTV2_VIDEO_FORMAT_HAS_PROGRESSIVE_PICTURE(mVideoFormat);
160 
161  // Set the frame buffer pixel format for all the channels on the device
162  // (assuming it supports that pixel format -- otherwise default to 8-bit YCbCr)...
163  if (!::NTV2DeviceCanDoFrameBufferFormat (mDeviceID, mConfig.fPixelFormat))
164  {
165  cerr << "## WARNING: " << ::NTV2FrameBufferFormatToString(mConfig.fPixelFormat)
166  << " unsupported, using " << ::NTV2FrameBufferFormatToString(NTV2_FBF_8BIT_YCBCR)
167  << " instead" << endl;
169  }
170 
171  // Set the device video format to whatever we detected at the input...
172  if (NTV2_IS_4K_VIDEO_FORMAT(mVideoFormat))
173  {
175  mDevice.SetVideoFormat (mVideoFormat, false, false, NTV2_CHANNEL1);
176  mDevice.SetTsiFrameEnable(true, NTV2_CHANNEL1);
178  }
179  else
180  {
182  mDevice.SetVideoFormat (mVideoFormat, false, false, mConfig.fInputChannel);
183  mDevice.SetTsiFrameEnable(false, mConfig.fInputChannel);
184  mDevice.SetFrameBufferFormat (mConfig.fInputChannel, mConfig.fPixelFormat);
185  }
186 
187  return AJA_STATUS_SUCCESS;
188 
189 } // SetupVideo
190 
191 
193 {
194  return AJA_STATUS_SUCCESS;
195 
196 } // SetupAudio
197 
198 
200 {
203  ULWord F1AncSize(0), F2AncSize(0);
204  mDevice.GetVANCMode (vancMode);
205  mDevice.GetStandard (standard);
206 
207  // Let my circular buffer know when it's time to quit...
208  mAVCircularBuffer.SetAbortFlag (&mGlobalQuit);
209 
210  // configure anc buffers
212  F1AncSize = NTV2_ANCILLARYSIZE_MAX;
213  F2AncSize = NTV2_ANCILLARYSIZE_MAX;
214 
215  mFormatDesc = NTV2FormatDescriptor (standard, mConfig.fPixelFormat, vancMode);
216 
217  // Allocate and add each in-host NTV2FrameData to my circular buffer member variable...
218  mHostBuffers.reserve(size_t(CIRCULAR_BUFFER_SIZE));
219  while (mHostBuffers.size() < size_t(CIRCULAR_BUFFER_SIZE))
220  {
221  mHostBuffers.push_back(NTV2FrameData());
222  NTV2FrameData & frameData(mHostBuffers.back());
223  frameData.fVideoBuffer.Allocate(::GetVideoWriteSize (mVideoFormat, mConfig.fPixelFormat, vancMode));
225  if (F1AncSize)
226  frameData.fAncBuffer.Allocate(F1AncSize);
227  if (!mProgressive && F2AncSize)
228  frameData.fAncBuffer2.Allocate(F2AncSize);
229  mAVCircularBuffer.Add(&frameData);
230 
231 #ifdef NTV2_BUFFER_LOCK
232  // Page lock the memory
233  if (frameData.fVideoBuffer)
234  mDevice.DMABufferLock(frameData.fVideoBuffer, true);
235  if (frameData.fAncBuffer)
236  mDevice.DMABufferLock(frameData.fAncBuffer, true);
237  if (frameData.fAncBuffer2)
238  mDevice.DMABufferLock(frameData.fAncBuffer2, true);
239 #endif
240  } // for each NTV2FrameData
241 
242 } // SetupHostBuffers
243 
244 
246 {
247  // For this simple example, tie the user-selected input to frame buffer 1.
248  // Is this user-selected input supported on the device?
249  if (!::NTV2DeviceCanDoInputSource (mDeviceID, mConfig.fInputSource))
251 
254  mDevice.GetHDMIInputColor (inputColor, mConfig.fInputChannel);
255 
256  const bool canVerify (mDevice.HasCanConnectROM());
257  const bool isInputRGB (inputColor == NTV2_LHIHDMIColorSpaceRGB);
258  const bool isFrameRGB (::IsRGBFormat(mConfig.fPixelFormat));
259  const NTV2OutputCrosspointID inputWidgetOutputXpt (::GetInputSourceOutputXpt(mConfig.fInputSource, false, isInputRGB, 0));
260  const NTV2InputCrosspointID frameBufferInputXpt (::GetFrameBufferInputXptFromChannel(mConfig.fInputChannel));
261  const NTV2InputCrosspointID cscWidgetVideoInputXpt (::GetCSCInputXptFromChannel(mConfig.fInputChannel));
262  const NTV2OutputCrosspointID cscWidgetRGBOutputXpt (::GetCSCOutputXptFromChannel(mConfig.fInputChannel, /*inIsKey*/ false, /*inIsRGB*/ true));
263  const NTV2OutputCrosspointID cscWidgetYUVOutputXpt (::GetCSCOutputXptFromChannel(mConfig.fInputChannel, /*inIsKey*/ false, /*inIsRGB*/ false));
264 
265 
266  if (!mConfig.fDoMultiFormat)
267  mDevice.ClearRouting();
268 
269  if (NTV2_IS_4K_VIDEO_FORMAT(mVideoFormat))
270  {
271  if (isInputRGB && !isFrameRGB)
272  {
273  mDevice.Connect(NTV2_XptCSC1VidInput, NTV2_XptHDMIIn1RGB, canVerify);
277 
278  mDevice.Connect(NTV2_Xpt425Mux1AInput, NTV2_XptCSC1VidYUV, canVerify);
279  mDevice.Connect(NTV2_Xpt425Mux1BInput, NTV2_XptCSC2VidYUV, canVerify);
280  mDevice.Connect(NTV2_Xpt425Mux2AInput, NTV2_XptCSC3VidYUV, canVerify);
281  mDevice.Connect(NTV2_Xpt425Mux2BInput, NTV2_XptCSC4VidYUV, canVerify);
282 
287  }
288  else if (!isInputRGB && isFrameRGB)
289  {
290  mDevice.Connect(NTV2_XptCSC1VidInput, NTV2_XptHDMIIn1, canVerify);
291  mDevice.Connect(NTV2_XptCSC2VidInput, NTV2_XptHDMIIn1Q2, canVerify);
292  mDevice.Connect(NTV2_XptCSC3VidInput, NTV2_XptHDMIIn1Q3, canVerify);
293  mDevice.Connect(NTV2_XptCSC4VidInput, NTV2_XptHDMIIn1Q4, canVerify);
294 
295  mDevice.Connect(NTV2_Xpt425Mux1AInput, NTV2_XptCSC1VidRGB, canVerify);
296  mDevice.Connect(NTV2_Xpt425Mux1BInput, NTV2_XptCSC2VidRGB, canVerify);
297  mDevice.Connect(NTV2_Xpt425Mux2AInput, NTV2_XptCSC3VidRGB, canVerify);
298  mDevice.Connect(NTV2_Xpt425Mux2BInput, NTV2_XptCSC4VidRGB, canVerify);
299 
304  }
305  else if (isInputRGB && isFrameRGB)
306  {
307  mDevice.Connect(NTV2_Xpt425Mux1AInput, NTV2_XptHDMIIn1RGB, canVerify);
311 
316  }
317  else
318  {
319  mDevice.Connect(NTV2_Xpt425Mux1AInput, NTV2_XptHDMIIn1, canVerify);
320  mDevice.Connect(NTV2_Xpt425Mux1BInput, NTV2_XptHDMIIn1Q2, canVerify);
321  mDevice.Connect(NTV2_Xpt425Mux2AInput, NTV2_XptHDMIIn1Q3, canVerify);
322  mDevice.Connect(NTV2_Xpt425Mux2BInput, NTV2_XptHDMIIn1Q4, canVerify);
323 
328  }
329  }
330  else
331  {
332  if (isInputRGB && !isFrameRGB)
333  {
334  mDevice.Connect (frameBufferInputXpt, cscWidgetYUVOutputXpt, canVerify); // Frame store input to CSC widget's YUV output
335  mDevice.Connect (cscWidgetVideoInputXpt, inputWidgetOutputXpt, canVerify); // CSC widget's RGB input to input widget's output
336  }
337  else if (!isInputRGB && isFrameRGB)
338  {
339  mDevice.Connect (frameBufferInputXpt, cscWidgetRGBOutputXpt, canVerify); // Frame store input to CSC widget's RGB output
340  mDevice.Connect (cscWidgetVideoInputXpt, inputWidgetOutputXpt, canVerify); // CSC widget's YUV input to input widget's output
341  }
342  else
343  mDevice.Connect (frameBufferInputXpt, inputWidgetOutputXpt, canVerify); // Frame store input to input widget's output
344  }
345 
346 } // RouteInputSignal
347 
348 
350 {
351  // Start the playout and capture threads...
354  return AJA_STATUS_SUCCESS;
355 
356 } // Run
357 
358 
360 
361 // This is where we will start the consumer thread
363 {
364  // Create and start the consumer thread...
365  mConsumerThread.Attach(ConsumerThreadStatic, this);
366  mConsumerThread.SetPriority(AJA_ThreadPriority_High);
367  mConsumerThread.Start();
368 
369 } // StartConsumerThread
370 
371 
372 // The consumer thread function
373 void NTV2DolbyCapture::ConsumerThreadStatic (AJAThread * pThread, void * pContext) // static
374 {
375  (void) pThread;
376 
377  // Grab the NTV2DolbyCapture instance pointer from the pContext parameter,
378  // then call its ConsumeFrames method...
379  NTV2DolbyCapture * pApp (reinterpret_cast <NTV2DolbyCapture *> (pContext));
380  pApp->ConsumeFrames ();
381 
382 } // ConsumerThreadStatic
383 
384 
386 {
387  uint64_t ancTally(0);
388  uint64_t audioTally(0);
389  uint64_t dolbyTally(0);
390  ofstream * pOFS(mConfig.fWithAnc ? new ofstream(mConfig.fAncDataFilePath.c_str(), ios::binary) : AJA_NULL);
391  ofstream * pAFS(mConfig.fWithAudio ? new ofstream(mConfig.fAudioDataFilePath.c_str(), ios::binary) : AJA_NULL);
392  ofstream * pDFS(mConfig.fWithDolby ? new ofstream(mConfig.fDolbyDataFilePath.c_str(), ios::binary) : AJA_NULL);
393  while (!mGlobalQuit)
394  {
395  // Wait for the next frame to become ready to "consume"...
396  NTV2FrameData * pFrameData (mAVCircularBuffer.StartConsumeNextBuffer ());
397  if (pFrameData)
398  {
399  if (mConfig.fDoFrameData && pFrameData->AncBuffer())
400  {
401  uint8_t* pData = (uint8_t*)pFrameData->AncBuffer().GetHostAddress(0);
402  uint32_t i;
403  for (i = 0; i < pFrameData->AncBufferSize(); i += 32)
404  {
405  if (pData[i] == 0xff)
406  break;
407  }
408  uint32_t audioSize = RecoverAudio(pFrameData->AncBuffer(), pFrameData->AncBufferSize() /*pFrameData->NumCapturedAncBytes()*/, pFrameData->AudioBuffer());
409  printf("f1 size reg %d ffs %d samples %d\n", pFrameData->NumCapturedAncBytes(), i, audioSize/4);
410  fflush(stdout);
411  }
412 
413  if (mConfig.fDoFrameData && !mProgressive && pFrameData->AncBuffer2())
414  {
415  uint8_t* pData = (uint8_t*)pFrameData->AncBuffer2().GetHostAddress(0);
416  uint32_t i;
417  for (i = 0; i < pFrameData->AncBuffer2Size(); i += 32)
418  {
419  if (pData[i] == 0xff)
420  break;
421  }
422  uint32_t audioSize = RecoverAudio(pFrameData->AncBuffer2(), pFrameData->AncBuffer2Size() /*pFrameData->NumCapturedAnc2Bytes()*/, pFrameData->AudioBuffer());
423  printf("f2 size reg %d ffs %d samples %d\n", pFrameData->NumCapturedAnc2Bytes(), i, audioSize/4);
424  fflush(stdout);
425  }
426 
427  if (pOFS && pFrameData->AncBuffer())
428  {
429  pOFS->write(pFrameData->AncBuffer(), streamsize(pFrameData->NumCapturedAncBytes()));
430  ancTally++;
431  if (!mProgressive && pFrameData->AncBuffer2())
432  {
433  if (pOFS && pFrameData->AncBuffer2())
434  pOFS->write(pFrameData->AncBuffer2(), streamsize(pFrameData->NumCapturedAnc2Bytes()));
435  }
436  }
437 
438  if (pAFS && pFrameData->AncBuffer() && pFrameData->AudioBuffer())
439  {
440  uint32_t audioSize = RecoverAudio(pFrameData->AncBuffer(), pFrameData->NumCapturedAncBytes(), pFrameData->AudioBuffer());
441  pAFS->write(pFrameData->AudioBuffer(), streamsize(audioSize));
442  audioTally++;
443  if (!mProgressive && pFrameData->AncBuffer2())
444  {
445  audioSize = RecoverAudio(pFrameData->AncBuffer2(), pFrameData->NumCapturedAnc2Bytes(), pFrameData->AudioBuffer());
446  pAFS->write(pFrameData->AudioBuffer(), streamsize(audioSize));
447  }
448  }
449 
450  if (pDFS && pFrameData->AncBuffer() && pFrameData->AudioBuffer())
451  {
452  uint32_t audioSize = RecoverAudio(pFrameData->AncBuffer(), pFrameData->NumCapturedAncBytes(), pFrameData->AudioBuffer());
453  uint32_t dolbySize = RecoverDolby(pFrameData->AudioBuffer(), audioSize, pFrameData->AncBuffer());
454  pDFS->write(pFrameData->AncBuffer(), streamsize(dolbySize));
455  dolbyTally++;
456  if (!mProgressive && pFrameData->AncBuffer2())
457  {
458  audioSize = RecoverAudio(pFrameData->AncBuffer2(), pFrameData->NumCapturedAnc2Bytes(), pFrameData->AudioBuffer());
459  dolbySize = RecoverDolby(pFrameData->AudioBuffer(), audioSize, pFrameData->AncBuffer2());
460  pDFS->write(pFrameData->AncBuffer2(), streamsize(dolbySize));
461  }
462  }
463 
464  // Now release and recycle the buffer...
465  mAVCircularBuffer.EndConsumeNextBuffer ();
466  } // if pFrameData
467  } // loop til quit signaled
468  if (pOFS)
469  { delete pOFS; cerr << "Wrote " << DEC(ancTally) << " frames of raw anc data" << endl; }
470  if (pAFS)
471  { delete pAFS; cerr << "Wrote " << DEC(audioTally) << " frames of raw audio data" << endl; }
472  if (pDFS)
473  { delete pDFS; cerr << "Wrote " << DEC(dolbyTally) << " frames of dolby data" << endl; }
474 
475 } // ConsumeFrames
476 
477 
479 
480 // This is where we start the capture thread
482 {
483  // Create and start the capture thread...
484  mProducerThread.Attach(ProducerThreadStatic, this);
485  mProducerThread.SetPriority(AJA_ThreadPriority_High);
486  mProducerThread.Start();
487 
488 } // StartProducerThread
489 
490 
491 // The capture thread function
492 void NTV2DolbyCapture::ProducerThreadStatic (AJAThread * pThread, void * pContext) // static
493 {
494  (void) pThread;
495 
496  // Grab the NTV2DolbyCapture instance pointer from the pContext parameter,
497  // then call its CaptureFrames method...
498  NTV2DolbyCapture * pApp (reinterpret_cast <NTV2DolbyCapture *> (pContext));
499  pApp->CaptureFrames ();
500 
501 } // ProducerThreadStatic
502 
503 
505 {
506  AUTOCIRCULATE_TRANSFER inputXfer; // My A/C input transfer info
507  ULWord acOptions (0);
508  acOptions |= AUTOCIRCULATE_WITH_ANC;
509  acOptions |= AUTOCIRCULATE_WITH_HDMIAUX;
510 
511  CAPNOTE("Thread started");
512  // Initialize and start capture AutoCirculate...
513  mDevice.AutoCirculateStop(mConfig.fInputChannel); // Just in case
514  mDevice.AutoCirculateInitForInput ( mConfig.fInputChannel, // primary channel
515  mConfig.fFrames.count(), // numFrames (zero if specifying range)
516  mAudioSystem, // audio system
517  acOptions, // flags
518  1, // numChannels to gang
519  mConfig.fFrames.firstFrame(), mConfig.fFrames.lastFrame());
520 
521  // This needs an ntv2card api
522  if (mConfig.fDoAudioFilter)
523  {
525  mDevice.WriteRegister(7628, 0x2);
526  }
527  else
528  {
530  mDevice.WriteRegister(7628, 0x0);
531  }
532 
533  mDevice.AutoCirculateStart(mConfig.fInputChannel);
534 
535  while (!mGlobalQuit)
536  {
537  AUTOCIRCULATE_STATUS acStatus;
538  mDevice.AutoCirculateGetStatus (mConfig.fInputChannel, acStatus);
539 
540  if (acStatus.IsRunning() && acStatus.HasAvailableInputFrame())
541  {
542  // At this point, there's at least one fully-formed frame available in the device's
543  // frame buffer to transfer to the host. Reserve an NTV2FrameData to "produce", and
544  // use it in the next transfer from the device...
545  NTV2FrameData * pCaptureData(mAVCircularBuffer.StartProduceNextBuffer());
546 
547  inputXfer.SetVideoBuffer (pCaptureData->VideoBuffer(), pCaptureData->VideoBufferSize());
548  if (acStatus.WithCustomAnc())
549  inputXfer.SetAncBuffers (pCaptureData->AncBuffer(), pCaptureData->AncBufferSize(),
550  pCaptureData->AncBuffer2(), pCaptureData->AncBuffer2Size());
551 
552  // Clear anc buffers
553  if (pCaptureData->AncBuffer())
554  pCaptureData->AncBuffer().Fill(uint8_t(0));
555  if (pCaptureData->AncBuffer2())
556  pCaptureData->AncBuffer2().Fill(uint8_t(0));
557 
558  // Transfer video/audio/anc from the device into our host buffers...
559  mDevice.AutoCirculateTransfer (mConfig.fInputChannel, inputXfer);
560 
561  // Get number of anc bytes
562  if (pCaptureData->AncBuffer())
563  pCaptureData->fNumAncBytes = inputXfer.GetCapturedAncByteCount(/*isF2*/false);
564  if (pCaptureData->AncBuffer2())
565  pCaptureData->fNumAnc2Bytes = inputXfer.GetCapturedAncByteCount(/*isF2*/true);
566 
567  // Signal that we're done "producing" the frame, making it available for future "consumption"...
568  mAVCircularBuffer.EndProduceNextBuffer();
569  } // if A/C running and frame(s) are available for transfer
570  else
571  {
572  // Either AutoCirculate is not running, or there were no frames available on the device to transfer.
573  // Rather than waste CPU cycles spinning, waiting until a frame becomes available, it's far more
574  // efficient to wait for the next input vertical interrupt event to get signaled...
576  }
577 
578  } // loop til quit signaled
579 
580  // Stop AutoCirculate...
581  mDevice.AutoCirculateStop(mConfig.fInputChannel);
582  CAPNOTE("Thread completed, will exit");
583 
584 } // CaptureFrames
585 
586 
587 void NTV2DolbyCapture::GetACStatus (ULWord & outGoodFrames, ULWord & outDroppedFrames, ULWord & outBufferLevel)
588 {
589  AUTOCIRCULATE_STATUS status;
590  mDevice.AutoCirculateGetStatus (mConfig.fInputChannel, status);
591  outGoodFrames = status.acFramesProcessed;
592  outDroppedFrames = status.acFramesDropped;
593  outBufferLevel = status.acBufferLevel;
594 }
595 
596 uint32_t NTV2DolbyCapture::RecoverAudio(NTV2Buffer & anc, uint32_t ancSize, NTV2Buffer & audio)
597 {
598  uint8_t* audioData = (uint8_t*)audio.GetHostAddress(0);
599  uint32_t audioSize = 0;
600  uint8_t* ancData = (uint8_t*)anc.GetHostAddress(0);
601 
602  // extract the first 16 bit stereo pair from the aux data
603  for (uint32_t i = 0; i < ancSize/32; i++)
604  {
605  // audio data aux packet?
606  if (ancData[0] == 0x02)
607  {
608  // first sample present?
609  if ((ancData[1] & 0x01) != 0)
610  {
611  // first sample flat?
612  if ((ancData[2] & 0x01) != 0)
613  {
614  *audioData++ = 0;
615  *audioData++ = 0;
616  *audioData++ = 0;
617  *audioData++ = 0;
618  }
619  else
620  {
621  *audioData++ = ancData[4];
622  *audioData++ = ancData[5];
623  *audioData++ = ancData[7];
624  *audioData++ = ancData[8];
625  }
626  audioSize += 4;
627  }
628  // only 2 channels?
629  if ((ancData[1] & 0x10) == 0)
630  {
631  // second sample present?
632  if ((ancData[1] & 0x02) != 0)
633  {
634  // second sampel flat?
635  if ((ancData[2] & 0x02) != 0)
636  {
637  *audioData++ = 0;
638  *audioData++ = 0;
639  *audioData++ = 0;
640  *audioData++ = 0;
641  }
642  else
643  {
644  *audioData++ = ancData[11];
645  *audioData++ = ancData[12];
646  *audioData++ = ancData[14];
647  *audioData++ = ancData[15];
648  }
649  audioSize += 4;
650  }
651  // third sample present?
652  if ((ancData[1] & 0x04) != 0)
653  {
654  // third sample flat?
655  if ((ancData[2] & 0x04) != 0)
656  {
657  *audioData++ = 0;
658  *audioData++ = 0;
659  *audioData++ = 0;
660  *audioData++ = 0;
661  }
662  else
663  {
664  *audioData++ = ancData[18];
665  *audioData++ = ancData[19];
666  *audioData++ = ancData[21];
667  *audioData++ = ancData[22];
668  }
669  audioSize += 4;
670  }
671  // fourth sample present?
672  if ((ancData[1] & 0x08) != 0)
673  {
674  // fourth sample flat?
675  if ((ancData[2] & 0x08) != 0)
676  {
677  *audioData++ = 0;
678  *audioData++ = 0;
679  *audioData++ = 0;
680  *audioData++ = 0;
681  }
682  else
683  {
684  *audioData++ = ancData[25];
685  *audioData++ = ancData[26];
686  *audioData++ = ancData[28];
687  *audioData++ = ancData[29];
688  }
689  audioSize += 4;
690  }
691  }
692  }
693  ancData += 32;
694  }
695 
696  return audioSize;
697 }
698 
699 uint32_t NTV2DolbyCapture::RecoverDolby(NTV2Buffer & audio, uint32_t audioSize, NTV2Buffer & dolby)
700 {
701  uint16_t* dolbyData = (uint16_t*)dolby.GetHostAddress(0);
702  uint32_t dolbySize = 0;
703  uint16_t* audioData = (uint16_t*)audio.GetHostAddress(0);
704 
705  // extract the dolby frames from the IEC61937 bursts
706  for (uint32_t i = 0; i < audioSize / 2; i++)
707  {
708  switch (mDolbyState)
709  {
710  // find IEC61937 burst preamble
711  case 0:
712  mDolbyState = (*audioData == 0xf872)? 1 : 0;
713  break;
714  case 1:
715  mDolbyState = (*audioData == 0x4e1f)? 2 : 0;
716  break;
717  // check dolby code
718  case 2:
719  mDolbyState = ((*audioData & 0xff) == 0x15)? 3 : 0;
720  break;
721  // get burst length
722  case 3:
723  mDolbyLength = (uint32_t)*audioData / 2;
724  mDolbyState = 4;
725  break;
726  // copy dolby samples
727  case 4:
728  if (mDolbyLength > 0)
729  {
730  if (dolbySize < dolby.GetByteCount() / 2)
731  {
732  // endian swap the data
733  *dolbyData = (*audioData >> 8) & 0xff;
734  *dolbyData |= (*audioData & 0xff) << 8;
735  dolbyData++;
736  dolbySize++;
737  mDolbyLength--;
738  }
739  }
740  else
741  {
742  mDolbyState = 0;
743  }
744  break;
745  default:
746  mDolbyState = 0;
747  break;
748  }
749  audioData++;
750  }
751 
752  return dolbySize * 2;
753 }
754 
755 
757 
758 
759 AJALabelValuePairs DolbyConfig::Get (const bool inCompact) const
760 {
761  AJALabelValuePairs result;
762  AJASystemInfo::append(result, "Capture Config");
763  AJASystemInfo::append(result, "Device Specifier", fDeviceSpec);
764  AJASystemInfo::append(result, "Input Channel", ::NTV2ChannelToString(fInputChannel, inCompact));
765  AJASystemInfo::append(result, "Input Source", ::NTV2InputSourceToString(fInputSource, inCompact));
766  AJASystemInfo::append(result, "Pixel Format", ::NTV2FrameBufferFormatToString(fPixelFormat, inCompact));
767  AJASystemInfo::append(result, "AutoCirc Frames", fFrames.toString());
768  AJASystemInfo::append(result, "MultiFormat Mode", fDoMultiFormat ? "Y" : "N");
769  AJASystemInfo::append(result, "Anc Capture File", fAncDataFilePath);
770  AJASystemInfo::append(result, "Audio Capture File", fAudioDataFilePath);
771  AJASystemInfo::append(result, "Dolby Capture File", fDolbyDataFilePath);
772  return result;
773 }
774 
775 
776 std::ostream & operator << (std::ostream & ioStrm, const DolbyConfig & inObj)
777 {
778  ioStrm << AJASystemInfo::ToString(inObj.Get());
779  return ioStrm;
780 }
NTV2FrameData::NumCapturedAnc2Bytes
ULWord NumCapturedAnc2Bytes(void) const
Definition: ntv2democommon.h:119
NTV2DeviceCanDoCapture
bool NTV2DeviceCanDoCapture(const NTV2DeviceID inDeviceID)
Definition: ntv2devicefeatures.hpp:1907
NTV2InputSourceToReferenceSource
NTV2ReferenceSource NTV2InputSourceToReferenceSource(const NTV2InputSource inInputSource)
Converts a given NTV2InputSource to its equivalent NTV2ReferenceSource value.
Definition: ntv2utils.cpp:5081
CNTV2Card::SetMultiFormatMode
virtual bool SetMultiFormatMode(const bool inEnable)
Enables or disables multi-format (per channel) device operation. If enabled, each device channel can ...
Definition: ntv2register.cpp:4281
NTV2DolbyCapture::ProducerThreadStatic
static void ProducerThreadStatic(AJAThread *pThread, void *pContext)
This is the capture thread's static callback function that gets called when the capture thread runs....
Definition: ntv2dolbycapture.cpp:492
NTV2_Xpt425Mux1AInput
@ NTV2_Xpt425Mux1AInput
Definition: ntv2enums.h:2797
NTV2ChannelToInputSource
NTV2InputSource NTV2ChannelToInputSource(const NTV2Channel inChannel, const NTV2IOKinds inKinds=NTV2_IOKINDS_SDI)
Definition: ntv2utils.cpp:5190
ntv2dolbycapture.h
Declares the NTV2DolbyCapture class.
NTV2InputSourceToChannel
NTV2Channel NTV2InputSourceToChannel(const NTV2InputSource inInputSource)
Converts a given NTV2InputSource to its equivalent NTV2Channel value.
Definition: ntv2utils.cpp:5105
AUTOCIRCULATE_STATUS::acFramesProcessed
ULWord acFramesProcessed
Total number of frames successfully processed since CNTV2Card::AutoCirculateStart called.
Definition: ntv2publicinterface.h:7116
NTV2_Xpt425Mux2BRGB
@ NTV2_Xpt425Mux2BRGB
Definition: ntv2enums.h:2596
NTV2_Xpt425Mux1ARGB
@ NTV2_Xpt425Mux1ARGB
Definition: ntv2enums.h:2590
NTV2DeviceGetNumHDMIVideoInputs
UWord NTV2DeviceGetNumHDMIVideoInputs(const NTV2DeviceID inDeviceID)
Definition: ntv2devicefeatures.hpp:10766
NTV2_Xpt425Mux1BRGB
@ NTV2_Xpt425Mux1BRGB
Definition: ntv2enums.h:2592
DolbyConfig::fDoAudioFilter
bool fDoAudioFilter
If true, capture only audio anc.
Definition: ntv2dolbycapture.h:37
AJA_ThreadPriority_High
@ AJA_ThreadPriority_High
Definition: thread.h:44
NTV2ACFrameRange::firstFrame
UWord firstFrame(void) const
Definition: ntv2utils.h:975
NTV2_ANCILLARYSIZE_MAX
#define NTV2_ANCILLARYSIZE_MAX
Definition: ntv2dolbycapture.cpp:22
ntv2devicefeatures.h
Declares device capability functions.
NTV2LHIHDMIColorSpace
NTV2LHIHDMIColorSpace
Definition: ntv2enums.h:3592
DolbyConfig::fDeviceSpec
std::string fDeviceSpec
The AJA device to use.
Definition: ntv2dolbycapture.h:29
NTV2FormatDescriptor
Describes a video frame for a given video standard or format and pixel format, including the total nu...
Definition: ntv2formatdescriptor.h:41
DolbyConfig::fDolbyDataFilePath
std::string fDolbyDataFilePath
Optional path to Dolby binary data file.
Definition: ntv2dolbycapture.h:32
NTV2FrameData
I encapsulate the video, audio and anc host buffers used in the AutoCirculate demos....
Definition: ntv2democommon.h:79
NTV2_VIDEO_FORMAT_HAS_PROGRESSIVE_PICTURE
#define NTV2_VIDEO_FORMAT_HAS_PROGRESSIVE_PICTURE(__f__)
Definition: ntv2enums.h:1008
NTV2FrameData::fNumAncBytes
ULWord fNumAncBytes
Actual number of captured F1 anc bytes.
Definition: ntv2democommon.h:89
NTV2Buffer
A generic user-space buffer object that has an address and a length. Used most often to share an arbi...
Definition: ntv2publicinterface.h:5967
AJA_STATUS_SUCCESS
@ AJA_STATUS_SUCCESS
Definition: types.h:368
CNTV2Card::GetStandard
virtual bool GetStandard(NTV2Standard &outValue, NTV2Channel inChannel=NTV2_CHANNEL1)
Definition: ntv2register.cpp:830
NTV2DolbyCapture::GetACStatus
virtual void GetACStatus(ULWord &outGoodFrames, ULWord &outDroppedFrames, ULWord &outBufferLevel)
Provides status information about my input (capture) process.
Definition: ntv2dolbycapture.cpp:587
NTV2Buffer::GetByteCount
ULWord GetByteCount(void) const
Definition: ntv2publicinterface.h:6040
NTV2_STANDARD_INVALID
@ NTV2_STANDARD_INVALID
Definition: ntv2enums.h:173
NTV2_XptCSC4VidInput
@ NTV2_XptCSC4VidInput
Definition: ntv2enums.h:2710
NTV2DolbyCapture::Init
virtual AJAStatus Init(void)
Initializes me and prepares me to Run.
Definition: ntv2dolbycapture.cpp:74
AJAThread::Attach
virtual AJAStatus Attach(AJAThreadFunction *pThreadFunction, void *pUserContext)
Definition: thread.cpp:169
CNTV2Card::WaitForInputVerticalInterrupt
virtual bool WaitForInputVerticalInterrupt(const NTV2Channel inChannel=NTV2_CHANNEL1, UWord inRepeatCount=1)
Efficiently sleeps the calling thread/process until the next one or more field (interlaced video) or ...
Definition: ntv2subscriptions.cpp:149
CNTV2Card::EnableInputInterrupt
virtual bool EnableInputInterrupt(const NTV2Channel channel=NTV2_CHANNEL1)
Allows the CNTV2Card instance to wait for and respond to input vertical blanking interrupts originati...
Definition: ntv2interrupts.cpp:23
NTV2FrameData::AncBuffer2
NTV2Buffer & AncBuffer2(void)
Definition: ntv2democommon.h:117
systemtime.h
Declares the AJATime class.
DolbyConfig::fDoFrameData
bool fDoFrameData
if true, output per frame statistics
Definition: ntv2dolbycapture.h:38
AJA_STATUS_BUSY
@ AJA_STATUS_BUSY
Definition: types.h:378
NTV2DolbyCapture::CaptureFrames
virtual void CaptureFrames(void)
Repeatedly captures frames using AutoCirculate (until global quit flag set).
Definition: ntv2dolbycapture.cpp:504
CNTV2DeviceScanner::GetFirstDeviceFromArgument
static bool GetFirstDeviceFromArgument(const std::string &inArgument, CNTV2Card &outDevice)
Rescans the host, and returns an open CNTV2Card instance for the AJA device that matches a command li...
Definition: ntv2devicescanner.cpp:327
NTV2_Xpt425Mux2AYUV
@ NTV2_Xpt425Mux2AYUV
Definition: ntv2enums.h:2593
operator<<
std::ostream & operator<<(std::ostream &ioStrm, const DolbyConfig &inObj)
Definition: ntv2dolbycapture.cpp:776
DolbyConfig::fInputChannel
NTV2Channel fInputChannel
The device channel to use.
Definition: ntv2dolbycapture.h:33
DolbyConfig
This class is used to configure an NTV2Capture instance.
Definition: ntv2dolbycapture.h:26
NTV2_AUDIOSYSTEM_1
@ NTV2_AUDIOSYSTEM_1
This identifies the first Audio System.
Definition: ntv2enums.h:3811
AJACircularBuffer::StartConsumeNextBuffer
FrameDataPtr StartConsumeNextBuffer(void)
The thread that's responsible for processing incoming frames – the consumer – calls this function to ...
Definition: circularbuffer.h:153
NTV2DolbyCapture::~NTV2DolbyCapture
virtual ~NTV2DolbyCapture()
Definition: ntv2dolbycapture.cpp:43
CNTV2Card::AncSetFrameBufferSize
virtual bool AncSetFrameBufferSize(const ULWord inF1Size, const ULWord inF2Size)
Sets the capacity of the ANC buffers in device frame memory. (Call NTV2DeviceCanDoCustomAnc to determ...
Definition: ntv2anc.cpp:123
NTV2ACFrameRange::count
UWord count(void) const
Definition: ntv2utils.h:974
NTV2DeviceCanDoMultiFormat
bool NTV2DeviceCanDoMultiFormat(const NTV2DeviceID inDeviceID)
Definition: ntv2devicefeatures.hpp:4065
GetFrameBufferInputXptFromChannel
NTV2InputXptID GetFrameBufferInputXptFromChannel(const NTV2Channel inFrameStore, const bool inIsBInput=false)
Definition: ntv2signalrouter.cpp:762
DolbyConfig::fInputSource
NTV2InputSource fInputSource
The device input connector to use.
Definition: ntv2dolbycapture.h:34
CNTV2Card::ClearRouting
virtual bool ClearRouting(void)
Removes all existing signal path connections between any and all widgets on the AJA device.
Definition: ntv2regroute.cpp:278
CNTV2Card::AutoCirculateInitForInput
virtual bool AutoCirculateInitForInput(const NTV2Channel inChannel, const UWord inFrameCount=7, const NTV2AudioSystem inAudioSystem=NTV2_AUDIOSYSTEM_INVALID, const ULWord inOptionFlags=0, const UByte inNumChannels=1, const UWord inStartFrameNumber=0, const UWord inEndFrameNumber=0)
Prepares for subsequent AutoCirculate ingest, designating a contiguous block of frame buffers on the ...
Definition: ntv2autocirculate.cpp:221
NTV2_AUDIOSIZE_MAX
#define NTV2_AUDIOSIZE_MAX
Definition: ntv2dolbycapture.cpp:21
NTV2_Xpt425Mux2BYUV
@ NTV2_Xpt425Mux2BYUV
Definition: ntv2enums.h:2595
CNTV2MacDriverInterface::ReleaseStreamForApplication
virtual bool ReleaseStreamForApplication(ULWord inApplicationType, int32_t inProcessID)
Releases exclusive use of the AJA device for the given process, permitting other processes to acquire...
Definition: ntv2macdriverinterface.cpp:832
NTV2_IOKINDS_HDMI
@ NTV2_IOKINDS_HDMI
Specifies HDMI input/output kinds.
Definition: ntv2enums.h:1252
DolbyConfig::fDoMultiFormat
bool fDoMultiFormat
If true, use multi-format/multi-channel mode, if device supports it; otherwise normal mode.
Definition: ntv2dolbycapture.h:39
NTV2FrameData::fAncBuffer2
NTV2Buffer fAncBuffer2
Additional "F2" host anc buffer.
Definition: ntv2democommon.h:86
AJACircularBuffer::EndProduceNextBuffer
void EndProduceNextBuffer(void)
The producer thread calls this function to signal that it has finished populating the frame it obtain...
Definition: circularbuffer.h:259
NTV2Buffer::Allocate
bool Allocate(const size_t inByteCount, const bool inPageAligned=false)
Allocates (or re-allocates) my user-space storage using the given byte count. I assume full responsib...
Definition: ntv2publicinterface.cpp:1554
NTV2_LHIHDMIColorSpaceRGB
@ NTV2_LHIHDMIColorSpaceRGB
Definition: ntv2enums.h:3595
CNTV2Card::GetVANCMode
virtual bool GetVANCMode(NTV2VANCMode &outVancMode, const NTV2Channel inChannel=NTV2_CHANNEL1)
Retrieves the current VANC mode for the given FrameStore.
Definition: ntv2register.cpp:2744
AUTOCIRCULATE_TRANSFER::SetAncBuffers
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.
Definition: ntv2publicinterface.cpp:2622
NTV2FrameData::fAncBuffer
NTV2Buffer fAncBuffer
Host ancillary data buffer.
Definition: ntv2democommon.h:85
NTV2DeviceCanDoFrameBufferFormat
bool NTV2DeviceCanDoFrameBufferFormat(const NTV2DeviceID inDeviceID, const NTV2FrameBufferFormat inFBFormat)
Definition: ntv2devicefeatures.hpp:15330
NTV2_CHANNEL1
@ NTV2_CHANNEL1
Specifies channel or Frame Store 1 (or the first item).
Definition: ntv2enums.h:1307
ntv2debug.h
NTV2_XptCSC1VidInput
@ NTV2_XptCSC1VidInput
Definition: ntv2enums.h:2704
CNTV2Card::SetVideoFormat
virtual bool SetVideoFormat(const NTV2VideoFormat inVideoFormat, const bool inIsAJARetail=true, const bool inKeepVancSettings=false, const NTV2Channel inChannel=NTV2_CHANNEL1)
Configures the AJA device to handle a specific video format.
Definition: ntv2register.cpp:204
NTV2_Xpt425Mux2BInput
@ NTV2_Xpt425Mux2BInput
Definition: ntv2enums.h:2800
NTV2DolbyCapture::SetupHostBuffers
virtual void SetupHostBuffers(void)
Sets up my circular buffers.
Definition: ntv2dolbycapture.cpp:199
NTV2DolbyCapture::SetupVideo
virtual AJAStatus SetupVideo(void)
Sets up everything I need for capturing video.
Definition: ntv2dolbycapture.cpp:143
NTV2DolbyCapture::RouteInputSignal
virtual void RouteInputSignal(void)
Sets up device routing for capture.
Definition: ntv2dolbycapture.cpp:245
NTV2FrameData::VideoBuffer
NTV2Buffer & VideoBuffer(void)
Definition: ntv2democommon.h:106
NTV2_IS_4K_VIDEO_FORMAT
#define NTV2_IS_4K_VIDEO_FORMAT(__f__)
Definition: ntv2enums.h:746
AJAThread
Definition: thread.h:69
AUTOCIRCULATE_WITH_ANC
#define AUTOCIRCULATE_WITH_ANC
Use this to AutoCirculate with ancillary data.
Definition: ntv2publicinterface.h:5496
NTV2FrameData::NumCapturedAncBytes
ULWord NumCapturedAncBytes(void) const
Definition: ntv2democommon.h:115
AJAThread::Active
virtual bool Active()
Definition: thread.cpp:116
NTV2_INPUTSOURCE_SDI1
@ NTV2_INPUTSOURCE_SDI1
Identifies the 1st SDI video input.
Definition: ntv2enums.h:1228
AJA_STATUS_NOINPUT
@ AJA_STATUS_NOINPUT
Definition: types.h:387
AJAStatus
AJAStatus
Definition: types.h:365
NTV2_XptCSC3VidRGB
@ NTV2_XptCSC3VidRGB
Definition: ntv2enums.h:2535
NTV2InputSourceToString
std::string NTV2InputSourceToString(const NTV2InputSource inValue, const bool inForRetailDisplay=false)
Definition: ntv2utils.cpp:7215
process.h
Declares the AJAProcess class.
NTV2_XptHDMIIn1Q2RGB
@ NTV2_XptHDMIIn1Q2RGB
Definition: ntv2enums.h:2545
NTV2_XptFrameBuffer1Input
@ NTV2_XptFrameBuffer1Input
Definition: ntv2enums.h:2688
AJATime::Sleep
static void Sleep(const int32_t inMilliseconds)
Suspends execution of the current thread for a given number of milliseconds.
Definition: systemtime.cpp:284
AJACircularBuffer::Add
AJAStatus Add(FrameDataPtr pInFrameData)
Appends a new frame buffer to me, increasing my frame storage capacity by one frame.
Definition: circularbuffer.h:92
NTV2Standard
NTV2Standard
Identifies a particular video standard.
Definition: ntv2enums.h:153
NTV2DolbyCapture::ConsumerThreadStatic
static void ConsumerThreadStatic(AJAThread *pThread, void *pContext)
This is the consumer thread's static callback function that gets called when the consumer thread runs...
Definition: ntv2dolbycapture.cpp:373
NTV2_XptCSC4VidRGB
@ NTV2_XptCSC4VidRGB
Definition: ntv2enums.h:2538
NTV2_XptCSC1VidYUV
@ NTV2_XptCSC1VidYUV
Definition: ntv2enums.h:2475
AJA_STATUS_FEATURE
@ AJA_STATUS_FEATURE
Definition: types.h:380
NTV2DolbyCapture::NTV2DolbyCapture
NTV2DolbyCapture(const DolbyConfig &inConfig)
Constructs me using the given settings.
Definition: ntv2dolbycapture.cpp:28
ULWord
uint32_t ULWord
Definition: ajatypes.h:246
AJASystemInfo::append
static AJALabelValuePairs & append(AJALabelValuePairs &inOutTable, const std::string &inLabel, const std::string &inValue=std::string())
A convenience function that appends the given label and value strings to the provided AJALabelValuePa...
Definition: info.h:168
NTV2FrameData::fVideoBuffer
NTV2Buffer fVideoBuffer
Host video buffer.
Definition: ntv2democommon.h:82
AUTOCIRCULATE_STATUS
This is returned from the CNTV2Card::AutoCirculateGetStatus function.
Definition: ntv2publicinterface.h:7105
NTV2_XptCSC4VidYUV
@ NTV2_XptCSC4VidYUV
Definition: ntv2enums.h:2537
NTV2FrameData::VideoBufferSize
ULWord VideoBufferSize(void) const
Definition: ntv2democommon.h:107
NTV2_XptHDMIIn1Q2
@ NTV2_XptHDMIIn1Q2
Definition: ntv2enums.h:2544
CNTV2MacDriverInterface::GetStreamingApplication
virtual bool GetStreamingApplication(ULWord &outAppType, int32_t &outProcessID)
Answers with the four-CC type and process ID of the application that currently "owns" the AJA device ...
Definition: ntv2macdriverinterface.cpp:944
CNTV2Card::SetReference
virtual bool SetReference(const NTV2ReferenceSource inRefSource, const bool inKeepFramePulseSelect=false)
Sets the device's clock reference source. See Device Clocking and Synchronization for more informatio...
Definition: ntv2register.cpp:1486
CNTV2Card::UnsubscribeInputVerticalEvent
virtual bool UnsubscribeInputVerticalEvent(const NTV2Channel inChannel=NTV2_CHANNEL1)
Unregisters me so I'm no longer notified when an input VBI is signaled on the given input channel.
Definition: ntv2subscriptions.cpp:75
GetCSCOutputXptFromChannel
NTV2OutputXptID GetCSCOutputXptFromChannel(const NTV2Channel inCSC, const bool inIsKey=false, const bool inIsRGB=false)
Definition: ntv2signalrouter.cpp:819
AJASystemInfo::ToString
virtual void ToString(std::string &outAllLabelsAndValues) const
Answers with a multi-line string that contains the complete host system info table.
AJAProcess::GetPid
static uint64_t GetPid()
Definition: process.cpp:35
NTV2FrameData::AncBufferSize
ULWord AncBufferSize(void) const
Definition: ntv2democommon.h:114
CNTV2Card::Connect
virtual bool Connect(const NTV2InputCrosspointID inInputXpt, const NTV2OutputCrosspointID inOutputXpt, const bool inValidate=false)
Connects the given widget signal input (sink) to the given widget signal output (source).
Definition: ntv2regroute.cpp:87
AUTOCIRCULATE_TRANSFER::GetCapturedAncByteCount
ULWord GetCapturedAncByteCount(const bool inField2=false) const
Definition: ntv2publicinterface.h:8280
NTV2DolbyCapture::StartConsumerThread
virtual void StartConsumerThread(void)
Starts my frame consumer thread.
Definition: ntv2dolbycapture.cpp:362
NTV2DolbyCapture::RecoverDolby
virtual uint32_t RecoverDolby(NTV2Buffer &audio, uint32_t audioSize, NTV2Buffer &dolby)
Recover dolby from audio data.
Definition: ntv2dolbycapture.cpp:699
AJACircularBuffer::StartProduceNextBuffer
FrameDataPtr StartProduceNextBuffer(void)
The thread that's responsible for providing frames – the producer – calls this function to populate t...
Definition: circularbuffer.h:109
CNTV2Card::AutoCirculateGetStatus
virtual bool AutoCirculateGetStatus(const NTV2Channel inChannel, AUTOCIRCULATE_STATUS &outStatus)
Returns the current AutoCirculate status for the given channel.
Definition: ntv2autocirculate.cpp:646
NTV2FrameData::AncBuffer2Size
ULWord AncBuffer2Size(void) const
Definition: ntv2democommon.h:118
NTV2_IS_VALID_INPUT_SOURCE
#define NTV2_IS_VALID_INPUT_SOURCE(_inpSrc_)
Definition: ntv2enums.h:1243
NTV2_FBF_8BIT_YCBCR
@ NTV2_FBF_8BIT_YCBCR
See 8-Bit YCbCr Format.
Definition: ntv2enums.h:211
AUTOCIRCULATE_TRANSFER
This object specifies the information that will be transferred to or from the AJA device in the CNTV2...
Definition: ntv2publicinterface.h:7904
NTV2_XptHDMIIn1Q4RGB
@ NTV2_XptHDMIIn1Q4RGB
Definition: ntv2enums.h:2549
NTV2_XptCSC3VidInput
@ NTV2_XptCSC3VidInput
Definition: ntv2enums.h:2708
ntv2utils.h
Declares numerous NTV2 utility functions.
NTV2DolbyCapture::SetupAudio
virtual AJAStatus SetupAudio(void)
Sets up everything I need for capturing audio.
Definition: ntv2dolbycapture.cpp:192
NTV2_INPUT_SOURCE_IS_HDMI
#define NTV2_INPUT_SOURCE_IS_HDMI(_inpSrc_)
Definition: ntv2enums.h:1240
NTV2InputCrosspointID
NTV2InputCrosspointID
Identifies a widget input that potentially can accept a signal emitted from another widget's output (...
Definition: ntv2enums.h:2685
NTV2FrameData::AudioBuffer
NTV2Buffer & AudioBuffer(void)
Definition: ntv2democommon.h:109
AUTOCIRCULATE_TRANSFER::SetVideoBuffer
bool SetVideoBuffer(ULWord *pInVideoBuffer, const ULWord inVideoByteCount)
Sets my video buffer for use in a subsequent call to CNTV2Card::AutoCirculateTransfer.
Definition: ntv2publicinterface.cpp:2606
GetCSCInputXptFromChannel
NTV2InputXptID GetCSCInputXptFromChannel(const NTV2Channel inCSC, const bool inIsKeyInput=false)
Definition: ntv2signalrouter.cpp:775
CNTV2Card::DMABufferLock
virtual bool DMABufferLock(const NTV2Buffer &inBuffer, bool inMap=false, bool inRDMA=false)
Page-locks the given host buffer to reduce transfer time and CPU usage of DMA transfers.
Definition: ntv2dma.cpp:487
CNTV2Card::AutoCirculateStop
virtual bool AutoCirculateStop(const NTV2Channel inChannel, const bool inAbort=false)
Stops AutoCirculate for the given channel, and releases the on-device frame buffers that were allocat...
Definition: ntv2autocirculate.cpp:519
NTV2_XptFrameBuffer1DS2Input
@ NTV2_XptFrameBuffer1DS2Input
Definition: ntv2enums.h:2689
shiftAuxFilterInvert
@ shiftAuxFilterInvert
Definition: ntv2publicinterface.h:5276
NTV2_Xpt425Mux2ARGB
@ NTV2_Xpt425Mux2ARGB
Definition: ntv2enums.h:2594
CNTV2DriverInterface::IsDeviceReady
virtual bool IsDeviceReady(const bool inCheckValid=(0))
Definition: ntv2driverinterface.cpp:1228
kDemoAppSignature
static const ULWord kDemoAppSignature((((uint32_t)( 'D'))<< 24)|(((uint32_t)( 'E'))<< 16)|(((uint32_t)( 'M'))<< 8)|(((uint32_t)( 'O'))<< 0))
NTV2_Xpt425Mux1AYUV
@ NTV2_Xpt425Mux1AYUV
Definition: ntv2enums.h:2589
GetVideoWriteSize
ULWord GetVideoWriteSize(const NTV2VideoFormat inVideoFormat, const NTV2FrameBufferFormat inFBFormat, const NTV2VANCMode inVancMode=NTV2_VANCMODE_OFF)
Identical to the GetVideoActiveSize function, except rounds the result up to the nearest 4K page size...
Definition: ntv2utils.cpp:2775
NTV2_Xpt425Mux1BYUV
@ NTV2_Xpt425Mux1BYUV
Definition: ntv2enums.h:2591
AJACircularBuffer::EndConsumeNextBuffer
void EndConsumeNextBuffer(void)
The consumer thread calls this function to signal that it has finished processing the frame it obtain...
Definition: circularbuffer.h:266
NTV2DolbyCapture::StartProducerThread
virtual void StartProducerThread(void)
Starts my capture thread.
Definition: ntv2dolbycapture.cpp:481
CNTV2Card::SetTsiFrameEnable
virtual bool SetTsiFrameEnable(const bool inIsEnabled, const NTV2Channel inChannel)
Enables or disables SMPTE 425 two-sample interleave (Tsi) frame mode on the device.
Definition: ntv2register.cpp:1313
NTV2_INPUTSOURCE_HDMI1
@ NTV2_INPUTSOURCE_HDMI1
Identifies the 1st HDMI video input.
Definition: ntv2enums.h:1224
AUTOCIRCULATE_STATUS::acBufferLevel
ULWord acBufferLevel
Number of buffered frames in driver ready to capture or play.
Definition: ntv2publicinterface.h:7118
CNTV2Card::SetEveryFrameServices
virtual bool SetEveryFrameServices(const NTV2EveryFrameTaskMode inMode)
Sets the device's task mode.
Definition: ntv2register.cpp:179
NTV2VANCMode
NTV2VANCMode
These enum values identify the available VANC modes.
Definition: ntv2enums.h:3711
NTV2DolbyCapture::RecoverAudio
virtual uint32_t RecoverAudio(NTV2Buffer &anc, uint32_t ancSize, NTV2Buffer &audio)
Recover audio from ancillary data.
Definition: ntv2dolbycapture.cpp:596
DolbyConfig::fWithAnc
bool fWithAnc
If true, also capture Anc.
Definition: ntv2dolbycapture.h:40
AJA_NULL
#define AJA_NULL
Definition: ajatypes.h:190
NTV2_IS_VALID_CHANNEL
#define NTV2_IS_VALID_CHANNEL(__x__)
Definition: ntv2enums.h:1319
NTV2_DISABLE_TASKS
@ NTV2_DISABLE_TASKS
0: Disabled: Device is completely configured by controlling application(s) – no driver involvement.
Definition: ntv2publicinterface.h:4259
NTV2_VANCMODE_INVALID
@ NTV2_VANCMODE_INVALID
This identifies the invalid (unspecified, uninitialized) VANC mode.
Definition: ntv2enums.h:3716
NTV2Buffer::GetHostAddress
void * GetHostAddress(const ULWord inByteOffset, const bool inFromEnd=false) const
Definition: ntv2publicinterface.cpp:1610
NTV2OutputCrosspointID
NTV2OutputCrosspointID
Identifies a widget output, a signal source, that potentially can drive another widget's input (ident...
Definition: ntv2enums.h:2467
CNTV2DriverInterface::GetDescription
virtual std::string GetDescription(void) const
Definition: ntv2driverinterface.h:574
NTV2ACFrameRange::toString
std::string toString(const bool inNormalized=false) const
Definition: ntv2utils.cpp:4205
NTV2_FORMAT_UNKNOWN
@ NTV2_FORMAT_UNKNOWN
Definition: ntv2enums.h:498
NTV2FrameData::fAudioBuffer
NTV2Buffer fAudioBuffer
Host audio buffer.
Definition: ntv2democommon.h:84
AJA_STATUS_INITIALIZE
@ AJA_STATUS_INITIALIZE
Definition: types.h:373
NTV2_LHIHDMIColorSpaceYCbCr
@ NTV2_LHIHDMIColorSpaceYCbCr
Definition: ntv2enums.h:3594
DolbyConfig::fFrames
CNTV2DemoCommon::ACFrameRange fFrames
AutoCirculate frame count or range.
Definition: ntv2dolbycapture.h:35
DEC
#define DEC(__x__)
Definition: ntv2publicinterface.h:5579
NTV2_XptHDMIIn1Q4
@ NTV2_XptHDMIIn1Q4
Definition: ntv2enums.h:2548
NTV2_XptFrameBuffer2Input
@ NTV2_XptFrameBuffer2Input
Definition: ntv2enums.h:2690
false
#define false
Definition: ntv2devicefeatures.h:25
DolbyConfig::fWithDolby
bool fWithDolby
If true, also capture Dolby.
Definition: ntv2dolbycapture.h:42
NTV2ACFrameRange::lastFrame
UWord lastFrame(void) const
Definition: ntv2utils.h:976
NTV2_XptHDMIIn1
@ NTV2_XptHDMIIn1
Definition: ntv2enums.h:2499
AUTOCIRCULATE_STATUS::IsRunning
bool IsRunning(void) const
Definition: ntv2publicinterface.h:7211
NTV2_XptHDMIIn1RGB
@ NTV2_XptHDMIIn1RGB
Definition: ntv2enums.h:2500
NTV2FrameBufferFormatToString
std::string NTV2FrameBufferFormatToString(const NTV2FrameBufferFormat inValue, const bool inForRetailDisplay=false)
Definition: ntv2utils.cpp:6940
NTV2DeviceCanDoInputSource
bool NTV2DeviceCanDoInputSource(const NTV2DeviceID inDeviceID, const NTV2InputSource inInputSource)
Definition: ntv2devicefeatures.hpp:17462
NTV2DolbyCapture::Run
virtual AJAStatus Run(void)
Runs me.
Definition: ntv2dolbycapture.cpp:349
maskAuxFilterInvert
@ maskAuxFilterInvert
Definition: ntv2publicinterface.h:5275
AUTOCIRCULATE_WITH_HDMIAUX
#define AUTOCIRCULATE_WITH_HDMIAUX
Use this to AutoCirculate with HDMI auxiliary data.
Definition: ntv2publicinterface.h:5499
IsRGBFormat
bool IsRGBFormat(const NTV2FrameBufferFormat format)
Definition: ntv2utils.cpp:5442
CNTV2Card::AutoCirculateTransfer
virtual bool AutoCirculateTransfer(const NTV2Channel inChannel, AUTOCIRCULATE_TRANSFER &transferInfo)
Transfers all or part of a frame as specified in the given AUTOCIRCULATE_TRANSFER object to/from the ...
Definition: ntv2autocirculate.cpp:695
NTV2FrameData::fNumAnc2Bytes
ULWord fNumAnc2Bytes
Actual number of captured F2 anc bytes.
Definition: ntv2democommon.h:90
CNTV2Card::GetHDMIInputColor
virtual bool GetHDMIInputColor(NTV2LHIHDMIColorSpace &outValue, const NTV2Channel inChannel=NTV2_CHANNEL1)
Answers with the current colorspace for the given HDMI input.
Definition: ntv2hdmi.cpp:52
NTV2_XptHDMIIn1Q3
@ NTV2_XptHDMIIn1Q3
Definition: ntv2enums.h:2546
CIRCULAR_BUFFER_SIZE
static const size_t CIRCULAR_BUFFER_SIZE(10)
Number of NTV2FrameData's in our ring.
CNTV2MacDriverInterface::AcquireStreamForApplication
virtual bool AcquireStreamForApplication(ULWord inApplicationType, int32_t inProcessID)
Reserves exclusive use of the AJA device for a given process, preventing other processes on the host ...
Definition: ntv2macdriverinterface.cpp:808
NTV2_XptCSC2VidRGB
@ NTV2_XptCSC2VidRGB
Definition: ntv2enums.h:2491
CNTV2DriverInterface::GetDeviceID
virtual NTV2DeviceID GetDeviceID(void)
Definition: ntv2driverinterface.cpp:371
AUTOCIRCULATE_STATUS::HasAvailableInputFrame
bool HasAvailableInputFrame(void) const
Definition: ntv2publicinterface.h:7181
CNTV2Card::GetEveryFrameServices
virtual bool GetEveryFrameServices(NTV2EveryFrameTaskMode &outMode)
Retrieves the device's current "retail service" task mode.
Definition: ntv2register.cpp:184
GetInputSourceOutputXpt
NTV2OutputXptID GetInputSourceOutputXpt(const NTV2InputSource inInputSource, const bool inIsSDI_DS2=false, const bool inIsHDMI_RGB=false, const UWord inHDMI_Quadrant=0)
Definition: ntv2signalrouter.cpp:865
NTV2DolbyCapture::Quit
virtual void Quit(void)
Gracefully stops me from running.
Definition: ntv2dolbycapture.cpp:54
DolbyConfig::Get
AJALabelValuePairs Get(const bool inCompact=(0)) const
Definition: ntv2dolbycapture.cpp:759
NTV2_XptCSC3VidYUV
@ NTV2_XptCSC3VidYUV
Definition: ntv2enums.h:2534
DolbyConfig::fWithAudio
bool fWithAudio
If true, also capture Audio.
Definition: ntv2dolbycapture.h:41
CNTV2Card::GetInputVideoFormat
virtual NTV2VideoFormat GetInputVideoFormat(const NTV2InputSource inVideoSource=NTV2_INPUTSOURCE_SDI1, const bool inIsProgressive=false)
Returns the video format of the signal that is present on the given input source.
Definition: ntv2register.cpp:3381
AUTOCIRCULATE_STATUS::WithCustomAnc
bool WithCustomAnc(void) const
Definition: ntv2publicinterface.h:7246
AJACircularBuffer::SetAbortFlag
void SetAbortFlag(const bool *pAbortFlag)
Tells me the boolean variable I should monitor such that when it gets set to "true" will cause any th...
Definition: circularbuffer.h:51
NTV2_XptCSC1VidRGB
@ NTV2_XptCSC1VidRGB
Definition: ntv2enums.h:2476
NTV2ChannelToString
std::string NTV2ChannelToString(const NTV2Channel inValue, const bool inForRetailDisplay=false)
Definition: ntv2utils.cpp:5759
NTV2Buffer::Fill
bool Fill(const T &inValue)
Fills me with the given scalar value.
Definition: ntv2publicinterface.h:6192
AJAThread::SetPriority
virtual AJAStatus SetPriority(AJAThreadPriority priority)
Definition: thread.cpp:133
CNTV2Card::AutoCirculateStart
virtual bool AutoCirculateStart(const NTV2Channel inChannel, const ULWord64 inStartTime=0)
Starts AutoCirculating the specified channel that was previously initialized by CNTV2Card::AutoCircul...
Definition: ntv2autocirculate.cpp:503
DolbyConfig::fPixelFormat
NTV2PixelFormat fPixelFormat
Pixel format to use.
Definition: ntv2dolbycapture.h:36
AJA_STATUS_OPEN
@ AJA_STATUS_OPEN
Definition: types.h:375
NTV2_XptCSC2VidYUV
@ NTV2_XptCSC2VidYUV
Definition: ntv2enums.h:2490
CNTV2Card::SetFrameBufferFormat
virtual bool SetFrameBufferFormat(NTV2Channel inChannel, NTV2FrameBufferFormat inNewFormat, bool inIsAJARetail=true, NTV2HDRXferChars inXferChars=NTV2_VPID_TC_SDR_TV, NTV2HDRColorimetry inColorimetry=NTV2_VPID_Color_Rec709, NTV2HDRLuminance inLuminance=NTV2_VPID_Luminance_YCbCr)
Sets the frame buffer format for the given FrameStore on the AJA device.
Definition: ntv2register.cpp:1828
NTV2DolbyCapture
Instances of me capture frames in real time from a video signal provided to an input of an AJA device...
Definition: ntv2dolbycapture.h:72
AJAThread::Start
virtual AJAStatus Start()
Definition: thread.cpp:91
AUTOCIRCULATE_STATUS::acFramesDropped
ULWord acFramesDropped
Total number of frames dropped since CNTV2Card::AutoCirculateStart called.
Definition: ntv2publicinterface.h:7117
AJALabelValuePairs
std::vector< AJALabelValuePair > AJALabelValuePairs
An ordered sequence of label/value pairs.
Definition: info.h:69
CNTV2Card::SubscribeInputVerticalEvent
virtual bool SubscribeInputVerticalEvent(const NTV2Channel inChannel=NTV2_CHANNEL1)
Causes me to be notified when an input vertical blanking interrupt occurs on the given input channel.
Definition: ntv2subscriptions.cpp:39
AJA_FAILURE
#define AJA_FAILURE(_status_)
Definition: types.h:358
DolbyConfig::fAudioDataFilePath
std::string fAudioDataFilePath
Optional path to Audio binary data file.
Definition: ntv2dolbycapture.h:31
DolbyConfig::fAncDataFilePath
std::string fAncDataFilePath
Optional path to Anc binary data file.
Definition: ntv2dolbycapture.h:30
CNTV2Card::EnableChannel
virtual bool EnableChannel(const NTV2Channel inChannel)
Enables the given FrameStore.
Definition: ntv2register.cpp:2113
NTV2FrameData::AncBuffer
NTV2Buffer & AncBuffer(void)
Definition: ntv2democommon.h:113
NTV2_XptFrameBuffer2DS2Input
@ NTV2_XptFrameBuffer2DS2Input
Definition: ntv2enums.h:2691
CNTV2MacDriverInterface::WriteRegister
virtual bool WriteRegister(const ULWord inRegNum, const ULWord inValue, const ULWord inMask=0xFFFFFFFF, const ULWord inShift=0)
Updates or replaces all or part of the 32-bit contents of a specific register (real or virtual) on th...
Definition: ntv2macdriverinterface.cpp:754
NTV2_XptCSC2VidInput
@ NTV2_XptCSC2VidInput
Definition: ntv2enums.h:2706
DEVICE_ID_NOTFOUND
@ DEVICE_ID_NOTFOUND
Invalid or "not found".
Definition: ntv2enums.h:90
NTV2_Xpt425Mux1BInput
@ NTV2_Xpt425Mux1BInput
Definition: ntv2enums.h:2798
CAPNOTE
#define CAPNOTE(_expr_)
Definition: ntv2democommon.h:31
NTV2_XptHDMIIn1Q3RGB
@ NTV2_XptHDMIIn1Q3RGB
Definition: ntv2enums.h:2547
NTV2_OEM_TASKS
@ NTV2_OEM_TASKS
2: OEM: Device is configured by controlling application(s), with minimal driver involvement.
Definition: ntv2publicinterface.h:4261
NTV2_Xpt425Mux2AInput
@ NTV2_Xpt425Mux2AInput
Definition: ntv2enums.h:2799
NTV2DolbyCapture::ConsumeFrames
virtual void ConsumeFrames(void)
Repeatedly consumes frames from the circular buffer (until global quit flag set).
Definition: ntv2dolbycapture.cpp:385