AJA NTV2 SDK  17.1.1.1245
NTV2 SDK 17.1.1.1245
ntv2dolbyplayer.cpp
Go to the documentation of this file.
1 /* SPDX-License-Identifier: MIT */
8 #include "ntv2dolbyplayer.h"
9 #include "ntv2debug.h"
10 #include "ntv2devicescanner.h"
11 #include "ntv2testpatterngen.h"
12 #include "ntv2audiodefines.h"
14 #include "ajabase/system/process.h"
15 
16 //#include "ajabase/system/debug.h"
17 
18 
19 using namespace std;
20 
21 // Convenience macros for EZ logging:
22 #define TCFAIL(_expr_) AJA_sERROR (AJA_DebugUnit_TimecodeGeneric, AJAFUNC << ": " << _expr_)
23 #define TCWARN(_expr_) AJA_sWARNING(AJA_DebugUnit_TimecodeGeneric, AJAFUNC << ": " << _expr_)
24 #define TCNOTE(_expr_) AJA_sNOTICE (AJA_DebugUnit_TimecodeGeneric, AJAFUNC << ": " << _expr_)
25 #define TCINFO(_expr_) AJA_sINFO (AJA_DebugUnit_TimecodeGeneric, AJAFUNC << ": " << _expr_)
26 #define TCDBG(_expr_) AJA_sDEBUG (AJA_DebugUnit_TimecodeGeneric, AJAFUNC << ": " << _expr_)
27 
35 static const uint32_t AUDIOBYTES_MAX_48K (201 * 1024);
36 
44 static const uint32_t AUDIOBYTES_MAX_192K (824 * 1024);
45 
46 static const bool BUFFER_PAGE_ALIGNED (true);
47 
48 // Audio tone generator data
49 static const double gFrequencies [] = {250.0, 500.0, 1000.0, 2000.0};
50 static const ULWord gNumFrequencies (sizeof (gFrequencies) / sizeof (double));
51 static const double gAmplitudes [] = { 0.10, 0.15, 0.20, 0.25, 0.30, 0.35, 0.40, 0.45, 0.50, 0.55, 0.60, 0.65, 0.70, 0.75, 0.80, 0.85,
52  0.85, 0.80, 0.75, 0.70, 0.65, 0.60, 0.55, 0.50, 0.45, 0.40, 0.35, 0.30, 0.25, 0.20, 0.15, 0.10};
53 
55  : mConfig (inConfig),
56  mConsumerThread (),
57  mProducerThread (),
58  mDevice (),
59  mSavedTaskMode (NTV2_TASK_MODE_INVALID),
60  mCurrentFrame (0),
61  mCurrentSample (0),
62  mToneFrequency (440.0),
63  mAudioSystem (NTV2_AUDIOSYSTEM_INVALID),
64  mFormatDesc (),
65  mTCIndexes (),
66  mGlobalQuit (false),
67  mTCBurner (),
68  mHostBuffers (),
69  mFrameDataRing (),
70  mTestPatRasters (),
71  mAudioRate (NTV2_AUDIO_192K),
72  mRampSample (0),
73  mBurstIndex (0),
74  mBurstSamples (0),
75  mBurstBuffer (NULL),
76  mBurstSize (0),
77  mBurstOffset (0),
78  mBurstMax (0),
79  mDolbyBuffer (NULL),
80  mDolbySize (0),
81  mDolbyBlocks (0)
82 { }
83 
84 
86 {
87  // Stop my playout and producer threads, then destroy them...
88  Quit ();
89 
91 
92  if (mDolbyBuffer)
93  {
94  delete [] mDolbyBuffer;
95  mDolbyBuffer = NULL;
96  }
97 
98  if (mBurstBuffer)
99  {
100  delete [] mBurstBuffer;
101  mBurstBuffer = NULL;
102  }
103 
104 } // destructor
105 
106 
108 {
109  // Set the global 'quit' flag, and wait for the threads to go inactive...
110  mGlobalQuit = true;
111 
112  while (mProducerThread.Active())
113  AJATime::Sleep(10);
114 
115  while (mConsumerThread.Active())
116  AJATime::Sleep(10);
117 
118  mDevice.SetAudioRate (NTV2_AUDIO_48K, mAudioSystem);
121 
122 #if defined(NTV2_BUFFER_LOCKING)
123  mDevice.DMABufferUnlockAll();
124 #endif // NTV2_BUFFER_LOCKING
125  if (!mConfig.fDoMultiFormat && mDevice.IsOpen())
126  {
128  if (NTV2_IS_VALID_TASK_MODE(mSavedTaskMode))
129  mDevice.SetEveryFrameServices(mSavedTaskMode); // Restore prior task mode
130  }
131 } // Quit
132 
133 
135 {
136  AJAStatus status (AJA_STATUS_SUCCESS);
137 
138  // Open the device...
140  {cerr << "## ERROR: Device '" << mConfig.fDeviceSpec << "' not found" << endl; return AJA_STATUS_OPEN;}
141 
142  if (!mDevice.IsDeviceReady(false))
143  {cerr << "## ERROR: Device '" << mDevice.GetDisplayName() << "' not ready" << endl; return AJA_STATUS_INITIALIZE;}
144  if (!mDevice.features().CanDoPlayback())
145  {cerr << "## ERROR: '" << mDevice.GetDisplayName() << "' is capture-only" << endl; return AJA_STATUS_FEATURE;}
146  if (!mDevice.features().GetNumHDMIVideoOutputs())
147  {cerr << "## ERROR: '" << mDevice.GetDisplayName() << "' has no HDMI outputs" << endl; return AJA_STATUS_FEATURE;}
148 
149  const UWord maxNumChannels (mDevice.features().GetNumFrameStores());
150 
151  // Beware -- some older devices (e.g. Corvid1) can only output from FrameStore 2...
152  if ((mConfig.fOutputChannel == NTV2_CHANNEL1) && (!mDevice.features().CanDoFrameStore1Display()))
153  mConfig.fOutputChannel = NTV2_CHANNEL2;
154  if (UWord(mConfig.fOutputChannel) >= maxNumChannels)
155  {
156  cerr << "## ERROR: '" << mDevice.GetDisplayName() << "' can't use Ch" << DEC(mConfig.fOutputChannel+1)
157  << " -- only supports Ch1" << (maxNumChannels > 1 ? string("-Ch") + string(1, char(maxNumChannels+'0')) : "") << endl;
158  return AJA_STATUS_UNSUPPORTED;
159  }
160 
161  if (!mConfig.fDoMultiFormat)
162  {
163  mDevice.GetEveryFrameServices(mSavedTaskMode); // Save the current task mode
165  return AJA_STATUS_BUSY; // Device is in use by another app -- fail
166  }
167  mDevice.SetEveryFrameServices(NTV2_OEM_TASKS); // Set OEM service level
168 
169  if (mDevice.features().CanDoMultiFormat())
170  mDevice.SetMultiFormatMode(mConfig.fDoMultiFormat);
171  else
172  mConfig.fDoMultiFormat = false;
173 
174  if (!mConfig.fDolbyFilePath.empty())
175  {
176  status = mDolbyFileIO.Open(mConfig.fDolbyFilePath.c_str(), eAJAReadOnly, 0);
177  if (status != AJA_STATUS_SUCCESS)
178  {cerr << "## ERROR: Could not open file: " << mConfig.fDolbyFilePath << endl; return status;}
179  }
180 
181 
182  // Set up the video and audio...
183  status = SetUpVideo();
184  if (AJA_FAILURE(status))
185  return status;
186  status = mConfig.WithAudio() ? SetUpAudio() : AJA_STATUS_SUCCESS;
187  if (AJA_FAILURE(status))
188  return status;
189 
190  // Set up the circular buffers, and the test pattern buffers...
191  status = SetUpHostBuffers();
192  if (AJA_FAILURE(status))
193  return status;
194  status = SetUpTestPatternBuffers();
195  if (AJA_FAILURE(status))
196  return status;
197 
198  // Set up the device signal routing...
199  if (!RouteOutputSignal())
200  return AJA_STATUS_FAIL;
201 
202  // Lastly, prepare my AJATimeCodeBurn instance...
203  if (!mTCBurner.RenderTimeCodeFont (CNTV2DemoCommon::GetAJAPixelFormat(mConfig.fPixelFormat), mFormatDesc.numPixels, mFormatDesc.numLines))
204  {cerr << "## ERROR: RenderTimeCodeFont failed for: " << mFormatDesc << endl; return AJA_STATUS_UNSUPPORTED;}
205 
206  // Ready to go...
207  #if defined(_DEBUG)
208  cerr << mConfig;
209  if (mDevice.IsRemote())
210  cerr << "Device Description: " << mDevice.GetDescription() << endl;
211  cerr << endl;
212  #endif // defined(_DEBUG)
213  return AJA_STATUS_SUCCESS;
214 
215 } // Init
216 
217 
219 {
220  // Configure the device to output the requested video format...
221  if (mConfig.fVideoFormat == NTV2_FORMAT_UNKNOWN)
222  return AJA_STATUS_BAD_PARAM;
223 
224  if (!mDevice.features().CanDoVideoFormat(mConfig.fVideoFormat))
225  { cerr << "## ERROR: '" << mDevice.GetDisplayName() << "' doesn't support "
226  << ::NTV2VideoFormatToString(mConfig.fVideoFormat) << endl;
227  return AJA_STATUS_UNSUPPORTED;
228  }
229  if (!mDevice.features().CanDoFrameBufferFormat(mConfig.fPixelFormat))
230  { cerr << "## ERROR: '" << mDevice.GetDisplayName() << "' doesn't support "
231  << ::NTV2FrameBufferFormatString(mConfig.fPixelFormat) << endl;
232  return AJA_STATUS_UNSUPPORTED;
233  }
234 
235  // Keep the raster description handy...
236  mFormatDesc = NTV2FormatDescriptor(mConfig.fVideoFormat, mConfig.fPixelFormat);
237  if (!mFormatDesc.IsValid())
238  return AJA_STATUS_FAIL;
239 
240  // Turn on the FrameStore (to read frame buffer memory and transmit video)...
241  mDevice.EnableChannel(mConfig.fOutputChannel);
242 
243  // This demo assumes VANC is disabled...
244  mDevice.SetVANCMode(NTV2_VANCMODE_OFF, mConfig.fOutputChannel);
246 
247  // Set the FrameStore video format...
248  mDevice.SetVideoFormat (mConfig.fVideoFormat, false, false, mConfig.fOutputChannel);
249 
250  // Set the frame buffer pixel format for the device FrameStore...
251  mDevice.SetFrameBufferFormat (mConfig.fOutputChannel, mConfig.fPixelFormat);
252 
253  // The output interrupt is Enabled by default, but on some platforms, you must subscribe to it
254  // in order to be able to wait on its event/semaphore...
256 
257  // Set output clock reference...
258  mDevice.SetReference(mDevice.features().CanDo2110() ? NTV2_REFERENCE_SFP1_PTP : NTV2_REFERENCE_FREERUN);
259 
260  return AJA_STATUS_SUCCESS;
261 
262 } // SetUpVideo
263 
264 
266 {
267  const uint16_t numberOfAudioChannels (8);
268 
269  mAudioSystem = NTV2_AUDIOSYSTEM_1; // Use NTV2_AUDIOSYSTEM_1...
270  if (mDevice.features().GetNumAudioSystems() > 1) // ...but if the device has more than one audio system...
271  mAudioSystem = ::NTV2ChannelToAudioSystem(mConfig.fOutputChannel); // ...base it on the channel
272  // However, there are a few older devices that have only 1 audio system,
273  // yet 2 frame stores (or must use channel 2 for playout)...
274  if (!mDevice.features().CanDoFrameStore1Display())
275  mAudioSystem = NTV2_AUDIOSYSTEM_1;
276 
277  mDevice.SetNumberAudioChannels (numberOfAudioChannels, mAudioSystem);
278  mDevice.SetAudioRate (mAudioRate, mAudioSystem);
279 
280  // How big should the on-device audio buffer be? 1MB? 2MB? 4MB? 8MB?
281  // For this demo, 4MB will work best across all platforms (Windows, Mac & Linux)...
282  mDevice.SetAudioBufferSize (NTV2_AUDIO_BUFFER_BIG, mAudioSystem);
283 
284  // Set the SDI output audio embedders to embed audio samples from the output of mAudioSystem...
285  mDevice.SetHDMIOutAudioSource2Channel (NTV2_AudioChannel1_2, mAudioSystem);
286 
287  mDevice.SetHDMIOutAudioRate(mAudioRate);
288 
290 
291  // If the last app using the device left it in end-to-end mode (input passthru),
292  // then loopback must be disabled, or else the output will contain whatever audio
293  // is present in whatever signal is feeding the device's SDI input...
294  mDevice.SetAudioLoopBack (NTV2_AUDIO_LOOPBACK_OFF, mAudioSystem);
295 
296  return AJA_STATUS_SUCCESS;
297 
298 } // SetUpAudio
299 
300 
302 {
303  CNTV2DemoCommon::SetDefaultPageSize(); // Set host-specific page size
304 
305  // Let my circular buffer know when it's time to quit...
306  mFrameDataRing.SetAbortFlag (&mGlobalQuit);
307 
308  // Calculate the size of the audio buffer, which mostly depends on the sample rate...
309  const uint32_t AUDIOBYTES_MAX = (mAudioRate == NTV2_AUDIO_192K) ? AUDIOBYTES_MAX_192K : AUDIOBYTES_MAX_48K;
310 
311  // Allocate and add each in-host NTV2FrameData to my circular buffer member variable...
312  mHostBuffers.reserve(CIRCULAR_BUFFER_SIZE);
313  while (mHostBuffers.size() < CIRCULAR_BUFFER_SIZE)
314  {
315  mHostBuffers.push_back(NTV2FrameData()); // Make a new NTV2FrameData...
316  NTV2FrameData & frameData(mHostBuffers.back()); // ...and get a reference to it
317 
318  // Allocate a page-aligned video buffer
319  if (mConfig.WithVideo())
320  if (!frameData.fVideoBuffer.Allocate (mFormatDesc.GetTotalBytes(), BUFFER_PAGE_ALIGNED))
321  {
322  PLFAIL("Failed to allocate " << xHEX0N(mFormatDesc.GetTotalBytes(),8) << "-byte video buffer");
323  return AJA_STATUS_MEMORY;
324  }
325  #ifdef NTV2_BUFFER_LOCKING
326  if (frameData.fVideoBuffer)
327  mDevice.DMABufferLock(frameData.fVideoBuffer, true);
328  #endif
329 
330  // Allocate a page-aligned audio buffer (if transmitting audio)
331  if (mConfig.WithAudio())
332  if (!frameData.fAudioBuffer.Allocate (AUDIOBYTES_MAX, BUFFER_PAGE_ALIGNED))
333  {
334  PLFAIL("Failed to allocate " << xHEX0N(AUDIOBYTES_MAX,8) << "-byte audio buffer");
335  return AJA_STATUS_MEMORY;
336  }
337  #ifdef NTV2_BUFFER_LOCKING
338  if (frameData.fAudioBuffer)
339  mDevice.DMABufferLock(frameData.fAudioBuffer, /*alsoPreLockSGL*/true);
340  #endif
341  mFrameDataRing.Add (&frameData);
342  } // for each NTV2FrameData
343 
344  if (mDolbyFileIO.IsOpen())
345  {
346  // Initialize IEC61937 burst size (32 milliseconds) for HDMI 192 kHz sample rate
347  mBurstSamples = 6144; // 192000 * 0.032 samples
348  mBurstMax = mBurstSamples * 2;
349  mBurstBuffer = new uint16_t [mBurstMax];
350  mDolbyBuffer = new uint16_t [mBurstMax];
351  }
352 
353  return AJA_STATUS_SUCCESS;
354 
355 } // SetUpHostBuffers
356 
358 {
359  vector<NTV2TestPatternSelect> testPatIDs;
360  testPatIDs.push_back(NTV2_TestPatt_ColorBars100);
361  testPatIDs.push_back(NTV2_TestPatt_ColorBars75);
362  testPatIDs.push_back(NTV2_TestPatt_Ramp);
363  testPatIDs.push_back(NTV2_TestPatt_MultiBurst);
364  testPatIDs.push_back(NTV2_TestPatt_LineSweep);
365  testPatIDs.push_back(NTV2_TestPatt_CheckField);
366  testPatIDs.push_back(NTV2_TestPatt_FlatField);
367  testPatIDs.push_back(NTV2_TestPatt_MultiPattern);
368 
369  mTestPatRasters.clear();
370  for (size_t tpNdx(0); tpNdx < testPatIDs.size(); tpNdx++)
371  mTestPatRasters.push_back(NTV2Buffer());
372 
373  if (!mFormatDesc.IsValid())
374  {PLFAIL("Bad format descriptor"); return AJA_STATUS_FAIL;}
375  if (mFormatDesc.IsVANC())
376  {PLFAIL("VANC should have been disabled: " << mFormatDesc); return AJA_STATUS_FAIL;}
377 
378  // Set up one video buffer for each test pattern...
379  for (size_t tpNdx(0); tpNdx < testPatIDs.size(); tpNdx++)
380  {
381  // Allocate the buffer memory...
382  if (!mTestPatRasters.at(tpNdx).Allocate (mFormatDesc.GetTotalBytes(), BUFFER_PAGE_ALIGNED))
383  { PLFAIL("Test pattern buffer " << DEC(tpNdx+1) << " of " << DEC(testPatIDs.size()) << ": "
384  << xHEX0N(mFormatDesc.GetTotalBytes(),8) << "-byte page-aligned alloc failed");
385  return AJA_STATUS_MEMORY;
386  }
387 
388  // Fill the buffer with test pattern...
389  NTV2TestPatternGen testPatternGen;
390  if (!testPatternGen.DrawTestPattern (testPatIDs.at(tpNdx), mFormatDesc, mTestPatRasters.at(tpNdx)))
391  {
392  cerr << "## ERROR: DrawTestPattern " << DEC(tpNdx) << " failed: " << mFormatDesc << endl;
393  return AJA_STATUS_FAIL;
394  }
395 
396  #ifdef NTV2_BUFFER_LOCKING
397  // Try to prelock the memory, including its scatter-gather list...
398  if (!mDevice.DMABufferLock(mTestPatRasters.at(tpNdx), /*alsoLockSegmentMap=*/true))
399  PLWARN("Test pattern buffer " << DEC(tpNdx+1) << " of " << DEC(testPatIDs.size()) << ": failed to pre-lock");
400  #endif
401  } // loop for each predefined pattern
402 
403  return AJA_STATUS_SUCCESS;
404 
405 } // SetUpTestPatternBuffers
406 
407 
409 {
410  const bool isRGB (::IsRGBFormat(mConfig.fPixelFormat));
411  const NTV2OutputXptID fsVidOutXpt (::GetFrameBufferOutputXptFromChannel (mConfig.fOutputChannel, isRGB, false/*is425*/));
412 
413  mDevice.ClearRouting(); // Start with clean slate
414 
415  // Connect HDMI video output...
416  return mDevice.Connect (::GetOutputDestInputXpt (NTV2_OUTPUTDESTINATION_HDMI), fsVidOutXpt);
417 
418 } // RouteOutputSignal
419 
420 
422 {
423  // Start my consumer and producer threads...
426  return AJA_STATUS_SUCCESS;
427 
428 } // Run
429 
430 
431 
433 // This is where the play thread starts
434 
436 {
437  // Create and start the playout thread...
438  mConsumerThread.Attach (ConsumerThreadStatic, this);
439  mConsumerThread.SetPriority (AJA_ThreadPriority_High);
440  mConsumerThread.Start ();
441 
442 } // StartConsumerThread
443 
444 
445 // The playout thread function
446 void NTV2DolbyPlayer::ConsumerThreadStatic (AJAThread * pThread, void * pContext) // static
447 { (void) pThread;
448  // Grab the NTV2DolbyPlayer instance pointer from the pContext parameter,
449  // then call its ConsumeFrames method...
450  NTV2DolbyPlayer * pApp (reinterpret_cast<NTV2DolbyPlayer*>(pContext));
451  if (pApp)
452  pApp->ConsumeFrames();
453 
454 } // ConsumerThreadStatic
455 
456 
458 {
459  AUTOCIRCULATE_TRANSFER outputXfer;
460  AUTOCIRCULATE_STATUS outputStatus;
461  ULWord goodXfers(0), badXfers(0), starves(0), noRoomWaits(0);
462 
463  // Stop AutoCirculate, just in case someone else left it running...
464  mDevice.AutoCirculateStop(mConfig.fOutputChannel);
465  mDevice.WaitForOutputVerticalInterrupt(mConfig.fOutputChannel, 4); // Let it stop
466  PLNOTE("Thread started");
467 
468  // Initialize & start AutoCirculate...
469  bool initOK = mDevice.AutoCirculateInitForOutput (mConfig.fOutputChannel, mConfig.fFrames.count(),
470  mAudioSystem, AUTOCIRCULATE_WITH_RP188, /*numChannels*/ 1,
471  mConfig.fFrames.firstFrame(), mConfig.fFrames.lastFrame());
472  if (!initOK)
473  {PLFAIL("AutoCirculateInitForOutput failed"); mGlobalQuit = true;}
474  else if (!mConfig.WithVideo())
475  { // Video suppressed --
476  // Clear device frame buffers being AutoCirculated (prevent garbage output frames)
477  NTV2Buffer tmpFrame (mFormatDesc.GetVideoWriteSize());
478  NTV2TestPatternGen blackPatternGen;
479  blackPatternGen.DrawTestPattern (NTV2_TestPatt_Black, mFormatDesc, tmpFrame);
480  mDevice.AutoCirculateGetStatus (mConfig.fOutputChannel, outputStatus);
481  for (uint16_t frmNum(outputStatus.GetStartFrame()); frmNum <= outputStatus.GetEndFrame(); frmNum++)
482  mDevice.DMAWriteFrame(ULWord(frmNum), tmpFrame, mFormatDesc.GetTotalBytes());
483  } // else if --novideo
484 
485 
486  while (!mGlobalQuit)
487  {
488  mDevice.AutoCirculateGetStatus (mConfig.fOutputChannel, outputStatus);
489 
490  // Check if there's room for another frame on the card...
491  if (outputStatus.CanAcceptMoreOutputFrames())
492  {
493  // Device has at least one free frame buffer that can be filled.
494  // Wait for the next frame in our ring to become ready to "consume"...
495  NTV2FrameData * pFrameData (mFrameDataRing.StartConsumeNextBuffer());
496  if (!pFrameData)
497  {starves++; continue;}
498 
499  outputXfer.SetOutputTimeCodes(pFrameData->fTimecodes);
500 
501  if (pFrameData->VideoBuffer()) // Transfer the timecode-burned frame to the device for playout...
502  outputXfer.SetVideoBuffer (pFrameData->VideoBuffer(), pFrameData->VideoBufferSize());
503  if (pFrameData->AudioBuffer()) // If also playing audio...
504  outputXfer.SetAudioBuffer (pFrameData->AudioBuffer(), pFrameData->fNumAudioBytes);
505 
506 
507  // Perform the DMA transfer to the device...
508  if (mDevice.AutoCirculateTransfer (mConfig.fOutputChannel, outputXfer))
509  goodXfers++;
510  else
511  badXfers++;
512 
513  if (goodXfers == 3)
514  mDevice.AutoCirculateStart(mConfig.fOutputChannel);
515 
516  // Signal that the frame has been "consumed"...
517  mFrameDataRing.EndConsumeNextBuffer();
518  continue; // Back to top of while loop
519 
520  }
521 
522  // Wait for one or more buffers to become available on the device, which should occur at next VBI...
523  noRoomWaits++;
525  } // loop til quit signaled
526 
527  // Stop AutoCirculate...
528  mDevice.AutoCirculateStop(mConfig.fOutputChannel);
529  PLNOTE("Thread completed: " << DEC(goodXfers) << " xfers, " << DEC(badXfers) << " failed, "
530  << DEC(starves) << " starves, " << DEC(noRoomWaits) << " VBI waits");
531 
532 } // ConsumeFrames
533 
534 
535 
537 // This is where the producer thread starts
538 
540 {
541  // Create and start the producer thread...
542  mProducerThread.Attach(ProducerThreadStatic, this);
543  mProducerThread.SetPriority(AJA_ThreadPriority_High);
544  mProducerThread.Start();
545 
546 } // StartProducerThread
547 
548 
549 void NTV2DolbyPlayer::ProducerThreadStatic (AJAThread * pThread, void * pContext) // static
550 {
551  (void) pThread;
552  NTV2DolbyPlayer * pApp (reinterpret_cast <NTV2DolbyPlayer *> (pContext));
553  if (pApp)
554  pApp->ProduceFrames ();
555 
556 } // ProducerThreadStatic
557 
558 
560 {
561  ULWord freqNdx(0), testPatNdx(0), badTally(0);
562  double timeOfLastSwitch (0.0);
563 
566  //const bool isInterlace (!NTV2_VIDEO_FORMAT_HAS_PROGRESSIVE_PICTURE(mConfig.fVideoFormat));
567  //const bool isPAL (NTV2_IS_PAL_VIDEO_FORMAT(mConfig.fVideoFormat));
568  const NTV2FrameRate ntv2FrameRate (::GetNTV2FrameRateFromVideoFormat(mConfig.fVideoFormat));
569  const TimecodeFormat tcFormat (CNTV2DemoCommon::NTV2FrameRate2TimecodeFormat(ntv2FrameRate));
570 
571  PLNOTE("Thread started");
572  while (!mGlobalQuit)
573  {
574  NTV2FrameData * pFrameData (mFrameDataRing.StartProduceNextBuffer());
575  // If no frame is available, wait and try again
576  if (!pFrameData)
577  { badTally++; // No frame available!
578  AJATime::Sleep(10); // Wait a bit for the consumer thread to free one up for me...
579  continue; // ...then try again
580  }
581 
582  // Copy my pre-made test pattern into my video buffer...
583  if (pFrameData->VideoBuffer()) // Copy fresh, unmodified, pre-rendered test pattern into this frame's video buffer...
584  pFrameData->fVideoBuffer.CopyFrom (mTestPatRasters.at(testPatNdx),
585  /*srcOffset*/ 0,
586  /*dstOffset*/ 0,
587  /*byteCount*/ pFrameData->fVideoBuffer.GetByteCount());
588 
589  const CRP188 rp188Info (mCurrentFrame++, 0, 0, 10, tcFormat);
590  NTV2_RP188 tcF1;
591  string tcString;
592 
593  rp188Info.GetRP188Reg (tcF1);
594  rp188Info.GetRP188Str (tcString);
595 
596  if (pFrameData->VideoBuffer()) // Burn current timecode into the video buffer...
597  mTCBurner.BurnTimeCode (pFrameData->VideoBuffer(), tcString.c_str(), 80);
598  TCDBG("F" << DEC0N(mCurrentFrame-1,6) << ": " << tcF1 << ": " << tcString);
599 
600  // If also playing audio...
601  if (pFrameData->AudioBuffer()) // ...then generate audio tone data for this frame...
602  {
603  if (mDolbyFileIO.IsOpen())
604  pFrameData->fNumAudioBytes = AddDolby(*pFrameData);
605  else
606  {
607  if (mConfig.fDoRamp)
608  pFrameData->fNumAudioBytes = AddRamp(*pFrameData);
609  else
610  pFrameData->fNumAudioBytes = AddTone(*pFrameData);
611  }
612  }
613 
614  // Every few seconds, change the test pattern and tone frequency...
615  const double currentTime (timeBase.FramesToSeconds(mCurrentFrame));
616  if (currentTime > timeOfLastSwitch + 4.0)
617  {
618  freqNdx = (freqNdx + 1) % gNumFrequencies;
619  testPatNdx = (testPatNdx + 1) % ULWord(mTestPatRasters.size());
620  mToneFrequency = gFrequencies[freqNdx];
621  timeOfLastSwitch = currentTime;
622  PLINFO("F" << DEC0N(mCurrentFrame,6) << ": " << tcString << ": tone=" << mToneFrequency << "Hz, pattern='" << tpNames.at(testPatNdx) << "'");
623  } // if time to switch test pattern & tone frequency
624 
625  // Signal that I'm done producing this FrameData, making it immediately available for transfer/playout...
626  mFrameDataRing.EndProduceNextBuffer();
627 
628  } // loop til mGlobalQuit goes true
629  PLNOTE("Thread completed: " << DEC(mCurrentFrame) << " frame(s) produced, " << DEC(badTally) << " failed");
630 
631 } // ProduceFrames
632 
634 {
635  mDevice.AutoCirculateGetStatus (mConfig.fOutputChannel, outStatus);
636 }
637 
638 
639 uint32_t NTV2DolbyPlayer::AddTone (NTV2FrameData & inFrameData)
640 {
643  ULWord numChannels (0);
644 
645  mDevice.GetFrameRate (frameRate, mConfig.fOutputChannel);
646  mDevice.GetAudioRate (audioRate, mAudioSystem);
647  mDevice.GetNumberAudioChannels (numChannels, mAudioSystem);
648 
649  // Set per-channel tone frequencies...
650  double pFrequencies [kNumAudioChannelsMax];
651  pFrequencies [0] = (mToneFrequency / 2.0);
652  for (ULWord chan (1); chan < numChannels; chan++)
653  // The 1.154782 value is the 16th root of 10, to ensure that if mToneFrequency is 2000,
654  // that the calculated frequency of audio channel 16 will be 20kHz...
655  pFrequencies [chan] = pFrequencies [chan - 1] * 1.154782;
656 
657  // Because audio on AJA devices use fixed sample rates (typically 48KHz), certain video frame rates will necessarily
658  // result in some frames having more audio samples than others. The GetAudioSamplesPerFrame function
659  // is used to calculate the correct sample count...
660  const ULWord numSamples (::GetAudioSamplesPerFrame (frameRate, audioRate, mCurrentFrame));
661  const double sampleRateHertz (::GetAudioSamplesPerSecond(audioRate));
662 
663  return ::AddAudioTone ( inFrameData.AudioBuffer(), // audio buffer to fill
664  mCurrentSample, // which sample for continuing the waveform
665  numSamples, // number of samples to generate
666  sampleRateHertz, // sample rate [Hz]
667  gAmplitudes, // per-channel amplitudes
668  pFrequencies, // per-channel tone frequencies [Hz]
669  31, // bits per sample
670  false, // don't byte swap
671  numChannels); // number of audio channels to generate
672 } // AddTone
673 
674 uint32_t NTV2DolbyPlayer::AddRamp (NTV2FrameData & inFrameData)
675 {
676  ULWord * audioBuffer (inFrameData.AudioBuffer());
679  ULWord numChannels (0);
680 
681  mDevice.GetFrameRate (frameRate, mConfig.fOutputChannel);
682  mDevice.GetAudioRate (audioRate, mAudioSystem);
683  mDevice.GetNumberAudioChannels (numChannels, mAudioSystem);
684 
685  // Because audio on AJA devices use fixed sample rates (typically 48KHz), certain video frame rates will necessarily
686  // result in some frames having more audio samples than others. The GetAudioSamplesPerFrame function
687  // is used to calculate the correct sample count...
688  const ULWord numSamples (::GetAudioSamplesPerFrame (frameRate, audioRate, mCurrentFrame));
689 
690  for (uint32_t samp(0); samp < numSamples; samp++)
691  {
692  for (uint32_t ch(0); ch < numChannels; ch++)
693  {
694  *audioBuffer = uint32_t(mRampSample) << 16;
695  audioBuffer++;
696  mRampSample++;
697  } // for each channel
698  } // for each sample
699 
700  return numSamples * numChannels * 4;
701 } // AddRamp
702 
703 #if defined(DOLBY_FULL_PARSER)
704 
705 uint32_t NTV2DolbyPlayer::AddDolby (NTV2FrameData & inFrameData)
706 {
707  ULWord* audioBuffer (inFrameData.AudioBuffer());
710  ULWord numChannels (0);
711  ULWord sampleOffset(0);
712  ULWord sampleCount (0);
713  NTV2DolbyBSI bsi;
714 
715  mDevice.GetFrameRate (frameRate, mConfig.fOutputChannel);
716  mDevice.GetAudioRate (audioRate, mAudioSystem);
717  mDevice.GetNumberAudioChannels (numChannels, mAudioSystem);
718  const ULWord numSamples (::GetAudioSamplesPerFrame (frameRate, audioRate, mCurrentFrame));
719 
720  if (!mDolbyFileIO.IsOpen() || !mDolbyBuffer)
721  goto silence;
722 
723  // Generate the samples for this frame
724  while (sampleOffset < numSamples)
725  {
726  if ((mBurstSize != 0) && (mBurstIndex < mBurstSamples))
727  {
728  if(mBurstOffset < mBurstSize)
729  {
730  uint32_t data0 = 0;
731  uint32_t data1 = 0;
732  if (mBurstIndex == 0)
733  {
734  // Add IEC61937 burst preamble
735  data0 = 0xf872; // Sync stuff
736  data1 = 0x4e1f;
737  }
738  else if (mBurstIndex == 1)
739  {
740  // Add more IEC61937 burst preamble
741  data0 = ((bsi.bsmod & 0x7) << 8) | 0x0015; // This is Dolby
742  data1 = mBurstSize * 2; // Data size in bytes
743  }
744  else
745  {
746  // Add sync frame data
747  data0 = (uint32_t)(mBurstBuffer[mBurstOffset]);
748  data0 = ((data0 & 0x00ff) << 8) | ((data0 & 0xff00) >> 8);
749  mBurstOffset++;
750  data1 = (uint32_t)(mBurstBuffer[mBurstOffset]);
751  data1 = ((data1 & 0x00ff) << 8) | ((data1 & 0xff00) >> 8);
752  mBurstOffset++;
753  }
754 
755  // Write data into 16 msbs of all audio channel pairs
756  data0 <<= 16;
757  data1 <<= 16;
758  for (ULWord i = 0; i < numChannels; i += 2)
759  {
760  audioBuffer[sampleOffset * numChannels + i] = data0;
761  audioBuffer[sampleOffset * numChannels + i + 1] = data1;
762  }
763  }
764  else
765  {
766  // Pad samples out to burst size
767  for (ULWord i = 0; i < numChannels; i++)
768  {
769  audioBuffer[sampleOffset * numChannels + i] = 0;
770  }
771  }
772  sampleOffset++;
773  mBurstIndex++;
774  }
775  else
776  {
777  ULWord dolbyOffset = 0;
778  ULWord burstOffset = 0;
779  ULWord numBlocks = 0;
780 
781  mBurstIndex = 0;
782  mBurstOffset = 0;
783 
784  if (mDolbySize == 0)
785  {
786  // Find first Dolby Digital Plus burst frame
787  while (true)
788  {
789  if (!GetDolbyFrame(&mDolbyBuffer[0], sampleCount))
790  {
791  cerr << "## ERROR: Dolby frame not found" << endl;
792  mDolbyFileIO.Close();
793  goto silence;
794  }
795 
796  if (!ParseBSI(&mDolbyBuffer[1], sampleCount - 1, &bsi))
797  continue;
798 
799  if ((bsi.strmtyp == 0) &&
800  (bsi.substreamid == 0) &&
801  (bsi.bsid == 16) &&
802  ((bsi.numblkscod == 3) || (bsi.convsync == 1)))
803  break;
804  }
805 
806  mDolbySize = sampleCount;
807  switch (bsi.numblkscod)
808  {
809  case 0: mDolbyBlocks = 1; break;
810  case 1: mDolbyBlocks = 2; break;
811  case 2: mDolbyBlocks = 3; break;
812  case 3: mDolbyBlocks = 6; break;
813  default: goto silence;
814  }
815  }
816 
817  while (numBlocks <= 6)
818  {
819  // Copy the Dolby frame into the burst buffer
820  while (dolbyOffset < mDolbySize)
821  {
822  // Check for burst size overrun
823  if (burstOffset >= mBurstMax)
824  {
825  cerr << "## ERROR: Dolby burst too large" << endl;
826  mDolbyFileIO.Close();
827  goto silence;
828  }
829 
830  // Copy sample
831  mBurstBuffer[burstOffset] = mDolbyBuffer[dolbyOffset];
832  burstOffset++;
833  dolbyOffset++;
834  }
835 
836  // Get the next Dolby frame
837  if (!GetDolbyFrame(&mDolbyBuffer[0], sampleCount))
838  {
839  // try to loop
840  if (!GetDolbyFrame(&mDolbyBuffer[0], sampleCount))
841  {
842  cerr << "## ERROR: Dolby frame not found" << endl;
843  mDolbyFileIO.Close();
844  goto silence;
845  }
846  }
847 
848  // Parse the Dolby bitstream header
849  if (!ParseBSI(&mDolbyBuffer[1], sampleCount - 1, &bsi))
850  continue;
851 
852  // Only Dolby Digital Plus
853  if (bsi.bsid != 16)
854  {
855  cerr << "## ERROR: Dolby frame bad bsid = " << bsi.bsid << endl;
856  continue;
857  }
858 
859  mDolbySize = sampleCount;
860  dolbyOffset = 0;
861 
862  // Increment block count on first substream
863  if ((bsi.strmtyp == 0) && (bsi.substreamid == 0))
864  {
865  // increment block count
866  numBlocks += mDolbyBlocks;
867 
868  switch (bsi.numblkscod)
869  {
870  case 0: mDolbyBlocks = 1; break;
871  case 1: mDolbyBlocks = 2; break;
872  case 2: mDolbyBlocks = 3; break;
873  case 3: mDolbyBlocks = 6; break;
874  default:
875  cerr << "## ERROR: Dolby frame bad numblkscod = " << bsi.numblkscod << endl;
876  goto silence;
877  }
878  }
879 
880  // Are we done?
881  if (numBlocks >= 6)
882  {
883  // First frame of new burst must have convsync == 1
884  if ((bsi.numblkscod != 3) &&
885  (bsi.convsync != 1))
886  {
887  cerr << "## ERROR: Dolby frame unexpected convsync = " << bsi.convsync << endl;
888  mDolbySize = 0;
889  mDolbyBlocks = 0;
890  }
891 
892  // Keep the burst size
893  mBurstSize = burstOffset;
894  break;
895  }
896  }
897  }
898  }
899 
900  return numSamples * numChannels * 4;
901 
902 silence:
903  // Output silence when done with file
904  memset(&audioBuffer[sampleOffset * numChannels], 0, (numSamples - sampleOffset) * numChannels * 4);
905  return numSamples * numChannels * 4;
906 }
907 
908 
909 bool NTV2DolbyPlayer::GetDolbyFrame (uint16_t * pInDolbyBuffer, uint32_t & numSamples)
910 {
911  uint32_t bytes;
912  bool done = false;
913 
914  while (!done)
915  {
916  bytes = mDolbyFileIO.Read((uint8_t*)(&pInDolbyBuffer[0]), 2);
917  if (bytes != 2)
918  {
919  // Reset file
920  mDolbyFileIO.Seek(0, eAJASeekSet);
921  return false;
922  }
923 
924  // Check sync word
925  if ((mDolbyBuffer[0] == 0x7705) ||
926  (mDolbyBuffer[0] == 0x770b))
927  done = true;
928  }
929 
930  // Read more of the sync frame header
931  bytes = mDolbyFileIO.Read((uint8_t*)(&pInDolbyBuffer[1]), 4);
932  if (bytes != 4)
933  return false;
934 
935  // Get frame size - 16 bit words plus sync word
936  uint32_t size = (uint32_t)mDolbyBuffer[1];
937  size = (((size & 0x00ff) << 8) | ((size & 0xff00) >> 8));
938  size = (size & 0x7ff) + 1;
939 
940  // Read the rest of the sync frame
941  uint32_t len = (size - 3) * 2;
942  bytes = mDolbyFileIO.Read((uint8_t*)(&pInDolbyBuffer[3]), len);
943  if (bytes != len)
944  return false;
945 
946  numSamples = size;
947 
948  return true;
949 }
950 
951 
952 bool NTV2DolbyPlayer::ParseBSI(uint16_t * pInDolbyBuffer, uint32_t numSamples, NTV2DolbyBSI * pBsi)
953 {
954  if ((pInDolbyBuffer == NULL) || (pBsi == NULL))
955  return false;
956 
957  memset(pBsi, 0, sizeof(NTV2DolbyBSI));
958 
959  SetBitBuffer((uint8_t*)pInDolbyBuffer, numSamples * 2);
960 
961  if (!GetBits(pBsi->strmtyp, 2)) return false;
962  if (!GetBits(pBsi->substreamid, 3)) return false;
963  if (!GetBits(pBsi->frmsiz, 11)) return false;
964  if (!GetBits(pBsi->fscod, 2)) return false;
965  if (!GetBits(pBsi->numblkscod, 2)) return false;
966  if (!GetBits(pBsi->acmod, 3)) return false;
967  if (!GetBits(pBsi->lfeon, 1)) return false;
968  if (!GetBits(pBsi->bsid, 5)) return false;
969  if (!GetBits(pBsi->dialnorm, 5)) return false;
970  if (!GetBits(pBsi->compre, 1)) return false;
971  if (pBsi->compre)
972  {
973  if (!GetBits(pBsi->compr, 8)) return false;
974  }
975  if (pBsi->acmod == 0x0) /* if 1+1 mode (dual mono, so some items need a second value) */
976  {
977  if (!GetBits(pBsi->dialnorm2, 5)) return false;
978  if (!GetBits(pBsi->compr2e, 1)) return false;
979  if (pBsi->compr2e)
980  {
981  if (!GetBits(pBsi->compr2, 8)) return false;
982  }
983  }
984  if (pBsi->strmtyp == 0x1) /* if dependent stream */
985  {
986  if (!GetBits(pBsi->chanmape, 1)) return false;
987  if (pBsi->chanmape)
988  {
989  if (!GetBits(pBsi->chanmap, 16)) return false;
990  }
991  }
992  if (!GetBits(pBsi->mixmdate, 1)) return false;
993  if (pBsi->mixmdate) /* mixing metadata */
994  {
995  if (pBsi->acmod > 0x2) /* if more than 2 channels */
996  {
997  if (!GetBits(pBsi->dmixmod, 2)) return false;
998  }
999  if ((pBsi->acmod & 0x1) && (pBsi->acmod > 0x2)) /* if three front channels exist */
1000  {
1001  if (!GetBits(pBsi->ltrtcmixlev, 3)) return false;
1002  if (!GetBits(pBsi->lorocmixlev, 3)) return false;
1003  }
1004  if (pBsi->acmod & 0x4) /* if a surround channel exists */
1005  {
1006  if (!GetBits(pBsi->ltrtsurmixlev, 3)) return false;
1007  if (!GetBits(pBsi->lorosurmixlev, 3)) return false;
1008  }
1009  if (pBsi->lfeon) /* if the LFE channel exists */
1010  {
1011  if (!GetBits(pBsi->lfemixlevcode, 1)) return false;
1012  if (pBsi->lfemixlevcode)
1013  {
1014  if (!GetBits(pBsi->lfemixlevcod, 5)) return false;
1015  }
1016  }
1017  if (pBsi->strmtyp == 0x0) /* if independent stream */
1018  {
1019  if (!GetBits(pBsi->pgmscle, 1)) return false;
1020  if (pBsi->pgmscle)
1021  {
1022  if (!GetBits(pBsi->pgmscl, 6)) return false;
1023  }
1024  if (pBsi->acmod == 0x0) /* if 1+1 mode (dual mono, so some items need a second value) */
1025  {
1026  if (!GetBits(pBsi->pgmscl2e, 1)) return false;
1027  if (pBsi->pgmscl2e)
1028  {
1029  if (!GetBits(pBsi->pgmscl2, 6)) return false;
1030  }
1031  }
1032  if (!GetBits(pBsi->extpgmscle, 1)) return false;
1033  if (pBsi->extpgmscle)
1034  {
1035  if (!GetBits(pBsi->extpgmscl, 6)) return false;
1036  }
1037  if (!GetBits(pBsi->mixdef, 2)) return false;
1038  if (pBsi->mixdef == 0x1) /* mixing option 2 */
1039  {
1040  if (!GetBits(pBsi->premixcmpsel, 1)) return false;
1041  if (!GetBits(pBsi->drcsrc, 1)) return false;
1042  if (!GetBits(pBsi->premixcmpscl, 3)) return false;
1043  }
1044  else if (pBsi->mixdef == 0x2) /* mixing option 3 */
1045  {
1046  if (!GetBits(pBsi->mixdata, 12)) return false;
1047  }
1048  else if (pBsi->mixdef == 0x3) /* mixing option 4 */
1049  {
1050  if (!GetBits(pBsi->mixdeflen, 5)) return false;
1051  if (!GetBits(pBsi->mixdata2e, 1)) return false;
1052  if (pBsi->mixdata2e)
1053  {
1054  if (!GetBits(pBsi->premixcmpsel, 1)) return false;
1055  if (!GetBits(pBsi->drcsrc, 1)) return false;
1056  if (!GetBits(pBsi->premixcmpscl, 3)) return false;
1057  if (!GetBits(pBsi->extpgmlscle, 1)) return false;
1058  if (pBsi->extpgmlscle)
1059  {
1060  if (!GetBits(pBsi->extpgmlscl, 4)) return false;
1061  }
1062  if (!GetBits(pBsi->extpgmcscle, 1)) return false;
1063  if (pBsi->extpgmcscle)
1064  {
1065  if (!GetBits(pBsi->extpgmcscl, 4)) return false;
1066  }
1067  if (!GetBits(pBsi->extpgmrscle, 1)) return false;
1068  if (pBsi->extpgmrscle)
1069  {
1070  if (!GetBits(pBsi->extpgmrscl, 4)) return false;
1071  }
1072  if (!GetBits(pBsi->extpgmlsscle, 1)) return false;
1073  if (pBsi->extpgmlsscle)
1074  {
1075  if (!GetBits(pBsi->extpgmlsscl, 4)) return false;
1076  }
1077  if (!GetBits(pBsi->extpgmrsscle, 1)) return false;
1078  if (pBsi->extpgmrsscle)
1079  {
1080  if (!GetBits(pBsi->extpgmrsscl, 4)) return false;
1081  }
1082  if (!GetBits(pBsi->extpgmlfescle, 1)) return false;
1083  if (pBsi->extpgmlfescle)
1084  {
1085  if (!GetBits(pBsi->extpgmlfescl, 4)) return false;
1086  }
1087  if (!GetBits(pBsi->dmixscle, 1)) return false;
1088  if (pBsi->dmixscle)
1089  {
1090  if (!GetBits(pBsi->dmixscl, 4)) return false;
1091  }
1092  if (!GetBits(pBsi->addche, 1)) return false;
1093  if (pBsi->addche)
1094  {
1095  if (!GetBits(pBsi->extpgmaux1scle, 1)) return false;
1096  if (pBsi->extpgmaux1scle)
1097  {
1098  if (!GetBits(pBsi->extpgmaux1scl, 4)) return false;
1099  }
1100  if (!GetBits(pBsi->extpgmaux2scle, 1)) return false;
1101  if (pBsi->extpgmaux2scle)
1102  {
1103  if (!GetBits(pBsi->extpgmaux2scl, 4)) return false;
1104  }
1105  }
1106  }
1107  if (!GetBits(pBsi->mixdata3e, 1)) return false;
1108  if (pBsi->mixdata3e)
1109  {
1110  if (!GetBits(pBsi->spchdat, 5)) return false;
1111  if (!GetBits(pBsi->addspchdate, 1)) return false;
1112  if (pBsi->addspchdate)
1113  {
1114  if (!GetBits(pBsi->spchdat1, 5)) return false;
1115  if (!GetBits(pBsi->spchan1att, 2)) return false;
1116  if (!GetBits(pBsi->addspchdat1e, 1)) return false;
1117  if (pBsi->addspdat1e)
1118  {
1119  if (!GetBits(pBsi->spchdat2, 5)) return false;
1120  if (!GetBits(pBsi->spchan2att, 3)) return false;
1121  }
1122  }
1123  }
1124  {
1125  uint32_t data;
1126  uint32_t size = 8 * (pBsi->mixdeflen + 2);
1127  size = (size + 7) / 8 * 8;
1128  uint32_t index = 0;
1129  while (size > 0)
1130  {
1131  if (!GetBits(data, (size > 8)? 8 : size)) return false;
1132  pBsi->mixdatabuffer[index++] = (uint8_t)data;
1133  size = size - 8;
1134  }
1135  }
1136  }
1137  if (pBsi->acmod < 0x2) /* if mono or dual mono source */
1138  {
1139  if (!GetBits(pBsi->paninfoe, 1)) return false;
1140  if (pBsi->paninfoe)
1141  {
1142  if (!GetBits(pBsi->panmean, 8)) return false;
1143  if (!GetBits(pBsi->paninfo, 6)) return false;
1144  }
1145  if (pBsi->acmod == 0x0) /* if 1+1 mode (dual mono - some items need a second value) */
1146  {
1147  if (!GetBits(pBsi->paninfo2e, 1)) return false;
1148  if (pBsi->paninfo2e)
1149  {
1150  if (!GetBits(pBsi->panmean2, 8)) return false;
1151  if (!GetBits(pBsi->paninfo2, 6)) return false;
1152  }
1153  }
1154  }
1155  if (!GetBits(pBsi->frmmixcfginfoe, 1)) return false;
1156  if (pBsi->frmmixcfginfoe) /* mixing configuration information */
1157  {
1158  if (pBsi->numblkscod == 0x0)
1159  {
1160  if (!GetBits(pBsi->blkmixcfginfo[0], 5)) return false;
1161  }
1162  else
1163  {
1164  uint32_t blk;
1165  uint32_t numblk;
1166  if (pBsi->numblkscod == 0x1)
1167  numblk = 2;
1168  else if (pBsi->numblkscod == 0x2)
1169  numblk = 3;
1170  else if (pBsi->numblkscod == 0x3)
1171  numblk = 6;
1172  else
1173  return false;
1174  for(blk = 0; blk < numblk; blk++)
1175  {
1176  if (!GetBits(pBsi->blkmixcfginfoe, 1)) return false;
1177  if (pBsi->blkmixcfginfoe)
1178  {
1179  if (!GetBits(pBsi->blkmixcfginfo[blk], 5)) return false;
1180  }
1181  }
1182  }
1183  }
1184  }
1185  }
1186  if (!GetBits(pBsi->infomdate, 1)) return false;
1187  if (pBsi->infomdate) /* informational metadata */
1188  {
1189  if (!GetBits(pBsi->bsmod, 3)) return false;
1190  if (!GetBits(pBsi->copyrightb, 1)) return false;
1191  if (!GetBits(pBsi->origbs, 1)) return false;
1192  if (pBsi->acmod == 0x2) /* if in 2/0 mode */
1193  {
1194  if (!GetBits(pBsi->dsurmod, 2)) return false;
1195  if (!GetBits(pBsi->dheadphonmod, 2)) return false;
1196  }
1197  if (pBsi->acmod >= 0x6) /* if both surround channels exist */
1198  {
1199  if (!GetBits(pBsi->dsurexmod, 2)) return false;
1200  }
1201  if (!GetBits(pBsi->audprodie, 1)) return false;
1202  if (pBsi->audprodie)
1203  {
1204  if (!GetBits(pBsi->mixlevel, 5)) return false;
1205  if (!GetBits(pBsi->roomtyp, 2)) return false;
1206  if (!GetBits(pBsi->adconvtyp, 1)) return false;
1207  }
1208  if (pBsi->acmod == 0x0) /* if 1+1 mode (dual mono, so some items need a second value) */
1209  {
1210  if (!GetBits(pBsi->audprodi2e, 1)) return false;
1211  if (pBsi->audprodi2e)
1212  {
1213  if (!GetBits(pBsi->mixlevel2, 5)) return false;
1214  if (!GetBits(pBsi->roomtyp2, 2)) return false;
1215  if (!GetBits(pBsi->adconvtyp2, 1)) return false;
1216  }
1217  }
1218  if (pBsi->fscod < 0x3) /* if not half sample rate */
1219  {
1220  if (!GetBits(pBsi->sourcefscod, 1)) return false;
1221  }
1222  }
1223  if ((pBsi->strmtyp == 0x0) && (pBsi->numblkscod != 0x3))
1224  {
1225  if (!GetBits(pBsi->convsync, 1)) return false;
1226  }
1227  if (pBsi->strmtyp == 0x2) /* if bit stream converted from AC-3 */
1228  {
1229  if (pBsi->numblkscod == 0x3) /* 6 blocks per syncframe */
1230  {
1231  pBsi->blkid = 1;
1232  }
1233  else
1234  {
1235  if (!GetBits(pBsi->blkid, 1)) return false;
1236  }
1237  if (pBsi->blkid)
1238  {
1239  if (!GetBits(pBsi->frmsizecod, 6)) return false;
1240  }
1241  }
1242  if (!GetBits(pBsi->addbsie, 1)) return false;
1243  if (pBsi->addbsie)
1244  {
1245  if (!GetBits(pBsi->addbsil, 6)) return false;
1246  {
1247  uint32_t data;
1248  uint32_t size = 8 * (pBsi->addbsil + 1);
1249  uint32_t index = 0;
1250  while (size > 0)
1251  {
1252  if (!GetBits(data, 8)) return false;
1253  pBsi->addbsibuffer[index++] = (uint8_t)data;
1254  size = size - 8;
1255  }
1256  }
1257  }
1258 
1259  return true;
1260 }
1261 
1262 void NTV2DolbyPlayer::SetBitBuffer(uint8_t * pBuffer, uint32_t size)
1263 {
1264  mBitBuffer = pBuffer;
1265  mBitSize = size;
1266  mBitIndex = 8;
1267 }
1268 
1269 bool NTV2DolbyPlayer::GetBits(uint32_t & data, uint32_t bits)
1270 {
1271  uint32_t cb;
1272  static uint8_t bitMask[] = { 0x00, 0x01, 0x03, 0x07, 0x0f, 0x1f, 0x3f, 0x7f, 0xff };
1273 
1274  data = 0;
1275  while (bits > 0)
1276  {
1277  if (mBitSize == 0)
1278  return false;
1279 
1280  if (mBitIndex == 0)
1281  {
1282  mBitBuffer++;
1283  mBitSize--;
1284  mBitIndex = 8;
1285  }
1286 
1287  cb = bits;
1288  if (cb > mBitIndex)
1289  cb = mBitIndex;
1290  bits -= cb;
1291  mBitIndex -= cb;
1292  data |= ((*mBitBuffer >> mBitIndex) & bitMask[cb]) << bits;
1293  }
1294 
1295  return true;
1296 }
1297 
1298 #else // DOLBY_FULL_PARSER
1299 // NOTE: The code under this #else is out of date and not maintaiend
1300 uint32_t NTV2DolbyPlayer::AddDolby (ULWord * pInAudioBuffer)
1301 {
1304  ULWord numChannels (0);
1305  ULWord sampleOffset(0);
1306 
1307  mDevice.GetFrameRate (frameRate, mOutputChannel);
1308  mDevice.GetAudioRate (audioRate, mAudioSystem);
1309  mDevice.GetNumberAudioChannels (numChannels, mAudioSystem);
1310  const ULWord numSamples (::GetAudioSamplesPerFrame (frameRate, audioRate, mCurrentFrame));
1311 
1312  if ((mConfig.fDolbyFile == NULL) || (mDolbyBuffer == NULL))
1313  goto silence;
1314 
1315  // Generate the samples for this frame
1316  while (sampleOffset < numSamples)
1317  {
1318  // Time for a new IEC61937 burst
1319  if (mBurstIndex >= mBurstSamples)
1320  mBurstIndex = 0;
1321 
1322  // Get a new Dolby Digital Plus sync frame
1323  if (mBurstIndex == 0)
1324  {
1325  // Read the sync word (all big endian)
1326  uint32_t bytes = mConfig.fDolbyFile->Read((uint8_t*)(&mDolbyBuffer[0]), 2);
1327  if (bytes != 2)
1328  {
1329  // Try to loop
1330  mConfig.fDolbyFile->Seek(0, eAJASeekSet);
1331  bytes = mConfig.fDolbyFile->Read((uint8_t*)(&mDolbyBuffer[0]), 2);
1332  if (bytes != 2)
1333  goto silence;
1334  }
1335 
1336  // Check sync word
1337  if ((mDolbyBuffer[0] != 0x7705) &&
1338  (mDolbyBuffer[0] != 0x770b))
1339  goto silence;
1340 
1341  // Read more of the sync frame header
1342  bytes = mConfig.fDolbyFile->Read((uint8_t*)(&mDolbyBuffer[1]), 4);
1343  if (bytes != 4)
1344  goto silence;
1345 
1346  // Get frame size - 16 bit words plus sync word
1347  uint32_t size = (uint32_t)mDolbyBuffer[1];
1348  size = (((size & 0x00ff) << 8) | ((size & 0xff00) >> 8)) + 1;
1349 
1350  // Read the rest of the sync frame
1351  uint32_t len = (size - 3) * 2;
1352  bytes = mConfig.fDolbyFile->Read((uint8_t*)(&mDolbyBuffer[3]), len);
1353  if (bytes != len)
1354  goto silence;
1355 
1356  // Good frame
1357  mBurstOffset = 0;
1358  mBurstSize = size;
1359  }
1360 
1361  // Add the Dolby data to the audio stream
1362  if (mBurstOffset < mBurstSize)
1363  {
1364  uint32_t data0 = 0;
1365  uint32_t data1 = 0;
1366  if (mBurstIndex == 0)
1367  {
1368  // Add IEC61937 burst preamble
1369  data0 = 0xf872; // Sync stuff
1370  data1 = 0x4e1f;
1371  }
1372  else if (mBurstIndex == 1)
1373  {
1374  // Add more IEC61937 burst preamble
1375  data0 = 0x0015; // This is Dolby
1376  data1 = mBurstSize * 2; // Data size in bytes
1377  }
1378  else
1379  {
1380  // Add sync frame data
1381  data0 = (uint32_t)(mDolbyBuffer[mBurstOffset]);
1382  data0 = ((data0 & 0x00ff) << 8) | ((data0 & 0xff00) >> 8);
1383  mBurstOffset++;
1384  data1 = (uint32_t)(mDolbyBuffer[mBurstOffset]);
1385  data1 = ((data1 & 0x00ff) << 8) | ((data1 & 0xff00) >> 8);
1386  mBurstOffset++;
1387  }
1388 
1389  // Write data into 16 msbs of all audio channel pairs
1390  data0 <<= 16;
1391  data1 <<= 16;
1392  for (ULWord i = 0; i < numChannels; i += 2)
1393  {
1394  pInAudioBuffer[sampleOffset * numChannels + i] = data0;
1395  pInAudioBuffer[sampleOffset * numChannels + i + 1] = data1;
1396  }
1397  }
1398  else
1399  {
1400  // Pad samples out to burst size
1401  for (ULWord i = 0; i < numChannels; i++)
1402  {
1403  pInAudioBuffer[sampleOffset * numChannels + i] = 0;
1404  }
1405  }
1406 
1407  sampleOffset++;
1408  mBurstIndex++;
1409  }
1410 
1411  return numSamples * numChannels * 4;
1412 
1413 silence:
1414  // Output silence when done with file
1415  memset(&pInAudioBuffer[sampleOffset * numChannels], 0, (numSamples - sampleOffset) * numChannels * 4);
1416  return numSamples * numChannels * 4;
1417 }
1418 #endif // DOLBY_FULL_PARSER
1419 
1420 AJALabelValuePairs DolbyPlayerConfig::Get (const bool inCompact) const
1421 {
1422  AJALabelValuePairs result (PlayerConfig::Get(inCompact));
1423  AJASystemInfo::append (result, "Dolby Playback File", fDolbyFilePath.empty() ? "---" : fDolbyFilePath);
1424  AJASystemInfo::append (result, "Audio Data Ramp", fDoRamp ? "Yes" : "No");
1425  return result;
1426 }
1427 
1428 std::ostream & operator << (std::ostream & ioStrm, const DolbyPlayerConfig & inObj)
1429 {
1430  ioStrm << AJASystemInfo::ToString(inObj.Get());
1431  return ioStrm;
1432 }
NTV2TestPatternGen::DrawTestPattern
virtual bool DrawTestPattern(const std::string &inTPName, const NTV2FormatDescriptor &inFormatDesc, NTV2Buffer &inBuffer)
Renders the given test pattern or color into a host raster buffer.
CNTV2Card::SubscribeOutputVerticalEvent
virtual bool SubscribeOutputVerticalEvent(const NTV2Channel inChannel)
Causes me to be notified when an output vertical blanking interrupt is generated for the given output...
Definition: ntv2subscriptions.cpp:25
CNTV2Card::SetVANCMode
virtual bool SetVANCMode(const NTV2VANCMode inVancMode, const NTV2Channel inChannel=NTV2_CHANNEL1)
Sets the VANC mode for the given FrameStore.
Definition: ntv2register.cpp:2640
NTV2DolbyPlayer::NTV2DolbyBSI::audprodie
uint32_t audprodie
Definition: ntv2dolbyplayer.h:171
NTV2DolbyPlayer::NTV2DolbyBSI::premixcmpscl
uint32_t premixcmpscl
Definition: ntv2dolbyplayer.h:122
NTV2DolbyPlayer::NTV2DolbyBSI::spchdat1
uint32_t spchdat1
Definition: ntv2dolbyplayer.h:148
AJAFileIO::IsOpen
bool IsOpen()
Definition: file_io.cpp:317
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:4379
NTV2DolbyPlayer::NTV2DolbyBSI::bsid
uint32_t bsid
Definition: ntv2dolbyplayer.h:96
NTV2DolbyPlayer::~NTV2DolbyPlayer
virtual ~NTV2DolbyPlayer(void)
Definition: ntv2dolbyplayer.cpp:85
DeviceCapabilities::CanDoVideoFormat
bool CanDoVideoFormat(const NTV2VideoFormat inVF)
Definition: ntv2devicecapabilities.h:251
NTV2DolbyPlayer::NTV2DolbyBSI::audprodi2e
uint32_t audprodi2e
Definition: ntv2dolbyplayer.h:175
NTV2DolbyPlayer::NTV2DolbyBSI::chanmape
uint32_t chanmape
Definition: ntv2dolbyplayer.h:103
NTV2DolbyPlayer::NTV2DolbyBSI::mixdata3e
uint32_t mixdata3e
Definition: ntv2dolbyplayer.h:145
NTV2_AUDIO_LOOPBACK_OFF
@ NTV2_AUDIO_LOOPBACK_OFF
Embeds silence (zeroes) into the data stream.
Definition: ntv2enums.h:1975
NTV2DolbyPlayer::RouteOutputSignal
virtual bool RouteOutputSignal(void)
Performs all widget/signal routing for playout.
Definition: ntv2dolbyplayer.cpp:408
NTV2FormatDescriptor::GetVideoWriteSize
ULWord GetVideoWriteSize(ULWord inPageSize=4096UL) const
Definition: ntv2formatdescriptor.cpp:862
NTV2DolbyPlayer::NTV2DolbyBSI::mixdata2e
uint32_t mixdata2e
Definition: ntv2dolbyplayer.h:125
NTV2_AUDIO_192K
@ NTV2_AUDIO_192K
Definition: ntv2enums.h:1877
NTV2_TestPatt_CheckField
@ NTV2_TestPatt_CheckField
Definition: ntv2testpatterngen.h:34
TCDBG
#define TCDBG(_expr_)
Definition: ntv2dolbyplayer.cpp:26
NTV2_REFERENCE_SFP1_PTP
@ NTV2_REFERENCE_SFP1_PTP
Specifies the PTP source on SFP 1.
Definition: ntv2enums.h:1413
NTV2_IS_VALID_TASK_MODE
#define NTV2_IS_VALID_TASK_MODE(__m__)
Definition: ntv2publicinterface.h:4296
NTV2DolbyPlayer::NTV2DolbyBSI::frmsiz
uint32_t frmsiz
Definition: ntv2dolbyplayer.h:91
NTV2_CHANNEL2
@ NTV2_CHANNEL2
Specifies channel or Frame Store 2 (or the 2nd item).
Definition: ntv2enums.h:1308
NTV2_VANCDATA_NORMAL
@ NTV2_VANCDATA_NORMAL
Definition: ntv2enums.h:3734
AJA_ThreadPriority_High
@ AJA_ThreadPriority_High
Definition: thread.h:44
NTV2ACFrameRange::firstFrame
UWord firstFrame(void) const
Definition: ntv2utils.h:975
CNTV2Card::SetVideoFormat
virtual bool SetVideoFormat(const NTV2VideoFormat inVideoFormat, const bool inIsAJARetail=(!(0)), const bool inKeepVancSettings=(0), const NTV2Channel inChannel=NTV2_CHANNEL1)
Configures the AJA device to handle a specific video format.
Definition: ntv2register.cpp:204
AJATimeCodeBurn::RenderTimeCodeFont
AJA_EXPORT bool RenderTimeCodeFont(AJA_PixelFormat pixelFormat, uint32_t numPixels, uint32_t numLines)
Definition: timecodeburn.cpp:447
NTV2DolbyPlayer::NTV2DolbyBSI::addspdat1e
uint32_t addspdat1e
Definition: ntv2dolbyplayer.h:151
NTV2_TestPatt_MultiBurst
@ NTV2_TestPatt_MultiBurst
Definition: ntv2testpatterngen.h:32
NTV2_AUDIO_BUFFER_BIG
@ NTV2_AUDIO_BUFFER_BIG
Definition: ntv2enums.h:1864
NTV2DolbyPlayer::NTV2DolbyBSI::frmmixcfginfoe
uint32_t frmmixcfginfoe
Definition: ntv2dolbyplayer.h:161
DolbyPlayerConfig::fDolbyFilePath
std::string fDolbyFilePath
Optional path to Dolby audio source file.
Definition: ntv2dolbyplayer.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
NTV2DolbyPlayer::NTV2DolbyBSI::lorosurmixlev
uint32_t lorosurmixlev
Definition: ntv2dolbyplayer.h:110
NTV2FrameData
I encapsulate the video, audio and anc host buffers used in the AutoCirculate demos....
Definition: ntv2democommon.h:79
AUTOCIRCULATE_TRANSFER::SetAudioBuffer
bool SetAudioBuffer(ULWord *pInAudioBuffer, const ULWord inAudioByteCount)
Sets my audio buffer for use in a subsequent call to CNTV2Card::AutoCirculateTransfer.
Definition: ntv2publicinterface.cpp:2716
NULL
#define NULL
Definition: ntv2caption608types.h:19
CRP188::GetRP188Reg
bool GetRP188Reg(RP188_STRUCT &outRP188) const
Definition: ntv2rp188.cpp:1241
NTV2Buffer
A generic user-space buffer object that has an address and a length. Used most often to share an arbi...
Definition: ntv2publicinterface.h:5993
AJA_STATUS_SUCCESS
@ AJA_STATUS_SUCCESS
Definition: types.h:381
ntv2audiodefines.h
Declares common audio macros and structs used in the SDK.
NTV2DolbyPlayer::NTV2DolbyBSI::lfeon
uint32_t lfeon
Definition: ntv2dolbyplayer.h:95
NTV2DolbyPlayer::NTV2DolbyBSI::addche
uint32_t addche
Definition: ntv2dolbyplayer.h:140
NTV2Buffer::GetByteCount
ULWord GetByteCount(void) const
Definition: ntv2publicinterface.h:6066
DolbyPlayerConfig::Get
AJALabelValuePairs Get(const bool inCompact=(0)) const
Definition: ntv2dolbyplayer.cpp:1420
GetNTV2FrameRateFromVideoFormat
NTV2FrameRate GetNTV2FrameRateFromVideoFormat(const NTV2VideoFormat inVideoFormat)
Definition: ntv2utils.cpp:3530
NTV2DolbyPlayer::NTV2DolbyBSI::roomtyp
uint32_t roomtyp
Definition: ntv2dolbyplayer.h:173
NTV2DolbyPlayer::NTV2DolbyBSI::compr2
uint32_t compr2
Definition: ntv2dolbyplayer.h:102
NTV2DolbyPlayer::NTV2DolbyBSI::addspchdat1e
uint32_t addspchdat1e
Definition: ntv2dolbyplayer.h:150
NTV2DolbyPlayer::NTV2DolbyBSI::infomdate
uint32_t infomdate
Definition: ntv2dolbyplayer.h:164
AJAThread::Attach
virtual AJAStatus Attach(AJAThreadFunction *pThreadFunction, void *pUserContext)
Definition: thread.cpp:169
NTV2DolbyPlayer::NTV2DolbyBSI::adconvtyp
uint32_t adconvtyp
Definition: ntv2dolbyplayer.h:174
NTV2_AUDIO_48K
@ NTV2_AUDIO_48K
Definition: ntv2enums.h:1875
NTV2DolbyPlayer::ConsumeFrames
virtual void ConsumeFrames(void)
My consumer thread that repeatedly plays frames using AutoCirculate (until quit).
Definition: ntv2dolbyplayer.cpp:457
NTV2_AUDIO_FORMAT_DOLBY
@ NTV2_AUDIO_FORMAT_DOLBY
Definition: ntv2enums.h:1899
NTV2DolbyPlayer::NTV2DolbyBSI::lorocmixlev
uint32_t lorocmixlev
Definition: ntv2dolbyplayer.h:108
AJATimeCodeBurn::BurnTimeCode
AJA_EXPORT bool BurnTimeCode(void *pBaseVideoAddress, const std::string &inTimeCodeStr, const uint32_t inYPercent)
Definition: timecodeburn.cpp:45
AUDIOBYTES_MAX_48K
static const uint32_t AUDIOBYTES_MAX_48K(201 *1024)
The maximum number of bytes of 48KHz audio that can be transferred for a single frame....
AJA_STATUS_BUSY
@ AJA_STATUS_BUSY
Definition: types.h:391
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:366
NTV2_FRAMERATE_INVALID
@ NTV2_FRAMERATE_INVALID
Definition: ntv2enums.h:425
NTV2_AUDIOSYSTEM_1
@ NTV2_AUDIOSYSTEM_1
This identifies the first Audio System.
Definition: ntv2enums.h:3816
AJACircularBuffer::StartConsumeNextBuffer
FrameDataPtr StartConsumeNextBuffer(void)
The thread that's responsible for processing incoming frames – the consumer – calls this function to ...
Definition: circularbuffer.h:153
NTV2ACFrameRange::count
UWord count(void) const
Definition: ntv2utils.h:974
ntv2testpatterngen.h
Declares the NTV2TestPatternGen class.
NTV2_TestPatt_ColorBars100
@ NTV2_TestPatt_ColorBars100
Definition: ntv2testpatterngen.h:28
NTV2DolbyPlayer::NTV2DolbyBSI::pgmscle
uint32_t pgmscle
Definition: ntv2dolbyplayer.h:113
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
NTV2DolbyPlayer::NTV2DolbyBSI::extpgmscle
uint32_t extpgmscle
Definition: ntv2dolbyplayer.h:117
DEC0N
#define DEC0N(__x__, __n__)
Definition: ntv2publicinterface.h:5607
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:516
AJA_STATUS_MEMORY
@ AJA_STATUS_MEMORY
Definition: types.h:397
NTV2DolbyPlayer::NTV2DolbyBSI::drcsrc
uint32_t drcsrc
Definition: ntv2dolbyplayer.h:121
eAJAReadOnly
@ eAJAReadOnly
Definition: file_io.h:31
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
NTV2DolbyPlayer::SetUpHostBuffers
virtual AJAStatus SetUpHostBuffers(void)
Sets up my host video & audio buffers.
Definition: ntv2dolbyplayer.cpp:301
NTV2DolbyPlayer::NTV2DolbyBSI::mixdatabuffer
uint8_t mixdatabuffer[64]
Definition: ntv2dolbyplayer.h:154
NTV2DolbyPlayer::NTV2DolbyBSI::paninfo2e
uint32_t paninfo2e
Definition: ntv2dolbyplayer.h:158
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:1630
NTV2DolbyPlayer::Run
virtual AJAStatus Run(void)
Runs me.
Definition: ntv2dolbyplayer.cpp:421
PlayerConfig::fDoMultiFormat
bool fDoMultiFormat
If true, enable device-sharing; otherwise take exclusive control of device.
Definition: ntv2democommon.h:323
NTV2DolbyPlayer::NTV2DolbyBSI::numblkscod
uint32_t numblkscod
Definition: ntv2dolbyplayer.h:93
ntv2dolbyplayer.h
Header file for NTV2DolbyPlayer demonstration class.
TimecodeFormat
TimecodeFormat
Definition: ntv2rp188.h:27
NTV2DolbyPlayer::NTV2DolbyBSI::copyrightb
uint32_t copyrightb
Definition: ntv2dolbyplayer.h:166
NTV2_AUDIO_FORMAT_LPCM
@ NTV2_AUDIO_FORMAT_LPCM
Definition: ntv2enums.h:1898
CNTV2Card::SetAudioLoopBack
virtual bool SetAudioLoopBack(const NTV2AudioLoopBack inMode, const NTV2AudioSystem inAudioSystem=NTV2_AUDIOSYSTEM_1)
Enables or disables NTV2AudioLoopBack mode for the given NTV2AudioSystem.
Definition: ntv2audio.cpp:300
NTV2_CHANNEL1
@ NTV2_CHANNEL1
Specifies channel or Frame Store 1 (or the first item).
Definition: ntv2enums.h:1307
NTV2DolbyPlayer::SetBitBuffer
virtual void SetBitBuffer(uint8_t *pBuffer, uint32_t size)
Set the bitstream buffer for bit retrieval.
Definition: ntv2dolbyplayer.cpp:1262
ntv2debug.h
CNTV2Card::SetFrameBufferFormat
virtual bool SetFrameBufferFormat(NTV2Channel inChannel, NTV2FrameBufferFormat inNewFormat, bool inIsAJARetail=(!(0)), NTV2HDRXferChars inXferChars=NTV2_VPID_TC_SDR_TV, NTV2HDRColorimetry inColorimetry=NTV2_VPID_Color_Rec709, NTV2HDRLuminance inLuminance=NTV2_VPID_Luminance_YCbCr)
Sets the frame buffer format for the given FrameStore on the AJA device.
Definition: ntv2register.cpp:1812
NTV2FrameBufferFormatString
const char * NTV2FrameBufferFormatString(NTV2FrameBufferFormat fmt)
Definition: ntv2debug.cpp:201
CNTV2Card::SetVANCShiftMode
virtual bool SetVANCShiftMode(NTV2Channel inChannel, NTV2VANCDataShiftMode inMode)
Enables or disables the "VANC Shift Mode" feature for the given channel.
Definition: ntv2register.cpp:2800
AUTOCIRCULATE_STATUS::CanAcceptMoreOutputFrames
bool CanAcceptMoreOutputFrames(void) const
Definition: ntv2publicinterface.h:7231
NTV2DolbyPlayer::NTV2DolbyBSI::extpgmscl
uint32_t extpgmscl
Definition: ntv2dolbyplayer.h:118
nlohmann::json_abiNLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON_v3_11_NLOHMANN_JSON_VERSION_PATCH::detail::void
j template void())
Definition: json.hpp:4893
NTV2DolbyPlayer::NTV2DolbyBSI::compre
uint32_t compre
Definition: ntv2dolbyplayer.h:98
NTV2DolbyPlayer::NTV2DolbyBSI::addbsibuffer
uint8_t addbsibuffer[64]
Definition: ntv2dolbyplayer.h:185
NTV2FrameRate
NTV2FrameRate
Identifies a particular video frame rate.
Definition: ntv2enums.h:396
AJAFileIO::Open
AJAStatus Open(const std::string &fileName, const int flags, const int properties)
Definition: file_io.cpp:201
NTV2DolbyPlayer::NTV2DolbyBSI::dmixscle
uint32_t dmixscle
Definition: ntv2dolbyplayer.h:138
NTV2FrameData::VideoBuffer
NTV2Buffer & VideoBuffer(void)
Definition: ntv2democommon.h:106
NTV2DolbyPlayer::NTV2DolbyBSI::spchdat
uint32_t spchdat
Definition: ntv2dolbyplayer.h:146
CNTV2Card::DMABufferLock
virtual bool DMABufferLock(const NTV2Buffer &inBuffer, bool inMap=(0), bool inRDMA=(0))
Page-locks the given host buffer to reduce transfer time and CPU usage of DMA transfers.
Definition: ntv2dma.cpp:429
NTV2DolbyPlayer::NTV2DolbyBSI::lfemixlevcode
uint32_t lfemixlevcode
Definition: ntv2dolbyplayer.h:111
GetOutputDestInputXpt
NTV2InputXptID GetOutputDestInputXpt(const NTV2OutputDestination inOutputDest, const bool inIsSDI_DS2=false, const UWord inHDMI_Quadrant=99)
Definition: ntv2signalrouter.cpp:928
CNTV2Card::features
virtual class DeviceCapabilities & features(void)
Definition: ntv2card.h:141
NTV2DolbyPlayer::NTV2DolbyBSI::extpgmlsscl
uint32_t extpgmlsscl
Definition: ntv2dolbyplayer.h:133
AJAThread
Definition: thread.h:69
NTV2DolbyPlayer::NTV2DolbyBSI::blkid
uint32_t blkid
Definition: ntv2dolbyplayer.h:181
NTV2DolbyPlayer::SetUpAudio
virtual AJAStatus SetUpAudio(void)
Performs all audio setup.
Definition: ntv2dolbyplayer.cpp:265
AJAThread::Active
virtual bool Active()
Definition: thread.cpp:116
gNumFrequencies
static const ULWord gNumFrequencies(sizeof(gFrequencies)/sizeof(double))
NTV2DolbyPlayer::NTV2DolbyBSI::extpgmcscle
uint32_t extpgmcscle
Definition: ntv2dolbyplayer.h:128
NTV2DolbyPlayer::NTV2DolbyPlayer
NTV2DolbyPlayer(const DolbyPlayerConfig &inConfigData)
Constructs me using the given configuration settings.
Definition: ntv2dolbyplayer.cpp:54
CNTV2Card::DMABufferUnlockAll
virtual bool DMABufferUnlockAll()
Unlocks all previously-locked buffers used for DMA transfers.
Definition: ntv2dma.cpp:457
CNTV2Card::GetDisplayName
virtual std::string GetDisplayName(void)
Answers with this device's display name.
Definition: ntv2card.cpp:86
AJAStatus
AJAStatus
Definition: types.h:378
NTV2DolbyPlayer
I am similar to NTV2Player, but I demonstrate how to play/output 8 channels of audio tone (or ramp da...
Definition: ntv2dolbyplayer.h:52
NTV2DolbyPlayer::NTV2DolbyBSI::extpgmaux2scle
uint32_t extpgmaux2scle
Definition: ntv2dolbyplayer.h:143
NTV2DolbyPlayer::NTV2DolbyBSI::mixlevel
uint32_t mixlevel
Definition: ntv2dolbyplayer.h:172
NTV2FormatDescriptor::numPixels
ULWord numPixels
Width – total number of pixels per line.
Definition: ntv2formatdescriptor.h:349
process.h
Declares the AJAProcess class.
NTV2DolbyPlayer::NTV2DolbyBSI::ltrtcmixlev
uint32_t ltrtcmixlev
Definition: ntv2dolbyplayer.h:107
PlayerConfig::fFrames
NTV2ACFrameRange fFrames
AutoCirculate frame count or range.
Definition: ntv2democommon.h:317
NTV2DolbyPlayer::SetUpVideo
virtual AJAStatus SetUpVideo(void)
Performs all video setup.
Definition: ntv2dolbyplayer.cpp:218
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
NTV2_TestPatt_Ramp
@ NTV2_TestPatt_Ramp
Definition: ntv2testpatterngen.h:31
NTV2_VANCMODE_OFF
@ NTV2_VANCMODE_OFF
This identifies the mode in which there are no VANC lines in the frame buffer.
Definition: ntv2enums.h:3718
CNTV2Card::GetNumberAudioChannels
virtual bool GetNumberAudioChannels(ULWord &outNumChannels, const NTV2AudioSystem inAudioSystem=NTV2_AUDIOSYSTEM_1)
Returns the current number of audio channels being captured or played by a given Audio System on the ...
Definition: ntv2audio.cpp:180
AJATimeBase
Definition: timebase.h:18
kNumAudioChannelsMax
@ kNumAudioChannelsMax
Definition: ntv2audiodefines.h:44
AJA_STATUS_FEATURE
@ AJA_STATUS_FEATURE
Definition: types.h:393
AJA_STATUS_FAIL
@ AJA_STATUS_FAIL
Definition: types.h:382
ULWord
uint32_t ULWord
Definition: ajatypes.h:253
NTV2DolbyPlayer::NTV2DolbyBSI::extpgmlfescle
uint32_t extpgmlfescle
Definition: ntv2dolbyplayer.h:136
NTV2_TestPatt_FlatField
@ NTV2_TestPatt_FlatField
Definition: ntv2testpatterngen.h:35
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
CNTV2Card::GetDescription
virtual std::string GetDescription(void) const
Definition: ntv2card.cpp:124
AJAFileIO::Seek
AJAStatus Seek(const int64_t distance, const AJAFileSetFlag flag) const
Definition: file_io.cpp:545
NTV2FrameData::fVideoBuffer
NTV2Buffer fVideoBuffer
Host video buffer.
Definition: ntv2democommon.h:82
AUTOCIRCULATE_STATUS
This is returned from the CNTV2Card::AutoCirculateGetStatus function.
Definition: ntv2publicinterface.h:7160
NTV2DolbyPlayer::NTV2DolbyBSI::dialnorm2
uint32_t dialnorm2
Definition: ntv2dolbyplayer.h:100
ntv2devicescanner.h
Declares the CNTV2DeviceScanner class.
NTV2FrameData::VideoBufferSize
ULWord VideoBufferSize(void) const
Definition: ntv2democommon.h:107
NTV2DolbyPlayer::NTV2DolbyBSI::frmsizecod
uint32_t frmsizecod
Definition: ntv2dolbyplayer.h:182
NTV2FormatDescriptor::numLines
ULWord numLines
Height – total number of lines.
Definition: ntv2formatdescriptor.h:348
NTV2DolbyPlayer::NTV2DolbyBSI::paninfo
uint32_t paninfo
Definition: ntv2dolbyplayer.h:157
NTV2FormatDescriptor::GetTotalBytes
ULWord GetTotalBytes(void) const
Definition: ntv2formatdescriptor.cpp:851
AUTOCIRCULATE_TRANSFER::SetOutputTimeCodes
bool SetOutputTimeCodes(const NTV2TimeCodes &inValues)
Intended for playout, replaces the contents of my acOutputTimeCodes member.
Definition: ntv2publicinterface.cpp:2735
CNTV2DemoCommon::SetDefaultPageSize
static size_t SetDefaultPageSize(void)
Definition: ntv2democommon.cpp:1484
NTV2DolbyPlayer::NTV2DolbyBSI::mixdata
uint32_t mixdata
Definition: ntv2dolbyplayer.h:123
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
NTV2DolbyPlayer::NTV2DolbyBSI::extpgmrscle
uint32_t extpgmrscle
Definition: ntv2dolbyplayer.h:130
NTV2DolbyPlayer::NTV2DolbyBSI::ltrtsurmixlev
uint32_t ltrtsurmixlev
Definition: ntv2dolbyplayer.h:109
NTV2DolbyPlayer::NTV2DolbyBSI::pgmscl2
uint32_t pgmscl2
Definition: ntv2dolbyplayer.h:116
NTV2DolbyPlayer::NTV2DolbyBSI::extpgmlfescl
uint32_t extpgmlfescl
Definition: ntv2dolbyplayer.h:137
CNTV2Card::UnsubscribeOutputVerticalEvent
virtual bool UnsubscribeOutputVerticalEvent(const NTV2Channel inChannel)
Unregisters me so I'm no longer notified when an output VBI is signaled on the given output channel.
Definition: ntv2subscriptions.cpp:61
NTV2Buffer::CopyFrom
bool CopyFrom(const void *pInSrcBuffer, const ULWord inByteCount)
Replaces my contents from the given memory buffer, resizing me to the new byte count.
Definition: ntv2publicinterface.cpp:1718
UWord
uint16_t UWord
Definition: ajatypes.h:251
PlayerConfig::fVideoFormat
NTV2VideoFormat fVideoFormat
The video format to use.
Definition: ntv2democommon.h:319
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
NTV2DolbyPlayer::NTV2DolbyBSI::fscod
uint32_t fscod
Definition: ntv2dolbyplayer.h:92
NTV2DolbyPlayer::NTV2DolbyBSI::dsurmod
uint32_t dsurmod
Definition: ntv2dolbyplayer.h:168
NTV2FrameData::fNumAudioBytes
ULWord fNumAudioBytes
Actual number of captured audio bytes.
Definition: ntv2democommon.h:88
NTV2DolbyPlayer::NTV2DolbyBSI::extpgmaux2scl
uint32_t extpgmaux2scl
Definition: ntv2dolbyplayer.h:144
NTV2_REFERENCE_FREERUN
@ NTV2_REFERENCE_FREERUN
Specifies the device's internal clock.
Definition: ntv2enums.h:1404
AUTOCIRCULATE_TRANSFER
This object specifies the information that will be transferred to or from the AJA device in the CNTV2...
Definition: ntv2publicinterface.h:7969
PlayerConfig::fOutputChannel
NTV2Channel fOutputChannel
The device channel to use.
Definition: ntv2democommon.h:315
PlayerConfig::Get
AJALabelValuePairs Get(const bool inCompact=(0)) const
Renders a human-readable representation of me.
Definition: ntv2democommon.cpp:1694
DolbyPlayerConfig
Configures an NTV2DolbyPlayer instance.
Definition: ntv2dolbyplayer.h:25
NTV2DolbyPlayer::NTV2DolbyBSI::blkmixcfginfo
uint32_t blkmixcfginfo[6]
Definition: ntv2dolbyplayer.h:162
NTV2VideoFormatToString
std::string NTV2VideoFormatToString(const NTV2VideoFormat inValue, const bool inUseFrameRate=false)
Definition: ntv2utils.cpp:6750
NTV2DolbyPlayer::NTV2DolbyBSI::spchdat2
uint32_t spchdat2
Definition: ntv2dolbyplayer.h:152
NTV2DolbyPlayer::NTV2DolbyBSI::compr2e
uint32_t compr2e
Definition: ntv2dolbyplayer.h:101
NTV2FrameData::AudioBuffer
NTV2Buffer & AudioBuffer(void)
Definition: ntv2democommon.h:109
NTV2_TestPatt_Black
@ NTV2_TestPatt_Black
Definition: ntv2testpatterngen.h:37
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:2708
NTV2DolbyPlayer::NTV2DolbyBSI::chanmap
uint32_t chanmap
Definition: ntv2dolbyplayer.h:104
NTV2DolbyPlayer::AddRamp
virtual uint32_t AddRamp(NTV2FrameData &inFrameData)
Inserts audio test ramp into the given NTV2FrameData's audio buffer.
Definition: ntv2dolbyplayer.cpp:674
NTV2_TestPatt_ColorBars75
@ NTV2_TestPatt_ColorBars75
Definition: ntv2testpatterngen.h:30
NTV2DolbyPlayer::NTV2DolbyBSI::extpgmlscl
uint32_t extpgmlscl
Definition: ntv2dolbyplayer.h:127
NTV2_TASK_MODE_INVALID
@ NTV2_TASK_MODE_INVALID
Definition: ntv2publicinterface.h:4293
CNTV2DriverInterface::IsDeviceReady
virtual bool IsDeviceReady(const bool inCheckValid=(0))
Definition: ntv2driverinterface.cpp:1284
NTV2DolbyPlayer::NTV2DolbyBSI::extpgmaux1scle
uint32_t extpgmaux1scle
Definition: ntv2dolbyplayer.h:141
NTV2DolbyPlayer::NTV2DolbyBSI::dmixmod
uint32_t dmixmod
Definition: ntv2dolbyplayer.h:106
kDemoAppSignature
static const ULWord kDemoAppSignature((((uint32_t)( 'D'))<< 24)|(((uint32_t)( 'E'))<< 16)|(((uint32_t)( 'M'))<< 8)|(((uint32_t)( 'O'))<< 0))
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
NTV2DolbyPlayer::NTV2DolbyBSI::panmean2
uint32_t panmean2
Definition: ntv2dolbyplayer.h:159
NTV2DolbyPlayer::NTV2DolbyBSI::spchan1att
uint32_t spchan1att
Definition: ntv2dolbyplayer.h:149
CRP188
Definition: ntv2rp188.h:55
NTV2DolbyPlayer::NTV2DolbyBSI::dheadphonmod
uint32_t dheadphonmod
Definition: ntv2dolbyplayer.h:169
AUTOCIRCULATE_STATUS::GetEndFrame
uint16_t GetEndFrame(void) const
Definition: ntv2publicinterface.h:7251
CNTV2Card::SetEveryFrameServices
virtual bool SetEveryFrameServices(const NTV2EveryFrameTaskMode inMode)
Sets the device's task mode.
Definition: ntv2register.cpp:179
NTV2DolbyPlayer::NTV2DolbyBSI::mixdef
uint32_t mixdef
Definition: ntv2dolbyplayer.h:119
NTV2StringList
std::vector< std::string > NTV2StringList
Definition: ntv2utils.h:1134
NTV2DolbyPlayer::NTV2DolbyBSI::pgmscl
uint32_t pgmscl
Definition: ntv2dolbyplayer.h:114
NTV2DolbyPlayer::ProduceFrames
virtual void ProduceFrames(void)
My producer thread that repeatedly produces video frames.
Definition: ntv2dolbyplayer.cpp:559
AJA_STATUS_UNSUPPORTED
@ AJA_STATUS_UNSUPPORTED
Definition: types.h:394
NTV2DolbyPlayer::AddDolby
virtual uint32_t AddDolby(NTV2FrameData &inFrameData)
Inserts dolby audio into the given NTV2FrameData's audio buffer.
Definition: ntv2dolbyplayer.cpp:705
CNTV2Card::SetHDMIOutAudioRate
virtual bool SetHDMIOutAudioRate(const NTV2AudioRate inNewValue)
Sets the HDMI output's audio rate.
Definition: ntv2audio.cpp:972
NTV2DolbyPlayer::NTV2DolbyBSI::extpgmlsscle
uint32_t extpgmlsscle
Definition: ntv2dolbyplayer.h:132
AddAudioTone
bool AddAudioTone(ULWord &outNumBytesWritten, NTV2Buffer &inAudioBuffer, ULWord &inOutCurrentSample, const ULWord inNumSamples, const double inSampleRate, const double inAmplitude, const double inFrequency, const ULWord inNumBits, const bool inByteSwap, const ULWord inNumChannels)
Fills the given buffer with 32-bit (ULWord) audio tone samples.
Definition: ntv2utils.cpp:4478
CNTV2DemoCommon::GetAJAFrameRate
static AJA_FrameRate GetAJAFrameRate(const NTV2FrameRate inFrameRate)
Definition: ntv2democommon.cpp:1011
NTV2DolbyPlayer::NTV2DolbyBSI::mixlevel2
uint32_t mixlevel2
Definition: ntv2dolbyplayer.h:176
NTV2TestPatternGen
The NTV2 test pattern generator.
Definition: ntv2testpatterngen.h:69
NTV2_FORMAT_UNKNOWN
@ NTV2_FORMAT_UNKNOWN
Definition: ntv2enums.h:498
NTV2DolbyPlayer::NTV2DolbyBSI
Definition: ntv2dolbyplayer.h:87
NTV2DolbyPlayer::NTV2DolbyBSI::pgmscl2e
uint32_t pgmscl2e
Definition: ntv2dolbyplayer.h:115
NTV2FrameData::fAudioBuffer
NTV2Buffer fAudioBuffer
Host audio buffer.
Definition: ntv2democommon.h:84
NTV2DolbyPlayer::NTV2DolbyBSI::extpgmrsscl
uint32_t extpgmrsscl
Definition: ntv2dolbyplayer.h:135
AJAFileIO::Read
uint32_t Read(uint8_t *pBuffer, const uint32_t length)
Definition: file_io.cpp:328
CNTV2Card::Connect
virtual bool Connect(const NTV2InputCrosspointID inInputXpt, const NTV2OutputCrosspointID inOutputXpt, const bool inValidate=(0))
Connects the given widget signal input (sink) to the given widget signal output (source).
Definition: ntv2regroute.cpp:87
NTV2AudioRate
NTV2AudioRate
Definition: ntv2enums.h:1873
NTV2DolbyPlayer::NTV2DolbyBSI::spchan2att
uint32_t spchan2att
Definition: ntv2dolbyplayer.h:153
AJA_STATUS_INITIALIZE
@ AJA_STATUS_INITIALIZE
Definition: types.h:386
NTV2DolbyPlayer::NTV2DolbyBSI::addspchdate
uint32_t addspchdate
Definition: ntv2dolbyplayer.h:147
CNTV2Card::SetHDMIOutAudioSource2Channel
virtual bool SetHDMIOutAudioSource2Channel(const NTV2AudioChannelPair inNewValue, const NTV2AudioSystem inAudioSystem=NTV2_AUDIOSYSTEM_1)
Sets the HDMI output's 2-channel audio source.
Definition: ntv2audio.cpp:863
NTV2DolbyPlayer::NTV2DolbyBSI::extpgmaux1scl
uint32_t extpgmaux1scl
Definition: ntv2dolbyplayer.h:142
DEC
#define DEC(__x__)
Definition: ntv2publicinterface.h:5605
NTV2DolbyPlayer::NTV2DolbyBSI::panmean
uint32_t panmean
Definition: ntv2dolbyplayer.h:156
NTV2DolbyPlayer::Quit
virtual void Quit(void)
Gracefully stops me from running.
Definition: ntv2dolbyplayer.cpp:107
NTV2_OUTPUTDESTINATION_HDMI
@ NTV2_OUTPUTDESTINATION_HDMI
Definition: ntv2enums.h:1279
false
#define false
Definition: ntv2devicefeatures.h:25
NTV2DolbyPlayer::NTV2DolbyBSI::adconvtyp2
uint32_t adconvtyp2
Definition: ntv2dolbyplayer.h:178
AUTOCIRCULATE_WITH_RP188
#define AUTOCIRCULATE_WITH_RP188
Use this to AutoCirculate with RP188.
Definition: ntv2publicinterface.h:5521
NTV2DolbyPlayer::GetDolbyFrame
virtual bool GetDolbyFrame(uint16_t *pInDolbyBuffer, uint32_t &numSamples)
Get a dolby audio frame from the input file.
Definition: ntv2dolbyplayer.cpp:909
NTV2ACFrameRange::lastFrame
UWord lastFrame(void) const
Definition: ntv2utils.h:976
GetFrameBufferOutputXptFromChannel
NTV2OutputXptID GetFrameBufferOutputXptFromChannel(const NTV2Channel inFrameStore, const bool inIsRGB=false, const bool inIs425=false)
Definition: ntv2signalrouter.cpp:845
NTV2DolbyPlayer::NTV2DolbyBSI::lfemixlevcod
uint32_t lfemixlevcod
Definition: ntv2dolbyplayer.h:112
NTV2DolbyPlayer::NTV2DolbyBSI::bsmod
uint32_t bsmod
Definition: ntv2dolbyplayer.h:165
PlayerConfig::fDeviceSpec
std::string fDeviceSpec
The AJA device to use.
Definition: ntv2democommon.h:313
AJA_STATUS_BAD_PARAM
@ AJA_STATUS_BAD_PARAM
Definition: types.h:392
NTV2DolbyPlayer::AddTone
virtual uint32_t AddTone(NTV2FrameData &inFrameData)
Inserts audio tone (based on my current tone frequency) into the given NTV2FrameData's audio buffer.
Definition: ntv2dolbyplayer.cpp:639
CNTV2Card::WaitForOutputVerticalInterrupt
virtual bool WaitForOutputVerticalInterrupt(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:134
NTV2DolbyPlayer::NTV2DolbyBSI::paninfoe
uint32_t paninfoe
Definition: ntv2dolbyplayer.h:155
NTV2DolbyPlayer::GetBits
virtual bool GetBits(uint32_t &data, uint32_t inBitCount)
Retreive the specified number of bits from the bitstream buffer.
Definition: ntv2dolbyplayer.cpp:1269
std
Definition: json.hpp:5362
NTV2_RP188
This struct replaces the old RP188_STRUCT.
Definition: ntv2publicinterface.h:6760
NTV2DolbyPlayer::NTV2DolbyBSI::dmixscl
uint32_t dmixscl
Definition: ntv2dolbyplayer.h:139
IsRGBFormat
bool IsRGBFormat(const NTV2FrameBufferFormat format)
Definition: ntv2utils.cpp:5442
AJAFileIO::Close
AJAStatus Close()
Definition: file_io.cpp:281
NTV2DolbyPlayer::NTV2DolbyBSI::addbsil
uint32_t addbsil
Definition: ntv2dolbyplayer.h:184
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
GetAudioSamplesPerFrame
ULWord GetAudioSamplesPerFrame(const NTV2FrameRate inFrameRate, const NTV2AudioRate inAudioRate, ULWord inCadenceFrame=0, bool inIsSMPTE372Enabled=false)
Returns the number of audio samples for a given video frame rate, audio sample rate,...
Definition: ntv2utils.cpp:2789
NTV2DolbyPlayer::NTV2DolbyBSI::extpgmrscl
uint32_t extpgmrscl
Definition: ntv2dolbyplayer.h:131
AUTOCIRCULATE_STATUS::GetStartFrame
uint16_t GetStartFrame(void) const
Definition: ntv2publicinterface.h:7246
NTV2DolbyPlayer::ParseBSI
virtual bool ParseBSI(uint16_t *pInDolbyBuffer, uint32_t numSamples, NTV2DolbyBSI *pBsi)
Parse the dolby audio bit stream information block.
Definition: ntv2dolbyplayer.cpp:952
CNTV2Card::AutoCirculateInitForOutput
virtual bool AutoCirculateInitForOutput(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 playout, designating a contiguous block of frame buffers on the...
Definition: ntv2autocirculate.cpp:353
NTV2DolbyPlayer::NTV2DolbyBSI::blkmixcfginfoe
uint32_t blkmixcfginfoe
Definition: ntv2dolbyplayer.h:163
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:481
NTV2DolbyPlayer::NTV2DolbyBSI::paninfo2
uint32_t paninfo2
Definition: ntv2dolbyplayer.h:160
NTV2DolbyPlayer::NTV2DolbyBSI::compr
uint32_t compr
Definition: ntv2dolbyplayer.h:99
NTV2DolbyPlayer::NTV2DolbyBSI::acmod
uint32_t acmod
Definition: ntv2dolbyplayer.h:94
NTV2DolbyPlayer::NTV2DolbyBSI::convsync
uint32_t convsync
Definition: ntv2dolbyplayer.h:180
NTV2DolbyPlayer::NTV2DolbyBSI::roomtyp2
uint32_t roomtyp2
Definition: ntv2dolbyplayer.h:177
NTV2DolbyPlayer::NTV2DolbyBSI::premixcmpsel
uint32_t premixcmpsel
Definition: ntv2dolbyplayer.h:120
CNTV2Card::GetEveryFrameServices
virtual bool GetEveryFrameServices(NTV2EveryFrameTaskMode &outMode)
Retrieves the device's current "retail service" task mode.
Definition: ntv2register.cpp:184
CNTV2Card::GetAudioRate
virtual bool GetAudioRate(NTV2AudioRate &outRate, const NTV2AudioSystem inAudioSystem=NTV2_AUDIOSYSTEM_1)
Returns the current NTV2AudioRate for the given Audio System.
Definition: ntv2audio.cpp:226
NTV2DolbyPlayer::NTV2DolbyBSI::substreamid
uint32_t substreamid
Definition: ntv2dolbyplayer.h:90
NTV2DolbyPlayer::ProducerThreadStatic
static void ProducerThreadStatic(AJAThread *pThread, void *pContext)
This is the producer thread's static callback function that gets called when the producer thread star...
Definition: ntv2dolbyplayer.cpp:549
NTV2DolbyPlayer::NTV2DolbyBSI::dialnorm
uint32_t dialnorm
Definition: ntv2dolbyplayer.h:97
gFrequencies
static const double gFrequencies[]
Definition: ntv2dolbyplayer.cpp:49
CNTV2Card::GetFrameRate
virtual bool GetFrameRate(NTV2FrameRate &outValue, NTV2Channel inChannel=NTV2_CHANNEL1)
Returns the AJA device's currently configured frame rate via its "value" parameter.
Definition: ntv2register.cpp:1022
CNTV2Card::DMAWriteFrame
virtual bool DMAWriteFrame(const ULWord inFrameNumber, const ULWord *pInFrameBuffer, const ULWord inByteCount)
Transfers a single frame from the host to the AJA device.
Definition: ntv2dma.cpp:65
GetAudioSamplesPerSecond
double GetAudioSamplesPerSecond(const NTV2AudioRate inAudioRate)
Returns the audio sample rate as a number of audio samples per second.
Definition: ntv2utils.cpp:3203
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
NTV2DolbyPlayer::NTV2DolbyBSI::strmtyp
uint32_t strmtyp
Definition: ntv2dolbyplayer.h:89
NTV2DolbyPlayer::Init
virtual AJAStatus Init(void)
Initializes me and prepares me to Run.
Definition: ntv2dolbyplayer.cpp:134
NTV2_TestPatt_MultiPattern
@ NTV2_TestPatt_MultiPattern
Definition: ntv2testpatterngen.h:36
NTV2DolbyPlayer::NTV2DolbyBSI::addbsie
uint32_t addbsie
Definition: ntv2dolbyplayer.h:183
NTV2DolbyPlayer::StartProducerThread
virtual void StartProducerThread(void)
Starts my producer thread.
Definition: ntv2dolbyplayer.cpp:539
PlayerConfig::fPixelFormat
NTV2PixelFormat fPixelFormat
The pixel format to use.
Definition: ntv2democommon.h:318
NTV2OutputXptID
enum NTV2OutputCrosspointID NTV2OutputXptID
NTV2DolbyPlayer::NTV2DolbyBSI::mixmdate
uint32_t mixmdate
Definition: ntv2dolbyplayer.h:105
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
NTV2TestPatternGen::getTestPatternNames
static NTV2TestPatternNames getTestPatternNames(void)
Definition: ntv2testpatterngen.cpp:2542
NTV2DolbyPlayer::NTV2DolbyBSI::extpgmlscle
uint32_t extpgmlscle
Definition: ntv2dolbyplayer.h:126
CNTV2Card::SetReference
virtual bool SetReference(const NTV2ReferenceSource inRefSource, const bool inKeepFramePulseSelect=(0))
Sets the device's clock reference source. See Video Output Clocking & Synchronization for more inform...
Definition: ntv2register.cpp:1484
NTV2DolbyPlayer::NTV2DolbyBSI::sourcefscod
uint32_t sourcefscod
Definition: ntv2dolbyplayer.h:179
PLNOTE
#define PLNOTE(_xpr_)
Definition: ntv2democommon.h:36
eAJASeekSet
@ eAJASeekSet
Definition: file_io.h:47
AJA_STATUS_OPEN
@ AJA_STATUS_OPEN
Definition: types.h:388
AJATimeBase::FramesToSeconds
double FramesToSeconds(int64_t frames) const
Definition: timebase.cpp:197
NTV2DolbyPlayer::NTV2DolbyBSI::extpgmcscl
uint32_t extpgmcscl
Definition: ntv2dolbyplayer.h:129
NTV2DolbyPlayer::StartConsumerThread
virtual void StartConsumerThread(void)
Starts my consumer thread.
Definition: ntv2dolbyplayer.cpp:435
CNTV2DemoCommon::NTV2FrameRate2TimecodeFormat
static TimecodeFormat NTV2FrameRate2TimecodeFormat(const NTV2FrameRate inFrameRate)
Definition: ntv2democommon.cpp:989
NTV2DolbyPlayer::NTV2DolbyBSI::origbs
uint32_t origbs
Definition: ntv2dolbyplayer.h:167
operator<<
std::ostream & operator<<(std::ostream &ioStrm, const DolbyPlayerConfig &inObj)
Definition: ntv2dolbyplayer.cpp:1428
CNTV2Card::SetNumberAudioChannels
virtual bool SetNumberAudioChannels(const ULWord inNumChannels, const NTV2AudioSystem inAudioSystem=NTV2_AUDIOSYSTEM_1)
Sets the number of audio channels to be concurrently captured or played for a given Audio System on t...
Definition: ntv2audio.cpp:146
NTV2_TestPatt_LineSweep
@ NTV2_TestPatt_LineSweep
Definition: ntv2testpatterngen.h:33
CNTV2Card::SetAudioBufferSize
virtual bool SetAudioBufferSize(const NTV2AudioBufferSize inValue, const NTV2AudioSystem inAudioSystem=NTV2_AUDIOSYSTEM_1)
Changes the size of the audio buffer that is used for a given Audio System in the AJA device.
Definition: ntv2audio.cpp:249
NTV2DolbyPlayer::SetUpTestPatternBuffers
virtual AJAStatus SetUpTestPatternBuffers(void)
Creates my test pattern buffers.
Definition: ntv2dolbyplayer.cpp:357
AJAThread::Start
virtual AJAStatus Start()
Definition: thread.cpp:91
NTV2DolbyPlayer::NTV2DolbyBSI::mixdeflen
uint32_t mixdeflen
Definition: ntv2dolbyplayer.h:124
BUFFER_PAGE_ALIGNED
static const bool BUFFER_PAGE_ALIGNED((!(0)))
PLFAIL
#define PLFAIL(_xpr_)
Definition: ntv2democommon.h:34
AJALabelValuePairs
std::vector< AJALabelValuePair > AJALabelValuePairs
An ordered sequence of label/value pairs.
Definition: info.h:69
CNTV2DemoCommon::GetAJAPixelFormat
static AJA_PixelFormat GetAJAPixelFormat(const NTV2FrameBufferFormat inFormat)
Definition: ntv2democommon.cpp:1043
xHEX0N
#define xHEX0N(__x__, __n__)
Definition: ntv2publicinterface.h:5604
AJA_FAILURE
#define AJA_FAILURE(_status_)
Definition: types.h:371
NTV2_AUDIO_RATE_INVALID
@ NTV2_AUDIO_RATE_INVALID
Definition: ntv2enums.h:1879
NTV2DolbyPlayer::NTV2DolbyBSI::extpgmrsscle
uint32_t extpgmrsscle
Definition: ntv2dolbyplayer.h:134
NTV2_AudioChannel1_2
@ NTV2_AudioChannel1_2
This selects audio channels 1 and 2 (Group 1 channels 1 and 2)
Definition: ntv2enums.h:3058
CNTV2Card::EnableChannel
virtual bool EnableChannel(const NTV2Channel inChannel)
Enables the given FrameStore.
Definition: ntv2register.cpp:2097
DeviceCapabilities::CanDoFrameBufferFormat
bool CanDoFrameBufferFormat(const NTV2PixelFormat inPF)
Definition: ntv2devicecapabilities.h:223
NTV2ChannelToAudioSystem
NTV2AudioSystem NTV2ChannelToAudioSystem(const NTV2Channel inChannel)
Converts the given NTV2Channel value into its equivalent NTV2AudioSystem.
Definition: ntv2utils.cpp:4927
CNTV2Card::SetHDMIOutAudioFormat
virtual bool SetHDMIOutAudioFormat(const NTV2AudioFormat inNewValue)
Sets the HDMI output's audio format.
Definition: ntv2audio.cpp:984
NTV2FormatDescriptor::IsValid
bool IsValid(void) const
Definition: ntv2formatdescriptor.h:94
NTV2DolbyPlayer::ConsumerThreadStatic
static void ConsumerThreadStatic(AJAThread *pThread, void *pContext)
This is the consumer thread's static callback function that gets called when the consumer thread star...
Definition: ntv2dolbyplayer.cpp:446
PLINFO
#define PLINFO(_xpr_)
Definition: ntv2democommon.h:37
CNTV2Card::AutoCirculateStop
virtual bool AutoCirculateStop(const NTV2Channel inChannel, const bool inAbort=(0))
Stops AutoCirculate for the given channel, and releases the on-device frame buffers that were allocat...
Definition: ntv2autocirculate.cpp:519
PLWARN
#define PLWARN(_xpr_)
Definition: ntv2democommon.h:35
NTV2DolbyPlayer::NTV2DolbyBSI::dsurexmod
uint32_t dsurexmod
Definition: ntv2dolbyplayer.h:170
gAmplitudes
static const double gAmplitudes[]
Definition: ntv2dolbyplayer.cpp:51
CRP188::GetRP188Str
bool GetRP188Str(std::string &sRP188) const
Definition: ntv2rp188.cpp:918
NTV2DolbyPlayer::GetACStatus
virtual void GetACStatus(AUTOCIRCULATE_STATUS &outStatus)
Provides status information about my output (playout) process.
Definition: ntv2dolbyplayer.cpp:633
NTV2_OEM_TASKS
@ NTV2_OEM_TASKS
2: OEM: Device is configured by controlling application(s), with minimal driver involvement.
Definition: ntv2publicinterface.h:4292
NTV2FrameData::fTimecodes
NTV2TimeCodes fTimecodes
Map of TC indexes to NTV2_RP188 values.
Definition: ntv2democommon.h:87
CNTV2Card::SetAudioRate
virtual bool SetAudioRate(const NTV2AudioRate inRate, const NTV2AudioSystem inAudioSystem=NTV2_AUDIOSYSTEM_1)
Sets the NTV2AudioRate for the given Audio System.
Definition: ntv2audio.cpp:205
AUDIOBYTES_MAX_192K
static const uint32_t AUDIOBYTES_MAX_192K(824 *1024)
The maximum number of bytes of 192KHz audio that can be transferred for a single frame....
DolbyPlayerConfig::fDoRamp
bool fDoRamp
If true, use audio ramp pattern instead of tone.
Definition: ntv2dolbyplayer.h:28
NTV2_AUDIOSYSTEM_INVALID
@ NTV2_AUDIOSYSTEM_INVALID
Definition: ntv2enums.h:3826
timebase.h
Declares the AJATimeBase class.