vsview-split-planes 0.3.0__tar.gz → 0.4.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -380,3 +380,4 @@ docs/assets/raws
380
380
 
381
381
  # Local AGENTS.md
382
382
  AGENTS.md
383
+ .vitest/
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: vsview-split-planes
3
- Version: 0.3.0
3
+ Version: 0.4.1
4
4
  Summary: A vsview plugin displaying video clips' constituent planes
5
5
  Project-URL: Documentation, https://jaded-encoding-thaumaturgy.github.io/vs-view/plugins/second-party/#split-planes
6
6
  Project-URL: Source Code, https://github.com/Jaded-Encoding-Thaumaturgy/vs-view/tree/main/src/plugins/split-planes
@@ -3,10 +3,10 @@ from typing import Annotated, Any, Literal, assert_never, override
3
3
 
4
4
  from jetpytools import fallback
5
5
  from pydantic import BaseModel
6
- from PySide6.QtCore import QSignalBlocker, Slot
6
+ from PySide6.QtCore import QSignalBlocker, QTimer, Slot
7
7
  from PySide6.QtWidgets import QBoxLayout, QDoubleSpinBox, QHBoxLayout, QLabel, QVBoxLayout, QWidget, QWidgetAction
8
- from vapoursynth import VideoNode
9
- from vstools import scale_mask, stack_planes
8
+ from vapoursynth import ColorFamily, SampleType, VideoNode
9
+ from vstools import Range, scale_mask, stack_planes
10
10
 
11
11
  from vsview.api import (
12
12
  Checkbox,
@@ -46,9 +46,9 @@ class GlobalSettings(BaseModel):
46
46
  label="Offset chroma",
47
47
  items=[("Fixed", 0.0), ("Min", "min"), ("Max", "max")],
48
48
  tooltip="Apply chroma plane offsetting\n"
49
- '- "min": match luma minimum\n'
50
- '- "max": match luma maximum\n'
51
- "- Fixed: use a custom float value",
49
+ "- Fixed: no offset. Set a custom value from the view context menu\n"
50
+ "- Min: move each chroma plane so its frame minimum sits at the lowest chroma value of the format\n"
51
+ "- Max: move each chroma plane so its frame maximum sits at the peak chroma value of the format",
52
52
  ),
53
53
  ] = 0.0
54
54
  mode: Annotated[
@@ -104,11 +104,19 @@ class SplitPlanesPlugin(WidgetPluginBase[GlobalSettings, LocalSettings]):
104
104
  self.current_layout.setSpacing(0)
105
105
  self.current_layout.addWidget(self.view)
106
106
 
107
+ self._applied_settings = self.settings.global_.model_dump()
107
108
  self.api.globalSettingsChanged.connect(self.on_settings_changed)
108
109
 
109
110
  @Slot()
110
111
  def on_settings_changed(self) -> None:
111
- self.view.autofit = fallback(self.settings.local_.autofit, self.settings.global_.autofit)
112
+ if (current := self.settings.global_.model_dump()) == self._applied_settings:
113
+ return
114
+
115
+ if current["autofit"] != self._applied_settings["autofit"]:
116
+ self.view.set_autofit(fallback(self.settings.local_.autofit, self.settings.global_.autofit))
117
+
118
+ self._applied_settings = current
119
+
112
120
  self.view.refresh()
113
121
  self.view.sync_offset_controls_from_settings()
114
122
 
@@ -161,6 +169,9 @@ class SplitPlanesView(PluginGraphicsView):
161
169
  action.setDefaultWidget(self._offset_container)
162
170
  self.context_menu.addAction(action)
163
171
 
172
+ self._offset_timer = QTimer(self, singleShot=True, interval=300)
173
+ self._offset_timer.timeout.connect(self._apply_offset_spinbox)
174
+
164
175
  # Connect signals
165
176
  self.offset_segment.segmentChanged.connect(self.on_offset_segment_changed)
166
177
  self.offset_spinbox.valueChanged.connect(self.on_offset_spinbox_changed)
@@ -168,8 +179,7 @@ class SplitPlanesView(PluginGraphicsView):
168
179
  # Set initial state from global settings
169
180
  self.sync_offset_controls_from_settings()
170
181
 
171
- if self.settings.local_.autofit:
172
- self.autofit_action.trigger()
182
+ self.set_autofit(fallback(self.settings.local_.autofit, self.settings.global_.autofit))
173
183
 
174
184
  @override
175
185
  def get_node(self, clip: VideoNode) -> VideoNode:
@@ -181,9 +191,21 @@ class SplitPlanesView(PluginGraphicsView):
181
191
  else:
182
192
  offset = offset_chroma
183
193
 
194
+ shift_float_chroma = self.settings.global_.shift_float_chroma
195
+
196
+ if (
197
+ shift_float_chroma
198
+ and clip.format.color_family == ColorFamily.YUV
199
+ and clip.format.sample_type == SampleType.FLOAT
200
+ ):
201
+ full = clip.std.Expr(["", "x 0.5 +"])
202
+ limited = clip.std.Expr(["", "x 0.5 + 224 219 / *"])
203
+ clip = full.std.FrameEval(lambda n, f: limited if Range.from_video(f).is_limited else full, prop_src=clip)
204
+ shift_float_chroma = False
205
+
184
206
  return stack_planes(
185
207
  clip,
186
- self.settings.global_.shift_float_chroma,
208
+ shift_float_chroma,
187
209
  offset,
188
210
  self.settings.global_.mode,
189
211
  self.settings.global_.write_plane_name,
@@ -227,8 +249,12 @@ class SplitPlanesView(PluginGraphicsView):
227
249
 
228
250
  @Slot(float)
229
251
  def on_offset_spinbox_changed(self, value: float) -> None:
252
+ self._offset_timer.start()
253
+
254
+ @Slot()
255
+ def _apply_offset_spinbox(self) -> None:
230
256
  if self.offset_segment.index == 0:
231
- self.settings.local_.offset_chroma = value
257
+ self.settings.local_.offset_chroma = self.offset_spinbox.value()
232
258
  self.refresh()
233
259
 
234
260
  @override