From 4056fd0f5c2554a04ab7e9ec48b4cc219523aaee Mon Sep 17 00:00:00 2001 From: f4exb Date: Wed, 8 Mar 2017 23:26:58 +0100 Subject: [PATCH] ATV Modulator: more generic synchro timings --- plugins/channeltx/modatv/atvmod.cpp | 6 +- plugins/channeltx/modatv/atvmod.h | 194 +++++++++++++++++----------- 2 files changed, 123 insertions(+), 77 deletions(-) diff --git a/plugins/channeltx/modatv/atvmod.cpp b/plugins/channeltx/modatv/atvmod.cpp index 7219b4c77..251b3b2ee 100644 --- a/plugins/channeltx/modatv/atvmod.cpp +++ b/plugins/channeltx/modatv/atvmod.cpp @@ -331,11 +331,12 @@ void ATVMod::applyStandard() // what is left in a 64/1.008 us line for the image m_pointsPerImgLine = 64 * m_pointsPerTU - m_pointsPerSync - m_pointsPerBP - m_pointsPerFP; m_nbLines = 525; - m_nbLines2 = 262; + m_nbLines2 = 263; m_nbImageLines = 510; m_nbImageLines2 = 255; m_interlaced = true; m_nbHorizPoints = 64 * m_pointsPerTU; // full line + m_nbSyncLinesH = 5; m_nbBlankLines = 15; // yields 480 lines (255 - 15) * 2 m_pointsPerHBar = m_pointsPerImgLine / m_nbBars; m_linesPerVBar = m_nbImageLines2 / m_nbBars; @@ -351,11 +352,12 @@ void ATVMod::applyStandard() // what is left in a 64 us line for the image m_pointsPerImgLine = 64 * m_pointsPerTU - m_pointsPerSync - m_pointsPerBP - m_pointsPerFP; m_nbLines = 625; - m_nbLines2 = 312; + m_nbLines2 = 313; m_nbImageLines = 610; m_nbImageLines2 = 305; m_interlaced = true; m_nbHorizPoints = 64 * m_pointsPerTU; // full line + m_nbSyncLinesH = 5; m_nbBlankLines = 17; // yields 576 lines (305 - 17) * 2 m_pointsPerHBar = m_pointsPerImgLine / m_nbBars; m_linesPerVBar = m_nbImageLines2 / m_nbBars; diff --git a/plugins/channeltx/modatv/atvmod.h b/plugins/channeltx/modatv/atvmod.h index 52c554d82..ba95f884f 100644 --- a/plugins/channeltx/modatv/atvmod.h +++ b/plugins/channeltx/modatv/atvmod.h @@ -198,6 +198,7 @@ private: uint32_t m_nbImageLines; //!< number of image lines excluding synchronization lines uint32_t m_nbImageLines2; //!< same number as above (non interlaced) or half the number above (interlaced) uint32_t m_nbHorizPoints; //!< number of line points per horizontal line + uint32_t m_nbSyncLinesH; //!< number of header sync lines uint32_t m_nbBlankLines; //!< number of lines in a frame (full or half) that are blanked (black) at the top of the image float m_hBarIncrement; //!< video level increment at each horizontal bar increment float m_vBarIncrement; //!< video level increment at each vertical bar increment @@ -242,6 +243,8 @@ private: { int pointIndex = m_horizontalCount - (m_pointsPerSync + m_pointsPerBP); int iLine = m_lineCount % m_nbLines2; + int oddity = m_lineCount < m_nbLines2 ? 0 : 1; + int iLineImage = iLine - m_nbSyncLinesH - m_nbBlankLines; switch(m_running.m_atvModInput) { @@ -252,7 +255,6 @@ private: sample = (iLine / m_linesPerVBar) * m_vBarIncrement + m_blackLevel; break; case ATVModInputChessboard: - sample = (((iLine / m_linesPerVBar)*5 + (pointIndex / m_pointsPerHBar)) % 2) * m_spanLevel * m_running.m_uniformLevel + m_blackLevel; break; case ATVModInputHGradient: @@ -262,6 +264,16 @@ private: sample = ((iLine -5) / (float) m_nbImageLines2) * m_spanLevel + m_blackLevel; break; case ATVModInputImage: + if (!m_imageOK || (iLineImage < 0)) + { + sample = m_spanLevel * m_running.m_uniformLevel + m_blackLevel; + } + else + { + unsigned char pixv = m_image.at(2*iLineImage+ oddity, pointIndex); // row (y), col (x) + sample = (pixv / 256.0f) * m_spanLevel + m_blackLevel; + } + break; case ATVModInputUniform: default: sample = m_spanLevel * m_running.m_uniformLevel + m_blackLevel; @@ -275,93 +287,125 @@ private: inline void pullVSyncLine(Real& sample) { - switch (m_lineCount) - { - case 0: - case 1: - case 313: - case 314: // Whole line "long" pulses - { - int halfIndex = m_horizontalCount % (m_nbHorizPoints/2); + int fieldLine = m_lineCount % m_nbLines2; - if (halfIndex < (m_nbHorizPoints/2) - m_pointsPerSync) // ultra-black + if (m_lineCount < m_nbLines2) // even + { + if (fieldLine < 2) // 0,1: Whole line "long" pulses { - sample = 0.0f; + int halfIndex = m_horizontalCount % (m_nbHorizPoints/2); + + if (halfIndex < (m_nbHorizPoints/2) - m_pointsPerSync) // ultra-black + { + sample = 0.0f; + } + else // black + { + sample = m_blackLevel; + } } - else // black + else if (fieldLine == 2) // long pulse then equalizing pulse { - sample = m_blackLevel; + if (m_horizontalCount < (m_nbHorizPoints/2) - m_pointsPerSync) + { + sample = 0.0f; // ultra-black + } + else if (m_horizontalCount < (m_nbHorizPoints/2)) + { + sample = m_blackLevel; // black + } + else if (m_horizontalCount < (m_nbHorizPoints/2) + m_pointsPerFSync) + { + sample = 0.0f; // ultra-black + } + else + { + sample = m_blackLevel; // black + } + } + else if ((fieldLine < 5) || (fieldLine > m_nbLines2 - 3)) // Whole line equalizing pulses + { + int halfIndex = m_horizontalCount % (m_nbHorizPoints/2); + + if (halfIndex < m_pointsPerFSync) // ultra-black + { + sample = 0.0f; + } + else // black + { + sample = m_blackLevel; + } + } + else // black images + { + if (m_horizontalCount < m_pointsPerSync) + { + sample = 0.0f; + } + else + { + sample = m_blackLevel; + } } } - break; - case 3: - case 4: - case 310: - case 311: - case 315: - case 316: - case 622: - case 623: - case 624: // Whole line equalizing pulses + else // odd { - int halfIndex = m_horizontalCount % (m_nbHorizPoints/2); + if (fieldLine < 1) // equalizing pulse then long pulse + { + if (m_horizontalCount < m_pointsPerFSync) + { + sample = 0.0f; // ultra-black + } + else if (m_horizontalCount < (m_nbHorizPoints/2)) + { + sample = m_blackLevel; // black + } + else if (m_horizontalCount < m_nbHorizPoints - m_pointsPerSync) + { + sample = 0.0f; // ultra-black + } + else + { + sample = m_blackLevel; // black + } + } + else if (fieldLine < 3) // Whole line "long" pulses + { + int halfIndex = m_horizontalCount % (m_nbHorizPoints/2); - if (halfIndex < m_pointsPerFSync) // ultra-black - { - sample = 0.0f; + if (halfIndex < (m_nbHorizPoints/2) - m_pointsPerSync) // ultra-black + { + sample = 0.0f; + } + else // black + { + sample = m_blackLevel; + } } - else // black + else if ((fieldLine < 5) || (fieldLine > m_nbLines2 - 5)) // Whole line equalizing pulses { - sample = m_blackLevel; + int halfIndex = m_horizontalCount % (m_nbHorizPoints/2); + + if (halfIndex < m_pointsPerFSync) // ultra-black + { + sample = 0.0f; + } + else // black + { + sample = m_blackLevel; + } } - } - break; - case 2: // long pulse then equalizing pulse - if (m_horizontalCount < (m_nbHorizPoints/2) - m_pointsPerSync) + else // black images { - sample = 0.0f; // ultra-black + if (m_horizontalCount < m_pointsPerSync) + { + sample = 0.0f; + } + else + { + sample = m_blackLevel; + } } - else if (m_horizontalCount < (m_nbHorizPoints/2)) - { - sample = m_blackLevel; // black - } - else if (m_horizontalCount < (m_nbHorizPoints/2) + m_pointsPerFSync) - { - sample = 0.0f; // ultra-black - } - else - { - sample = m_blackLevel; // black - } - break; - case 312: // equalizing pulse then long pulse - if (m_horizontalCount < m_pointsPerFSync) - { - sample = 0.0f; // ultra-black - } - else if (m_horizontalCount < (m_nbHorizPoints/2)) - { - sample = m_blackLevel; // black - } - else if (m_horizontalCount < m_nbHorizPoints - m_pointsPerSync) - { - sample = 0.0f; // ultra-black - } - else - { - sample = m_blackLevel; // black - } - break; - default: // black images - if (m_horizontalCount < m_pointsPerSync) - { - sample = 0.0f; - } - else - { - sample = m_blackLevel; - } - break; } } };