Skip to content

Commit

Permalink
Always setFrameProps of original clip in prepare_vs_output
Browse files Browse the repository at this point in the history
  • Loading branch information
Setsugennoao committed Oct 29, 2023
1 parent 624ddb4 commit 1e96bec
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions vspreview/core/types/video.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,10 @@ def setValue(
self.prepared = VideoOutputNode(vs_output.clip, vs_output.alpha, self.cached)

if self.source.alpha is not None:
self.prepared.alpha = self.prepare_vs_output(self.source.alpha, True).std.CopyFrameProps(self.source.alpha)
self.prepared.alpha = self.prepare_vs_output(self.source.alpha, True)

self.prepared.clip = self.prepare_vs_output(self.source.clip)

self.prepared.clip = self.prepare_vs_output(self.source.clip).std.CopyFrameProps(self.source.clip)
self.width = self.prepared.clip.width
self.height = self.prepared.clip.height
self.fps_num = self.prepared.clip.fps.numerator
Expand Down Expand Up @@ -268,7 +269,7 @@ def set_fmt_values(self) -> None:
def prepare_vs_output(self, clip: vs.VideoNode, is_alpha: bool = False) -> vs.VideoNode:
from vstools import ChromaLocation, ColorRange, KwargsT, Matrix, Primaries, Transfer, video_heuristics

assert clip.format
assert (src := clip).format

heuristics = video_heuristics(clip, True)

Expand All @@ -285,9 +286,9 @@ def prepare_vs_output(self, clip: vs.VideoNode, is_alpha: bool = False) -> vs.Vi
'primaries': self.main.settings.output_primaries_zimg
})

if clip.format.color_family == vs.RGB:
if src.format.color_family == vs.RGB:
del resizer_kwargs['matrix_in']
elif clip.format.color_family == vs.GRAY:
elif src.format.color_family == vs.GRAY:
clip = clip.std.RemoveFrameProps('_Matrix')

if isinstance(resizer_kwargs['range_in'], ColorRange):
Expand All @@ -296,21 +297,21 @@ def prepare_vs_output(self, clip: vs.VideoNode, is_alpha: bool = False) -> vs.Vi
assert clip.format

if is_alpha:
if clip.format.id == self._ALPHA_FMT.id:
if src.format.id == self._ALPHA_FMT.id:
return clip
resizer_kwargs['format'] = self._ALPHA_FMT.id
elif clip.format.id == vs.GRAY32:
elif src.format.id == vs.GRAY32:
return clip

clip = clip.resize.Bicubic(**resizer_kwargs)

if not self.cached:
clip.std.SetVideoCache(0)

if is_alpha:
return clip
if not is_alpha:
clip = self.pack_rgb_clip(clip)

return self.pack_rgb_clip(clip)
return clip.std.CopyFrameProps(src)

def pack_rgb_clip(self, clip: vs.VideoNode) -> vs.VideoNode:
if PACKING_TYPE.shuffle:
Expand Down

0 comments on commit 1e96bec

Please sign in to comment.