AJA NTV2 SDK  17.0.1.1246
NTV2 SDK 17.0.1.1246
ntv2configts2022.cpp
Go to the documentation of this file.
1 /* SPDX-License-Identifier: MIT */
8 #include "ntv2configts2022.h"
9 #include "ntv2endian.h"
10 #include "ntv2card.h"
11 #include "ntv2utils.h"
12 #include "ntv2formatdescriptor.h"
13 
15 #include <sstream>
16 
17 #if defined (AJALinux) || defined (AJAMac)
18  #include <stdlib.h>
19  #include <sys/socket.h>
20  #include <netinet/in.h>
21  #include <arpa/inet.h>
22 #else
23 #pragma warning(disable:4800)
24 #endif
25 
26 using namespace std;
27 
29 {
30  uint32_t features = GetFeatures();
31 
32  _is2022_6 = (bool)(features & SAREK_2022_6);
33  _is2022_2 = (bool)(features & SAREK_2022_2);
34 }
35 
37 {
38 #define WAIT_RESET_MS 800
39 
40  kipdprintf("CNTV2ConfigTs2022::SetupJ2KEncoder channel = %d\n", channel);
41 
42  // Check for a proper channnel (we only configure NTV2_CHANNEL1 and NTV2_CHANNEL2)
43  if ((channel != NTV2_CHANNEL2) && (channel != NTV2_CHANNEL1))
44  {
46  return false;
47  }
48 
49  // Before we do anything lets make sure video format and bitdepth are in valid ranges
51  {
53  return false;
54  }
55 
56  if ((config.bitDepth != 8) && (config.bitDepth != 10))
57  {
59  return false;
60  }
61 
62  // Set T2 to mode stop
63  J2kSetMode(channel, 2, MODE_STOP);
64 
65  // Now wait until T2 has stopped
66  uint32_t lastFrameCount = J2kGetFrameCounter(channel, 2);
67  uint32_t currentFrameCount = 0;
68  uint32_t tries = 20;
69 
70  while (tries)
71  {
72  // Wait
73  AJATime::Sleep(50);
74 
75  currentFrameCount = J2kGetFrameCounter(channel, 2);
76  // See if t2 is still running
77  if (lastFrameCount != currentFrameCount)
78  {
79  // Yep wait some more
80  lastFrameCount = currentFrameCount;
81  tries--;
82  }
83  else
84  {
85  // Nope end the wait
86  tries = 0;
87  }
88  }
89 
90  // Disable encoder inputs
91  SetEncoderInputEnable( channel, false, false );
92 
93  // Assert reset
94  SetEncoderReset( channel, true );
95 
96  // Wait
98 
99  // De-assert reset
100  SetEncoderReset( channel, false );
101 
102  // Wait
104 
105  // Now proceed to configure the device
106  WriteJ2KConfigReg(channel, kRegSarekEncodeVideoFormat1, (uint32_t) config.videoFormat);
107  WriteJ2KConfigReg(channel, kRegSarekEncodeUllMode1, config.ullMode);
108  WriteJ2KConfigReg(channel, kRegSarekEncodeBitDepth1, config.bitDepth);
109  WriteJ2KConfigReg(channel, kRegSarekEncodeChromaSubSamp1, (uint32_t) config.chromaSubsamp);
110  WriteJ2KConfigReg(channel, kRegSarekEncodeMbps1, config.mbps);
111  WriteJ2KConfigReg(channel, kRegSarekEncodeStreamType1, (uint32_t) config.streamType);
112  WriteJ2KConfigReg(channel, kRegSarekEncodeAudioChannels1, (uint32_t) config.audioChannels);
113  WriteJ2KConfigReg(channel, kRegSarekEncodeProgramPid1, config.pmtPid);
114  WriteJ2KConfigReg(channel, kRegSarekEncodeVideoPid1, config.videoPid);
115  WriteJ2KConfigReg(channel, kRegSarekEncodePcrPid1, config.pcrPid);
116  WriteJ2KConfigReg(channel, kRegSarekEncodeAudio1Pid1, config.audio1Pid);
117 
118  // setup the TS
119  if (!SetupTsForEncode(channel))
120  return false;
121 
122  // setup the J2K encoder
123  if (!SetupJ2KForEncode(channel))
124  return false;
125 
126  // Need to set 20 or 24 bit audio in NTV2 audio control reg. For now we are doing this on
127  // a global basis and setting all audio engines to the same value.
128  J2KStreamType streamType;
129  ReadJ2KConfigReg(channel, kRegSarekEncodeStreamType1, (uint32_t *) &streamType);
130  bool do20Bit = true;
131 
132  // Set PTS_MUX depending on streamtype
133  if (streamType == kJ2KStreamTypeNonElsm)
134  {
135  do20Bit = false;
136  }
137 
138  for (uint32_t i = NTV2_AUDIOSYSTEM_1; i<NTV2_MAX_NUM_AudioSystemEnums; i++)
139  {
141  }
142 
143  // Set T2 to mode record
144  J2kSetMode(channel, 2, MODE_RECORD);
145  // We don't need to do this because the firwmare does it
146  // J2kSetMode(channel, 0, MODE_RECORD);
147 
148  // Turn on input to the encoder
149  SetEncoderInputEnable( channel, true, (config.streamType == kJ2KStreamTypeNonElsm));
150 
151  return true;
152 }
153 
155 {
156  if ((channel == NTV2_CHANNEL1) || (channel == NTV2_CHANNEL2))
157  {
158  ReadJ2KConfigReg(channel, kRegSarekEncodeVideoFormat1, (uint32_t*) &config.videoFormat);
159  ReadJ2KConfigReg(channel, kRegSarekEncodeUllMode1, &config.ullMode);
160  ReadJ2KConfigReg(channel, kRegSarekEncodeBitDepth1, &config.bitDepth);
161  ReadJ2KConfigReg(channel, kRegSarekEncodeChromaSubSamp1, (uint32_t *) &config.chromaSubsamp);
162  ReadJ2KConfigReg(channel, kRegSarekEncodeMbps1, &config.mbps);
163  ReadJ2KConfigReg(channel, kRegSarekEncodeStreamType1, (uint32_t *) &config.streamType);
164  ReadJ2KConfigReg(channel, kRegSarekEncodeAudioChannels1, (uint32_t *) &config.audioChannels);
165  ReadJ2KConfigReg(channel, kRegSarekEncodeProgramPid1, &config.pmtPid);
166  ReadJ2KConfigReg(channel, kRegSarekEncodeVideoPid1, &config.videoPid);
167  ReadJ2KConfigReg(channel, kRegSarekEncodePcrPid1, &config.pcrPid);
168  ReadJ2KConfigReg(channel, kRegSarekEncodeAudio1Pid1, &config.audio1Pid);
169  return true;
170  }
171  else
172  {
174  return false;
175  }
176 }
177 
178 bool CNTV2ConfigTs2022::SetupJ2KForEncode(const NTV2Channel channel)
179 {
180  NTV2VideoFormat videoFormat;
181  uint32_t ullMode;
182  uint32_t bitDepth;
183  J2KChromaSubSampling subSamp;
184  uint32_t mbps;
185 
186  uint32_t bitRateMsb;
187  uint32_t bitRateLsb;
188  uint32_t rtConstant;
189  uint32_t ull;
190 
191  // Subband removal Component 0, 1 and 2
192  uint32_t sb_rmv_c0 = 0;
193  uint32_t sb_rmv_c1 = 0;
194  uint32_t sb_rmv_c2 = 0;
196 
197  uint32_t regulator_type = 0;
198  uint32_t Rsiz = 258;
199  uint32_t reg_cap = 0;
200  uint32_t clk_fx_freq = 200;
201  uint32_t marker = 0x02;
202  uint32_t guard_bit = 1;
203  uint32_t prog_order = 0;
204  uint32_t fdwt_type = 1;
205  uint32_t mct = 0;
206  uint32_t num_comp = 3;
207  uint32_t num_levels = 5;
208 
209  uint32_t GOB[8] = {03, 03, 03, 03, 03, 03, 03, 03};
210  uint32_t QS_C0[8] = {12, 13, 14, 15, 16, 16, 16, 16};
211  uint32_t QS_C1[8] = {12, 13, 14, 15, 16, 16, 16, 16};
212  uint32_t QS_C2[8] = {12, 13, 14, 15, 16, 16, 16, 16};
213 
214  // Get our variable user params
215  ReadJ2KConfigReg(channel, kRegSarekEncodeVideoFormat1, (uint32_t*) &videoFormat);
216  ReadJ2KConfigReg(channel, kRegSarekEncodeUllMode1, &ullMode);
217  ReadJ2KConfigReg(channel, kRegSarekEncodeBitDepth1, &bitDepth);
218  ReadJ2KConfigReg(channel, kRegSarekEncodeChromaSubSamp1, (uint32_t *) &subSamp);
219  ReadJ2KConfigReg(channel, kRegSarekEncodeMbps1, &mbps);
220 
221  // Calculate height and width based on video format
222  NTV2Standard standard = GetNTV2StandardFromVideoFormat(videoFormat);
224  uint32_t width = fd.GetRasterWidth();
225  uint32_t height = fd.GetVisibleRasterHeight();
226 
227  // Calculate framerate based on video format
228  NTV2FrameRate frameRate = GetNTV2FrameRateFromVideoFormat(videoFormat);
229  uint32_t framesPerSecNum;
230  uint32_t framesPerSecDen;
231  uint32_t fieldsPerSec;
232 
233  GetFramesPerSecond (frameRate, framesPerSecNum, framesPerSecDen);
234  if (framesPerSecDen == 1001)
235  framesPerSecDen = 1000;
236  fieldsPerSec = framesPerSecNum/framesPerSecDen;
238  fieldsPerSec*=2;
239 
240  kipdprintf("CNTV2ConfigTs2022::SetupJ2KForEncode width=%d, height=%d fpsNum=%d,\n", width, height, fieldsPerSec);
241 
242  if (ullMode)
243  {
244  ull = 1;
245  bitRateMsb = ((((mbps*1000000)/fieldsPerSec)/8)/9) >> 16;
246  bitRateLsb = ((((mbps*1000000)/fieldsPerSec)/8)/9) & 0xFFFF;
247  rtConstant = (((clk_fx_freq*149000)/200)/fieldsPerSec)/9;
248  }
249  else
250  {
251  ull = 0;
252  bitRateMsb = (((mbps*1000000)/fieldsPerSec)/8) >> 16;
253  bitRateLsb = (((mbps*1000000)/fieldsPerSec)/8) & 0xFFFF;
254  rtConstant = (((clk_fx_freq*149000)/200)/fieldsPerSec);
255  }
256 
257 
258  for (uint32_t config=0; config < 3; config++)
259  {
260  J2kSetParam(channel, config, 0x00, width);
261  J2kSetParam(channel, config, 0x01, height);
262  J2kSetParam(channel, config, 0x02, bitDepth);
263  J2kSetParam(channel, config, 0x03, guard_bit);
264  J2kSetParam(channel, config, 0x04, subSamp);
265  J2kSetParam(channel, config, 0x05, num_comp);
266  J2kSetParam(channel, config, 0x06, mct);
267  J2kSetParam(channel, config, 0x07, fdwt_type);
268  J2kSetParam(channel, config, 0x08, num_levels);
269  J2kSetParam(channel, config, 0x09, codeBlocksize);
270 
271  J2kSetParam(channel, config, 0x0A, prog_order);
272  J2kSetParam(channel, config, 0x0B, bitRateMsb);
273  J2kSetParam(channel, config, 0x0C, bitRateLsb);
274  J2kSetParam(channel, config, 0x0D, rtConstant);
275  J2kSetParam(channel, config, 0x0E, marker);
276  J2kSetParam(channel, config, 0x0F, ull);
277  J2kSetParam(channel, config, 0x10, sb_rmv_c0);
278  J2kSetParam(channel, config, 0x11, sb_rmv_c1);
279  J2kSetParam(channel, config, 0x12, sb_rmv_c2);
280  J2kSetParam(channel, config, 0x13, regulator_type);
281  J2kSetParam(channel, config, 0x14, Rsiz);
282  J2kSetParam(channel, config, 0x15, reg_cap);
283  }
284 
285  if (ullMode)
286  {
287  // Sanity checks
288  if ((height != 1080) && (height != 540))
289  {
291  return false;
292  }
293 
294  if ((height == 1080) && (num_levels > 4))
295  {
297  return false;
298  }
299 
300  if ((height == 540) && (num_levels > 3))
301  {
303  return false;
304  }
305 
307  return false;
308  }
309 
310 #if 0
311  if {$ull} {
312 
313  #Set ULL in active mode
314  opb_write $env [expr 0x10000*$enc+0x1006] 1
315 
316  #Set img height for each kind of tile
317  if {$im_height == 1080} {
318  ipx_jp2k_e_set_param $env $enc 0 0x1 128
319  ipx_jp2k_e_set_param $env $enc 1 0x1 128
320  ipx_jp2k_e_set_param $env $enc 2 0x1 56
321  }
322  if {$im_height == 540} {
323  ipx_jp2k_e_set_param $env $enc 0 0x1 64
324  ipx_jp2k_e_set_param $env $enc 1 0x1 64
325  ipx_jp2k_e_set_param $env $enc 2 0x1 28
326  }
327 
328  #Specify all kind of tile
329  ipx_jp2k_e_set_param $env $enc 0 0xF 1
330  ipx_jp2k_e_set_param $env $enc 1 0xF 2
331  ipx_jp2k_e_set_param $env $enc 2 0xF 3
332  }
333 
334  #ipx_jp2k_e_get_all_status $env $enc 0
335  for {set config 0} {$config<3} {incr config} {
336  for {set lvl 0} {$lvl<7} {incr lvl} {
337  ipx_jp2k_e_set_param $env $enc $config [expr 0x80+$lvl] [lindex $GOB $lvl]
338  ipx_jp2k_e_set_param $env $enc $config [expr 0x88+$lvl] [expr [lindex $QS_C0 $lvl]*0x800]
339  ipx_jp2k_e_set_param $env $enc $config [expr 0x90+$lvl] [expr [lindex $QS_C1 $lvl]*0x800]
340  ipx_jp2k_e_set_param $env $enc $config [expr 0x98+$lvl] [expr [lindex $QS_C2 $lvl]*0x800]
341  }
342  }
343 
344 #endif
345 
346 
347  for (uint32_t config=0; config < 3; config++)
348  {
349  for (uint32_t lvl=0; lvl < 7; lvl++)
350  {
351  J2kSetParam(channel, config, 0x80+lvl, GOB[lvl]);
352  J2kSetParam(channel, config, 0x88+lvl, QS_C0[lvl]*0x800);
353  J2kSetParam(channel, config, 0x90+lvl, QS_C1[lvl]*0x800);
354  J2kSetParam(channel, config, 0x98+lvl, QS_C2[lvl]*0x800);
355  }
356  }
357 
358  //J2kSetConfig( channel, 0 /*select config 0*/ );
359 
360  return true;
361 }
362 
363 
365 {
367  mDevice.WriteRegister(SAREK_IPX_J2K_DECODER_1 + kRegJ2kPopMainCsr, 0x12); // pop mode play once
368 
373 
374  uint32_t seqNum;
377 
378  return true;
379 }
380 
382 {
387 
388  return true;
389 }
390 
392 {
393  status.init();
394 
397  for (uint32_t i=0; i < status.numAvailablePrograms; i++)
398  {
399  uint32_t val;
401  status.availableProgramNumbers.push_back(val);
403  status.availableProgramPIDs.push_back(val);
404  }
405  for (uint32_t i=0; i < status.numAvailableAudios; i++)
406  {
407  uint32_t val;
409  status.availableAudioPIDs.push_back(val);
410  }
411 
412  return true;
413 }
414 
415 bool CNTV2ConfigTs2022::SetupTsForEncode(const NTV2Channel channel)
416 {
417  // program TS timer
418  if (!SetupEncodeTsTimer(channel))
419  return false;
420 
421  // program TS for mpeg j2k encapsulator
422  if (!SetupEncodeTsMpegJ2kEncap(channel))
423  return false;
424 
425  // program TS for mpeg pcr encapsulator
426  if (!SetupEncodeTsMpegPcrEncap(channel))
427  return false;
428 
429  // program TS for mpeg aes encapsulator
430  if (!SetupEncodeTsMpegAesEncap(channel))
431  return false;
432 
433  // program TS for aes encapsulator
434  if (!SetupEncodeTsAesEncap(channel))
435  return false;
436 
437  // finally setup TS for the encoder
438  if (!SetupEncodeTsJ2KEncoder(channel))
439  return false;
440 
441  return true;
442 }
443 
444 
445 // Private functions
446 
447 // Setup individual TS encode parts
448 bool CNTV2ConfigTs2022::SetupEncodeTsTimer(const NTV2Channel channel)
449 {
450  uint32_t addr = GetIpxTsAddr(channel);
451  int32_t tsGen = 0;
452 
453  kipdprintf("CNTV2ConfigTs2022::SetupEncodeTsTimer\n");
454 
455  mDevice.WriteRegister(addr + (0x800*ENCODE_TS_TIMER) + kRegTsTimerJ2kTsLoad, (0x103110));
456 
457  // Calculate TS Gen based on total bitrate and system clock
458  tsGen = CalculateTsGen(channel);
460 
461  J2KStreamType streamType;
462  ReadJ2KConfigReg(channel, kRegSarekEncodeStreamType1, (uint32_t *) &streamType);
463 
464  // Set PTS_MUX depending on streamtype
465  if (streamType == kJ2KStreamTypeNonElsm)
466  {
468  }
469  else
470  {
472  }
473 
474  return true;
475 }
476 
477 
478 bool CNTV2ConfigTs2022::SetupEncodeTsJ2KEncoder(const NTV2Channel channel)
479 {
480  NTV2VideoFormat videoFormat;
481  uint32_t addr = GetIpxTsAddr(channel);
482 
483  kipdprintf("CNTV2ConfigTs2022::SetupEncodeTsJ2KEncoder\n");
484 
485  ReadJ2KConfigReg(channel, kRegSarekEncodeVideoFormat1, (uint32_t*) &videoFormat);
487  {
488  // progressive format
490  }
491  else
492  {
493  // interlaced format
495  }
496 
499 
500  // Wait 60 ms
501  AJATime::Sleep(60);
502 
504 
505  return true;
506 }
507 
508 
509 bool CNTV2ConfigTs2022::SetupEncodeTsMpegJ2kEncap(const NTV2Channel channel)
510 {
511  uint32_t addr = GetIpxTsAddr(channel);
512 
513  kipdprintf("CNTV2ConfigTs2022::SetupEncodeTsMpegJ2kEncap\n");
514 
515  GenerateTableForMpegJ2kEncap(channel);
516 
517  // Program Transaction Table
518  for (int32_t index=0; index < _transactionCount; index++)
519  {
520  mDevice.WriteRegister(addr + (0x800*ENCODE_TS_MPEG_J2K_ENCAP) + (_transactionTable[index][0]), _transactionTable[index][1]);
521  //printf("SetupEncodeTsMpegJ2kEncap - addr=%08x, val=%08x\n",
522  // addr + (0x800*ENCODE_TS_MPEG_J2K_ENCAP) + (_transactionTable[index][0]), _transactionTable[index][1]);
523  }
524  return true;
525 }
526 
527 
528 bool CNTV2ConfigTs2022::SetupEncodeTsMpegPcrEncap(const NTV2Channel channel)
529 {
530  uint32_t addr = GetIpxTsAddr(channel);
531 
532  kipdprintf("CNTV2ConfigTs2022::SetupEncodeTsMpegPcrEncap\n");
533 
534  GenerateTableForMpegPcrEncap(channel);
535 
536  // Program Transaction Table
537  for (int32_t index=0; index < _transactionCount; index++)
538  {
539  mDevice.WriteRegister(addr + (0x800*ENCODE_TS_MPEG_PCR_ENCAP) + (_transactionTable[index][0]), _transactionTable[index][1]);
540  //printf("SetupEncodeTsMpegPcrEncap - addr=%08x, val=%08x\n",
541  // addr + (0x800*ENCODE_TS_MPEG_PCR_ENCAP) + (_transactionTable[index][0]), _transactionTable[index][1]);
542  }
543  return true;
544 }
545 
546 
547 bool CNTV2ConfigTs2022::SetupEncodeTsMpegAesEncap(const NTV2Channel channel)
548 {
549  uint32_t addr = GetIpxTsAddr(channel);
550 
551  kipdprintf("CNTV2ConfigTs2022::SetupEncodeTsMpegAesEncap\n");
552 
553  GenerateTableForMpegAesEncap(channel);
554 
555  // Program Transaction Table
556  for (int32_t index=0; index < _transactionCount; index++)
557  {
558  mDevice.WriteRegister(addr + (0x800*ENCODE_TS_MPEG_AES_ENCAP) + (_transactionTable[index][0]), _transactionTable[index][1]);
559  //printf("SetupEncodeTsMpegAesEncap - addr=%08x, val=%08x\n",
560  // addr + (0x800*ENCODE_TS_MPEG_AES_ENCAP) + (_transactionTable[index][0]), _transactionTable[index][1]);
561  }
562  return true;
563 }
564 
565 
566 bool CNTV2ConfigTs2022::SetupEncodeTsAesEncap(const NTV2Channel channel)
567 {
568  uint32_t addr = GetIpxTsAddr(channel);
569 
570  J2KStreamType streamType;
571  uint32_t numAudioChannels = 0;
572  uint32_t audioChannels = 0;
573 
574  ReadJ2KConfigReg(channel, kRegSarekEncodeStreamType1, (uint32_t *) &streamType);
575  ReadJ2KConfigReg(channel, kRegSarekEncodeAudioChannels1, (uint32_t *) &numAudioChannels);
576 
577  // Need to figure out how many stereo pairs we have (0 is actually 1 stereo pair)
578  if (numAudioChannels)
579  audioChannels = (numAudioChannels/2) - 1;
580 
581  // Write number of audio channels and set bit 4 for non elsm streams to indicate 24 bit audio
582  if (streamType == kJ2KStreamTypeNonElsm)
583  {
584  mDevice.WriteRegister(addr + (0x800*ENCODE_TS_AES_ENCAP) + kRegTsAesEncapNumChannels, audioChannels | 0x10);
585  }
586  else
587  {
588  mDevice.WriteRegister(addr + (0x800*ENCODE_TS_AES_ENCAP) + kRegTsAesEncapNumChannels, audioChannels);
589  }
590 
591  // Enable the AES encapsulator if there is audio
592  mDevice.WriteRegister(addr + (0x800*ENCODE_TS_AES_ENCAP) + kRegTsAesEncapHostEn, numAudioChannels?1:0);
593 
594  return true;
595 }
596 
597 
598 uint32_t CNTV2ConfigTs2022::GetFeatures()
599 {
600  uint32_t val;
602  return val;
603 }
604 
605 
607 {
608  NTV2IpError error = mIpErrorCode;
610  return error;
611 }
612 
613 
614 bool CNTV2ConfigTs2022::J2kCanAcceptCmd(const NTV2Channel channel)
615 {
616  uint32_t val;
617  uint32_t addr = GetIpxJ2KAddr(channel);
618 
619  // Read T0 Main CSR Register
621 
622  // Check CF bit note this is bit reversed from documentation
623  // so we check 6 instead of 25
624  if(val & BIT(6))
625  return false;
626  else
627  return true;
628 }
629 
630 bool CNTV2ConfigTs2022::J2KGetNextT0Status(const NTV2Channel channel, uint32_t *pStatus)
631 {
632  uint32_t val;
633  uint32_t addr = GetIpxJ2KAddr(channel);
634  if (!pStatus)
635  return false;
636 
637  // Read T0 Main CSR Register
639 
640  // Clear SF Status Full & SO Status Overflow bits
641  if (val & (BIT(10) | BIT(9))) {
642  printf("Overflow / status full 0x%08x\n", val);
643  mDevice.WriteRegister( addr + kRegJ2kT0FIFOCsr, BIT(10) | BIT(9) );
644  }
645 
646  // Check SE Status Empty bit
647  if(val & BIT(11))
648  return false;
649 
650  return mDevice.ReadRegister( addr + kRegJ2kT0StatusFIFO, *pStatus );
651 }
652 
653 
654 bool CNTV2ConfigTs2022::GetT0CmdStatus( const NTV2Channel channel, const uint32_t cmdId, uint32_t *pStatus ) {
655  uint32_t val;
656  static const int MAX_STATUSES_TO_WAIT = 16;
657  int count = 0;
658  while( J2KGetNextT0Status(channel, &val) )
659  {
660  if ( ((val >> 16)& 0xff) == cmdId )
661  {
662  *pStatus = val;
663  return true;
664  }
665  else
666  {
667  count++;
668  if (count == MAX_STATUSES_TO_WAIT)
669  return false;
670  }
671  }
672  return false;
673 }
674 
675 
676 void CNTV2ConfigTs2022::J2kSetMode(const NTV2Channel channel, uint32_t tier, uint32_t mode)
677 {
678  uint32_t addr = GetIpxJ2KAddr(channel);
679 
680  mDevice.WriteRegister(addr + (tier*0x40) + kRegJ2kT0MainCsr, mode);
681  //printf("J2kSetMode - %d wrote 0x%08x to MAIN CSR in tier %d\n", channel, mode, tier);
682 }
683 
684 
685 void CNTV2ConfigTs2022::J2kSetConfig(const NTV2Channel channel, uint32_t config)
686 {
687  uint32_t val;
688  uint32_t addr = GetIpxJ2KAddr(channel);
689 
690  mDevice.WriteRegister(addr + kRegJ2kT0CmdFIFO, 0x73010000 | (config & 0xffff));
691 
692  if (!GetT0CmdStatus( channel, 0x01, &val))
693  {
694  printf("No status received for setconfig\n");
695  return;
696  }
697 
698  if (val >> 24 != 0xf3)
699  {
700  printf("J2KSetConfig: Expected status 0xf3...... received 0x%08x\n", val);
701  }
702 }
703 
704 
705 uint32_t CNTV2ConfigTs2022::J2kGetFrameCounter(const NTV2Channel channel, uint32_t tier)
706 {
707  uint32_t addr = GetIpxJ2KAddr(channel);
708  uint32_t val = 0;
709 
710  mDevice.ReadRegister(addr + (tier*0x40) + kRegJ2kT0Framecount, val);
711  //printf("J2kGetFrameCounter - %d read 0x%08x to MAIN CSR in tier %d\n", channel, val, tier);
712  return val;
713 }
714 
715 
716 void CNTV2ConfigTs2022::J2kSetParam (const NTV2Channel channel, uint32_t config, uint32_t param, uint32_t value)
717 {
718  uint32_t val;
719  uint32_t addr = GetIpxJ2KAddr(channel);
720 
721  //printf("J2kSetParam - ch=%d config=0x%08x param=0x%08x value=0x%08x\n", channel, config, param, value);
722 
723  while(!J2kCanAcceptCmd(channel))
724  {
725  printf("J2kSetParam - command fifo full\n");
726  }
727 
728  // we use param as cmd id
729  val = 0x70000000 + (param<<16) + (config&0x7)*0x2000 + param;
731  //printf("J2kSetParam - wrote 0x%08x to CMD FIFO\n", val);
732 
733  while(!J2kCanAcceptCmd(channel))
734  {
735  printf("J2kSetParam - command fifo full\n");
736  }
737 
738  val = 0x7f000000 + (param<<16) + value;
740  //printf("J2kSetParam - wrote 0x%08x to CMD FIFO\n", val);
741 
742  if (!GetT0CmdStatus( channel, param /* doubles as cmd id*/, &val))
743  {
744  printf("No status received for SetParam\n");
745  return;
746  }
747 
748  if (val >> 24 != 0xf0)
749  {
750  printf("J2KSetConfig: Expected status 0xf0...... received 0x%08x\n", val);
751  }
752 }
753 
754 
755 void CNTV2ConfigTs2022::GenerateTableForMpegJ2kEncap(const NTV2Channel channel)
756 {
757  NTV2VideoFormat videoFormat;
758  int32_t w1;
759  TsEncapStreamData streamData;
760 
761  kipdprintf("CNTV2ConfigTs2022::GenerateTransactionTableForMpegJ2kEncap\n");
762 
763  // Get our variable user params
764  ReadJ2KConfigReg(channel, kRegSarekEncodeVideoFormat1, (uint32_t*) &videoFormat);
765  ReadJ2KConfigReg(channel, kRegSarekEncodeStreamType1, (uint32_t *) &streamData.j2kStreamType);
766  ReadJ2KConfigReg(channel, kRegSarekEncodeAudioChannels1, (uint32_t *) &streamData.numAudioChannels);
767 
768  streamData.interlaced = !NTV2_VIDEO_FORMAT_HAS_PROGRESSIVE_PICTURE(videoFormat);
769 
770  // Calculate height and width based on video format
771  NTV2Standard standard = GetNTV2StandardFromVideoFormat(videoFormat);
773  streamData.width = fd.GetRasterWidth();
774  streamData.height = fd.GetVisibleRasterHeight();
775 
776  // Calculate framerate based on video format
777  NTV2FrameRate frameRate = GetNTV2FrameRateFromVideoFormat(videoFormat);
778  GetFramesPerSecond (frameRate, streamData.numFrameRate, streamData.denFrameRate);
779 
780  // set the PIDs for all streams
781  ReadJ2KConfigReg(channel, kRegSarekEncodeProgramPid1, &streamData.programPid);
782  ReadJ2KConfigReg(channel, kRegSarekEncodeVideoPid1, &streamData.videoPid);
783  ReadJ2KConfigReg(channel, kRegSarekEncodePcrPid1, &streamData.pcrPid);
784  ReadJ2KConfigReg(channel, kRegSarekEncodeAudio1Pid1, &streamData.audio1Pid);
785 
786  kipdprintf("Program PID = 0x%02x\n", streamData.programPid);
787  kipdprintf("Video PID = 0x%02x\n", streamData.videoPid);
788  kipdprintf("PCR PID = 0x%02x\n", streamData.pcrPid);
789  kipdprintf("Audio 1 PID = 0x%02x\n\n", streamData.audio1Pid);
790 
791  _transactionCount = 0;
792 
793  // Start with enable off
794  _transactionTable[_transactionCount][0] = HOST_EN;
795  _transactionTable[_transactionCount++][1] = 0;
796 
797  PESGen pes;
799  pes._elemNumToPID[1] = streamData.videoPid;
801  pes._videoStreamData.width = streamData.width;
802  pes._videoStreamData.height = streamData.height;
803  pes._videoStreamData.denFrameRate = streamData.denFrameRate;
804  pes._videoStreamData.numFrameRate = streamData.numFrameRate;
806  pes._videoStreamData.interlaced = streamData.interlaced;
807 
808  kipdprintf("Host Register Settings:\n\n");
809  _transactionTable[_transactionCount][0] = PAYLOAD_PARAMS;
810  _transactionTable[_transactionCount++][1] = streamData.videoPid;
811  kipdprintf("Payload Parameters = 0x%x\n", _transactionTable[_transactionCount-1][1]);
812 
813  _transactionTable[_transactionCount][0] = INTERLACED_VIDEO;
814  _transactionTable[_transactionCount++][1] = streamData.interlaced;
815  kipdprintf("Interlaced Video = %i\n", _transactionTable[_transactionCount-1][1]);
816 
817  _transactionTable[_transactionCount][0] = PAT_PMT_PERIOD;
818  _transactionTable[_transactionCount++][1] = pes.calcPatPmtPeriod() | 0x01000000;
819  kipdprintf("PAT/PMT Transmission Period = %i (0x%x)\n", _transactionTable[_transactionCount-1][1], _transactionTable[_transactionCount-1][1]);
820 
821  _transactionTable[_transactionCount][0] = PACKET_RATE;
822  _transactionTable[_transactionCount++][1] = 0;
823  kipdprintf("Packet Rate = %i (0x%x)\n", _transactionTable[_transactionCount-1][1], _transactionTable[_transactionCount-1][1]);
824 
825  int length = pes.makePacket();
826 
827  kipdprintf("PTS Offset = 0x%02x J2K TS Offset = 0x%02x auf1 offset = 0x%02x auf2 offset = 0x%02x\n\n",
828  pes._ptsOffset, pes._j2kTsOffset, pes._auf1Offset, pes._auf2Offset);
829  _transactionTable[_transactionCount][0] = PTS_OFFSET;
830  _transactionTable[_transactionCount++][1] = pes._ptsOffset;
831  _transactionTable[_transactionCount][0] = J2K_TS_OFFSET;
832  _transactionTable[_transactionCount++][1] = pes._j2kTsOffset;
833  _transactionTable[_transactionCount][0] = AUF1_OFFSET;
834  _transactionTable[_transactionCount++][1] = pes._auf1Offset;
835  _transactionTable[_transactionCount][0] = AUF2_OFFSET;
836  _transactionTable[_transactionCount++][1] = pes._auf2Offset;
837 
838  kipdprintf("PES Template Length = %i, Data:\n", length);
839  _transactionTable[_transactionCount][0] = PES_HDR_LEN;
840  _transactionTable[_transactionCount++][1] = length;
841 
842  for (w1 = 0; w1 < 188; w1++)
843  {
844  _transactionTable[_transactionCount][0] = PES_HDR_LOOKUP + w1;
845  _transactionTable[_transactionCount++][1] = pes._pkt8[w1];
846  }
847  pes.dump8();
848 
849  ADPGen adp;
851  adp._elemNumToPID[1] = streamData.videoPid;
852  length = adp.makePacket();
853 
854  kipdprintf("Adaptation Template Length = %i, Data:\n", length);
855  _transactionTable[_transactionCount][0] = ADAPTATION_HDR_LENGTH;
856  _transactionTable[_transactionCount++][1] = length;
857  for (w1 = 0; w1 < 188; w1++)
858  {
859  _transactionTable[_transactionCount][0] = ADAPTATION_LOOKUP + w1;
860  _transactionTable[_transactionCount++][1] = adp._pkt32[w1];
861  }
862  adp.dump32();
863 
864  PATGen pat;
866  pat._progNumToPID[1] = streamData.programPid;
867  length = pat.makePacket();
868 
869  kipdprintf("PAT Template Length = %i, Data:\n", length);
870  for (w1 = 0; w1 < 188; w1++)
871  {
872  _transactionTable[_transactionCount][0] = PAT_TABLE_LOOKUP + w1;
873  _transactionTable[_transactionCount++][1] = pat._pkt8[w1];
874  }
875  pat.dump8();
876 
877  PMTGen pmt;
879  pmt._progNumToPID[1] = streamData.programPid;
880  pmt._videoNumToPID[1] = streamData.videoPid;
881  pmt._pcrNumToPID[1] = streamData.pcrPid;
882  pmt._audioNumToPID[1] = streamData.audio1Pid;
884  pmt._videoStreamData.width = streamData.width;
885  pmt._videoStreamData.height = streamData.height;
886  pmt._videoStreamData.denFrameRate = streamData.denFrameRate;
887  pmt._videoStreamData.numFrameRate = streamData.numFrameRate;
889  pmt._videoStreamData.interlaced = streamData.interlaced;
890  length = pmt.makePacket();
891 
892  kipdprintf("PMT Template Length = %i, Data:\n", length);
893  for (w1 = 0; w1 < 188; w1++)
894  {
895  _transactionTable[_transactionCount][0] = PMT_TABLE_LOOKUP + w1;
896  _transactionTable[_transactionCount++][1] = pmt._pkt8[w1];
897  }
898  pmt.dump8();
899 
900  // On last entry enable is on
901  _transactionTable[_transactionCount][0] = HOST_EN;
902  _transactionTable[_transactionCount++][1] = 1;
903 }
904 
905 
906 void CNTV2ConfigTs2022::GenerateTableForMpegPcrEncap(const NTV2Channel channel)
907 {
908  int32_t w1;
909  uint32_t pcrPid;
910 
911  kipdprintf("CNTV2ConfigTs2022::GenerateTableForMpegPcrEncap\n");
912 
913  // Get the PCR pid
914  ReadJ2KConfigReg(channel, kRegSarekEncodePcrPid1, &pcrPid);
915  kipdprintf("PCR PID = 0x%02x\n", pcrPid);
916 
917  _transactionCount = 0;
918 
919  // Start with enable off
920  _transactionTable[_transactionCount][0] = HOST_EN;
921  _transactionTable[_transactionCount++][1] = 0;
922 
923  _transactionTable[_transactionCount][0] = PAT_PMT_PERIOD;
924  _transactionTable[_transactionCount++][1] = 0;
925  kipdprintf("PAT/PMT Transmission Period = %i (0x%x)\n", _transactionTable[_transactionCount-1][1], _transactionTable[_transactionCount-1][1]);
926 
927  _transactionTable[_transactionCount][0] = PACKET_RATE;
928  _transactionTable[_transactionCount++][1] = 0;
929  kipdprintf("Packet Rate = %i (0x%x)\n", _transactionTable[_transactionCount-1][1], _transactionTable[_transactionCount-1][1]);
930 
931  ADPGen adp;
933  adp._elemNumToPID[1] = pcrPid;
934  uint32_t length = adp.makePacket();
935 
936  kipdprintf("Adaptation Template Length = %i, Data:\n", length);
937  _transactionTable[_transactionCount][0] = ADAPTATION_HDR_LENGTH;
938  _transactionTable[_transactionCount++][1] = length;
939  for (w1 = 0; w1 < 188; w1++)
940  {
941  _transactionTable[_transactionCount][0] = ADAPTATION_LOOKUP + w1;
942  _transactionTable[_transactionCount++][1] = adp._pkt32[w1];
943  }
944  adp.dump32();
945 
946  // On last entry enable is on
947  _transactionTable[_transactionCount][0] = HOST_EN;
948  _transactionTable[_transactionCount++][1] = 1;
949 }
950 
951 
952 void CNTV2ConfigTs2022::GenerateTableForMpegAesEncap(const NTV2Channel channel)
953 {
954  int32_t w1;
955  uint32_t audioPid;
956  J2KStreamType j2kStreamType;
957 
958  kipdprintf("CNTV2ConfigTs2022::GenerateTableForMpegAesEncap\n");
959 
960  // Get the Audio pid and stream type
961  ReadJ2KConfigReg(channel, kRegSarekEncodeAudio1Pid1, &audioPid);
962  ReadJ2KConfigReg(channel, kRegSarekEncodeStreamType1, (uint32_t *) &j2kStreamType);
963  kipdprintf("Audio 1 PID = 0x%02x\n\n", audioPid);
964 
965  _transactionCount = 0;
966 
967  // Start with enable off
968  _transactionTable[_transactionCount][0] = HOST_EN;
969  _transactionTable[_transactionCount++][1] = 0;
970 
971  // First we must set this to zero while disabled later we will set this same register to the proper value.
972  _transactionTable[_transactionCount][0] = PACKET_RATE;
973  _transactionTable[_transactionCount++][1] = 0;
974 
975  PESGen pes;
977  pes._elemNumToPID[1] = audioPid;
978  // For Aes PES generator the streamType is the only thing we need to pass in the videoStreamData struct
979  pes._videoStreamData.j2kStreamType = j2kStreamType;
980 
981  kipdprintf("Host Register Settings:\n\n");
982 
983  _transactionTable[_transactionCount][0] = PAYLOAD_PARAMS;
984  _transactionTable[_transactionCount++][1] = audioPid;
985  kipdprintf("Payload Parameters = 0x%x\n", _transactionTable[_transactionCount-1][1]);
986 
987  _transactionTable[_transactionCount][0] = PACKET_RATE;
988  _transactionTable[_transactionCount++][1] = 0x10000;
989  kipdprintf("Packet Rate = %i (0x%x)\n", _transactionTable[_transactionCount-1][1], _transactionTable[_transactionCount-1][1]);
990 
991  int length = pes.makePacket();
992 
993  kipdprintf("PTS Offset = 0x%02x auf1 offset = 0x%02x auf2 offset = 0x%02x\n\n",
994  pes._ptsOffset, pes._auf1Offset, pes._auf2Offset);
995  _transactionTable[_transactionCount][0] = PTS_OFFSET;
996  _transactionTable[_transactionCount++][1] = pes._ptsOffset;
997  _transactionTable[_transactionCount][0] = AUF1_OFFSET;
998  _transactionTable[_transactionCount++][1] = pes._auf1Offset;
999  _transactionTable[_transactionCount][0] = AUF2_OFFSET;
1000  _transactionTable[_transactionCount++][1] = pes._auf2Offset;
1001 
1002  kipdprintf("PES Template Length = %i, Data:\n", length);
1003  _transactionTable[_transactionCount][0] = PES_HDR_LEN;
1004  _transactionTable[_transactionCount++][1] = length;
1005 
1006  for (w1 = 0; w1 < 188; w1++)
1007  {
1008  _transactionTable[_transactionCount][0] = PES_HDR_LOOKUP + w1;
1009  _transactionTable[_transactionCount++][1] = pes._pkt8[w1];
1010  }
1011  pes.dump8();
1012 
1013  ADPGen adp;
1015  adp._elemNumToPID[1] = audioPid;
1016  length = adp.makePacket();
1017 
1018  kipdprintf("Adaptation Template Length = %i, Data:\n", length);
1019  _transactionTable[_transactionCount][0] = ADAPTATION_HDR_LENGTH;
1020  _transactionTable[_transactionCount++][1] = length;
1021  for (w1 = 0; w1 < 188; w1++)
1022  {
1023  _transactionTable[_transactionCount][0] = ADAPTATION_LOOKUP + w1;
1024  _transactionTable[_transactionCount++][1] = adp._pkt32[w1];
1025  }
1026  adp.dump32();
1027 
1028  // On last entry enable is on
1029  _transactionTable[_transactionCount][0] = HOST_EN;
1030  _transactionTable[_transactionCount++][1] = 1;
1031 }
1032 
1033 
1034 uint32_t CNTV2ConfigTs2022::GetIpxJ2KAddr(const NTV2Channel channel)
1035 {
1036  // Only NTV2_CHANNEL1 and NTV2_CHANNEL2 are valid.
1037  uint32_t addr = SAREK_J2K_ENCODER_1;
1038 
1039  if (channel == NTV2_CHANNEL2)
1040  {
1041  addr = SAREK_J2K_ENCODER_2;
1042  }
1043  return addr;
1044 }
1045 
1046 
1047 uint32_t CNTV2ConfigTs2022::GetIpxTsAddr(const NTV2Channel channel)
1048 {
1049  // Only NTV2_CHANNEL1 and NTV2_CHANNEL2 are valid.
1050  uint32_t addr = SAREK_TS_ENCODER_1;
1051 
1052  if (channel == NTV2_CHANNEL2)
1053  {
1054  addr = SAREK_TS_ENCODER_2;
1055  }
1056  return addr;
1057 }
1058 
1059 bool CNTV2ConfigTs2022::WriteJ2KConfigReg(const NTV2Channel channel, const uint32_t reg, const uint32_t value)
1060 {
1061  bool rv = false;
1062 
1063  // Only NTV2_CHANNEL1 and NTV2_CHANNEL2 are valid.
1064  if ((channel == NTV2_CHANNEL1) || (channel == NTV2_CHANNEL2))
1065  {
1067  }
1068  else
1070 
1071  //printf("CNTV2ConfigTs2022::WriteJ2KConfigReg reg = %08x %d\n", SAREK_REGS2 + reg + ((kRegSarekEncodeAudio1Pid1-kRegSarekEncodeVideoFormat1+1) * channel), value);
1072  return rv;
1073 }
1074 
1075 bool CNTV2ConfigTs2022::ReadJ2KConfigReg(const NTV2Channel channel, const uint32_t reg, uint32_t * value)
1076 {
1077  bool rv = false;
1078 
1079  // Only NTV2_CHANNEL1 and NTV2_CHANNEL2 are valid.
1080  if ((channel == NTV2_CHANNEL1) || (channel == NTV2_CHANNEL2))
1081  {
1083  }
1084  else
1086 
1087  //printf("CNTV2ConfigTs2022::ReadJ2KConfigVReg reg = %08x %d\n", SAREK_REGS2 + reg + ((kRegSarekEncodeAudio1Pid1-kRegSarekEncodeVideoFormat1+1) * channel), *value);
1088  return rv;
1089 }
1090 
1091 void CNTV2ConfigTs2022::SetEncoderInputEnable(const NTV2Channel channel, bool bEnable, bool bMDEnable )
1092 {
1093 #ifdef COCHRANE
1094  mDevice.WriteRegister( 0x20000, (bEnable?BIT(16):0)|(bMDEnable?BIT(17):0)|(bMDEnable?BIT(18):0), BIT(16)|BIT(17)|BIT(18));
1095 #else
1096  uint32_t encoderBit(0), mdBit(0);
1097  if (channel == NTV2_CHANNEL2)
1098  {
1099  encoderBit = ENCODER_2_ENABLE;
1100  mdBit = ENCODER_2_MD_ENABLE; // Bits 24 and 25
1101  } else if (channel == NTV2_CHANNEL1)
1102  {
1103  encoderBit = ENCODER_1_ENABLE;
1104  mdBit = ENCODER_1_MD_ENABLE; // Bits 24 and 25
1105  }
1106 
1107  uint32_t val;
1108  uint32_t tmp = (bEnable?encoderBit:0) | (bMDEnable?mdBit:0);
1110  val &= ~(encoderBit|mdBit);
1111  val |= tmp;
1113 #endif
1114 }
1115 
1116 
1117 void CNTV2ConfigTs2022::SetEncoderReset(const NTV2Channel channel, bool bReset )
1118 {
1119 #ifdef COCHRANE
1120  mDevice.WriteRegister( 0x20000, (bReset?BIT(12):0), BIT(12));
1121 #else
1122  uint32_t resetBit = (channel == NTV2_CHANNEL2)?ENCODER_2_RESET:ENCODER_1_RESET;
1123  uint32_t val;
1125  if (bReset)
1126  val |= (resetBit);
1127  else
1128  val &= (~resetBit);
1130 #endif
1131 }
1132 
1133 
1134 int32_t CNTV2ConfigTs2022::CalculateTsGen(const NTV2Channel channel)
1135 {
1136  uint32_t mbps;
1137  uint32_t audioChannels1;
1138 
1139  ReadJ2KConfigReg(channel, kRegSarekEncodeMbps1, &mbps);
1140  ReadJ2KConfigReg(channel, kRegSarekEncodeAudioChannels1, &audioChannels1);
1141 
1142  // Calculate bitrate, allow 1.2mbps per audio channel, then add an additional 20%
1143  double ts_bitrate = (((double) mbps + ((double) audioChannels1 * 1.6)) * 1.2) * 1000000;
1144  double sys_clk = 125e6;
1145  double d1, d2;
1146 
1147  // First packet rate
1148  d1 = ts_bitrate / 8.0 / 188.0; // Packet Rate
1149  d1 = 1.0 / d1; // Packet Period
1150  d2 = 1.0 / sys_clk; // Clock Period
1151  d1 = d1 / d2 - 1.0; // One less as it counts from 0
1152 
1153  return (int32_t) d1;
1154 }
1155 
ADAPTATION_LOOKUP
#define ADAPTATION_LOOKUP
Definition: ntv2configts2022.h:50
kTsEncapTypeAes
@ kTsEncapTypeAes
Definition: ntv2tshelper.h:95
kRegSarekNumAudios
#define kRegSarekNumAudios
Definition: ntv2registersmb.h:143
ENCODE_TS_J2K_ENCODER
#define ENCODE_TS_J2K_ENCODER
Definition: ntv2configts2022.h:21
kRegJ2kT0FIFOCsr
#define kRegJ2kT0FIFOCsr
Definition: ntv2registers2022.h:255
kRegSarekEncodeMbps1
#define kRegSarekEncodeMbps1
Definition: ntv2registersmb.h:157
SAREK_2022_6
#define SAREK_2022_6
Definition: ntv2registersmb.h:198
PTS_OFFSET
#define PTS_OFFSET
Definition: ntv2configts2022.h:38
kRegTsTimerJ2kTsGenTc
#define kRegTsTimerJ2kTsGenTc
Definition: ntv2registers2022.h:313
j2kEncoderConfig
Definition: ntv2config2022.h:87
SAREK_IPX_J2K_DECODER_1
#define SAREK_IPX_J2K_DECODER_1
Definition: ntv2registers2022.h:34
j2kDecoderStatus::availableProgramNumbers
std::vector< uint32_t > availableProgramNumbers
Definition: ntv2config2022.h:143
kRegSarekFwCfg
#define kRegSarekFwCfg
Definition: ntv2registersmb.h:105
SAREK_TS_ENCODER_2
#define SAREK_TS_ENCODER_2
Definition: ntv2registers2022.h:32
PESGen::_ptsOffset
int32_t _ptsOffset
Definition: ntv2tshelper.h:275
CNTV2ConfigTs2022::CNTV2ConfigTs2022
CNTV2ConfigTs2022(CNTV2Card &device)
Definition: ntv2configts2022.cpp:28
j2kEncoderConfig::mbps
uint32_t mbps
Specifies the mbits per-second for J2K encode.
Definition: ntv2config2022.h:101
NTV2_CHANNEL2
@ NTV2_CHANNEL2
Specifies channel or Frame Store 2 (or the 2nd item).
Definition: ntv2enums.h:1308
SAREK_REGS2
#define SAREK_REGS2
Definition: ntv2registersmb.h:58
PMTGen::_videoStreamData
TsVideoStreamData _videoStreamData
Definition: ntv2tshelper.h:570
PESGen
Definition: ntv2tshelper.h:266
CNTV2MailBox::mDevice
CNTV2Card & mDevice
Definition: ntv2mailbox.h:79
NTV2_MAX_NUM_AudioSystemEnums
@ NTV2_MAX_NUM_AudioSystemEnums
Definition: ntv2enums.h:3819
j2kDecoderStatus::numAvailablePrograms
uint32_t numAvailablePrograms
Definition: ntv2config2022.h:141
kRegSarekAudioPIDs
#define kRegSarekAudioPIDs
Definition: ntv2registersmb.h:147
AUF1_OFFSET
#define AUF1_OFFSET
Definition: ntv2configts2022.h:40
CNTV2MacDriverInterface::ReadRegister
virtual bool ReadRegister(const ULWord inRegNum, ULWord &outValue, const ULWord inMask=0xFFFFFFFF, const ULWord inShift=0)
Reads all or part of the 32-bit contents of a specific register (real or virtual) on the AJA device....
Definition: ntv2macdriverinterface.cpp:709
NTV2FormatDescriptor
Describes a video frame for a given video standard or format and pixel format, including the total nu...
Definition: ntv2formatdescriptor.h:41
J2K_TS_OFFSET
#define J2K_TS_OFFSET
Definition: ntv2configts2022.h:39
NTV2_VIDEO_FORMAT_HAS_PROGRESSIVE_PICTURE
#define NTV2_VIDEO_FORMAT_HAS_PROGRESSIVE_PICTURE(__f__)
Definition: ntv2enums.h:1008
NTV2Channel
NTV2Channel
These enum values are mostly used to identify a specific Frame Store. They're also commonly used to i...
Definition: ntv2enums.h:1305
PESGen::calcPatPmtPeriod
int32_t calcPatPmtPeriod()
Definition: ntv2tshelper.h:495
ENCODER_1_RESET
#define ENCODER_1_RESET
Definition: ntv2registersmb.h:191
J2KChromaSubSampling
J2KChromaSubSampling
Definition: ntv2tshelper.h:75
GetNTV2FrameRateFromVideoFormat
NTV2FrameRate GetNTV2FrameRateFromVideoFormat(const NTV2VideoFormat inVideoFormat)
Definition: ntv2utils.cpp:3530
kRegSarekEncodeProgramPid1
#define kRegSarekEncodeProgramPid1
Definition: ntv2registersmb.h:160
kRegTsTimerJ2kTsPtsMux
#define kRegTsTimerJ2kTsPtsMux
Definition: ntv2registers2022.h:314
j2kEncoderConfig::videoPid
uint32_t videoPid
Specifies the PID for the video.
Definition: ntv2config2022.h:105
systemtime.h
Declares the AJATime class.
kRegSarekEncodeUllMode1
#define kRegSarekEncodeUllMode1
Definition: ntv2registersmb.h:154
kRegSarekPGMNums
#define kRegSarekPGMNums
Definition: ntv2registersmb.h:145
TsEncapStreamData::width
uint32_t width
Definition: ntv2tshelper.h:101
ntv2endian.h
Defines a number of handy byte-swapping macros.
kRegTsJ2kEncoderFlushTimeout
#define kRegTsJ2kEncoderFlushTimeout
Definition: ntv2registers2022.h:319
NTV2_AUDIOSYSTEM_1
@ NTV2_AUDIOSYSTEM_1
This identifies the first Audio System.
Definition: ntv2enums.h:3811
PESGen::_j2kTsOffset
int32_t _j2kTsOffset
Definition: ntv2tshelper.h:276
CNTV2ConfigTs2022::GetJ2KDecoderStatus
bool GetJ2KDecoderStatus(j2kDecoderStatus &status)
Definition: ntv2configts2022.cpp:391
kRegSarekEncodeAudioChannels1
#define kRegSarekEncodeAudioChannels1
Definition: ntv2registersmb.h:159
PESGen::_elemNumToPID
std::map< uint16_t, uint16_t > _elemNumToPID
Definition: ntv2tshelper.h:270
kRegTsJ2kEncoderInterlacedVideo
#define kRegTsJ2kEncoderInterlacedVideo
Definition: ntv2registers2022.h:318
kRegSarekAudioNumSelect
#define kRegSarekAudioNumSelect
Definition: ntv2registersmb.h:140
kRegTsJ2kEncoderHostEn
#define kRegTsJ2kEncoderHostEn
Definition: ntv2registers2022.h:317
j2kDecoderConfig::programPID
uint32_t programPID
Definition: ntv2config2022.h:131
NTV2IpErrUllNotSupported
@ NTV2IpErrUllNotSupported
Definition: ntv2enums.h:4232
kRegSarekEncodeChromaSubSamp1
#define kRegSarekEncodeChromaSubSamp1
Definition: ntv2registersmb.h:156
kRegSarekNumPGMs
#define kRegSarekNumPGMs
Definition: ntv2registersmb.h:142
TsEncapStreamData::numFrameRate
uint32_t numFrameRate
Definition: ntv2tshelper.h:104
j2kEncoderConfig::streamType
J2KStreamType streamType
Specifies the stream type for J2K encode.
Definition: ntv2config2022.h:102
j2kEncoderConfig::audioChannels
uint32_t audioChannels
Specifies the number of audio channels for J2K encode, a value of 0 indicates no audio.
Definition: ntv2config2022.h:103
NTV2_CHANNEL1
@ NTV2_CHANNEL1
Specifies channel or Frame Store 1 (or the first item).
Definition: ntv2enums.h:1307
ENCODER_2_RESET
#define ENCODER_2_RESET
Definition: ntv2registersmb.h:196
GetFramesPerSecond
double GetFramesPerSecond(const NTV2FrameRate inFrameRate)
Definition: ntv2utils.cpp:1737
kRegSarekEncodeStreamType1
#define kRegSarekEncodeStreamType1
Definition: ntv2registersmb.h:158
kRegJ2kT0CmdFIFO
#define kRegJ2kT0CmdFIFO
Definition: ntv2registers2022.h:256
NTV2FrameRate
NTV2FrameRate
Identifies a particular video frame rate.
Definition: ntv2enums.h:396
TsEncapStreamData::audio1Pid
uint32_t audio1Pid
Definition: ntv2tshelper.h:109
CNTV2ConfigTs2022::SetupJ2KEncoder
bool SetupJ2KEncoder(const NTV2Channel channel, const j2kEncoderConfig &config)
Definition: ntv2configts2022.cpp:36
PATGen::makePacket
int makePacket()
Definition: ntv2tshelper.h:527
HOST_EN
#define HOST_EN
Definition: ntv2configts2022.h:43
kJ2KStreamTypeNonElsm
@ kJ2KStreamTypeNonElsm
Definition: ntv2tshelper.h:72
TsVideoStreamData::width
uint32_t width
Definition: ntv2tshelper.h:117
PESGen::makePacket
int makePacket()
Definition: ntv2tshelper.h:308
kRegJ2kT0MainCsr
#define kRegJ2kT0MainCsr
Definition: ntv2registers2022.h:254
TsVideoStreamData::denFrameRate
uint32_t denFrameRate
Definition: ntv2tshelper.h:119
kRegTsAesEncapNumChannels
#define kRegTsAesEncapNumChannels
Definition: ntv2registers2022.h:363
PES_HDR_LOOKUP
#define PES_HDR_LOOKUP
Definition: ntv2configts2022.h:36
kipdprintf
#define kipdprintf(_format_...)
Definition: ntv2tshelper.h:46
TsEncapStreamData::pcrPid
uint32_t pcrPid
Definition: ntv2tshelper.h:108
ENCODER_2_ENABLE
#define ENCODER_2_ENABLE
Definition: ntv2registersmb.h:192
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
PMTGen::_progNumToPID
std::map< uint16_t, uint16_t > _progNumToPID
Definition: ntv2tshelper.h:571
j2kEncoderConfig::bitDepth
uint32_t bitDepth
Specifies the bit depth for J2K encode.
Definition: ntv2config2022.h:99
j2kDecoderStatus
Definition: ntv2config2022.h:135
NTV2Standard
NTV2Standard
Identifies a particular video standard.
Definition: ntv2enums.h:153
NTV2IpErrInvalidChannel
@ NTV2IpErrInvalidChannel
Definition: ntv2enums.h:4227
CNTV2ConfigTs2022::ReadbackJ2KEncoder
bool ReadbackJ2KEncoder(const NTV2Channel channel, j2kEncoderConfig &config)
Definition: ntv2configts2022.cpp:154
ENCODE_TS_TIMER
#define ENCODE_TS_TIMER
Definition: ntv2configts2022.h:20
TsEncapStreamData::height
uint32_t height
Definition: ntv2tshelper.h:102
kTsEncapTypePcr
@ kTsEncapTypePcr
Definition: ntv2tshelper.h:94
NTV2IpErrNone
@ NTV2IpErrNone
Definition: ntv2enums.h:4226
PATGen::_progNumToPID
std::map< uint16_t, uint16_t > _progNumToPID
Definition: ntv2tshelper.h:510
PESGen::_auf1Offset
int32_t _auf1Offset
Definition: ntv2tshelper.h:277
TsVideoStreamData::numAudioChannels
uint32_t numAudioChannels
Definition: ntv2tshelper.h:121
CNTV2ConfigTs2022::getLastErrorCode
NTV2IpError getLastErrorCode()
Definition: ntv2configts2022.cpp:606
ntv2card.h
Declares the CNTV2Card class.
j2kDecoderStatus::numAvailableAudios
uint32_t numAvailableAudios
Definition: ntv2config2022.h:142
kRegSarekControl
#define kRegSarekControl
Definition: ntv2registersmb.h:73
ADPGen::makePacket
int makePacket()
Definition: ntv2tshelper.h:795
TsEncapStreamData
Definition: ntv2tshelper.h:98
TsVideoStreamData::height
uint32_t height
Definition: ntv2tshelper.h:118
NTV2IpErrInvalidUllLevels
@ NTV2IpErrInvalidUllLevels
Definition: ntv2enums.h:4231
PES_HDR_LEN
#define PES_HDR_LEN
Definition: ntv2configts2022.h:37
kRegSarekHostSeqNum
#define kRegSarekHostSeqNum
Definition: ntv2registersmb.h:136
SAREK_REGS
#define SAREK_REGS
Definition: ntv2registersmb.h:54
TsEncapStreamData::videoPid
uint32_t videoPid
Definition: ntv2tshelper.h:107
TsVideoStreamData::numFrameRate
uint32_t numFrameRate
Definition: ntv2tshelper.h:120
kRegTsAesEncapHostEn
#define kRegTsAesEncapHostEn
Definition: ntv2registers2022.h:371
TSGenerator::dump32
void dump32()
Definition: ntv2tshelper.h:237
TsEncapStreamData::j2kStreamType
J2KStreamType j2kStreamType
Definition: ntv2tshelper.h:100
ntv2utils.h
Declares numerous NTV2 utility functions.
j2kEncoderConfig::ullMode
uint32_t ullMode
Specifies the ull mode for J2K encode.
Definition: ntv2config2022.h:98
PMTGen::_videoNumToPID
std::map< uint16_t, uint16_t > _videoNumToPID
Definition: ntv2tshelper.h:573
j2kDecoderStatus::availableAudioPIDs
std::vector< uint32_t > availableAudioPIDs
Definition: ntv2config2022.h:145
CNTV2Card
I interrogate and control an AJA video/audio capture/playout device.
Definition: ntv2card.h:262
TsVideoStreamData::j2kStreamType
J2KStreamType j2kStreamType
Definition: ntv2tshelper.h:116
TSGenerator::_tsEncapType
TsEncapType _tsEncapType
Definition: ntv2tshelper.h:132
INTERLACED_VIDEO
#define INTERLACED_VIDEO
Definition: ntv2configts2022.h:44
j2kDecoderConfig
Definition: ntv2config2022.h:110
ENCODER_2_MD_ENABLE
#define ENCODER_2_MD_ENABLE
Definition: ntv2registersmb.h:193
TSGenerator::_pkt32
uint32_t _pkt32[188]
Definition: ntv2tshelper.h:136
kRegJ2kPopMainCsr
#define kRegJ2kPopMainCsr
Definition: ntv2registers2022.h:280
PMTGen::_audioNumToPID
std::map< uint16_t, uint16_t > _audioNumToPID
Definition: ntv2tshelper.h:574
kRegSarekEncodeVideoPid1
#define kRegSarekEncodeVideoPid1
Definition: ntv2registersmb.h:161
CNTV2Card::SetAudio20BitMode
virtual bool SetAudio20BitMode(const NTV2AudioSystem inAudioSystem, const bool inEnable)
Enables or disables 20-bit mode for the NTV2AudioSystem.
Definition: ntv2audio.cpp:1188
ENCODE_TS_AES_ENCAP
#define ENCODE_TS_AES_ENCAP
Definition: ntv2configts2022.h:23
TsEncapStreamData::interlaced
bool interlaced
Definition: ntv2tshelper.h:110
CNTV2MailBox::mIpErrorCode
NTV2IpError mIpErrorCode
Definition: ntv2mailbox.h:81
kRegJ2kT0StatusFIFO
#define kRegJ2kT0StatusFIFO
Definition: ntv2registers2022.h:257
kRegSarekProgNumSelect
#define kRegSarekProgNumSelect
Definition: ntv2registersmb.h:138
ENCODE_TS_MPEG_J2K_ENCAP
#define ENCODE_TS_MPEG_J2K_ENCAP
Definition: ntv2configts2022.h:22
ADPGen
Definition: ntv2tshelper.h:775
J2KStreamType
J2KStreamType
Definition: ntv2tshelper.h:69
IsVideoFormatJ2KSupported
bool IsVideoFormatJ2KSupported(const NTV2VideoFormat format)
Definition: ntv2utils.cpp:5501
SAREK_J2K_ENCODER_1
#define SAREK_J2K_ENCODER_1
Definition: ntv2registers2022.h:29
CNTV2ConfigTs2022::ReadbackJ2KDecoder
bool ReadbackJ2KDecoder(j2kDecoderConfig &config)
Definition: ntv2configts2022.cpp:381
ntv2formatdescriptor.h
Declares the NTV2FormatDescriptor class.
j2kDecoderConfig::audioNumber
uint32_t audioNumber
Definition: ntv2config2022.h:132
ENCODE_TS_MPEG_AES_ENCAP
#define ENCODE_TS_MPEG_AES_ENCAP
Definition: ntv2configts2022.h:24
ENCODER_1_MD_ENABLE
#define ENCODER_1_MD_ENABLE
Definition: ntv2registersmb.h:187
kRegJ2kPrpMainCsr
#define kRegJ2kPrpMainCsr
Definition: ntv2registers2022.h:274
NTV2_FBF_10BIT_YCBCR
@ NTV2_FBF_10BIT_YCBCR
See 10-Bit YCbCr Format.
Definition: ntv2enums.h:210
PESGen::_auf2Offset
int32_t _auf2Offset
Definition: ntv2tshelper.h:278
NTV2IpErrInvalidBitdepth
@ NTV2IpErrInvalidBitdepth
Definition: ntv2enums.h:4229
kTsEncapTypeJ2k
@ kTsEncapTypeJ2k
Definition: ntv2tshelper.h:93
kRegSarekEncodePcrPid1
#define kRegSarekEncodePcrPid1
Definition: ntv2registersmb.h:162
PMTGen::_pcrNumToPID
std::map< uint16_t, uint16_t > _pcrNumToPID
Definition: ntv2tshelper.h:572
CNTV2MBController
Definition: ntv2mbcontroller.h:128
kRegSarekEncodeVideoFormat1
#define kRegSarekEncodeVideoFormat1
Definition: ntv2registersmb.h:153
j2kEncoderConfig::pmtPid
uint32_t pmtPid
Specifies the PID for the PMT.
Definition: ntv2config2022.h:104
kRegTsTimerJ2kTsLoad
#define kRegTsTimerJ2kTsLoad
Definition: ntv2registers2022.h:312
ENCODE_TS_MPEG_PCR_ENCAP
#define ENCODE_TS_MPEG_PCR_ENCAP
Definition: ntv2configts2022.h:26
SAREK_TS_ENCODER_1
#define SAREK_TS_ENCODER_1
Definition: ntv2registers2022.h:30
PAYLOAD_PARAMS
#define PAYLOAD_PARAMS
Definition: ntv2configts2022.h:45
SAREK_J2K_ENCODER_2
#define SAREK_J2K_ENCODER_2
Definition: ntv2registers2022.h:31
NTV2IpError
NTV2IpError
Definition: ntv2enums.h:4224
TsVideoStreamData::interlaced
bool interlaced
Definition: ntv2tshelper.h:122
kRegSarekEncodeBitDepth1
#define kRegSarekEncodeBitDepth1
Definition: ntv2registersmb.h:155
CNTV2ConfigTs2022::SetupJ2KDecoder
bool SetupJ2KDecoder(const j2kDecoderConfig &config)
Definition: ntv2configts2022.cpp:364
ADPGen::_elemNumToPID
std::map< uint16_t, uint16_t > _elemNumToPID
Definition: ntv2tshelper.h:778
NTV2VideoFormat
enum _NTV2VideoFormat NTV2VideoFormat
Identifies a particular video format.
J2KCodeBlocksize
J2KCodeBlocksize
Definition: ntv2tshelper.h:82
AUF2_OFFSET
#define AUF2_OFFSET
Definition: ntv2configts2022.h:41
MODE_STOP
#define MODE_STOP
Definition: ntv2configts2022.h:53
j2kEncoderConfig::videoFormat
NTV2VideoFormat videoFormat
Specifies the video format for J2K encode.
Definition: ntv2config2022.h:97
kRegJ2kT0Framecount
#define kRegJ2kT0Framecount
Definition: ntv2registers2022.h:258
TsEncapStreamData::denFrameRate
uint32_t denFrameRate
Definition: ntv2tshelper.h:103
NTV2IpErrInvalidUllHeight
@ NTV2IpErrInvalidUllHeight
Definition: ntv2enums.h:4230
MODE_RECORD
#define MODE_RECORD
Definition: ntv2configts2022.h:54
TsEncapStreamData::numAudioChannels
uint32_t numAudioChannels
Definition: ntv2tshelper.h:105
TSGenerator::dump8
void dump8()
Definition: ntv2tshelper.h:224
PMTGen
Definition: ntv2tshelper.h:567
GetNTV2StandardFromVideoFormat
NTV2Standard GetNTV2StandardFromVideoFormat(const NTV2VideoFormat inVideoFormat)
Definition: ntv2utils.cpp:2277
j2kEncoderConfig::chromaSubsamp
J2KChromaSubSampling chromaSubsamp
Specifies the chroma sub sampling for J2K encode.
Definition: ntv2config2022.h:100
PAT_TABLE_LOOKUP
#define PAT_TABLE_LOOKUP
Definition: ntv2configts2022.h:47
PESGen::_videoStreamData
TsVideoStreamData _videoStreamData
Definition: ntv2tshelper.h:269
PMT_TABLE_LOOKUP
#define PMT_TABLE_LOOKUP
Definition: ntv2configts2022.h:49
PACKET_RATE
#define PACKET_RATE
Definition: ntv2configts2022.h:42
kRegSarekModeSelect
#define kRegSarekModeSelect
Definition: ntv2registersmb.h:137
j2kDecoderStatus::availableProgramPIDs
std::vector< uint32_t > availableProgramPIDs
Definition: ntv2config2022.h:144
kRegSarekPGMPIDs
#define kRegSarekPGMPIDs
Definition: ntv2registersmb.h:146
kRegSarekProgPIDSelect
#define kRegSarekProgPIDSelect
Definition: ntv2registersmb.h:139
j2kDecoderConfig::programNumber
uint32_t programNumber
Definition: ntv2config2022.h:130
TSGenerator::_pkt8
uint8_t _pkt8[188]
Definition: ntv2tshelper.h:135
NTV2IpErrInvalidFormat
@ NTV2IpErrInvalidFormat
Definition: ntv2enums.h:4228
j2kEncoderConfig::pcrPid
uint32_t pcrPid
Specifies the PID for the PCR.
Definition: ntv2config2022.h:106
BIT
#define BIT(_x_)
Definition: ajatypes.h:654
NTV2AudioSystem
NTV2AudioSystem
Used to identify an Audio System on an NTV2 device. See Audio System Operation for more information.
Definition: ntv2enums.h:3809
ntv2configts2022.h
Declares the CNTV2ConfigTs2022 class.
PATGen
Definition: ntv2tshelper.h:506
j2kEncoderConfig::audio1Pid
uint32_t audio1Pid
Specifies the PID for audio 1.
Definition: ntv2config2022.h:107
PAT_PMT_PERIOD
#define PAT_PMT_PERIOD
Definition: ntv2configts2022.h:48
kRegSarekEncodeAudio1Pid1
#define kRegSarekEncodeAudio1Pid1
Definition: ntv2registersmb.h:163
j2kDecoderStatus::init
void init()
Definition: ntv2config2022.cpp:194
SAREK_2022_2
#define SAREK_2022_2
Definition: ntv2registersmb.h:199
ENCODER_1_ENABLE
#define ENCODER_1_ENABLE
Definition: ntv2registersmb.h:186
CNTV2MacDriverInterface::WriteRegister
virtual bool WriteRegister(const ULWord inRegNum, const ULWord inValue, const ULWord inMask=0xFFFFFFFF, const ULWord inShift=0)
Updates or replaces all or part of the 32-bit contents of a specific register (real or virtual) on th...
Definition: ntv2macdriverinterface.cpp:754
TsEncapStreamData::programPid
uint32_t programPid
Definition: ntv2tshelper.h:106
ADAPTATION_HDR_LENGTH
#define ADAPTATION_HDR_LENGTH
Definition: ntv2configts2022.h:51
j2kDecoderConfig::selectionMode
eProgSelMode_t selectionMode
Definition: ntv2config2022.h:129
kJ2KCodeBlocksize_32x32
@ kJ2KCodeBlocksize_32x32
Definition: ntv2tshelper.h:84
WAIT_RESET_MS
#define WAIT_RESET_MS
PMTGen::makePacket
int makePacket()
Definition: ntv2tshelper.h:594