13 #if defined (INCLUDE_AJACC)
19 #define NTV2_NUM_IMAGES (10)
22 #define FGFAIL(_expr_) AJA_sERROR (AJA_DebugUnit_Application, AJAFUNC << ": " << _expr_)
23 #define FGWARN(_expr_) AJA_sWARNING(AJA_DebugUnit_Application, AJAFUNC << ": " << _expr_)
24 #define FGDBG(_expr_) AJA_sDEBUG (AJA_DebugUnit_Application, AJAFUNC << ": " << _expr_)
25 #define FGNOTE(_expr_) AJA_sNOTICE (AJA_DebugUnit_Application, AJAFUNC << ": " << _expr_)
26 #define FGINFO(_expr_) AJA_sINFO (AJA_DebugUnit_Application, AJAFUNC << ": " << _expr_)
37 mbFixedReference (
false),
47 mFormatIsProgressive (
true),
50 mDoMultiChannel (
false),
54 mNumAudioChannels (0),
79 if (inInputSource != mInputSource)
83 mInputSource = inInputSource;
93 if (inDeviceIndex != mBoardNumber)
96 mBoardNumber = inDeviceIndex;
105 if (inTCIndex != mTimeCodeSource)
108 mTimeCodeSource = inTCIndex;
118 const UWord result (mBoardNumber);
124 #if defined (INCLUDE_AJACC)
126 static const UWord gTest [15][32] =
129 {{0x250C, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014,
130 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2510},
131 {0x007C, 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037, 0x0038, 0x0039, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E,
132 0x003F, 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047, 0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x007C},
133 {0x007C, 0x004E, 0x004F, 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057, 0x0058, 0x0059, 0x005A, 0x005B, 0x005D,
134 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067, 0x0068, 0x0069, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F, 0x007C},
135 {0x007C, 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077, 0x0078, 0x0079, 0x007A, 0x0020, 0x00E1, 0x00E9, 0x00ED,
136 0x00F3, 0x00FA, 0x00E7, 0x00F7, 0x00D1, 0x00E1, 0x00F1, 0x2588, 0x00AE, 0x00B0, 0x00BD, 0x00BF, 0x2122, 0x00A2, 0x00A3, 0x007C},
137 {0x007C, 0x266A, 0x00E0, 0x00A0, 0x00E8, 0x00E2, 0x00EA, 0x00EE, 0x00F4, 0x00FB, 0x00C1, 0x00C9, 0x00D3, 0x00DA, 0x00DC, 0x00FC,
138 0x2018, 0x00A1, 0x002A, 0x2019, 0x2014, 0x00A9, 0x2120, 0x2022, 0x201C, 0x201D, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x007C},
139 {0x007C, 0x00C0, 0x00C2, 0x00C7, 0x00C8, 0x00CA, 0x00CB, 0x00EB, 0x00CE, 0x00CF, 0x00EF, 0x00D4, 0x00D9, 0x00F9, 0x00DB, 0x00AB,
140 0x00BB, 0x0020, 0x0020, 0x00C3, 0x00E3, 0x00CD, 0x00CC, 0x00EC, 0x00D2, 0x00F2, 0x00D5, 0x00F5, 0x007B, 0x007D, 0x005C, 0x007C},
141 {0x007C, 0x005E, 0x005F, 0x007C, 0x007E, 0x0020, 0x0020, 0x00C4, 0x00E4, 0x00D6, 0x00F6, 0x00DF, 0x00A5, 0x00A4, 0x007C, 0x00C5,
142 0x00E5, 0x00D8, 0x00F8, 0x00C4, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x007C},
143 {0x007C, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020,
144 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x007C},
145 {0x007C, 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037, 0x0038, 0x0039, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E,
146 0x003F, 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047, 0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x007C},
147 {0x007C, 0x004E, 0x004F, 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057, 0x0058, 0x0059, 0x005A, 0x005B, 0x005D,
148 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067, 0x0068, 0x0069, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F, 0x007C},
149 {0x007C, 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077, 0x0078, 0x0079, 0x007A, 0x0020, 0x00E1, 0x00E9, 0x00ED,
150 0x00F3, 0x00FA, 0x00E7, 0x00F7, 0x00D1, 0x00E1, 0x00F1, 0x2588, 0x00AE, 0x00B0, 0x00BD, 0x00BF, 0x2122, 0x00A2, 0x00A3, 0x007C},
151 {0x007C, 0x266A, 0x00E0, 0x00A0, 0x00E8, 0x00E2, 0x00EA, 0x00EE, 0x00F4, 0x00FB, 0x00C1, 0x00C9, 0x00D3, 0x00DA, 0x00DC, 0x00FC,
152 0x2018, 0x00A1, 0x002A, 0x2019, 0x2014, 0x00A9, 0x2120, 0x2022, 0x201C, 0x201D, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x007C},
153 {0x007C, 0x00C0, 0x00C2, 0x00C7, 0x00C8, 0x00CA, 0x00CB, 0x00EB, 0x00CE, 0x00CF, 0x00EF, 0x00D4, 0x00D9, 0x00F9, 0x00DB, 0x00AB,
154 0x00BB, 0x0020, 0x0020, 0x00C3, 0x00E3, 0x00CD, 0x00CC, 0x00EC, 0x00D2, 0x00F2, 0x00D5, 0x00F5, 0x007B, 0x007D, 0x005C, 0x007C},
155 {0x007C, 0x005E, 0x005F, 0x007C, 0x007E, 0x0020, 0x0020, 0x00C4, 0x00E4, 0x00D6, 0x00F6, 0x00DF, 0x00A5, 0x00A4, 0x007C, 0x00C5,
156 0x00E5, 0x00D8, 0x00F8, 0x00C4, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x007C},
157 {0x2514, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014,
158 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2014, 0x2518}};
160 #endif // defined (INCLUDE_AJACC)
165 #if defined (INCLUDE_AJACC)
168 mScreenBuffer [row-1][col-1] = 0x0020;
172 (
void) inNotifyClients;
179 #if defined (INCLUDE_AJACC)
183 if (mNTV2Card.
features().CanDoCustomAnc())
185 bool gotCaptionPacket (
false);
199 if (ancCEA708DataIn.
GetPayloadData () && ancCEA708DataIn.GetPayloadByteCount ())
200 gotCaptionPacket = m708Decoder ? m708Decoder->SetSMPTE334AncData (ancCEA708DataIn.
GetPayloadData (), ancCEA708DataIn.GetPayloadByteCount ()) :
false;
206 if (ancCEA608DataIn.
GetPayloadData () && ancCEA608DataIn.GetPayloadByteCount ())
207 gotCaptionPacket = m708Decoder ? m708Decoder->SetSMPTE334AncData (ancCEA608DataIn.
GetPayloadData (), ancCEA608DataIn.GetPayloadByteCount ()) :
false;
215 gotCaptionPacket =
true;
223 gotCaptionPacket =
true;
229 if (gotCaptionPacket && m708Decoder && m708Decoder->ParseSMPTE334AncPacket ())
230 captionData = m708Decoder->GetCC608CaptionData ();
237 m608Decoder->ProcessNew608FrameData (captionData);
241 #endif // defined (INCLUDE_AJACC)
245 void NTV2FrameGrabber::changeCaptionChannel (
int inNewCaptionChannelId)
247 #if defined (INCLUDE_AJACC)
255 m608Decoder->SubscribeChangeNotification (Caption608Changed,
this);
256 m608Decoder->SetDisplayChannel (chosenCaptionChannel);
262 else if (m608Decoder)
267 else if (m608Decoder->GetDisplayChannel () != chosenCaptionChannel)
268 m608Decoder->SetDisplayChannel (chosenCaptionChannel);
272 (
void) inNewCaptionChannelId;
273 #endif // defined (INCLUDE_AJACC)
281 ULWord framesCaptured (0);
291 if (mNTV2Card.
Open(mBoardNumber))
305 if (mNTV2Card.
features().HasBiDirectionalSDI())
307 bool waitForInput =
false;
308 for (
unsigned offset (0); offset < 8; offset++)
339 currentImage->load (
":/resources/splash.png");
341 emit
newFrame (*currentImage,
true);
350 if (mNTV2Card.IsOpen ())
352 if (!mDoMultiChannel)
362 if (mNTV2Card.
Open(mBoardNumber))
367 qDebug() <<
"Could not acquire board number " <<
GetDeviceIndex();
378 if (mNTV2Card.
features().CanDoMultiFormat())
383 qDebug (
"Device not ready");
394 ULWord startFrameBuffer = (numFrameBuffersAvailable / mNTV2Card.
features().GetNumFrameStores()) *
ULWord(mChannel);
396 acOptions, 1, startFrameBuffer, startFrameBuffer+7);
400 mAudioDevice = mAudioOutput->start ();
410 images[i] =
new QImage (mFrameDimensions.Width (), mFrameDimensions.Height (), QImage::Format_RGB32);
421 qDebug() <<
"## WARNING: Open failed for device " <<
GetDeviceIndex ();
432 currentImage->fill (qRgba (40, 40, 40, 255));
436 emit
newFrame (*currentImage,
true);
448 #if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
454 if (!mFormatIsProgressive && mDeinterlace)
458 if (currentImage->height() ==
int(mFrameDimensions.Height()) && currentImage->width() ==
int(mFrameDimensions.Width()))
459 for (
ULWord line (0); line < mFrameDimensions.Height(); line += 2)
460 ::memcpy (currentImage->scanLine (
int(line) + 1), currentImage->scanLine(
int(line)), mFrameDimensions.Width() * 4);
466 CRP188 tc (tcValues.at(mTimeCodeSource));
467 if (!tcValues.at (mTimeCodeSource).IsValid())
477 outString.append (
" ");
479 outString.append (
" ");
480 outString.append (mTimeCode.c_str());
484 emit
newFrame (*currentImage, (framesCaptured == 0) ?
true :
false);
494 if (mNTV2Card.IsOpen ())
498 if (!mDoMultiChannel)
516 bool validInput (
false);
526 bool waitForInput(
false);
527 if (mNTV2Card.
features().HasBiDirectionalSDI())
528 for (
unsigned offset (0); offset < 4; offset++)
551 mNTV2Card.
SetVideoFormat (mCurrentVideoFormat,
false,
false, mChannel);
557 qDebug() <<
"## DEBUG: mInputSource=" << mChannel <<
", mCurrentVideoFormat=" << vfString <<
", width=" << mFrameDimensions.Width() <<
", height=" << mFrameDimensions.Height();
560 if (!mbFixedReference)
573 if (mNTV2Card.
features().CanDo12gRouting() && (is6g || is12g))
583 for (
unsigned offset (0); offset < 4; offset++)
606 if (!mbFixedReference)
616 if (!mbFixedReference)
620 if (mNTV2Card.
features().CanDo12gRouting())
729 if (mNTV2Card.
features().GetHDMIVersion() == 2)
743 if (mNTV2Card.IsOpen ())
747 bool tsiEnable(
false);
749 for (
ULWord i(0); i < (tsiEnable ? 2 : mNumChannels); i++)
764 mCurrentVideoFormat = videoFormat;
767 else if ((mCurrentVideoFormat != videoFormat) ||
768 (mCurrentColorSpace != colorSpace))
770 if (mDebounceCounter == 0)
773 mLastVideoFormat = videoFormat;
776 else if (mDebounceCounter == 6)
780 mCurrentVideoFormat = videoFormat;
781 mDebounceCounter = 0;
785 if (mLastVideoFormat == videoFormat)
788 mDebounceCounter = 0;
813 if (mNTV2Card.
features().CanDo12gRouting() && (is6g || is12g))
820 switch (mInputSource)
831 if (videoFormatNext == videoFormat)
834 if (videoFormatNext == videoFormat)
837 if (videoFormatNext == videoFormat)
900 mNumAudioChannels = mNTV2Card.
features().GetMaxAudioChannels();
908 #if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
909 mFormat.setSampleRate (48000);
910 mFormat.setChannelCount (2);
911 mFormat.setSampleSize (16);
912 mFormat.setCodec (
"audio/pcm");
913 mFormat.setByteOrder (QAudioFormat::LittleEndian);
914 mFormat.setSampleType (QAudioFormat::SignedInt);
916 mFormat.setSampleRate (48000);
917 mFormat.setChannelCount (2);
918 mFormat.setSampleFormat (QAudioFormat::Int16);
921 #if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
922 QAudioDeviceInfo audioDeviceInfo (QAudioDeviceInfo::defaultOutputDevice ());
923 if (audioDeviceInfo.isFormatSupported (mFormat))
924 mAudioOutput =
new QAudioOutput (mFormat,
AJA_NULL);
926 QAudioDevice deviceInfo (QMediaDevices::defaultAudioOutput());
927 if (deviceInfo.isFormatSupported (mFormat))
928 mAudioOutput =
new QAudioSink(deviceInfo, mFormat,
AJA_NULL);
936 const ULWord nBytesPerAJASample (4);
937 unsigned channel (0);
938 UWord qtSampleNdx (0);
939 const ULWord totalSamples (inNumValidBytes / mNumAudioChannels);
940 const ULWord totalAjaSamples (inNumValidBytes / nBytesPerAJASample);
941 UWord * pQtAudioBuffer (
reinterpret_cast <UWord *
> (pInOutBuffer));
950 for (
unsigned ajaSampleNdx = 0; ajaSampleNdx < totalAjaSamples; ajaSampleNdx++)
954 pQtAudioBuffer [qtSampleNdx] = pInOutBuffer [ajaSampleNdx] >> 16;
959 if (channel == mNumAudioChannels)
964 mAudioDevice->write (
reinterpret_cast <const char *
> (pQtAudioBuffer), totalSamples);
969 #if defined (INCLUDE_AJACC)
974 pFG->caption608Changed (inChangeInfo);
980 bool changed (
false);
984 ushort utf16Char (m608Decoder ? m608Decoder->GetOnAirUTF16CharacterWithAttributes (row, col, attrs) : 0x0020);
987 if (utf16Char != mScreenBuffer [row-1][col-1])
989 mScreenBuffer [row-1][col-1] = utf16Char;
996 #endif // defined (INCLUDE_AJACC)