AJA NTV2 SDK  17.5.0.1242
NTV2 SDK 17.5.0.1242
timecodeburn.cpp
Go to the documentation of this file.
1 /* SPDX-License-Identifier: MIT */
7 #include "videoutilities.h"
8 #include "timecodeburn.h"
9 #include <string.h> //for memcpy
10 #include <stdio.h>
11 
12 
13 const int kTCDigColon = 10; // index of ':' character
14 const int kTCDigSemicolon = 11; // index of ';' character
15 //const int kTCDigDash = 12; // index of '-' character UNUSED
16 const int kTCDigSpace = 13; // index of ' ' character
17 //const int kTCDigAsterisk = 14; // index of '*' character UNUSED
18 const int kTCMaxTCChars = 15; // number of characters we know how to make
19 
20 
22  _bRendered(false),
23  _pCharRenderMap(NULL),
24  _charRenderPixelFormat(AJA_PixelFormat_Unknown),
25  _charRenderHeight(0),
26  _charRenderWidth(0),
27  _charWidthBytes(0),
28  _charHeightLines(0),
29  _charPositionX(0),
30  _charPositionY(0),
31  _rowBytes(0)
32 {
33 }
34 
36 {
37  if (_pCharRenderMap != NULL)
38  {
39  delete []_pCharRenderMap;
40  _pCharRenderMap = NULL;
41  }
42 }
43 
44 
45 bool AJATimeCodeBurn::BurnTimeCode (void * pBaseVideoAddress, const std::string & inTimeCodeStr, uint32_t percentY)
46 {
47  if ( !_bRendered )
48  return false; // Uninitialized
49  if (!pBaseVideoAddress)
50  return false; // NULL address
51 
52  const size_t timeCodeLength (inTimeCodeStr.length());
53  if (timeCodeLength > size_t(kTCMaxTCChars))
54  return false; // String too long
55 
56  if (percentY > 100)
57  percentY = 100; // Limit to 100%
58  else if (!percentY)
59  percentY = 80; // 0% ==> 80%
60 
61  _charPositionY = (_charRenderHeight * percentY) / 100;
62 
63  // 10-bit YUV has to start on a 16-byte boundary in order to match the "cadence"
64  if (_charRenderPixelFormat == AJA_PixelFormat_YCbCr10)
65  _charPositionX &= ~0x0f;
66 
67  char *pFrameBuff = reinterpret_cast<char*>(pBaseVideoAddress) + (_charPositionY * _rowBytes) + _charPositionX;
68 
69  for (size_t charNdx(0); charNdx < timeCodeLength; charNdx++)
70  {
71  const char currentChar (inTimeCodeStr[charNdx]);
72  uint32_t digitOffset (kTCDigSpace);
73  if ( currentChar >= '0' && currentChar <= '9' )
74  digitOffset = currentChar - '0';
75  else if ( currentChar == ':' )
76  digitOffset = kTCDigColon;
77  else if ( currentChar == ';' )
78  digitOffset = kTCDigSemicolon;
79 
80  CopyDigit (digitOffset, pFrameBuff);
81  pFrameBuff += _charWidthBytes;
82  }
83 
84  return true;
85 }
86 
87 
88 bool AJATimeCodeBurn::BurnTimeCode (char * pBaseVideoAddress, const char * pTimeCodeString , const uint32_t percentY)
89 {
90  return BurnTimeCode(pBaseVideoAddress, std::string(pTimeCodeString), percentY);
91 }
92 
93 void AJATimeCodeBurn::CopyDigit (int digitOffset,char *pFrameBuff)
94 {
95  char *pDigit = (_pCharRenderMap + (digitOffset * _charWidthBytes * _charHeightLines));
96 
97  for (int y = 0; y < _charHeightLines; y++)
98  {
99  char *pSrc = (pDigit + (y * _charWidthBytes));
100  char *pDst = (pFrameBuff + (y * _rowBytes));
101 
102  memcpy(pDst, pSrc, _charWidthBytes);
103  }
104 }
105 
106 
107 const int kTCNumBurnInChars = 11; // number of characters in burn-in display (assume "xx:xx:xx:xx")
108 
109 const int kTCDigitDotWidth = 24; // width of dot map for each character (NOTE: kDigitDotWidth must be evenly divisible by 6 if you want this to work for 10-bit YUV!)
110 const int kTCDigitDotHeight = 18; // height of dot map for each character
111 
112 
114 {
115 // '0'
116  {
117  {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
118  {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
119  {0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 3, 3, 3, 3, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0},
120  {0, 0, 0, 0, 1, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,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 3, 3, 3, 3, 3, 3, 3, 2, 1, 0, 0, 0, 0},
433  {0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 3, 3, 3, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0},
434  {0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 3, 2, 3, 2, 3, 3, 2, 1, 0, 0, 0, 0, 0, 0},
435  {0, 0, 0, 0, 0, 0, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 0, 0, 0, 0, 0},
436  {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0},
437  {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
438  {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
439  {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
440  {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
441  {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
442  {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
443  },
444 };
445 
446 
447 bool AJATimeCodeBurn::RenderTimeCodeFont( AJA_PixelFormat pixelFormat, uint32_t numPixels, uint32_t numLines )
448 {
449  bool bResult = true;
450 
451  // see if we've already rendered this format/size
452  if (_bRendered && _pCharRenderMap != NULL && pixelFormat == _charRenderPixelFormat && (int)numLines == _charRenderHeight && (int)numPixels == _charRenderWidth)
453  {
454  return bResult; // already rendered...
455  }
456 
457  else
458  {
459  // these are the pixel formats we know how to do...
460  bool bFormatOK = true;
461  _rowBytes = AJA_CalcRowBytesForFormat(pixelFormat,numPixels);
462  int bytesPerPixel;
463  switch (pixelFormat)
464  {
466  bytesPerPixel = 2;
467  break;
468 
470  bytesPerPixel = 2;
471  break;
472 
474  bytesPerPixel = 4;
475  break;
476 
478  bytesPerPixel = 4;
479  break;
480 
482  bytesPerPixel = 4;
483  break;
484 
486  bytesPerPixel = 3; // not really - we'll have to override this wherever "bytesPerPixel" is used below...
487  break;
488 
490  bytesPerPixel = 4;
491  break;
492 
494  bytesPerPixel = 4;
495  break;
496 
499  bytesPerPixel = 3;
500  break;
501 
504  bytesPerPixel = 2; // not really - we'll have to override this wherever "bytesPerPixel" is used below...
505  break;
506 
509  bytesPerPixel = 1;
510  break;
511 
512  default:
513  bFormatOK = false;
514  break;
515  }
516 
517  if (bFormatOK)
518  {
519  // scale the characters based on the frame size they'll be used in
520  int dotScale = 1; // SD scale
521  if (numLines > 900)
522  dotScale = 3; // HD 1080
523  else if (numLines > 650)
524  dotScale = 2; // HD 720
525 
526  int dotWidth = 1 * dotScale; // pixels per "dot"
527  int dotHeight = 2 * dotScale; // frame lines per "dot"
528 
529  // exceptions: if this is DVCProHD or HDV, we're working with horizontally-scaled pixels. Tweak the dotWidth to compensate.
530  if (numLines > 900 && numPixels <= 1440)
531  dotWidth = 2; // 1280x1080 or 1440x1080
532 
533  // else if (numLines > 650 && numPixels < 1100)
534  // dotWidth = 1; // 960x720
535 
536  int charWidthBytes = kTCDigitDotWidth * dotWidth * bytesPerPixel;
537  if (pixelFormat == AJA_PixelFormat_YCbCr10)
538  charWidthBytes = (kTCDigitDotWidth * dotWidth * 16) / 6; // note: assumes kDigitDotWidth is evenly divisible by 6!
539  if ((pixelFormat == AJA_PixelFormat_YCBCR10_420PL) ||
540  (pixelFormat == AJA_PixelFormat_YCBCR10_422PL))
541  charWidthBytes = (kTCDigitDotWidth * dotWidth * 5) / 4; // note: assumes kDigitDotWidth is evenly divisible by 4!
542 
543  int charHeightLines = kTCDigitDotHeight * dotHeight;
544 
545  // if we had a previous render map, free it now
546  if (_pCharRenderMap != NULL)
547  {
548  delete []_pCharRenderMap;
549  _pCharRenderMap = NULL;
550  }
551 
552  // malloc space for a new render map
553  _pCharRenderMap = new char[(kTCMaxTCChars * charWidthBytes * charHeightLines)];
554  if (_pCharRenderMap != NULL)
555  {
556  char *pRenderMap = _pCharRenderMap;
557 
558  // for each character...
559  for (int c = 0; c < kTCMaxTCChars; c++)
560  {
561  // for each scan line...
562  for (int y = 0; y < kTCDigitDotHeight; y++)
563  {
564  // each rendered line is duplicated N times
565  for (int ydup = 0; ydup < dotHeight; ydup++)
566  {
567  // each dot...
568  for (int x = 0; x < kTCDigitDotWidth; x++)
569  {
570  char dot = CharMap[c][y][x];
571 
572  if (pixelFormat == AJA_PixelFormat_YCbCr8)
573  {
574  char val = 0;
575  switch (dot)
576  {
577  case 0: val = char(0x040 >> 2); break; // 16
578  case 1: val = char(0x164 >> 2); break; // 89
579  case 2: val = char(0x288 >> 2); break; // 162
580  case 3: val = char(0x3AC >> 2); break; // 235
581  }
582 
583  // each rendered pixel is duplicated N times
584  for (int xdup = 0; xdup < dotWidth; xdup++)
585  {
586  *pRenderMap++ = char(0x80); // C
587  *pRenderMap++ = val; // Y
588  }
589  }
590 
591  else if (pixelFormat == AJA_PixelFormat_YUY28)
592  {
593  char val = 0;
594  switch (dot)
595  {
596  case 0: val = (char)0x10; break;
597  case 1: val = (char)0x4c; break;
598  case 2: val = (char)0x86; break;
599  case 3: val = (char)0xc0; break;
600  }
601 
602  // each rendered pixel is duplicated N times
603  for (int xdup = 0; xdup < dotWidth; xdup++)
604  {
605  *pRenderMap++ = val; // Y
606  *pRenderMap++ = (char)0x80; // C
607  }
608  }
609 
610  else if (pixelFormat == AJA_PixelFormat_YCbCr10)
611  {
612  int val = 0;
613  switch (dot)
614  {
615  case 0: val = 0x040; break; // 64
616  case 1: val = 0x164; break; // 356
617  case 2: val = 0x288; break; // 648
618  case 3: val = 0x3AC; break; // 940
619  }
620 
621  // each rendered pixel is duplicated N times
622  for (int xdup = 0; xdup < dotWidth; xdup++)
623  {
624  writeV210Pixel (&pRenderMap, ((x * dotWidth) + xdup), 0x200, val);
625  }
626  }
627 
628  else if (pixelFormat == AJA_PixelFormat_ABGR8 || pixelFormat == AJA_PixelFormat_ARGB8 )
629  {
630  char val = 0;
631  switch (dot)
632  {
633  case 0: val = (char)0x00; break;
634  case 1: val = (char)0x55; break;
635  case 2: val = (char)0xaa; break;
636  case 3: val = (char)0xff; break;
637  }
638 
639  // each rendered pixel is duplicated N times
640  for (int xdup = 0; xdup < dotWidth; xdup++)
641  {
642  *pRenderMap++ = val; // B
643  *pRenderMap++ = val; // G
644  *pRenderMap++ = val; // R
645  *pRenderMap++ = 0; // A
646  }
647  }
648 
649  else if ( pixelFormat == AJA_PixelFormat_RGBA8 )
650  {
651  char val = 0;
652  switch (dot)
653  {
654  case 0: val = (char)0x00; break;
655  case 1: val = (char)0x55; break;
656  case 2: val = (char)0xaa; break;
657  case 3: val = (char)0xff; break;
658  }
659 
660  // each rendered pixel is duplicated N times
661  for (int xdup = 0; xdup < dotWidth; xdup++)
662  {
663  *pRenderMap++ = 0; // A
664  *pRenderMap++ = val; // R
665  *pRenderMap++ = val; // G
666  *pRenderMap++ = val; // B
667  }
668  }
669 
670  else if ( pixelFormat == AJA_PixelFormat_RGB8_PACK || pixelFormat == AJA_PixelFormat_BGR8_PACK )
671  {
672  char val = 0;
673  switch (dot)
674  {
675  case 0: val = (char)0x00; break;
676  case 1: val = (char)0x55; break;
677  case 2: val = (char)0xaa; break;
678  case 3: val = (char)0xff; break;
679  }
680 
681  // each rendered pixel is duplicated N times
682  for (int xdup = 0; xdup < dotWidth; xdup++)
683  {
684  *pRenderMap++ = val; // R
685  *pRenderMap++ = val; // G
686  *pRenderMap++ = val; // B
687  }
688  }
689 
690  else if (pixelFormat == AJA_PixelFormat_RGB_DPX)
691  {
692  int val = 0;
693  switch (dot)
694  {
695  case 0: val = 64; break; // 0x40
696  case 1: val = 356; break; // 0x164
697  case 2: val = 648; break; // 0x288
698  case 3: val = 940; break; // 0x3ac
699  }
700 
701  // each rendered pixel is duplicated N times
702  for (int xdup = 0; xdup < dotWidth; xdup++)
703  {
704  *pRenderMap++ = ((val & 0x3fc) >> 2);
705  *pRenderMap++ = ((val & 0x003) << 6) | ((val & 0x3f0) >> 4);
706  *pRenderMap++ = ((val & 0x00f) << 4) | ((val & 0x3c0) >> 6);
707  *pRenderMap++ = ((val & 0x03f) << 2);
708  }
709  }
710  else if (pixelFormat == AJA_PixelFormat_RGB10)
711  {
712  int val = 0;
713  switch (dot)
714  {
715  case 0: val = 0x000; break;
716  case 1: val = 0x154; break;
717  case 2: val = 0x2a8; break;
718  case 3: val = 0x3ff; break;
719  }
720 
721  // each rendered pixel is duplicated N times
722  for (int xdup = 0; xdup < dotWidth; xdup++)
723  {
724  *pRenderMap++ = ((val & 0x0ff));
725  *pRenderMap++ = ((val & 0x03f) << 2) | ((val & 0x300) >> 8);
726  *pRenderMap++ = ((val & 0x00f) << 4) | ((val & 0x3c0) >> 6);
727  *pRenderMap++ = ((val & 0x3f0) >> 4) | 0x300;
728  }
729  }
730 
731  else if ((pixelFormat == AJA_PixelFormat_YCBCR10_420PL) ||
732  (pixelFormat == AJA_PixelFormat_YCBCR10_422PL))
733  {
734  int val = 0;
735  switch (dot)
736  {
737  case 0: val = 64; break;
738  case 1: val = 356; break;
739  case 2: val = 648; break;
740  case 3: val = 940; break;
741  }
742 
743  // each rendered pixel is duplicated N times
744  for (int xdup = 0; xdup < dotWidth; xdup++)
745  {
746  writeYCbCr10PackedPlanerPixel (&pRenderMap, ((x * dotWidth) + xdup), val);
747  }
748  }
749 
750  else if ((pixelFormat == AJA_PixelFormat_YCBCR8_420PL) ||
751  (pixelFormat == AJA_PixelFormat_YCBCR8_422PL))
752  {
753  char val = 0;
754  switch (dot)
755  {
756  case 0: val = (char)0x10; break;
757  case 1: val = (char)0x4c; break;
758  case 2: val = (char)0x86; break;
759  case 3: val = (char)0xc0; break;
760  }
761 
762  // each rendered pixel is duplicated N times
763  for (int xdup = 0; xdup < dotWidth; xdup++)
764  {
765  *pRenderMap++ = val; // Y
766  }
767  }
768 
769  }
770  }
771  }
772  }
773 
774  _bRendered = true;
775  _charRenderPixelFormat = pixelFormat;
776  _charRenderHeight = numLines;
777  _charRenderWidth = numPixels;
778 
779  // character sizes
780  _charWidthBytes = charWidthBytes;
781  _charHeightLines = charHeightLines;
782 
783  // burn-in offset
784  int byteWidth = (numPixels * bytesPerPixel);
785  if (pixelFormat == AJA_PixelFormat_YCbCr10)
786  byteWidth = (numPixels * 16) / 6; // in 10-bit YUV, 6 pixels = 16 bytes
787  if ((pixelFormat == AJA_PixelFormat_YCBCR10_420PL) ||
788  (pixelFormat == AJA_PixelFormat_YCBCR10_422PL))
789  byteWidth = (numPixels * 5) / 4; // in 10-bit YUV packed planer, 4 pixels = 5 bytes
790 
791  _charPositionX = (byteWidth - (kTCNumBurnInChars * charWidthBytes)) / 2; // assume centered
792  }
793  }
794 
795  else // we don't know how to do this pixel format...
796  bResult = false;
797  }
798 
799  return bResult;
800 }
801 
802 
803 // write a single chroma/luma pair of components
804 // note that it's up to the caller to make sure that the chroma is the correct Cb or Cr,
805 // and is properly timed with adjacent pixels!
806 void AJATimeCodeBurn::writeV210Pixel (char **pBytePtr, int x, int c, int y)
807 {
808  char *p = *pBytePtr;
809 
810  // the components in each v210 6-pixel block are laid out like this (note that the UInt32s are swixelled!):
811  //
812  // Addr: | 3 2 1 0 | 7 6 5 4 | 11 10 9 8 | 15 14 13 12 |
813  // { 00 Cr0 Y0 Cb0 00 Y2 Cb2 Y1 00 Cb4 Y3 Cr2 00 Y5 Cr4 Y4 }
814  //
815  int cadence = x % 3;
816 
817  switch (cadence)
818  {
819  case 0: // Cb0/Y0 or Cr2/Y3: we assume that p points to byte 0/8. When we are finished, it will still point to byte 0/8
820  p[0] = c & 0x0FF; // c<7:0>
821  p[1] = (( y & 0x03F) << 2) + (( c & 0x300) >> 8); // y<5:0> + c<9:8>
822  p[2] = (p[2] & 0x0F0) + (( y & 0x3C0) >> 6); // (merge) + y<9:6>
823  break;
824 
825  case 1: // Cr0/Y1 or Cb4/Y4: we assume that p points to byte 0/8. When we are finished, it will point to byte 4/12
826  p[2] = (( c & 0x00F) << 4) + (p[2] & 0x00F); // c<3:0> + (merge)
827  p[3] = (( c & 0x3F0) >> 4); // '00' + c<9:4>
828  p[4] = y & 0x0FF; // y<7:0>
829  p[5] = (p[5] & 0x0FC) + (( y & 0x300) >> 8); // (merge) + y<9:8>
830  *pBytePtr += 4;
831  break;
832 
833  case 2: // Cb2/Y2 or Cr4/Y5: we assume that p points to byte 4/12. When we are finished, it will point to byte 8/16
834  p[1] = (( c & 0x03F) << 2) + (p[1] & 0x003); // c<5:0> + (merge)
835  p[2] = (( y & 0x00F) << 4) + (( c & 0x3C0) >> 6); // y<3:0> + c<9:6>
836  p[3] = (( y & 0x3F0) >> 4); // '00' + y<9:4>
837  *pBytePtr += 4;
838  break;
839  }
840 }
841 
842 
843 // write a single luma components
844 void AJATimeCodeBurn::writeYCbCr10PackedPlanerPixel (char **pBytePtr, int x, int y)
845 {
846  char *p = *pBytePtr;
847 
848  int cadence = x % 4;
849 
850  switch (cadence)
851  {
852  case 0:
853  p[0] = (y & 0x0FF) << 0;;
854  p[1] = (y & 0x300) >> 8;
855  *pBytePtr += 1;
856  break;
857  case 1:
858  p[0] |= (y & 0x03F) << 2;
859  p[1] = (y & 0x3C0) >> 6;
860  *pBytePtr += 1;
861  break;
862  case 2:
863  p[0] |= (y & 0x00F) << 4;
864  p[1] = (y & 0x3F0) >> 4;
865  *pBytePtr += 1;
866  break;
867  case 3:
868  p[0] |= (y & 0x003) << 6;
869  p[1] = (y & 0x3FC) >> 2;
870  *pBytePtr += 2;
871  break;
872  }
873 }
AJA_PixelFormat_YCBCR10_422PL
@ AJA_PixelFormat_YCBCR10_422PL
Definition: videotypes.h:157
AJATimeCodeBurn::writeYCbCr10PackedPlanerPixel
void writeYCbCr10PackedPlanerPixel(char **pBytePtr, int x, int y)
Definition: timecodeburn.cpp:844
AJA_PixelFormat_ARGB8
@ AJA_PixelFormat_ARGB8
Definition: videotypes.h:126
AJA_PixelFormat_YUY28
@ AJA_PixelFormat_YUY28
Definition: videotypes.h:129
AJATimeCodeBurn::RenderTimeCodeFont
AJA_EXPORT bool RenderTimeCodeFont(AJA_PixelFormat pixelFormat, uint32_t numPixels, uint32_t numLines)
Definition: timecodeburn.cpp:447
NULL
#define NULL
Definition: ntv2caption608types.h:19
videoutilities.h
Declares the ajabase library's video utility functions.
AJA_PixelFormat_BGR8_PACK
@ AJA_PixelFormat_BGR8_PACK
Definition: videotypes.h:137
AJA_PixelFormat_YCbCr8
@ AJA_PixelFormat_YCbCr8
Definition: videotypes.h:125
AJATimeCodeBurn::AJATimeCodeBurn
AJA_EXPORT AJATimeCodeBurn(void)
Definition: timecodeburn.cpp:21
AJA_PixelFormat_RGB10
@ AJA_PixelFormat_RGB10
Definition: videotypes.h:128
AJATimeCodeBurn::BurnTimeCode
AJA_EXPORT bool BurnTimeCode(void *pBaseVideoAddress, const std::string &inTimeCodeStr, const uint32_t inYPercent)
Definition: timecodeburn.cpp:45
AJA_PixelFormat_YCBCR8_422PL
@ AJA_PixelFormat_YCBCR8_422PL
Definition: videotypes.h:159
kTCNumBurnInChars
const int kTCNumBurnInChars
Definition: timecodeburn.cpp:107
kTCDigColon
const int kTCDigColon
Definition: timecodeburn.cpp:13
timecodeburn.h
Declares the AJATimeCodeBurn class.
AJA_PixelFormat_RGB8_PACK
@ AJA_PixelFormat_RGB8_PACK
Definition: videotypes.h:136
CharMap
static const char CharMap[kTCMaxTCChars][kTCDigitDotHeight][kTCDigitDotWidth]
Definition: timecodeburn.cpp:113
AJA_PixelFormat_YCBCR10_420PL
@ AJA_PixelFormat_YCBCR10_420PL
Definition: videotypes.h:156
kTCDigitDotHeight
const int kTCDigitDotHeight
Definition: timecodeburn.cpp:110
AJA_PixelFormat_RGBA8
@ AJA_PixelFormat_RGBA8
Definition: videotypes.h:127
kTCMaxTCChars
const int kTCMaxTCChars
Definition: timecodeburn.cpp:18
AJA_PixelFormat_RGB_DPX
@ AJA_PixelFormat_RGB_DPX
Definition: videotypes.h:131
kTCDigSpace
const int kTCDigSpace
Definition: timecodeburn.cpp:16
false
#define false
Definition: ntv2devicefeatures.h:25
kTCDigitDotWidth
const int kTCDigitDotWidth
Definition: timecodeburn.cpp:109
AJA_PixelFormat_ABGR8
@ AJA_PixelFormat_ABGR8
Definition: videotypes.h:130
AJA_PixelFormat_Unknown
@ AJA_PixelFormat_Unknown
Definition: videotypes.h:123
AJATimeCodeBurn::~AJATimeCodeBurn
virtual AJA_EXPORT ~AJATimeCodeBurn(void)
Definition: timecodeburn.cpp:35
AJA_CalcRowBytesForFormat
uint32_t AJA_CalcRowBytesForFormat(AJA_PixelFormat format, uint32_t width)
Definition: videoutilities.cpp:174
AJA_PixelFormat_YCbCr10
@ AJA_PixelFormat_YCbCr10
Definition: videotypes.h:124
kTCDigSemicolon
const int kTCDigSemicolon
Definition: timecodeburn.cpp:14
AJA_PixelFormat
AJA_PixelFormat
Definition: videotypes.h:121
AJATimeCodeBurn::CopyDigit
void CopyDigit(int digitOffset, char *pFrameBuff)
Definition: timecodeburn.cpp:93
AJATimeCodeBurn::writeV210Pixel
void writeV210Pixel(char **pBytePtr, int x, int c, int y)
Definition: timecodeburn.cpp:806
AJA_PixelFormat_YCBCR8_420PL
@ AJA_PixelFormat_YCBCR8_420PL
Definition: videotypes.h:158