From 5cdcfdb9be43618369e1b89ef16e8f0c2216258d Mon Sep 17 00:00:00 2001 From: f4exb Date: Thu, 6 Apr 2017 05:11:48 +0200 Subject: [PATCH] ATV Demod: classical vsync enhanced hsync correction: correcting only once per full frame with amortizing --- plugins/channelrx/demodatv/atvdemod.h | 36 +++++++++++++++++---------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/plugins/channelrx/demodatv/atvdemod.h b/plugins/channelrx/demodatv/atvdemod.h index 672e31a64..6acc4e5f2 100644 --- a/plugins/channelrx/demodatv/atvdemod.h +++ b/plugins/channelrx/demodatv/atvdemod.h @@ -528,25 +528,34 @@ private: bool blnNewLine = false; + if (m_blnSynchroDetected) + { + m_intAvgColIndex = m_intSampleIndex - m_intColIndex - (m_intColIndex < m_intNumberSamplePerLine/2 ? 150 : 0); + //qDebug("HSync: %d %d %d", m_intSampleIndex, m_intColIndex, m_intAvgColIndex); + m_intSampleIndex = 0; + } + else + { + m_intSampleIndex++; + } + if (!m_objRunning.m_blnHSync && (m_intColIndex >= m_intNumberSamplePerLine)) // H Sync not active { m_intColIndex = 0; blnNewLine = true; } - else if (m_objRunning.m_blnHSync && m_blnSynchroDetected // Valid H sync detected - && (m_intColIndex > m_intNumberSamplePerLine - m_intNumberSamplePerTop) - && (m_intColIndex < m_intNumberSamplePerLine + m_intNumberSamplePerTop)) - { - // qDebug("HSync: %d", m_intColIndex); - // m_intColIndex = 0; - m_intAvgColIndex = m_objAvgColIndex.run(m_intColIndex); - m_intColIndex = m_intColIndex - m_intAvgColIndex; - blnNewLine = true; - } else if (m_intColIndex >= m_intNumberSamplePerLine + m_intNumberSamplePerTop) // No valid H sync { - //qDebug("HLine: %d", m_intColIndex); - m_intColIndex = m_intNumberSamplePerTop; + if (m_objRunning.m_blnHSync && (m_intLineIndex == 0)) + { + //qDebug("HSync: %d %d", m_intColIndex, m_intAvgColIndex); + m_intColIndex = m_intNumberSamplePerTop + m_intAvgColIndex/4; // amortizing 1/4 + } + else + { + m_intColIndex = m_intNumberSamplePerTop; + } + blnNewLine = true; } @@ -585,7 +594,8 @@ private: // Filling pixels - m_objRegisteredATVScreen->setDataColor(m_intColIndex - m_intNumberSaplesPerHSync + m_intNumberSamplePerTop, intVal, intVal, intVal); + // +4 is to compensate shift due to hsync amortizing factor of 1/4 + m_objRegisteredATVScreen->setDataColor(m_intColIndex - m_intNumberSaplesPerHSync + m_intNumberSamplePerTop + 4, intVal, intVal, intVal); m_intColIndex++; // Vertical sync and image rendering