From 4119a21db92d23adbc7c2f0d84a0c4f7915c60bd Mon Sep 17 00:00:00 2001 From: LightArrowsEXE Date: Thu, 21 Nov 2024 23:14:14 +0100 Subject: [PATCH] OrphanFrames: Fix props method --- vswobbly/components/orphans.py | 29 +++++++++++++++++++------- vswobbly/process/processor.py | 5 +++-- vswobbly/process/strategies/orphans.py | 2 +- 3 files changed, 26 insertions(+), 10 deletions(-) diff --git a/vswobbly/components/orphans.py b/vswobbly/components/orphans.py index 5efed81..021058f 100644 --- a/vswobbly/components/orphans.py +++ b/vswobbly/components/orphans.py @@ -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] diff --git a/vswobbly/process/processor.py b/vswobbly/process/processor.py index d559b21..a70188a 100644 --- a/vswobbly/process/processor.py +++ b/vswobbly/process/processor.py @@ -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.""" diff --git a/vswobbly/process/strategies/orphans.py b/vswobbly/process/strategies/orphans.py index ddbdefb..184db79 100644 --- a/vswobbly/process/strategies/orphans.py +++ b/vswobbly/process/strategies/orphans.py @@ -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)