From 44989a42c8206c4f8ac7c57491325e8b82bfa0e6 Mon Sep 17 00:00:00 2001
From: f4exb <f4exb06@gmail.com>
Date: Wed, 1 Jul 2020 03:19:42 +0200
Subject: [PATCH] ATV demod: removed useless member
 m_horizontalSynchroDetected. Process classic: fixed m_avgColIndex
 synchronization

---
 plugins/channelrx/demodatv/atvdemodsink.cpp |  1 -
 plugins/channelrx/demodatv/atvdemodsink.h   | 14 ++++----------
 2 files changed, 4 insertions(+), 11 deletions(-)

diff --git a/plugins/channelrx/demodatv/atvdemodsink.cpp b/plugins/channelrx/demodatv/atvdemodsink.cpp
index 075eea5cc..abdc65ae4 100644
--- a/plugins/channelrx/demodatv/atvdemodsink.cpp
+++ b/plugins/channelrx/demodatv/atvdemodsink.cpp
@@ -38,7 +38,6 @@ ATVDemodSink::ATVDemodSink() :
     m_numberSamplesPerHTop(0),
     m_imageIndex(0),
     m_synchroSamples(0),
-    m_horizontalSynchroDetected(false),
     m_verticalSynchroDetected(false),
     m_ampLineSum(0.0f),
     m_ampLineAvg(0.0f),
diff --git a/plugins/channelrx/demodatv/atvdemodsink.h b/plugins/channelrx/demodatv/atvdemodsink.h
index dbc13aab6..8494e360f 100644
--- a/plugins/channelrx/demodatv/atvdemodsink.h
+++ b/plugins/channelrx/demodatv/atvdemodsink.h
@@ -128,7 +128,6 @@ private:
     int m_imageIndex;
     int m_synchroSamples;
 
-    bool m_horizontalSynchroDetected;
     bool m_verticalSynchroDetected;
 
     float m_ampLineSum;
@@ -202,9 +201,7 @@ private:
         }
 
         // H sync pulse
-        m_horizontalSynchroDetected = (m_synchroSamples == m_numberSamplesPerHTop);
-
-        if (m_horizontalSynchroDetected)
+        if (m_synchroSamples == m_numberSamplesPerHTop) // horizontal synchro detected
         {
             // Vertical sync and image rendering
             if ((m_sampleIndex >= (3*m_samplesPerLine) / 2) // Vertical sync is first horizontal sync after skip (count at least 1.5 line length)
@@ -273,14 +270,11 @@ private:
             m_synchroSamples = 0;
         }
 
-        // H sync pulse
-        m_horizontalSynchroDetected = (m_synchroSamples == m_numberSamplesPerHTop) && (m_sampleIndex > (m_samplesPerLine/2) + m_numberSamplesPerLineSignals);
-
         //Horizontal Synchro processing
-
-        if (m_horizontalSynchroDetected)
+        if ((m_synchroSamples == m_numberSamplesPerHTop) // horizontal synchro detected
+         && (m_sampleIndex > (m_samplesPerLine/2) + m_numberSamplesPerLineSignals))
         {
-            m_avgColIndex = m_sampleIndex - m_colIndex - (m_colIndex < m_samplesPerLine/2 ? 150 : 0);
+            m_avgColIndex = m_sampleIndex - m_colIndex;
             //qDebug("HSync: %d %d %d", m_sampleIndex, m_colIndex, m_avgColIndex);
             m_sampleIndex = 0;
         }