From 1ca0e4c0a998dcf5012032b17df731c3e3fe2ea0 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 | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/app/ntsc.py b/app/ntsc.py index d59dc4a..fff810d 100755 --- a/app/ntsc.py +++ b/app/ntsc.py @@ -332,7 +332,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,11 +343,12 @@ 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) + p = int(fmod(vhs_head_switching_point + noise, 1.0) * t) x = p % twidth y -= (262 - 240) * 2 if self._output_ntsc else (312 - 288) * 2 tx = x @@ -588,7 +589,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)