Skip to content

Commit

Permalink
Make head switching consistent across frames
Browse files Browse the repository at this point in the history
  • Loading branch information
valadaptive committed Aug 19, 2023
1 parent cdcd25c commit 1ca0e4c
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions app/ntsc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 1ca0e4c

Please sign in to comment.