Skip to content

Commit

Permalink
OrphanFrames: Fix props method
Browse files Browse the repository at this point in the history
  • Loading branch information
LightArrowsEXE committed Nov 21, 2024
1 parent aa5112b commit 4119a21
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 10 deletions.
29 changes: 22 additions & 7 deletions vswobbly/components/orphans.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,16 +112,31 @@ def find_frame(self, frame: int) -> OrphanFrame | None:
except StopIteration:
return None

def find_matches(self, match: ValidMatchT) -> list[OrphanFrame]:
def find_matches(self, match: ValidMatchT) -> Self:
"""Find all frames with a specific match."""

return [f for f in self if f.match == match]
return OrphanFrames([f for f in self if f.match == match])

def set_props(self, clip: vs.VideoNode) -> vs.VideoNode:
"""Set the orphan frame properties on the clip."""

return replace_ranges(
clip.std.SetFrameProps(WobblyOrphanFrame=False),
clip.std.SetFrameProps(WobblyOrphanFrame=True),
self
)
if not self:
return clip

for match in ValidMatchT.__args__: # type: ignore
if match == 'c':
continue

clip = replace_ranges(
clip.std.SetFrameProps(WobblyOrphanFrame=False),
clip.std.SetFrameProps(WobblyOrphanFrame=match),
self.find_matches(match).frames
)

return clip

@property
def frames(self) -> list[int]:
"""Get all frames in the list."""

return [frame.frame for frame in self]
5 changes: 3 additions & 2 deletions vswobbly/process/processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,14 @@ def apply_post_source(self) -> None:

self.apply_strategies_of_position(FilteringPositionEnum.POST_SOURCE)

if any('orphan' in strategy.__class__.__name__.lower() for strategy in self.strategies):
if any('orphan' in str(strategy).lower() for strategy in self.strategies):
self.parser.field_matches.set_orphans_to_combed_matches(self.parser.orphan_frames)

self.proc_clip = self.parser.sections.set_props(self.proc_clip, wobbly_parsed=self.parser)
self.proc_clip = self.parser.field_matches.apply(self.proc_clip)
self.proc_clip = self.parser.combed_frames.set_props(self.proc_clip)
self.proc_clip = self.parser.interlaced_fades.set_props(self.proc_clip)
self.proc_clip = self.parser.orphan_frames.set_props(self.proc_clip)
self.proc_clip = self.parser.field_matches.apply(self.proc_clip)

def apply_post_field_match(self) -> None:
"""Post-field matching filtering."""
Expand Down
2 changes: 1 addition & 1 deletion vswobbly/process/strategies/orphans.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def apply(self, clip: vs.VideoNode, wobbly_parsed: WobblyParser) -> vs.VideoNode
deint_n = self._qtgmc(QTGMC, clip, not wobbly_parsed.field_based.field, **qtgmc_kwargs)
deint_b = self._qtgmc(QTGMC, clip, wobbly_parsed.field_based.field, **qtgmc_kwargs)

orphan_n, orphan_b, _, _ = self._match_grouper.split_fields(wobbly_parsed)
orphan_n, orphan_b = (wobbly_parsed.orphan_frames.find_matches(m) for m in ('n', 'b'))

deint = replace_ranges(clip, deint_n, orphan_n)
deint = replace_ranges(deint, deint_b, orphan_b)
Expand Down

0 comments on commit 4119a21

Please sign in to comment.