From 8949c74b3b1876fb0a28055718df19883ed83889 Mon Sep 17 00:00:00 2001 From: valadaptive Date: Sat, 19 Aug 2023 09:37:37 -0400 Subject: [PATCH] Make head switching consistent across frames --- app/ntsc.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/ntsc.py b/app/ntsc.py index d59dc4a..3ec3298 100755 --- a/app/ntsc.py +++ b/app/ntsc.py @@ -223,7 +223,6 @@ def __init__(self, precise: bool, random: NumpyRandom): self._vhs_head_switching = False # turn this on only on frames height 486 pixels or more self._head_switching_speed = 0 # 0..100 this is /1000 increment for _vhs_head_switching_point 0 is static - self._vhs_head_switching_point = 1.0 - (4.5 + 0.01) / 262.5 # 4 scanlines NTSC up from vsync self._vhs_head_switching_phase = (1.0 - 0.01) / 262.5 # 4 scanlines NTSC up from vsync self._vhs_head_switching_phase_noise = 1.0 / 500 / 262.5 # 1/500th of a scanline @@ -332,7 +331,7 @@ def video_chroma_phase_noise(self, yiq: numpy.ndarray, field: int, video_chroma_ U[y, :] = u V[y, :] = v - def vhs_head_switching(self, yiq: numpy.ndarray, field: int = 0): + def vhs_head_switching(self, yiq: numpy.ndarray, field: int, frameno: int): _, height, width = yiq.shape fY, fI, fQ = yiq twidth = width + width // 10 @@ -343,9 +342,10 @@ def vhs_head_switching(self, yiq: numpy.ndarray, field: int = 0): noise = x / 1000000000.0 - 1.0 noise *= self._vhs_head_switching_phase_noise + vhs_head_switching_point = (self._head_switching_speed / 1000) * frameno + t = twidth * (262.5 if self._output_ntsc else 312.5) - p = int(fmod(self._vhs_head_switching_point + noise, 1.0) * t) - self._vhs_head_switching_point += self._head_switching_speed/1000 + p = int(fmod(vhs_head_switching_point + noise, 1.0) * t) y = int(p // twidth * 2) + field p = int(fmod(self._vhs_head_switching_phase + noise, 1.0) * t) x = p % twidth @@ -588,7 +588,7 @@ def composite_layer(self, dst: numpy.ndarray, src: numpy.ndarray, field: int, fi self.video_noise(yiq, field, self._video_noise) if self._vhs_head_switching: - self.vhs_head_switching(yiq, field) + self.vhs_head_switching(yiq, field, frameno) if not self._nocolor_subcarrier: self.chroma_from_luma(yiq, field, fieldno, self._subcarrier_amplitude_back)