136 if (pInAncData->GetLocationLineNumber() == 14 || pInAncData->GetLocationLineNumber() == 277)
169 uint8_t luma = pLine[pixelNum];
177 static void addToCRC (
const bool inBit, uint8_t & inOutCRC)
183 newBit = (inBit ? 0 : 1);
185 newBit = (inBit ? 1 : 0);
187 inOutCRC = (inOutCRC << 1) + newBit;
204 bool bResult =
false;
207 uint8_t tcData[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
224 uint32_t currIndex = 0;
234 if (!lastPixel && thisPixel)
252 for (uint8_t group = 0; group < 9; group++)
260 for (i = 1; i < 8; i++)
280 for (i = 0; i < 8; i++)
284 currIndex += (i%2 ? 8 : 7);
287 data = (bit ? 0x80 : 0) + (data >> 1);
292 tcData[group] = data;
301 else if (CRC == 0xFF)
307 else if (CRC == 0x0F)
358 #ifdef USE_SMPTE_266M
361 static inline void DoVITCPixel (uint8_t * pOutLine,
const uint32_t inPixelNum,
const uint8_t inLevel)
363 pOutLine[inPixelNum] = inLevel;
371 if (!bBit0 && !bBit1)
379 else if (!bBit0 && bBit1)
386 else if (bBit0 && !bBit1)
406 static void DoHalfTransition (uint8_t *pLine, uint32_t& pixelIndex,
bool bBit0,
bool bBit1)
408 if (!bBit0 && !bBit1)
415 else if (!bBit0 && bBit1)
421 else if (bBit0 && !bBit1)
438 static void DoVITCBitPair (uint8_t *pLine, uint32_t& pixelIndex,
bool bPrevBit,
bool bBit0,
bool bBit1)
469 uint32_t pixelIndex = 0;
472 bool bPrevBit =
false;
476 for (i = 0; i < 26; i++)
484 uint8_t tcData, bgData;
487 uint8_t data = (bgData << 4) + tcData;
496 for (bitPair = 0; bitPair < 4; bitPair++)
498 bBit0 = (data & 0x01) > 0;
499 bBit1 = (data & 0x02) > 0;
529 for (i = 0; i < 4; i++)
531 bBit0 = (CRC & 0x80) > 0;
532 bBit1 = (CRC & 0x40) > 0;
544 const uint32_t remainingPixels (GetDC() > pixelIndex ? GetDC() - pixelIndex : 0);
546 for (i = 0; i < (uint32_t)remainingPixels; i++)
554 #else // use original NTV2 VITC algorithm
558 static void DoVITCPixel (uint8_t *pLine, uint32_t pixelNum,
float level)
565 pLine[pixelNum] = luma;
570 static void DoNormalTransition (uint8_t *pLine, uint32_t& pixelIndex,
bool bBit0,
bool bBit1)
572 if (!bBit0 && !bBit1)
581 else if (!bBit0 && bBit1)
590 else if (bBit0 && !bBit1)
613 static void DoHalfTransition (uint8_t *pLine, uint32_t& pixelIndex,
bool bBit0,
bool bBit1)
615 if (!bBit0 && !bBit1)
623 else if (!bBit0 && bBit1)
631 else if (bBit0 && !bBit1)
651 static void DoVITCBitPair (uint8_t *pLine, uint32_t& pixelIndex,
bool bPrevBit,
bool bBit0,
bool bBit1,
bool bDropBit)
659 level = (bBit0 ? (float)1.0 : (
float)0.0);
668 level = (bBit1 ? (float)1.0 : (
float)0.0);
682 uint32_t pixelIndex = 0;
686 bool bPrevBit =
false;
687 bool bDropBit =
false;
691 for (i = 0; i < 24; i++)
699 uint8_t tcData, bgData;
702 uint8_t data = (bgData << 4) + tcData;
711 for (bitPair = 0; bitPair < 4; bitPair++)
713 bBit0 = (data & 0x01) > 0;
714 bBit1 = (data & 0x02) > 0;
717 bDropBit = (group % 2 && bitPair == 3);
719 DoVITCBitPair(pLine, pixelIndex, bPrevBit, bBit0, bBit1, bDropBit);
747 for (i = 0; i < 4; i++)
749 bBit0 = (CRC & 0x80) > 0;
750 bBit1 = (CRC & 0x40) > 0;
752 DoVITCBitPair(pLine, pixelIndex, bPrevBit, bBit0, bBit1, bDropBit);
763 int32_t remainingPixels = m_DC - pixelIndex;
765 if (remainingPixels > 0)
767 for (i = 0; i < (uint32_t)remainingPixels; i++)
774 #endif // !USE_SMPTE_266M