AJA NTV2 SDK  17.6.0.2675
NTV2 SDK 17.6.0.2675
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  mAudioSystem = NTV2_AUDIOSYSTEM_1; // Use NTV2_AUDIOSYSTEM_1...
268  if (mDevice.features().GetNumAudioSystems() > 1) // ...but if the device has more than one audio system...
269  mAudioSystem = ::NTV2ChannelToAudioSystem(mConfig.fOutputChannel); // ...base it on the channel
270  // However, there are a few older devices that have only 1 audio system,
271  // yet 2 frame stores (or must use channel 2 for playout)...
272  if (!mDevice.features().CanDoFrameStore1Display())
273  mAudioSystem = NTV2_AUDIOSYSTEM_1;
274 
275  mDevice.SetNumberAudioChannels (8, mAudioSystem); // This demo uses 8 channels -- no more, no less
276  mDevice.SetAudioRate (mAudioRate, mAudioSystem);
277 
278  // How big should the on-device audio buffer be? 1MB? 2MB? 4MB? 8MB?
279  // For this demo, 4MB will work best across all platforms (Windows, Mac & Linux)...
280  mDevice.SetAudioBufferSize (NTV2_AUDIO_BUFFER_BIG, mAudioSystem);
281 
282  // Set the SDI output audio embedders to embed audio samples from the output of mAudioSystem...
283  mDevice.SetHDMIOutAudioSource2Channel (NTV2_AudioChannel1_2, mAudioSystem);
284 
285  mDevice.SetHDMIOutAudioRate(mAudioRate);
286 
288 
289  // If the last app using the device left it in end-to-end mode (input passthru),
290  // then loopback must be disabled, or else the output will contain whatever audio
291  // is present in whatever signal is feeding the device's SDI input...
292  mDevice.SetAudioLoopBack (NTV2_AUDIO_LOOPBACK_OFF, mAudioSystem);
293 
294  return AJA_STATUS_SUCCESS;
295 
296 } // SetUpAudio
297 
298 
300 {
301  CNTV2DemoCommon::SetDefaultPageSize(); // Set host-specific page size
302 
303  // Let my circular buffer know when it's time to quit...
304  mFrameDataRing.SetAbortFlag (&mGlobalQuit);
305 
306  // Calculate the size of the audio buffer, which mostly depends on the sample rate...
307  const uint32_t AUDIOBYTES_MAX = (mAudioRate == NTV2_AUDIO_192K) ? AUDIOBYTES_MAX_192K : AUDIOBYTES_MAX_48K;
308 
309  // Allocate and add each in-host NTV2FrameData to my circular buffer member variable...
310  mHostBuffers.reserve(CIRCULAR_BUFFER_SIZE);
311  while (mHostBuffers.size() < CIRCULAR_BUFFER_SIZE)
312  {
313  mHostBuffers.push_back(NTV2FrameData()); // Make a new NTV2FrameData...
314  NTV2FrameData & frameData(mHostBuffers.back()); // ...and get a reference to it
315 
316  // Allocate a page-aligned video buffer
317  if (mConfig.WithVideo())
318  if (!frameData.fVideoBuffer.Allocate (mFormatDesc.GetTotalBytes(), BUFFER_PAGE_ALIGNED))
319  {
320  PLFAIL("Failed to allocate " << xHEX0N(mFormatDesc.GetTotalBytes(),8) << "-byte video buffer");
321  return AJA_STATUS_MEMORY;
322  }
323  #ifdef NTV2_BUFFER_LOCKING
324  if (frameData.fVideoBuffer)
325  mDevice.DMABufferLock(frameData.fVideoBuffer, true);
326  #endif
327 
328  // Allocate a page-aligned audio buffer (if transmitting audio)
329  if (mConfig.WithAudio())
330  if (!frameData.fAudioBuffer.Allocate (AUDIOBYTES_MAX, BUFFER_PAGE_ALIGNED))
331  {
332  PLFAIL("Failed to allocate " << xHEX0N(AUDIOBYTES_MAX,8) << "-byte audio buffer");
333  return AJA_STATUS_MEMORY;
334  }
335  #ifdef NTV2_BUFFER_LOCKING
336  if (frameData.fAudioBuffer)
337  mDevice.DMABufferLock(frameData.fAudioBuffer, /*alsoPreLockSGL*/true);
338  #endif
339  mFrameDataRing.Add (&frameData);
340  } // for each NTV2FrameData
341 
342  if (mDolbyFileIO.IsOpen())
343  {
344  // Initialize IEC61937 burst size (32 milliseconds) for HDMI 192 kHz sample rate
345  mBurstSamples = 6144; // 192000 * 0.032 samples
346  mBurstMax = mBurstSamples * 2;
347  mBurstBuffer = new uint16_t [mBurstMax];
348  mDolbyBuffer = new uint16_t [mBurstMax];
349  }
350 
351  return AJA_STATUS_SUCCESS;
352 
353 } // SetUpHostBuffers
354 
356 {
357  vector<NTV2TestPatternSelect> testPatIDs;
358  testPatIDs.push_back(NTV2_TestPatt_ColorBars100);
359  testPatIDs.push_back(NTV2_TestPatt_ColorBars75);
360  testPatIDs.push_back(NTV2_TestPatt_Ramp);
361  testPatIDs.push_back(NTV2_TestPatt_MultiBurst);
362  testPatIDs.push_back(NTV2_TestPatt_LineSweep);
363  testPatIDs.push_back(NTV2_TestPatt_CheckField);
364  testPatIDs.push_back(NTV2_TestPatt_FlatField);
365  testPatIDs.push_back(NTV2_TestPatt_MultiPattern);
366 
367  mTestPatRasters.clear();
368  for (size_t tpNdx(0); tpNdx < testPatIDs.size(); tpNdx++)
369  mTestPatRasters.push_back(NTV2Buffer());
370 
371  if (!mFormatDesc.IsValid())
372  {PLFAIL("Bad format descriptor"); return AJA_STATUS_FAIL;}
373  if (mFormatDesc.IsVANC())
374  {PLFAIL("VANC should have been disabled: " << mFormatDesc); return AJA_STATUS_FAIL;}
375 
376  // Set up one video buffer for each test pattern...
377  for (size_t tpNdx(0); tpNdx < testPatIDs.size(); tpNdx++)
378  {
379  // Allocate the buffer memory...
380  if (!mTestPatRasters.at(tpNdx).Allocate (mFormatDesc.GetTotalBytes(), BUFFER_PAGE_ALIGNED))
381  { PLFAIL("Test pattern buffer " << DEC(tpNdx+1) << " of " << DEC(testPatIDs.size()) << ": "
382  << xHEX0N(mFormatDesc.GetTotalBytes(),8) << "-byte page-aligned alloc failed");
383  return AJA_STATUS_MEMORY;
384  }
385 
386  // Fill the buffer with test pattern...
387  NTV2TestPatternGen testPatternGen;
388  if (!testPatternGen.DrawTestPattern (testPatIDs.at(tpNdx), mFormatDesc, mTestPatRasters.at(tpNdx)))
389  {
390  cerr << "## ERROR: DrawTestPattern " << DEC(tpNdx) << " failed: " << mFormatDesc << endl;
391  return AJA_STATUS_FAIL;
392  }
393 
394  #ifdef NTV2_BUFFER_LOCKING
395  // Try to prelock the memory, including its scatter-gather list...
396  if (!mDevice.DMABufferLock(mTestPatRasters.at(tpNdx), /*alsoLockSegmentMap=*/true))
397  PLWARN("Test pattern buffer " << DEC(tpNdx+1) << " of " << DEC(testPatIDs.size()) << ": failed to pre-lock");
398  #endif
399  } // loop for each predefined pattern
400 
401  return AJA_STATUS_SUCCESS;
402 
403 } // SetUpTestPatternBuffers
404 
405 
407 {
408  const bool isRGB (::IsRGBFormat(mConfig.fPixelFormat));
409  const NTV2OutputXptID fsVidOutXpt (::GetFrameBufferOutputXptFromChannel (mConfig.fOutputChannel, isRGB, false/*is425*/));
410 
411  mDevice.ClearRouting(); // Start with clean slate
412 
413  // Connect HDMI video output...
414  return mDevice.Connect (::GetOutputDestInputXpt(NTV2_OUTPUTDESTINATION_HDMI1), fsVidOutXpt);
415 
416 } // RouteOutputSignal
417 
418 
420 {
421  // Start my consumer and producer threads...
424  return AJA_STATUS_SUCCESS;
425 
426 } // Run
427 
428 
429 
431 // This is where the play thread starts
432 
434 {
435  // Create and start the playout thread...
436  mConsumerThread.Attach (ConsumerThreadStatic, this);
437  mConsumerThread.SetPriority (AJA_ThreadPriority_High);
438  mConsumerThread.Start ();
439 
440 } // StartConsumerThread
441 
442 
443 // The playout thread function
444 void NTV2DolbyPlayer::ConsumerThreadStatic (AJAThread * pThread, void * pContext) // static
445 { (void) pThread;
446  // Grab the NTV2DolbyPlayer instance pointer from the pContext parameter,
447  // then call its ConsumeFrames method...
448  NTV2DolbyPlayer * pApp (reinterpret_cast<NTV2DolbyPlayer*>(pContext));
449  if (pApp)
450  pApp->ConsumeFrames();
451 
452 } // ConsumerThreadStatic
453 
454 
456 {
457  AUTOCIRCULATE_TRANSFER outputXfer;
458  AUTOCIRCULATE_STATUS outputStatus;
459  ULWord goodXfers(0), badXfers(0), starves(0), noRoomWaits(0);
460 
461  // Stop AutoCirculate, just in case someone else left it running...
462  mDevice.AutoCirculateStop(mConfig.fOutputChannel);
463  mDevice.WaitForOutputVerticalInterrupt(mConfig.fOutputChannel, 4); // Let it stop
464  PLNOTE("Thread started");
465 
466  // Initialize & start AutoCirculate...
467  bool initOK = mDevice.AutoCirculateInitForOutput (mConfig.fOutputChannel, mConfig.fFrames.count(),
468  mAudioSystem, AUTOCIRCULATE_WITH_RP188, /*numChannels*/ 1,
469  mConfig.fFrames.firstFrame(), mConfig.fFrames.lastFrame());
470  if (!initOK)
471  {PLFAIL("AutoCirculateInitForOutput failed"); mGlobalQuit = true;}
472  else if (!mConfig.WithVideo())
473  { // Video suppressed --
474  // Clear device frame buffers being AutoCirculated (prevent garbage output frames)
475  NTV2Buffer tmpFrame (mFormatDesc.GetVideoWriteSize());
476  NTV2TestPatternGen blackPatternGen;
477  blackPatternGen.DrawTestPattern (NTV2_TestPatt_Black, mFormatDesc, tmpFrame);
478  mDevice.AutoCirculateGetStatus (mConfig.fOutputChannel, outputStatus);
479  for (uint16_t frmNum(outputStatus.GetStartFrame()); frmNum <= outputStatus.GetEndFrame(); frmNum++)
480  mDevice.DMAWriteFrame(ULWord(frmNum), tmpFrame, mFormatDesc.GetTotalBytes());
481  } // else if --novideo
482 
483 
484  while (!mGlobalQuit)
485  {
486  mDevice.AutoCirculateGetStatus (mConfig.fOutputChannel, outputStatus);
487 
488  // Check if there's room for another frame on the card...
489  if (outputStatus.CanAcceptMoreOutputFrames())
490  {
491  // Device has at least one free frame buffer that can be filled.
492  // Wait for the next frame in our ring to become ready to "consume"...
493  NTV2FrameData * pFrameData (mFrameDataRing.StartConsumeNextBuffer());
494  if (!pFrameData)
495  {starves++; continue;}
496 
497  outputXfer.SetOutputTimeCodes(pFrameData->fTimecodes);
498 
499  if (pFrameData->VideoBuffer()) // Transfer the timecode-burned frame to the device for playout...
500  outputXfer.SetVideoBuffer (pFrameData->VideoBuffer(), pFrameData->VideoBufferSize());
501  if (pFrameData->AudioBuffer()) // If also playing audio...
502  outputXfer.SetAudioBuffer (pFrameData->AudioBuffer(), pFrameData->fNumAudioBytes);
503 
504 
505  // Perform the DMA transfer to the device...
506  if (mDevice.AutoCirculateTransfer (mConfig.fOutputChannel, outputXfer))
507  goodXfers++;
508  else
509  badXfers++;
510 
511  if (goodXfers == 3)
512  mDevice.AutoCirculateStart(mConfig.fOutputChannel);
513 
514  // Signal that the frame has been "consumed"...
515  mFrameDataRing.EndConsumeNextBuffer();
516  continue; // Back to top of while loop
517 
518  }
519 
520  // Wait for one or more buffers to become available on the device, which should occur at next VBI...
521  noRoomWaits++;
523  } // loop til quit signaled
524 
525  // Stop AutoCirculate...
526  mDevice.AutoCirculateStop(mConfig.fOutputChannel);
527  PLNOTE("Thread completed: " << DEC(goodXfers) << " xfers, " << DEC(badXfers) << " failed, "
528  << DEC(starves) << " starves, " << DEC(noRoomWaits) << " VBI waits");
529 
530 } // ConsumeFrames
531 
532 
533 
535 // This is where the producer thread starts
536 
538 {
539  // Create and start the producer thread...
540  mProducerThread.Attach(ProducerThreadStatic, this);
541  mProducerThread.SetPriority(AJA_ThreadPriority_High);
542  mProducerThread.Start();
543 
544 } // StartProducerThread
545 
546 
547 void NTV2DolbyPlayer::ProducerThreadStatic (AJAThread * pThread, void * pContext) // static
548 {
549  (void) pThread;
550  NTV2DolbyPlayer * pApp (reinterpret_cast <NTV2DolbyPlayer *> (pContext));
551  if (pApp)
552  pApp->ProduceFrames ();
553 
554 } // ProducerThreadStatic
555 
556 
558 {
559  ULWord freqNdx(0), testPatNdx(0), badTally(0);
560  double timeOfLastSwitch (0.0);
561 
564  //const bool isInterlace (!NTV2_VIDEO_FORMAT_HAS_PROGRESSIVE_PICTURE(mConfig.fVideoFormat));
565  //const bool isPAL (NTV2_IS_PAL_VIDEO_FORMAT(mConfig.fVideoFormat));
566  const NTV2FrameRate ntv2FrameRate (::GetNTV2FrameRateFromVideoFormat(mConfig.fVideoFormat));
567  const TimecodeFormat tcFormat (CNTV2DemoCommon::NTV2FrameRate2TimecodeFormat(ntv2FrameRate));
568 
569  PLNOTE("Thread started");
570  while (!mGlobalQuit)
571  {
572  NTV2FrameData * pFrameData (mFrameDataRing.StartProduceNextBuffer());
573  // If no frame is available, wait and try again
574  if (!pFrameData)
575  { badTally++; // No frame available!
576  AJATime::Sleep(10); // Wait a bit for the consumer thread to free one up for me...
577  continue; // ...then try again
578  }
579 
580  // Copy my pre-made test pattern into my video buffer...
581  if (pFrameData->VideoBuffer()) // Copy fresh, unmodified, pre-rendered test pattern into this frame's video buffer...
582  pFrameData->fVideoBuffer.CopyFrom (mTestPatRasters.at(testPatNdx),
583  /*srcOffset*/ 0,
584  /*dstOffset*/ 0,
585  /*byteCount*/ pFrameData->fVideoBuffer.GetByteCount());
586 
587  const CRP188 rp188Info (mCurrentFrame++, 0, 0, 10, tcFormat);
588  NTV2_RP188 tcF1;
589  string tcString;
590 
591  rp188Info.GetRP188Reg (tcF1);
592  rp188Info.GetRP188Str (tcString);
593 
594  if (pFrameData->VideoBuffer()) // Burn current timecode into the video buffer...
595  mTCBurner.BurnTimeCode (pFrameData->VideoBuffer(), tcString.c_str(), 80);
596  TCDBG("F" << DEC0N(mCurrentFrame-1,6) << ": " << tcF1 << ": " << tcString);
597 
598  // If also playing audio...
599  if (pFrameData->AudioBuffer()) // ...then generate audio tone data for this frame...
600  {
601  if (mDolbyFileIO.IsOpen())
602  pFrameData->fNumAudioBytes = AddDolby(*pFrameData);
603  else
604  {
605  if (mConfig.fDoRamp)
606  pFrameData->fNumAudioBytes = AddRamp(*pFrameData);
607  else
608  pFrameData->fNumAudioBytes = AddTone(*pFrameData);
609  }
610  }
611 
612  // Every few seconds, change the test pattern and tone frequency...
613  const double currentTime (timeBase.FramesToSeconds(mCurrentFrame));
614  if (currentTime > timeOfLastSwitch + 4.0)
615  {
616  freqNdx = (freqNdx + 1) % gNumFrequencies;
617  testPatNdx = (testPatNdx + 1) % ULWord(mTestPatRasters.size());
618  mToneFrequency = gFrequencies[freqNdx];
619  timeOfLastSwitch = currentTime;
620  PLINFO("F" << DEC0N(mCurrentFrame,6) << ": " << tcString << ": tone=" << mToneFrequency << "Hz, pattern='" << tpNames.at(testPatNdx) << "'");
621  } // if time to switch test pattern & tone frequency
622 
623  // Signal that I'm done producing this FrameData, making it immediately available for transfer/playout...
624  mFrameDataRing.EndProduceNextBuffer();
625 
626  } // loop til mGlobalQuit goes true
627  PLNOTE("Thread completed: " << DEC(mCurrentFrame) << " frame(s) produced, " << DEC(badTally) << " failed");
628 
629 } // ProduceFrames
630 
632 {
633  mDevice.AutoCirculateGetStatus (mConfig.fOutputChannel, outStatus);
634 }
635 
636 
637 uint32_t NTV2DolbyPlayer::AddTone (NTV2FrameData & inFrameData)
638 {
641  ULWord numChannels (0);
642 
643  mDevice.GetFrameRate (frameRate, mConfig.fOutputChannel);
644  mDevice.GetAudioRate (audioRate, mAudioSystem);
645  mDevice.GetNumberAudioChannels (numChannels, mAudioSystem);
646 
647  // Set per-channel tone frequencies...
648  double pFrequencies [kNumAudioChannelsMax];
649  pFrequencies [0] = (mToneFrequency / 2.0);
650  for (ULWord chan (1); chan < numChannels; chan++)
651  // The 1.154782 value is the 16th root of 10, to ensure that if mToneFrequency is 2000,
652  // that the calculated frequency of audio channel 16 will be 20kHz...
653  pFrequencies [chan] = pFrequencies [chan - 1] * 1.154782;
654 
655  // Because audio on AJA devices use fixed sample rates (typically 48KHz), certain video frame rates will necessarily
656  // result in some frames having more audio samples than others. The GetAudioSamplesPerFrame function
657  // is used to calculate the correct sample count...
658  const ULWord numSamples (::GetAudioSamplesPerFrame (frameRate, audioRate, mCurrentFrame));
659  const double sampleRateHertz (::GetAudioSamplesPerSecond(audioRate));
660 
661  return ::AddAudioTone ( inFrameData.AudioBuffer(), // audio buffer to fill
662  mCurrentSample, // which sample for continuing the waveform
663  numSamples, // number of samples to generate
664  sampleRateHertz, // sample rate [Hz]
665  gAmplitudes, // per-channel amplitudes
666  pFrequencies, // per-channel tone frequencies [Hz]
667  31, // bits per sample
668  false, // don't byte swap
669  numChannels); // number of audio channels to generate
670 } // AddTone
671 
672 uint32_t NTV2DolbyPlayer::AddRamp (NTV2FrameData & inFrameData)
673 {
674  ULWord * audioBuffer (inFrameData.AudioBuffer());
677  ULWord numChannels (0);
678 
679  mDevice.GetFrameRate (frameRate, mConfig.fOutputChannel);
680  mDevice.GetAudioRate (audioRate, mAudioSystem);
681  mDevice.GetNumberAudioChannels (numChannels, mAudioSystem);
682 
683  // Because audio on AJA devices use fixed sample rates (typically 48KHz), certain video frame rates will necessarily
684  // result in some frames having more audio samples than others. The GetAudioSamplesPerFrame function
685  // is used to calculate the correct sample count...
686  const ULWord numSamples (::GetAudioSamplesPerFrame (frameRate, audioRate, mCurrentFrame));
687 
688  for (uint32_t samp(0); samp < numSamples; samp++)
689  {
690  for (uint32_t ch(0); ch < numChannels; ch++)
691  {
692  *audioBuffer = uint32_t(mRampSample) << 16;
693  audioBuffer++;
694  mRampSample++;
695  } // for each channel
696  } // for each sample
697 
698  return numSamples * numChannels * 4;
699 } // AddRamp
700 
701 #if defined(DOLBY_FULL_PARSER)
702 
703 uint32_t NTV2DolbyPlayer::AddDolby (NTV2FrameData & inFrameData)
704 {
705  ULWord* audioBuffer (inFrameData.AudioBuffer());
708  ULWord numChannels (0);
709  ULWord sampleOffset(0);
710  ULWord sampleCount (0);
711  NTV2DolbyBSI bsi;
712 
713  mDevice.GetFrameRate (frameRate, mConfig.fOutputChannel);
714  mDevice.GetAudioRate (audioRate, mAudioSystem);
715  mDevice.GetNumberAudioChannels (numChannels, mAudioSystem);
716  const ULWord numSamples (::GetAudioSamplesPerFrame (frameRate, audioRate, mCurrentFrame));
717 
718  if (!mDolbyFileIO.IsOpen() || !mDolbyBuffer)
719  goto silence;
720 
721  // Generate the samples for this frame
722  while (sampleOffset < numSamples)
723  {
724  if ((mBurstSize != 0) && (mBurstIndex < mBurstSamples))
725  {
726  if(mBurstOffset < mBurstSize)
727  {
728  uint32_t data0 = 0;
729  uint32_t data1 = 0;
730  if (mBurstIndex == 0)
731  {
732  // Add IEC61937 burst preamble
733  data0 = 0xf872; // Sync stuff
734  data1 = 0x4e1f;
735  }
736  else if (mBurstIndex == 1)
737  {
738  // Add more IEC61937 burst preamble
739  data0 = ((bsi.bsmod & 0x7) << 8) | 0x0015; // This is Dolby
740  data1 = mBurstSize * 2; // Data size in bytes
741  }
742  else
743  {
744  // Add sync frame data
745  data0 = (uint32_t)(mBurstBuffer[mBurstOffset]);
746  data0 = ((data0 & 0x00ff) << 8) | ((data0 & 0xff00) >> 8);
747  mBurstOffset++;
748  data1 = (uint32_t)(mBurstBuffer[mBurstOffset]);
749  data1 = ((data1 & 0x00ff) << 8) | ((data1 & 0xff00) >> 8);
750  mBurstOffset++;
751  }
752 
753  // Write data into 16 msbs of all audio channel pairs
754  data0 <<= 16;
755  data1 <<= 16;
756  for (ULWord i = 0; i < numChannels; i += 2)
757  {
758  audioBuffer[sampleOffset * numChannels + i] = data0;
759  audioBuffer[sampleOffset * numChannels + i + 1] = data1;
760  }
761  }
762  else
763  {
764  // Pad samples out to burst size
765  for (ULWord i = 0; i < numChannels; i++)
766  {
767  audioBuffer[sampleOffset * numChannels + i] = 0;
768  }
769  }
770  sampleOffset++;
771  mBurstIndex++;
772  }
773  else
774  {
775  ULWord dolbyOffset = 0;
776  ULWord burstOffset = 0;
777  ULWord numBlocks = 0;
778 
779  mBurstIndex = 0;
780  mBurstOffset = 0;
781 
782  if (mDolbySize == 0)
783  {
784  // Find first Dolby Digital Plus burst frame
785  while (true)
786  {
787  if (!GetDolbyFrame(&mDolbyBuffer[0], sampleCount))
788  {
789  cerr << "## ERROR: Dolby frame not found" << endl;
790  mDolbyFileIO.Close();
791  goto silence;
792  }
793 
794  if (!ParseBSI(&mDolbyBuffer[1], sampleCount - 1, &bsi))
795  continue;
796 
797  if ((bsi.strmtyp == 0) &&
798  (bsi.substreamid == 0) &&
799  (bsi.bsid == 16) &&
800  ((bsi.numblkscod == 3) || (bsi.convsync == 1)))
801  break;
802  }
803 
804  mDolbySize = sampleCount;
805  switch (bsi.numblkscod)
806  {
807  case 0: mDolbyBlocks = 1; break;
808  case 1: mDolbyBlocks = 2; break;
809  case 2: mDolbyBlocks = 3; break;
810  case 3: mDolbyBlocks = 6; break;
811  default: goto silence;
812  }
813  }
814 
815  while (numBlocks <= 6)
816  {
817  // Copy the Dolby frame into the burst buffer
818  while (dolbyOffset < mDolbySize)
819  {
820  // Check for burst size overrun
821  if (burstOffset >= mBurstMax)
822  {
823  cerr << "## ERROR: Dolby burst too large" << endl;
824  mDolbyFileIO.Close();
825  goto silence;
826  }
827 
828  // Copy sample
829  mBurstBuffer[burstOffset] = mDolbyBuffer[dolbyOffset];
830  burstOffset++;
831  dolbyOffset++;
832  }
833 
834  // Get the next Dolby frame
835  if (!GetDolbyFrame(&mDolbyBuffer[0], sampleCount))
836  {
837  // try to loop
838  if (!GetDolbyFrame(&mDolbyBuffer[0], sampleCount))
839  {
840  cerr << "## ERROR: Dolby frame not found" << endl;
841  mDolbyFileIO.Close();
842  goto silence;
843  }
844  }
845 
846  // Parse the Dolby bitstream header
847  if (!ParseBSI(&mDolbyBuffer[1], sampleCount - 1, &bsi))
848  continue;
849 
850  // Only Dolby Digital Plus
851  if (bsi.bsid != 16)
852  {
853  cerr << "## ERROR: Dolby frame bad bsid = " << bsi.bsid << endl;
854  continue;
855  }
856 
857  mDolbySize = sampleCount;
858  dolbyOffset = 0;
859 
860  // Increment block count on first substream
861  if ((bsi.strmtyp == 0) && (bsi.substreamid == 0))
862  {
863  // increment block count
864  numBlocks += mDolbyBlocks;
865 
866  switch (bsi.numblkscod)
867  {
868  case 0: mDolbyBlocks = 1; break;
869  case 1: mDolbyBlocks = 2; break;
870  case 2: mDolbyBlocks = 3; break;
871  case 3: mDolbyBlocks = 6; break;
872  default:
873  cerr << "## ERROR: Dolby frame bad numblkscod = " << bsi.numblkscod << endl;
874  goto silence;
875  }
876  }
877 
878  // Are we done?
879  if (numBlocks >= 6)
880  {
881  // First frame of new burst must have convsync == 1
882  if ((bsi.numblkscod != 3) &&
883  (bsi.convsync != 1))
884  {
885  cerr << "## ERROR: Dolby frame unexpected convsync = " << bsi.convsync << endl;
886  mDolbySize = 0;
887  mDolbyBlocks = 0;
888  }
889 
890  // Keep the burst size
891  mBurstSize = burstOffset;
892  break;
893  }
894  }
895  }
896  }
897 
898  return numSamples * numChannels * 4;
899 
900 silence:
901  // Output silence when done with file
902  memset(&audioBuffer[sampleOffset * numChannels], 0, (numSamples - sampleOffset) * numChannels * 4);
903  return numSamples * numChannels * 4;
904 }
905 
906 
907 bool NTV2DolbyPlayer::GetDolbyFrame (uint16_t * pInDolbyBuffer, uint32_t & numSamples)
908 {
909  uint32_t bytes;
910  bool done = false;
911 
912  while (!done)
913  {
914  bytes = mDolbyFileIO.Read((uint8_t*)(&pInDolbyBuffer[0]), 2);
915  if (bytes != 2)
916  {
917  // Reset file
918  mDolbyFileIO.Seek(0, eAJASeekSet);
919  return false;
920  }
921 
922  // Check sync word
923  if ((mDolbyBuffer[0] == 0x7705) ||
924  (mDolbyBuffer[0] == 0x770b))
925  done = true;
926  }
927 
928  // Read more of the sync frame header
929  bytes = mDolbyFileIO.Read((uint8_t*)(&pInDolbyBuffer[1]), 4);
930  if (bytes != 4)
931  return false;
932 
933  // Get frame size - 16 bit words plus sync word
934  uint32_t size = (uint32_t)mDolbyBuffer[1];
935  size = (((size & 0x00ff) << 8) | ((size & 0xff00) >> 8));
936  size = (size & 0x7ff) + 1;
937 
938  // Read the rest of the sync frame
939  uint32_t len = (size - 3) * 2;
940  bytes = mDolbyFileIO.Read((uint8_t*)(&pInDolbyBuffer[3]), len);
941  if (bytes != len)
942  return false;
943 
944  numSamples = size;
945 
946  return true;
947 }
948 
949 
950 bool NTV2DolbyPlayer::ParseBSI(uint16_t * pInDolbyBuffer, uint32_t numSamples, NTV2DolbyBSI * pBsi)
951 {
952  if ((pInDolbyBuffer == NULL) || (pBsi == NULL))
953  return false;
954 
955  memset(pBsi, 0, sizeof(NTV2DolbyBSI));
956 
957  SetBitBuffer((uint8_t*)pInDolbyBuffer, numSamples * 2);
958 
959  if (!GetBits(pBsi->strmtyp, 2)) return false;
960  if (!GetBits(pBsi->substreamid, 3)) return false;
961  if (!GetBits(pBsi->frmsiz, 11)) return false;
962  if (!GetBits(pBsi->fscod, 2)) return false;
963  if (!GetBits(pBsi->numblkscod, 2)) return false;
964  if (!GetBits(pBsi->acmod, 3)) return false;
965  if (!GetBits(pBsi->lfeon, 1)) return false;
966  if (!GetBits(pBsi->bsid, 5)) return false;
967  if (!GetBits(pBsi->dialnorm, 5)) return false;
968  if (!GetBits(pBsi->compre, 1)) return false;
969  if (pBsi->compre)
970  {
971  if (!GetBits(pBsi->compr, 8)) return false;
972  }
973  if (pBsi->acmod == 0x0) /* if 1+1 mode (dual mono, so some items need a second value) */
974  {
975  if (!GetBits(pBsi->dialnorm2, 5)) return false;
976  if (!GetBits(pBsi->compr2e, 1)) return false;
977  if (pBsi->compr2e)
978  {
979  if (!GetBits(pBsi->compr2, 8)) return false;
980  }
981  }
982  if (pBsi->strmtyp == 0x1) /* if dependent stream */
983  {
984  if (!GetBits(pBsi->chanmape, 1)) return false;
985  if (pBsi->chanmape)
986  {
987  if (!GetBits(pBsi->chanmap, 16)) return false;
988  }
989  }
990  if (!GetBits(pBsi->mixmdate, 1)) return false;
991  if (pBsi->mixmdate) /* mixing metadata */
992  {
993  if (pBsi->acmod > 0x2) /* if more than 2 channels */
994  {
995  if (!GetBits(pBsi->dmixmod, 2)) return false;
996  }
997  if ((pBsi->acmod & 0x1) && (pBsi->acmod > 0x2)) /* if three front channels exist */
998  {
999  if (!GetBits(pBsi->ltrtcmixlev, 3)) return false;
1000  if (!GetBits(pBsi->lorocmixlev, 3)) return false;
1001  }
1002  if (pBsi->acmod & 0x4) /* if a surround channel exists */
1003  {
1004  if (!GetBits(pBsi->ltrtsurmixlev, 3)) return false;
1005  if (!GetBits(pBsi->lorosurmixlev, 3)) return false;
1006  }
1007  if (pBsi->lfeon) /* if the LFE channel exists */
1008  {
1009  if (!GetBits(pBsi->lfemixlevcode, 1)) return false;
1010  if (pBsi->lfemixlevcode)
1011  {
1012  if (!GetBits(pBsi->lfemixlevcod, 5)) return false;
1013  }
1014  }
1015  if (pBsi->strmtyp == 0x0) /* if independent stream */
1016  {
1017  if (!GetBits(pBsi->pgmscle, 1)) return false;
1018  if (pBsi->pgmscle)
1019  {
1020  if (!GetBits(pBsi->pgmscl, 6)) return false;
1021  }
1022  if (pBsi->acmod == 0x0) /* if 1+1 mode (dual mono, so some items need a second value) */
1023  {
1024  if (!GetBits(pBsi->pgmscl2e, 1)) return false;
1025  if (pBsi->pgmscl2e)
1026  {
1027  if (!GetBits(pBsi->pgmscl2, 6)) return false;
1028  }
1029  }
1030  if (!GetBits(pBsi->extpgmscle, 1)) return false;
1031  if (pBsi->extpgmscle)
1032  {
1033  if (!GetBits(pBsi->extpgmscl, 6)) return false;
1034  }
1035  if (!GetBits(pBsi->mixdef, 2)) return false;
1036  if (pBsi->mixdef == 0x1) /* mixing option 2 */
1037  {
1038  if (!GetBits(pBsi->premixcmpsel, 1)) return false;
1039  if (!GetBits(pBsi->drcsrc, 1)) return false;
1040  if (!GetBits(pBsi->premixcmpscl, 3)) return false;
1041  }
1042  else if (pBsi->mixdef == 0x2) /* mixing option 3 */
1043  {
1044  if (!GetBits(pBsi->mixdata, 12)) return false;
1045  }
1046  else if (pBsi->mixdef == 0x3) /* mixing option 4 */
1047  {
1048  if (!GetBits(pBsi->mixdeflen, 5)) return false;
1049  if (!GetBits(pBsi->mixdata2e, 1)) return false;
1050  if (pBsi->mixdata2e)
1051  {
1052  if (!GetBits(pBsi->premixcmpsel, 1)) return false;
1053  if (!GetBits(pBsi->drcsrc, 1)) return false;
1054  if (!GetBits(pBsi->premixcmpscl, 3)) return false;
1055  if (!GetBits(pBsi->extpgmlscle, 1)) return false;
1056  if (pBsi->extpgmlscle)
1057  {
1058  if (!GetBits(pBsi->extpgmlscl, 4)) return false;
1059  }
1060  if (!GetBits(pBsi->extpgmcscle, 1)) return false;
1061  if (pBsi->extpgmcscle)
1062  {
1063  if (!GetBits(pBsi->extpgmcscl, 4)) return false;
1064  }
1065  if (!GetBits(pBsi->extpgmrscle, 1)) return false;
1066  if (pBsi->extpgmrscle)
1067  {
1068  if (!GetBits(pBsi->extpgmrscl, 4)) return false;
1069  }
1070  if (!GetBits(pBsi->extpgmlsscle, 1)) return false;
1071  if (pBsi->extpgmlsscle)
1072  {
1073  if (!GetBits(pBsi->extpgmlsscl, 4)) return false;
1074  }
1075  if (!GetBits(pBsi->extpgmrsscle, 1)) return false;
1076  if (pBsi->extpgmrsscle)
1077  {
1078  if (!GetBits(pBsi->extpgmrsscl, 4)) return false;
1079  }
1080  if (!GetBits(pBsi->extpgmlfescle, 1)) return false;
1081  if (pBsi->extpgmlfescle)
1082  {
1083  if (!GetBits(pBsi->extpgmlfescl, 4)) return false;
1084  }
1085  if (!GetBits(pBsi->dmixscle, 1)) return false;
1086  if (pBsi->dmixscle)
1087  {
1088  if (!GetBits(pBsi->dmixscl, 4)) return false;
1089  }
1090  if (!GetBits(pBsi->addche, 1)) return false;
1091  if (pBsi->addche)
1092  {
1093  if (!GetBits(pBsi->extpgmaux1scle, 1)) return false;
1094  if (pBsi->extpgmaux1scle)
1095  {
1096  if (!GetBits(pBsi->extpgmaux1scl, 4)) return false;
1097  }
1098  if (!GetBits(pBsi->extpgmaux2scle, 1)) return false;
1099  if (pBsi->extpgmaux2scle)
1100  {
1101  if (!GetBits(pBsi->extpgmaux2scl, 4)) return false;
1102  }
1103  }
1104  }
1105  if (!GetBits(pBsi->mixdata3e, 1)) return false;
1106  if (pBsi->mixdata3e)
1107  {
1108  if (!GetBits(pBsi->spchdat, 5)) return false;
1109  if (!GetBits(pBsi->addspchdate, 1)) return false;
1110  if (pBsi->addspchdate)
1111  {
1112  if (!GetBits(pBsi->spchdat1, 5)) return false;
1113  if (!GetBits(pBsi->spchan1att, 2)) return false;
1114  if (!GetBits(pBsi->addspchdat1e, 1)) return false;
1115  if (pBsi->addspdat1e)
1116  {
1117  if (!GetBits(pBsi->spchdat2, 5)) return false;
1118  if (!GetBits(pBsi->spchan2att, 3)) return false;
1119  }
1120  }
1121  }
1122  {
1123  uint32_t data;
1124  uint32_t size = 8 * (pBsi->mixdeflen + 2);
1125  size = (size + 7) / 8 * 8;
1126  uint32_t index = 0;
1127  while (size > 0)
1128  {
1129  if (!GetBits(data, (size > 8)? 8 : size)) return false;
1130  pBsi->mixdatabuffer[index++] = (uint8_t)data;
1131  size = size - 8;
1132  }
1133  }
1134  }
1135  if (pBsi->acmod < 0x2) /* if mono or dual mono source */
1136  {
1137  if (!GetBits(pBsi->paninfoe, 1)) return false;
1138  if (pBsi->paninfoe)
1139  {
1140  if (!GetBits(pBsi->panmean, 8)) return false;
1141  if (!GetBits(pBsi->paninfo, 6)) return false;
1142  }
1143  if (pBsi->acmod == 0x0) /* if 1+1 mode (dual mono - some items need a second value) */
1144  {
1145  if (!GetBits(pBsi->paninfo2e, 1)) return false;
1146  if (pBsi->paninfo2e)
1147  {
1148  if (!GetBits(pBsi->panmean2, 8)) return false;
1149  if (!GetBits(pBsi->paninfo2, 6)) return false;
1150  }
1151  }
1152  }
1153  if (!GetBits(pBsi->frmmixcfginfoe, 1)) return false;
1154  if (pBsi->frmmixcfginfoe) /* mixing configuration information */
1155  {
1156  if (pBsi->numblkscod == 0x0)
1157  {
1158  if (!GetBits(pBsi->blkmixcfginfo[0], 5)) return false;
1159  }
1160  else
1161  {
1162  uint32_t blk;
1163  uint32_t numblk;
1164  if (pBsi->numblkscod == 0x1)
1165  numblk = 2;
1166  else if (pBsi->numblkscod == 0x2)
1167  numblk = 3;
1168  else if (pBsi->numblkscod == 0x3)
1169  numblk = 6;
1170  else
1171  return false;
1172  for(blk = 0; blk < numblk; blk++)
1173  {
1174  if (!GetBits(pBsi->blkmixcfginfoe, 1)) return false;
1175  if (pBsi->blkmixcfginfoe)
1176  {
1177  if (!GetBits(pBsi->blkmixcfginfo[blk], 5)) return false;
1178  }
1179  }
1180  }
1181  }
1182  }
1183  }
1184  if (!GetBits(pBsi->infomdate, 1)) return false;
1185  if (pBsi->infomdate) /* informational metadata */
1186  {
1187  if (!GetBits(pBsi->bsmod, 3)) return false;
1188  if (!GetBits(pBsi->copyrightb, 1)) return false;
1189  if (!GetBits(pBsi->origbs, 1)) return false;
1190  if (pBsi->acmod == 0x2) /* if in 2/0 mode */
1191  {
1192  if (!GetBits(pBsi->dsurmod, 2)) return false;
1193  if (!GetBits(pBsi->dheadphonmod, 2)) return false;
1194  }
1195  if (pBsi->acmod >= 0x6) /* if both surround channels exist */
1196  {
1197  if (!GetBits(pBsi->dsurexmod, 2)) return false;
1198  }
1199  if (!GetBits(pBsi->audprodie, 1)) return false;
1200  if (pBsi->audprodie)
1201  {
1202  if (!GetBits(pBsi->mixlevel, 5)) return false;
1203  if (!GetBits(pBsi->roomtyp, 2)) return false;
1204  if (!GetBits(pBsi->adconvtyp, 1)) return false;
1205  }
1206  if (pBsi->acmod == 0x0) /* if 1+1 mode (dual mono, so some items need a second value) */
1207  {
1208  if (!GetBits(pBsi->audprodi2e, 1)) return false;
1209  if (pBsi->audprodi2e)
1210  {
1211  if (!GetBits(pBsi->mixlevel2, 5)) return false;
1212  if (!GetBits(pBsi->roomtyp2, 2)) return false;
1213  if (!GetBits(pBsi->adconvtyp2, 1)) return false;
1214  }
1215  }
1216  if (pBsi->fscod < 0x3) /* if not half sample rate */
1217  {
1218  if (!GetBits(pBsi->sourcefscod, 1)) return false;
1219  }
1220  }
1221  if ((pBsi->strmtyp == 0x0) && (pBsi->numblkscod != 0x3))
1222  {
1223  if (!GetBits(pBsi->convsync, 1)) return false;
1224  }
1225  if (pBsi->strmtyp == 0x2) /* if bit stream converted from AC-3 */
1226  {
1227  if (pBsi->numblkscod == 0x3) /* 6 blocks per syncframe */
1228  {
1229  pBsi->blkid = 1;
1230  }
1231  else
1232  {
1233  if (!GetBits(pBsi->blkid, 1)) return false;
1234  }
1235  if (pBsi->blkid)
1236  {
1237  if (!GetBits(pBsi->frmsizecod, 6)) return false;
1238  }
1239  }
1240  if (!GetBits(pBsi->addbsie, 1)) return false;
1241  if (pBsi->addbsie)
1242  {
1243  if (!GetBits(pBsi->addbsil, 6)) return false;
1244  {
1245  uint32_t data;
1246  uint32_t size = 8 * (pBsi->addbsil + 1);
1247  uint32_t index = 0;
1248  while (size > 0)
1249  {
1250  if (!GetBits(data, 8)) return false;
1251  pBsi->addbsibuffer[index++] = (uint8_t)data;
1252  size = size - 8;
1253  }
1254  }
1255  }
1256 
1257  return true;
1258 }
1259 
1260 void NTV2DolbyPlayer::SetBitBuffer(uint8_t * pBuffer, uint32_t size)
1261 {
1262  mBitBuffer = pBuffer;
1263  mBitSize = size;
1264  mBitIndex = 8;
1265 }
1266 
1267 bool NTV2DolbyPlayer::GetBits(uint32_t & data, uint32_t bits)
1268 {
1269  uint32_t cb;
1270  static uint8_t bitMask[] = { 0x00, 0x01, 0x03, 0x07, 0x0f, 0x1f, 0x3f, 0x7f, 0xff };
1271 
1272  data = 0;
1273  while (bits > 0)
1274  {
1275  if (mBitSize == 0)
1276  return false;
1277 
1278  if (mBitIndex == 0)
1279  {
1280  mBitBuffer++;
1281  mBitSize--;
1282  mBitIndex = 8;
1283  }
1284 
1285  cb = bits;
1286  if (cb > mBitIndex)
1287  cb = mBitIndex;
1288  bits -= cb;
1289  mBitIndex -= cb;
1290  data |= ((*mBitBuffer >> mBitIndex) & bitMask[cb]) << bits;
1291  }
1292 
1293  return true;
1294 }
1295 
1296 #else // DOLBY_FULL_PARSER
1297 // NOTE: The code under this #else is out of date and not maintaiend
1298 uint32_t NTV2DolbyPlayer::AddDolby (ULWord * pInAudioBuffer)
1299 {
1302  ULWord numChannels (0);
1303  ULWord sampleOffset(0);
1304 
1305  mDevice.GetFrameRate (frameRate, mOutputChannel);
1306  mDevice.GetAudioRate (audioRate, mAudioSystem);
1307  mDevice.GetNumberAudioChannels (numChannels, mAudioSystem);
1308  const ULWord numSamples (::GetAudioSamplesPerFrame (frameRate, audioRate, mCurrentFrame));
1309 
1310  if ((mConfig.fDolbyFile == NULL) || (mDolbyBuffer == NULL))
1311  goto silence;
1312 
1313  // Generate the samples for this frame
1314  while (sampleOffset < numSamples)
1315  {
1316  // Time for a new IEC61937 burst
1317  if (mBurstIndex >= mBurstSamples)
1318  mBurstIndex = 0;
1319 
1320  // Get a new Dolby Digital Plus sync frame
1321  if (mBurstIndex == 0)
1322  {
1323  // Read the sync word (all big endian)
1324  uint32_t bytes = mConfig.fDolbyFile->Read((uint8_t*)(&mDolbyBuffer[0]), 2);
1325  if (bytes != 2)
1326  {
1327  // Try to loop
1328  mConfig.fDolbyFile->Seek(0, eAJASeekSet);
1329  bytes = mConfig.fDolbyFile->Read((uint8_t*)(&mDolbyBuffer[0]), 2);
1330  if (bytes != 2)
1331  goto silence;
1332  }
1333 
1334  // Check sync word
1335  if ((mDolbyBuffer[0] != 0x7705) &&
1336  (mDolbyBuffer[0] != 0x770b))
1337  goto silence;
1338 
1339  // Read more of the sync frame header
1340  bytes = mConfig.fDolbyFile->Read((uint8_t*)(&mDolbyBuffer[1]), 4);
1341  if (bytes != 4)
1342  goto silence;
1343 
1344  // Get frame size - 16 bit words plus sync word
1345  uint32_t size = (uint32_t)mDolbyBuffer[1];
1346  size = (((size & 0x00ff) << 8) | ((size & 0xff00) >> 8)) + 1;
1347 
1348  // Read the rest of the sync frame
1349  uint32_t len = (size - 3) * 2;
1350  bytes = mConfig.fDolbyFile->Read((uint8_t*)(&mDolbyBuffer[3]), len);
1351  if (bytes != len)
1352  goto silence;
1353 
1354  // Good frame
1355  mBurstOffset = 0;
1356  mBurstSize = size;
1357  }
1358 
1359  // Add the Dolby data to the audio stream
1360  if (mBurstOffset < mBurstSize)
1361  {
1362  uint32_t data0 = 0;
1363  uint32_t data1 = 0;
1364  if (mBurstIndex == 0)
1365  {
1366  // Add IEC61937 burst preamble
1367  data0 = 0xf872; // Sync stuff
1368  data1 = 0x4e1f;
1369  }
1370  else if (mBurstIndex == 1)
1371  {
1372  // Add more IEC61937 burst preamble
1373  data0 = 0x0015; // This is Dolby
1374  data1 = mBurstSize * 2; // Data size in bytes
1375  }
1376  else
1377  {
1378  // Add sync frame data
1379  data0 = (uint32_t)(mDolbyBuffer[mBurstOffset]);
1380  data0 = ((data0 & 0x00ff) << 8) | ((data0 & 0xff00) >> 8);
1381  mBurstOffset++;
1382  data1 = (uint32_t)(mDolbyBuffer[mBurstOffset]);
1383  data1 = ((data1 & 0x00ff) << 8) | ((data1 & 0xff00) >> 8);
1384  mBurstOffset++;
1385  }
1386 
1387  // Write data into 16 msbs of all audio channel pairs
1388  data0 <<= 16;
1389  data1 <<= 16;
1390  for (ULWord i = 0; i < numChannels; i += 2)
1391  {
1392  pInAudioBuffer[sampleOffset * numChannels + i] = data0;
1393  pInAudioBuffer[sampleOffset * numChannels + i + 1] = data1;
1394  }
1395  }
1396  else
1397  {
1398  // Pad samples out to burst size
1399  for (ULWord i = 0; i < numChannels; i++)
1400  {
1401  pInAudioBuffer[sampleOffset * numChannels + i] = 0;
1402  }
1403  }
1404 
1405  sampleOffset++;
1406  mBurstIndex++;
1407  }
1408 
1409  return numSamples * numChannels * 4;
1410 
1411 silence:
1412  // Output silence when done with file
1413  memset(&pInAudioBuffer[sampleOffset * numChannels], 0, (numSamples - sampleOffset) * numChannels * 4);
1414  return numSamples * numChannels * 4;
1415 }
1416 #endif // else DOLBY_FULL_PARSER
1417 
1418 AJALabelValuePairs DolbyPlayerConfig::Get (const bool inCompact) const
1419 {
1420  AJALabelValuePairs result (PlayerConfig::Get(inCompact));
1421  AJASystemInfo::append (result, "Dolby Playback File", fDolbyFilePath.empty() ? "---" : fDolbyFilePath);
1422  AJASystemInfo::append (result, "Audio Data Ramp", fDoRamp ? "Yes" : "No");
1423  return result;
1424 }
1425 
1426 std::ostream & operator << (std::ostream & ioStrm, const DolbyPlayerConfig & inObj)
1427 {
1428  ioStrm << AJASystemInfo::ToString(inObj.Get());
1429  return ioStrm;
1430 }
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:2704
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:4429
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:255
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:2019
NTV2DolbyPlayer::RouteOutputSignal
virtual bool RouteOutputSignal(void)
Performs all widget/signal routing for playout.
Definition: ntv2dolbyplayer.cpp:406
NTV2FormatDescriptor::GetVideoWriteSize
ULWord GetVideoWriteSize(ULWord inPageSize=4096UL) const
Definition: ntv2formatdescriptor.cpp:957
NTV2DolbyPlayer::NTV2DolbyBSI::mixdata2e
uint32_t mixdata2e
Definition: ntv2dolbyplayer.h:125
NTV2_AUDIO_192K
@ NTV2_AUDIO_192K
Definition: ntv2enums.h:1921
NTV2_OUTPUTDESTINATION_HDMI1
@ NTV2_OUTPUTDESTINATION_HDMI1
Definition: ntv2enums.h:1316
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:1457
NTV2_IS_VALID_TASK_MODE
#define NTV2_IS_VALID_TASK_MODE(__m__)
Definition: ntv2publicinterface.h:4470
NTV2DolbyPlayer::NTV2DolbyBSI::frmsiz
uint32_t frmsiz
Definition: ntv2dolbyplayer.h:91
NTV2_CHANNEL2
@ NTV2_CHANNEL2
Specifies channel or FrameStore 2 (or the 2nd item).
Definition: ntv2enums.h:1349
NTV2_VANCDATA_NORMAL
@ NTV2_VANCDATA_NORMAL
Definition: ntv2enums.h:3793
AJA_ThreadPriority_High
@ AJA_ThreadPriority_High
Definition: thread.h:44
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:1908
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:2900
NULL
#define NULL
Definition: ntv2caption608types.h:19
CRP188::GetRP188Reg
bool GetRP188Reg(RP188_STRUCT &outRP188) const
Definition: ntv2rp188.cpp:1241
NTV2Buffer
Describes a user-space buffer on the host computer. I have an address and a length,...
Definition: ntv2publicinterface.h:6212
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:6286
DolbyPlayerConfig::Get
AJALabelValuePairs Get(const bool inCompact=(0)) const
Definition: ntv2dolbyplayer.cpp:1418
GetNTV2FrameRateFromVideoFormat
NTV2FrameRate GetNTV2FrameRateFromVideoFormat(const NTV2VideoFormat inVideoFormat)
Definition: ntv2utils.cpp:3534
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:1919
NTV2DolbyPlayer::ConsumeFrames
virtual void ConsumeFrames(void)
My consumer thread that repeatedly plays frames using AutoCirculate (until quit).
Definition: ntv2dolbyplayer.cpp:455
NTV2_AUDIO_FORMAT_DOLBY
@ NTV2_AUDIO_FORMAT_DOLBY
Definition: ntv2enums.h:1943
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:329
NTV2_FRAMERATE_INVALID
@ NTV2_FRAMERATE_INVALID
Definition: ntv2enums.h:435
NTV2_AUDIOSYSTEM_1
@ NTV2_AUDIOSYSTEM_1
This identifies the first Audio System.
Definition: ntv2enums.h:3875
AJACircularBuffer::StartConsumeNextBuffer
FrameDataPtr StartConsumeNextBuffer(void)
The thread that's responsible for processing incoming frames – the consumer – calls this function to ...
Definition: circularbuffer.h:153
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:313
NTV2DolbyPlayer::NTV2DolbyBSI::extpgmscle
uint32_t extpgmscle
Definition: ntv2dolbyplayer.h:117
DEC0N
#define DEC0N(__x__, __n__)
Definition: ntv2publicinterface.h:5767
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:524
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:299
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:1810
NTV2DolbyPlayer::Run
virtual AJAStatus Run(void)
Runs me.
Definition: ntv2dolbyplayer.cpp:419
PlayerConfig::fDoMultiFormat
bool fDoMultiFormat
If true, enable device-sharing; otherwise take exclusive control of device.
Definition: ntv2democommon.h:331
NTV2DolbyPlayer::NTV2DolbyBSI::numblkscod
uint32_t numblkscod
Definition: ntv2dolbyplayer.h:93
ntv2dolbyplayer.h
Header file for NTV2DolbyPlayer demonstration class.
TimecodeFormat
TimecodeFormat
Definition: ntv2rp188.h:22
NTV2DolbyPlayer::NTV2DolbyBSI::copyrightb
uint32_t copyrightb
Definition: ntv2dolbyplayer.h:166
NTV2_AUDIO_FORMAT_LPCM
@ NTV2_AUDIO_FORMAT_LPCM
Definition: ntv2enums.h:1942
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 FrameStore 1 (or the first item).
Definition: ntv2enums.h:1348
NTV2DolbyPlayer::SetBitBuffer
virtual void SetBitBuffer(uint8_t *pBuffer, uint32_t size)
Set the bitstream buffer for bit retrieval.
Definition: ntv2dolbyplayer.cpp:1260
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:1876
NTV2FrameBufferFormatString
const char * NTV2FrameBufferFormatString(NTV2FrameBufferFormat fmt)
Definition: ntv2debug.cpp:207
CNTV2Card::SetVANCShiftMode
virtual bool SetVANCShiftMode(NTV2Channel inChannel, NTV2VANCDataShiftMode inMode)
Enables or disables the "VANC Shift Mode" feature for the given channel.
Definition: ntv2register.cpp:2864
AUTOCIRCULATE_STATUS::CanAcceptMoreOutputFrames
bool CanAcceptMoreOutputFrames(void) const
Definition: ntv2publicinterface.h:7472
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:406
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:958
CNTV2Card::features
virtual class DeviceCapabilities & features(void)
Definition: ntv2card.h:148
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:367
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:326
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:3777
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:256
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:143
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:7401
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:366
NTV2DolbyPlayer::NTV2DolbyBSI::paninfo
uint32_t paninfo
Definition: ntv2dolbyplayer.h:157
NTV2FormatDescriptor::GetTotalBytes
ULWord GetTotalBytes(void) const
Definition: ntv2formatdescriptor.cpp:946
AUTOCIRCULATE_TRANSFER::SetOutputTimeCodes
bool SetOutputTimeCodes(const NTV2TimeCodes &inValues)
Intended for playout, replaces the contents of my acOutputTimeCodes member.
Definition: ntv2publicinterface.cpp:2919
CNTV2DemoCommon::SetDefaultPageSize
static size_t SetDefaultPageSize(void)
Definition: ntv2democommon.cpp:1553
CNTV2Card::SetHDMIOutAudioFormat
virtual bool SetHDMIOutAudioFormat(const NTV2AudioFormat inNewValue, const NTV2Channel inWhichHDMIOut=NTV2_CHANNEL1)
Sets the HDMI output's audio format.
Definition: ntv2audio.cpp:1031
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:1898
UWord
uint16_t UWord
Definition: ajatypes.h:254
PlayerConfig::fVideoFormat
NTV2VideoFormat fVideoFormat
The video format to use.
Definition: ntv2democommon.h:328
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:668
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:1448
AUTOCIRCULATE_TRANSFER
This object specifies the information that will be transferred to or from the AJA device in the CNTV2...
Definition: ntv2publicinterface.h:8288
PlayerConfig::fOutputChannel
NTV2Channel fOutputChannel
The device channel to use.
Definition: ntv2democommon.h:324
PlayerConfig::Get
AJALabelValuePairs Get(const bool inCompact=(0)) const
Renders a human-readable representation of me.
Definition: ntv2democommon.cpp:1763
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:6638
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:2892
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:672
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:4467
CNTV2DriverInterface::IsDeviceReady
virtual bool IsDeviceReady(const bool inCheckValid=(0))
Definition: ntv2driverinterface.cpp:1335
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:50
NTV2DolbyPlayer::NTV2DolbyBSI::dheadphonmod
uint32_t dheadphonmod
Definition: ntv2dolbyplayer.h:169
AUTOCIRCULATE_STATUS::GetEndFrame
uint16_t GetEndFrame(void) const
Definition: ntv2publicinterface.h:7526
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:1151
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:557
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:703
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:4317
CNTV2DemoCommon::GetAJAFrameRate
static AJA_FrameRate GetAJAFrameRate(const NTV2FrameRate inFrameRate)
Definition: ntv2democommon.cpp:1080
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:528
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:1917
mFormatDesc
mFormatDesc
Definition: ntv2vcam.cpp:942
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
NTV2DolbyPlayer::NTV2DolbyBSI::extpgmaux1scl
uint32_t extpgmaux1scl
Definition: ntv2dolbyplayer.h:142
DEC
#define DEC(__x__)
Definition: ntv2publicinterface.h:5765
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
CNTV2Card::SetHDMIOutAudioRate
virtual bool SetHDMIOutAudioRate(const NTV2AudioRate inNewValue, const NTV2Channel inWhichHDMIOut=NTV2_CHANNEL1)
Sets the HDMI output's audio rate.
Definition: ntv2audio.cpp:1009
CNTV2Card::SetHDMIOutAudioSource2Channel
virtual bool SetHDMIOutAudioSource2Channel(const NTV2AudioChannelPair inNewValue, const NTV2AudioSystem inAudioSystem=NTV2_AUDIOSYSTEM_1, const NTV2Channel inWhichHDMIOut=NTV2_CHANNEL1)
Sets the HDMI output's 2-channel audio source.
Definition: ntv2audio.cpp:868
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:5699
NTV2DolbyPlayer::GetDolbyFrame
virtual bool GetDolbyFrame(uint16_t *pInDolbyBuffer, uint32_t &numSamples)
Get a dolby audio frame from the input file.
Definition: ntv2dolbyplayer.cpp:907
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:322
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:637
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
GetFrameBufferOutputXptFromChannel
#define GetFrameBufferOutputXptFromChannel
Definition: ntv2signalrouter.h:731
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:1267
std
Definition: json.hpp:5362
NTV2_RP188
This struct replaces the old RP188_STRUCT.
Definition: ntv2publicinterface.h:6998
NTV2DolbyPlayer::NTV2DolbyBSI::dmixscl
uint32_t dmixscl
Definition: ntv2dolbyplayer.h:139
IsRGBFormat
bool IsRGBFormat(const NTV2FrameBufferFormat format)
Definition: ntv2utils.cpp:5310
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:717
CNTV2DemoCommon::GetAJAPixelFormat
static AJA_PixelFormat GetAJAPixelFormat(const NTV2PixelFormat inFormat)
Definition: ntv2democommon.cpp:1112
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:2793
NTV2DolbyPlayer::NTV2DolbyBSI::extpgmrscl
uint32_t extpgmrscl
Definition: ntv2dolbyplayer.h:131
AUTOCIRCULATE_STATUS::GetStartFrame
uint16_t GetStartFrame(void) const
Definition: ntv2publicinterface.h:7521
NTV2DolbyPlayer::ParseBSI
virtual bool ParseBSI(uint16_t *pInDolbyBuffer, uint32_t numSamples, NTV2DolbyBSI *pBsi)
Parse the dolby audio bit stream information block.
Definition: ntv2dolbyplayer.cpp:950
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:364
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:489
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:547
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:3207
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:537
PlayerConfig::fPixelFormat
NTV2PixelFormat fPixelFormat
The pixel format to use.
Definition: ntv2democommon.h:327
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:525
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:433
CNTV2DemoCommon::NTV2FrameRate2TimecodeFormat
static TimecodeFormat NTV2FrameRate2TimecodeFormat(const NTV2FrameRate inFrameRate)
Definition: ntv2democommon.cpp:1058
NTV2DolbyPlayer::NTV2DolbyBSI::origbs
uint32_t origbs
Definition: ntv2dolbyplayer.h:167
operator<<
std::ostream & operator<<(std::ostream &ioStrm, const DolbyPlayerConfig &inObj)
Definition: ntv2dolbyplayer.cpp:1426
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:355
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
xHEX0N
#define xHEX0N(__x__, __n__)
Definition: ntv2publicinterface.h:5764
AJA_FAILURE
#define AJA_FAILURE(_status_)
Definition: types.h:371
NTV2_AUDIO_RATE_INVALID
@ NTV2_AUDIO_RATE_INVALID
Definition: ntv2enums.h:1923
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:3114
CNTV2Card::EnableChannel
virtual bool EnableChannel(const NTV2Channel inChannel)
Enables the given FrameStore.
Definition: ntv2register.cpp:2161
DeviceCapabilities::CanDoFrameBufferFormat
bool CanDoFrameBufferFormat(const NTV2PixelFormat inPF)
Definition: ntv2devicecapabilities.h:227
NTV2ChannelToAudioSystem
NTV2AudioSystem NTV2ChannelToAudioSystem(const NTV2Channel inChannel)
Converts the given NTV2Channel value into its equivalent NTV2AudioSystem.
Definition: ntv2utils.cpp:4769
NTV2FormatDescriptor::IsValid
bool IsValid(void) const
Definition: ntv2formatdescriptor.h:112
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:444
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:541
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:631
NTV2_OEM_TASKS
@ NTV2_OEM_TASKS
2: OEM (recommended): device configured by client application(s) with some driver involvement.
Definition: ntv2publicinterface.h:4466
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:3885
timebase.h
Declares the AJATimeBase class.