Skip to content

Commit

Permalink
Add sRGB/P3 primaries convert support
Browse files Browse the repository at this point in the history
  • Loading branch information
Setsugennoao committed Sep 24, 2023
1 parent 9c16530 commit 51e8cd9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
3 changes: 2 additions & 1 deletion vspreview/core/types/video.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,8 @@ def prepare_vs_output(self, clip: vs.VideoNode, is_alpha: bool = False) -> vs.Vi
'range_in': ColorRange.LIMITED,
'chromaloc_in': ChromaLocation.LEFT
} | heuristics | {
'dither_type': self.main.toolbars.playback.settings.dither_type
'dither_type': self.main.toolbars.playback.settings.dither_type,
'primaries': self.main.settings.output_primaries_zimg
})

if clip.format.color_family == vs.RGB:
Expand Down
15 changes: 15 additions & 0 deletions vspreview/main/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@ def setup_ui(self) -> None:

self.dragnavigator_timeout_spinbox = SpinBox(self, 0, 1000 * 60 * 5)

self.primaries_combobox = ComboBox[str](
model=GeneralModel[str]([
'sRGB', 'DCI-P3 (6300K White point)', 'DCI-P3 (6500K White point)'
], False)
)

self.color_management_checkbox = CheckBox('Color management', self)

HBoxLayout(self.vlayout, [QLabel('Autosave interval (0 - disable)'), self.autosave_control])
Expand Down Expand Up @@ -110,6 +116,8 @@ def setup_ui(self) -> None:

HBoxLayout(self.vlayout, [QLabel('Drag Navigator Timeout (ms)'), self.dragnavigator_timeout_spinbox])

HBoxLayout(self.vlayout, [QLabel('Output Primaries'), self.primaries_combobox])

if sys.platform == 'win32':
HBoxLayout(self.vlayout, [self.color_management_checkbox])

Expand Down Expand Up @@ -276,6 +284,11 @@ def zoom_levels_combobox_on_remove(self, checkFocus: bool = False) -> None:

self.zoom_levels = [x for x in zoom_levels if round(x) != round(old_value)]

@property
def output_primaries_zimg(self) -> int:
from vstools.enums.color import Primaries
return Primaries([1, 11, 12][self.primaries_combobox.currentIndex()])

@property
def color_management(self) -> bool:
return self.color_management_checkbox.isChecked()
Expand All @@ -293,6 +306,7 @@ def __getstate__(self) -> Mapping[str, Any]:
'force_old_storages_removal': self.force_old_storages_removal,
'zoom_levels': sorted([int(x * 100) for x in self.zoom_levels]),
'zoom_default_index': self.zoom_default_index,
'output_primaries_index': self.primaries_combobox.currentIndex(),
'dragnavigator_timeout': self.dragnavigator_timeout,
'color_management': self.color_management
}
Expand All @@ -310,6 +324,7 @@ def _setstate_(self, state: Mapping[str, Any]) -> None:
try_load(state, 'zoom_levels', list, self)
try_load(state, 'zoom_default_index', int, self.zoom_level_default_combobox.setCurrentIndex)
try_load(state, 'dragnavigator_timeout', int, self.dragnavigator_timeout_spinbox.setValue)
try_load(state, 'output_primaries_index', int, self.primaries_combobox.setCurrentIndex)
try_load(state, 'color_management', bool, self.color_management_checkbox.setChecked)


Expand Down

0 comments on commit 51e8cd9

Please sign in to comment.