nativeres 0.1.0__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.
- nativeres-0.1.0/.gitignore +219 -0
- nativeres-0.1.0/LICENSE +21 -0
- nativeres-0.1.0/PKG-INFO +363 -0
- nativeres-0.1.0/README.md +308 -0
- nativeres-0.1.0/pyproject.toml +133 -0
- nativeres-0.1.0/scripts/generate_svg.py +86 -0
- nativeres-0.1.0/src/nativeres/__init__.py +3 -0
- nativeres-0.1.0/src/nativeres/cli/__init__.py +313 -0
- nativeres-0.1.0/src/nativeres/cli/components.py +171 -0
- nativeres-0.1.0/src/nativeres/cli/helpers.py +115 -0
- nativeres-0.1.0/src/nativeres/constants.py +1 -0
- nativeres-0.1.0/src/nativeres/funcs.py +367 -0
- nativeres-0.1.0/src/nativeres/kernels.py +17 -0
- nativeres-0.1.0/src/nativeres/plotting.py +772 -0
- nativeres-0.1.0/src/nativeres/py.typed +0 -0
- nativeres-0.1.0/stubs/vapoursynth/__init__.pyi +1565 -0
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[codz]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
.Python
|
|
11
|
+
build/
|
|
12
|
+
develop-eggs/
|
|
13
|
+
dist/
|
|
14
|
+
downloads/
|
|
15
|
+
eggs/
|
|
16
|
+
.eggs/
|
|
17
|
+
lib/
|
|
18
|
+
lib64/
|
|
19
|
+
parts/
|
|
20
|
+
sdist/
|
|
21
|
+
var/
|
|
22
|
+
wheels/
|
|
23
|
+
share/python-wheels/
|
|
24
|
+
*.egg-info/
|
|
25
|
+
.installed.cfg
|
|
26
|
+
*.egg
|
|
27
|
+
MANIFEST
|
|
28
|
+
|
|
29
|
+
# PyInstaller
|
|
30
|
+
# Usually these files are written by a python script from a template
|
|
31
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
32
|
+
*.manifest
|
|
33
|
+
*.spec
|
|
34
|
+
|
|
35
|
+
# Installer logs
|
|
36
|
+
pip-log.txt
|
|
37
|
+
pip-delete-this-directory.txt
|
|
38
|
+
|
|
39
|
+
# Unit test / coverage reports
|
|
40
|
+
htmlcov/
|
|
41
|
+
.tox/
|
|
42
|
+
.nox/
|
|
43
|
+
.coverage
|
|
44
|
+
.coverage.*
|
|
45
|
+
.cache
|
|
46
|
+
nosetests.xml
|
|
47
|
+
coverage.xml
|
|
48
|
+
*.cover
|
|
49
|
+
*.py.cover
|
|
50
|
+
.hypothesis/
|
|
51
|
+
.pytest_cache/
|
|
52
|
+
cover/
|
|
53
|
+
|
|
54
|
+
# Translations
|
|
55
|
+
*.mo
|
|
56
|
+
*.pot
|
|
57
|
+
|
|
58
|
+
# Django stuff:
|
|
59
|
+
*.log
|
|
60
|
+
local_settings.py
|
|
61
|
+
db.sqlite3
|
|
62
|
+
db.sqlite3-journal
|
|
63
|
+
|
|
64
|
+
# Flask stuff:
|
|
65
|
+
instance/
|
|
66
|
+
.webassets-cache
|
|
67
|
+
|
|
68
|
+
# Scrapy stuff:
|
|
69
|
+
.scrapy
|
|
70
|
+
|
|
71
|
+
# Sphinx documentation
|
|
72
|
+
docs/_build/
|
|
73
|
+
|
|
74
|
+
# PyBuilder
|
|
75
|
+
.pybuilder/
|
|
76
|
+
target/
|
|
77
|
+
|
|
78
|
+
# Jupyter Notebook
|
|
79
|
+
.ipynb_checkpoints
|
|
80
|
+
|
|
81
|
+
# IPython
|
|
82
|
+
profile_default/
|
|
83
|
+
ipython_config.py
|
|
84
|
+
|
|
85
|
+
# pyenv
|
|
86
|
+
# For a library or package, you might want to ignore these files since the code is
|
|
87
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
88
|
+
# .python-version
|
|
89
|
+
|
|
90
|
+
# pipenv
|
|
91
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
92
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
93
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
94
|
+
# install all needed dependencies.
|
|
95
|
+
# Pipfile.lock
|
|
96
|
+
|
|
97
|
+
# UV
|
|
98
|
+
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
|
|
99
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
100
|
+
# commonly ignored for libraries.
|
|
101
|
+
# uv.lock
|
|
102
|
+
|
|
103
|
+
# poetry
|
|
104
|
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
|
105
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
106
|
+
# commonly ignored for libraries.
|
|
107
|
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
|
108
|
+
# poetry.lock
|
|
109
|
+
# poetry.toml
|
|
110
|
+
|
|
111
|
+
# pdm
|
|
112
|
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
|
113
|
+
# pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
|
|
114
|
+
# https://pdm-project.org/en/latest/usage/project/#working-with-version-control
|
|
115
|
+
# pdm.lock
|
|
116
|
+
# pdm.toml
|
|
117
|
+
.pdm-python
|
|
118
|
+
.pdm-build/
|
|
119
|
+
|
|
120
|
+
# pixi
|
|
121
|
+
# Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
|
|
122
|
+
# pixi.lock
|
|
123
|
+
# Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
|
|
124
|
+
# in the .venv directory. It is recommended not to include this directory in version control.
|
|
125
|
+
.pixi
|
|
126
|
+
|
|
127
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
|
128
|
+
__pypackages__/
|
|
129
|
+
|
|
130
|
+
# Celery stuff
|
|
131
|
+
celerybeat-schedule
|
|
132
|
+
celerybeat.pid
|
|
133
|
+
|
|
134
|
+
# Redis
|
|
135
|
+
*.rdb
|
|
136
|
+
*.aof
|
|
137
|
+
*.pid
|
|
138
|
+
|
|
139
|
+
# RabbitMQ
|
|
140
|
+
mnesia/
|
|
141
|
+
rabbitmq/
|
|
142
|
+
rabbitmq-data/
|
|
143
|
+
|
|
144
|
+
# ActiveMQ
|
|
145
|
+
activemq-data/
|
|
146
|
+
|
|
147
|
+
# SageMath parsed files
|
|
148
|
+
*.sage.py
|
|
149
|
+
|
|
150
|
+
# Environments
|
|
151
|
+
.env
|
|
152
|
+
.envrc
|
|
153
|
+
.venv
|
|
154
|
+
env/
|
|
155
|
+
venv/
|
|
156
|
+
ENV/
|
|
157
|
+
env.bak/
|
|
158
|
+
venv.bak/
|
|
159
|
+
|
|
160
|
+
# Spyder project settings
|
|
161
|
+
.spyderproject
|
|
162
|
+
.spyproject
|
|
163
|
+
|
|
164
|
+
# Rope project settings
|
|
165
|
+
.ropeproject
|
|
166
|
+
|
|
167
|
+
# mkdocs documentation
|
|
168
|
+
/site
|
|
169
|
+
|
|
170
|
+
# mypy
|
|
171
|
+
.mypy_cache/
|
|
172
|
+
.dmypy.json
|
|
173
|
+
dmypy.json
|
|
174
|
+
|
|
175
|
+
# Pyre type checker
|
|
176
|
+
.pyre/
|
|
177
|
+
|
|
178
|
+
# pytype static type analyzer
|
|
179
|
+
.pytype/
|
|
180
|
+
|
|
181
|
+
# Cython debug symbols
|
|
182
|
+
cython_debug/
|
|
183
|
+
|
|
184
|
+
# PyCharm
|
|
185
|
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
|
186
|
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
|
187
|
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
|
188
|
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
|
189
|
+
# .idea/
|
|
190
|
+
|
|
191
|
+
# Abstra
|
|
192
|
+
# Abstra is an AI-powered process automation framework.
|
|
193
|
+
# Ignore directories containing user credentials, local state, and settings.
|
|
194
|
+
# Learn more at https://abstra.io/docs
|
|
195
|
+
.abstra/
|
|
196
|
+
|
|
197
|
+
# Visual Studio Code
|
|
198
|
+
# Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
|
|
199
|
+
# that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
|
|
200
|
+
# and can be added to the global gitignore or merged into this file. However, if you prefer,
|
|
201
|
+
# you could uncomment the following to ignore the entire vscode folder
|
|
202
|
+
# .vscode/
|
|
203
|
+
|
|
204
|
+
# Ruff stuff:
|
|
205
|
+
.ruff_cache/
|
|
206
|
+
|
|
207
|
+
# PyPI configuration file
|
|
208
|
+
.pypirc
|
|
209
|
+
|
|
210
|
+
# Marimo
|
|
211
|
+
marimo/_static/
|
|
212
|
+
marimo/_lsp/
|
|
213
|
+
__marimo__/
|
|
214
|
+
|
|
215
|
+
# Streamlit
|
|
216
|
+
.streamlit/secrets.toml
|
|
217
|
+
|
|
218
|
+
# vsjet files
|
|
219
|
+
.vsjet
|
nativeres-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Jaded Encoding Thaumaturgy
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
nativeres-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,363 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: nativeres
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Descale analysis tools for VapourSynth
|
|
5
|
+
Project-URL: Documentation, https://github.com/Jaded-Encoding-Thaumaturgy/nativeres/blob/master/README.md
|
|
6
|
+
Project-URL: Source Code, https://github.com/Jaded-Encoding-Thaumaturgy/nativeres
|
|
7
|
+
Project-URL: Bug Tracker, https://github.com/Jaded-Encoding-Thaumaturgy/nativeres/issues
|
|
8
|
+
Project-URL: Contact, https://discord.gg/XTpc6Fa9eB
|
|
9
|
+
Author-email: Vardë <ichunjo.le.terrible@gmail.com>
|
|
10
|
+
Maintainer-email: Vardë <ichunjo.le.terrible@gmail.com>
|
|
11
|
+
License: MIT License
|
|
12
|
+
|
|
13
|
+
Copyright (c) 2025 Jaded Encoding Thaumaturgy
|
|
14
|
+
|
|
15
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
16
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
17
|
+
in the Software without restriction, including without limitation the rights
|
|
18
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
19
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
20
|
+
furnished to do so, subject to the following conditions:
|
|
21
|
+
|
|
22
|
+
The above copyright notice and this permission notice shall be included in all
|
|
23
|
+
copies or substantial portions of the Software.
|
|
24
|
+
|
|
25
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
26
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
27
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
28
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
29
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
30
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
31
|
+
SOFTWARE.
|
|
32
|
+
License-File: LICENSE
|
|
33
|
+
Keywords: encoding,native,resolution,vapoursynth,video,video-processing
|
|
34
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
35
|
+
Classifier: Operating System :: OS Independent
|
|
36
|
+
Classifier: Programming Language :: Python :: 3
|
|
37
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
38
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
39
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
40
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
41
|
+
Classifier: Topic :: Multimedia :: Graphics
|
|
42
|
+
Classifier: Typing :: Typed
|
|
43
|
+
Requires-Python: >=3.12
|
|
44
|
+
Requires-Dist: jetpytools
|
|
45
|
+
Requires-Dist: numpy>=2.0.0
|
|
46
|
+
Requires-Dist: pyside6>=6.10.1
|
|
47
|
+
Requires-Dist: rich
|
|
48
|
+
Requires-Dist: scipy>=1.16.0
|
|
49
|
+
Requires-Dist: typer>=0.24.0
|
|
50
|
+
Requires-Dist: vsjetengine>=1.2.0
|
|
51
|
+
Requires-Dist: vsjetpack>=1.3.0
|
|
52
|
+
Provides-Extra: plugin
|
|
53
|
+
Requires-Dist: vsview-nativeres; extra == 'plugin'
|
|
54
|
+
Description-Content-Type: text/markdown
|
|
55
|
+
|
|
56
|
+
# nativeres
|
|
57
|
+
|
|
58
|
+
`nativeres` is a set of descale analysis tools for VapourSynth.
|
|
59
|
+
|
|
60
|
+
It combines and supersedes the following tools:
|
|
61
|
+
|
|
62
|
+
- Original **getscaler** by **cN3rd** https://gist.github.com/cN3rd/51077b6abf45b684bf9a3c657d859b43
|
|
63
|
+
- Original **getnative** by **Infiziert90** https://github.com/Infiziert90/getnative
|
|
64
|
+
- **GetFnative** by **YomikoR** https://github.com/YomikoR/GetFnative
|
|
65
|
+
- **getfscaler** https://github.com/Jaded-Encoding-Thaumaturgy/getscaler
|
|
66
|
+
|
|
67
|
+
The package provides:
|
|
68
|
+
|
|
69
|
+
- A CLI for frame analysis
|
|
70
|
+
- A Python API for VapourSynth scripts and tooling
|
|
71
|
+
- An optional **[VSView](https://github.com/Jaded-Encoding-Thaumaturgy/vs-view)** plugin
|
|
72
|
+
|
|
73
|
+
## What it does
|
|
74
|
+
|
|
75
|
+
`nativeres` helps answer three common descale questions:
|
|
76
|
+
|
|
77
|
+
- `getnative`: What native resolution was this frame likely upscaled from?
|
|
78
|
+
- `getscaler`: Which scaler most likely produced this upscale?
|
|
79
|
+
- `getfreq`: Does the frame's frequency distribution show likely scaling artifacts or native-resolution clues?
|
|
80
|
+
|
|
81
|
+
## Installation
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
# Install the package with `pip`
|
|
85
|
+
pip install nativeres
|
|
86
|
+
# Or with `uv`
|
|
87
|
+
uv tool install nativeres
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### VSView plugin
|
|
91
|
+
|
|
92
|
+
This repository also contains a **[VSView](https://github.com/Jaded-Encoding-Thaumaturgy/vs-view)** plugin package.
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
pip install nativeres[plugin]
|
|
96
|
+
# Or with uv
|
|
97
|
+
uv tool install nativeres[plugin]
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
The plugin registers as a VSView tool panel and tool dock under `Native Resolution`.
|
|
101
|
+
|
|
102
|
+
Usage can be found in the **[plugin README](https://github.com/Jaded-Encoding-Thaumaturgy/nativeres/blob/master/src/plugin/README.md)**.
|
|
103
|
+
|
|
104
|
+
## Usage
|
|
105
|
+
|
|
106
|
+
### CLI
|
|
107
|
+
|
|
108
|
+
`nativeres` accepts regular media files, images, and VapourSynth scripts (`.vpy` / `.py`). For scripts, the first VapourSynth output is used.
|
|
109
|
+
|
|
110
|
+
- Displays a plot to determine the native resolution height for the frame 15000 with the Bilinear kernel:
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
nativeres getnative file.m2ts --frame 15000 --dim-mode height --kernel bilinear
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+

|
|
117
|
+
|
|
118
|
+
Right-click the plot to open the context menu, where you can reset zoom and copy or export the plot as `PNG`, `SVG`, `JSON`, or `CSV`.
|
|
119
|
+
|
|
120
|
+
- Displays a table showing the errors of the inverse scalers at height 800 for frame 15000.
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
nativeres getscaler file.m2ts 800 --frame 15000 --dim-mode height
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+

|
|
127
|
+
|
|
128
|
+
- Compute and display a DCT-based frequency plot for the selected frame.
|
|
129
|
+
|
|
130
|
+
```bash
|
|
131
|
+
nativeres getfreq file.m2ts --frame 15000
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+

|
|
135
|
+
|
|
136
|
+
The frequency plot uses the same right-click context menu for reset zoom plus copy/export actions.
|
|
137
|
+
|
|
138
|
+
### Python
|
|
139
|
+
|
|
140
|
+
```python
|
|
141
|
+
from nativeres import getnative
|
|
142
|
+
from vskernels import Bilinear
|
|
143
|
+
|
|
144
|
+
clip = ... # Your VapourSynth clip
|
|
145
|
+
|
|
146
|
+
results = getnative(
|
|
147
|
+
clip,
|
|
148
|
+
frame_num=15000,
|
|
149
|
+
dimensions=((clip.width, h) for h in range(540, 901)),
|
|
150
|
+
kernel=Bilinear(),
|
|
151
|
+
)
|
|
152
|
+
|
|
153
|
+
best = min(results, key=lambda result: result.error)
|
|
154
|
+
print(best.dim.height, best.error)
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
## CLI Reference
|
|
158
|
+
|
|
159
|
+
Main help:
|
|
160
|
+
|
|
161
|
+

|
|
162
|
+
|
|
163
|
+
`getnative` help:
|
|
164
|
+
|
|
165
|
+

|
|
166
|
+
|
|
167
|
+
`getscaler` help:
|
|
168
|
+
|
|
169
|
+

|
|
170
|
+
|
|
171
|
+
`getfreq` help:
|
|
172
|
+
|
|
173
|
+

|
|
174
|
+
|
|
175
|
+
## Python API
|
|
176
|
+
|
|
177
|
+
<!-- markdownlint-disable -->
|
|
178
|
+
|
|
179
|
+
<a href="src/nativeres/funcs.py#L70"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
|
|
180
|
+
|
|
181
|
+
## <kbd>function</kbd> `getnative`
|
|
182
|
+
|
|
183
|
+
```python
|
|
184
|
+
getnative(
|
|
185
|
+
clip: VideoNode,
|
|
186
|
+
frame_num: int,
|
|
187
|
+
dimensions: Iterable[tuple[float, float]],
|
|
188
|
+
kernel: ComplexKernelLike,
|
|
189
|
+
crop: tuple[LeftCrop, RightCrop, TopCrop, BottomCrop] | None = None,
|
|
190
|
+
shift: tuple[TopShift, LeftShift] = (0, 0),
|
|
191
|
+
metric_mode: MetricMode = 'MAE',
|
|
192
|
+
borders_aware: bool | int | tuple[LeftCrop, RightCrop, TopCrop, BottomCrop] = 8,
|
|
193
|
+
progress_cb: Callable[[int, int], None] | None = None,
|
|
194
|
+
func: FuncExcept | None = None,
|
|
195
|
+
**kwargs: Any
|
|
196
|
+
) -> list[GetNativeResult]
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
Determine the best (fractional) native resolution for a selected frame.
|
|
200
|
+
|
|
201
|
+
This checks a list of candidate resolutions by descaling the selected frame using `kernel` and comparing the result to the source frame using `metric_mode`.
|
|
202
|
+
|
|
203
|
+
**Args:**
|
|
204
|
+
|
|
205
|
+
- <b>`clip`</b>: Source clip.
|
|
206
|
+
- <b>`frame_num`</b>: Frame index in `clip` to evaluate.
|
|
207
|
+
- <b>`dimensions`</b>: Iterable of candidate resolutions to test. Each item may be a `(width, height)` tuple.
|
|
208
|
+
- <b>`kernel`</b>: Kernel used to perform each descale attempt.
|
|
209
|
+
- <b>`crop`</b>: Optional crop to apply before descaling. Aspect ratio is preserved.
|
|
210
|
+
- <b>`shift`</b>: Optional pixel shift applied during descaling: `(top_shift, left_shift)`.
|
|
211
|
+
- <b>`metric_mode`</b>: Error metric to use: `"MSE"`, `"MAE"`, or `"RMSE"`.
|
|
212
|
+
- <b>`borders_aware`</b>: Amount (or crop tuple) to ignore at image borders to avoid edge noise when computing the metric.
|
|
213
|
+
- <b>`progress_cb`</b>: Optional progress callback called as `progress_cb(current, total)`.
|
|
214
|
+
- <b>`func`</b>: Function returned for custom error handling.
|
|
215
|
+
- <b>`kwargs`</b>: Additional arguments passed to the Rescale class.
|
|
216
|
+
|
|
217
|
+
**Returns:**
|
|
218
|
+
A list of `GetNativeResult` items. Each item contains the tested fractional resolution (`dim`) and its associated `error`.
|
|
219
|
+
|
|
220
|
+
---
|
|
221
|
+
|
|
222
|
+
<a href="src/nativeres/funcs.py#L160"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
|
|
223
|
+
|
|
224
|
+
## <kbd>function</kbd> `getscaler`
|
|
225
|
+
|
|
226
|
+
```python
|
|
227
|
+
getscaler(
|
|
228
|
+
clip: VideoNode,
|
|
229
|
+
frame_num: int,
|
|
230
|
+
width: float,
|
|
231
|
+
height: float,
|
|
232
|
+
kernels: ComplexKernelLike | Sequence[ComplexKernelLike],
|
|
233
|
+
base_width: int | None = None,
|
|
234
|
+
base_height: int | None = None,
|
|
235
|
+
crop: tuple[LeftCrop, RightCrop, TopCrop, BottomCrop] | None = None,
|
|
236
|
+
shift: tuple[TopShift, LeftShift] = (0, 0),
|
|
237
|
+
metric_mode: MetricMode = 'MAE',
|
|
238
|
+
mask: MaskLike | None = None,
|
|
239
|
+
borders_aware: bool | int | tuple[LeftCrop, RightCrop, TopCrop, BottomCrop] = 8,
|
|
240
|
+
func: FuncExcept | None = None,
|
|
241
|
+
**kwargs: Any
|
|
242
|
+
) → list[GetScalerResult]
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
Find the best inverse scaler (kernel) for a given frame of a clip.
|
|
246
|
+
|
|
247
|
+
Each supplied kernel is tested by descaling the selected frame to the provided `(width, height)` and computing an error metric.
|
|
248
|
+
|
|
249
|
+
**Args:**
|
|
250
|
+
|
|
251
|
+
- <b>`clip`</b>: Source clip.
|
|
252
|
+
- <b>`frame_num`</b>: Frame index in `clip` to evaluate.
|
|
253
|
+
- <b>`width`</b>: Width to be descaled to. If passed as a float, a fractional descale is performed.
|
|
254
|
+
- <b>`height`</b>: Height to be descaled to. If passed as a float, a fractional descale is performed.
|
|
255
|
+
- <b>`kernels`</b>: A single kernel or a sequence of kernels to evaluate.
|
|
256
|
+
- <b>`base_width`</b>: Optional integer height to contain the clip within.
|
|
257
|
+
- <b>`base_height`</b>: Optional integer width to contain the clip within.
|
|
258
|
+
- <b>`crop`</b>: Optional crop to apply before descaling. Aspect ratio is preserved.
|
|
259
|
+
- <b>`shift`</b>: Pixel shifts applied during descaling: `(top_shift, left_shift)`.
|
|
260
|
+
- <b>`metric_mode`</b>: Error metric to use: `"MSE"`, `"MAE"`, or `"RMSE"`.
|
|
261
|
+
- <b>`mask`</b>: Optional edge-detection mask to reduce noise influence on the metric.
|
|
262
|
+
- <b>`borders_aware`</b>: Amount (or crop tuple) to ignore at image borders to avoid edge noise when computing the metric.
|
|
263
|
+
- <b>`func`</b>: Function returned for custom error handling.
|
|
264
|
+
- <b>`kwargs`</b>: Additional arguments passed to the Rescale class.
|
|
265
|
+
|
|
266
|
+
**Returns:**
|
|
267
|
+
A list of `GetScalerResult` items. Each item contains the evaluated `kernel` and its associated `error`.
|
|
268
|
+
|
|
269
|
+
---
|
|
270
|
+
|
|
271
|
+
<a href="src/nativeres/funcs.py#L234"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
|
|
272
|
+
|
|
273
|
+
## <kbd>function</kbd> `get_descale_error`
|
|
274
|
+
|
|
275
|
+
```python
|
|
276
|
+
get_descale_error(
|
|
277
|
+
clip: VideoNode,
|
|
278
|
+
frame_num: int,
|
|
279
|
+
width: float,
|
|
280
|
+
height: float,
|
|
281
|
+
kernel: ComplexKernelLike,
|
|
282
|
+
base_width: int | None = None,
|
|
283
|
+
base_height: int | None = None,
|
|
284
|
+
crop: tuple[LeftCrop, RightCrop, TopCrop, BottomCrop] | None = None,
|
|
285
|
+
shift: tuple[TopShift, LeftShift] = (0, 0),
|
|
286
|
+
metric_mode: MetricMode = 'MAE',
|
|
287
|
+
mask: MaskLike | None = None,
|
|
288
|
+
borders_aware: bool | int | tuple[LeftCrop, RightCrop, TopCrop, BottomCrop] = 8,
|
|
289
|
+
func: FuncExcept | None = None,
|
|
290
|
+
**kwargs: Any
|
|
291
|
+
) → float
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
Compute the descale error for a selected frame using a specific kernel.
|
|
295
|
+
|
|
296
|
+
**Args:**
|
|
297
|
+
|
|
298
|
+
- <b>`clip`</b>: Source clip.
|
|
299
|
+
- <b>`frame_num`</b>: Frame index in `clip` to evaluate.
|
|
300
|
+
- <b>`width`</b>: Width to be descaled to. If passed as a float, a fractional descale is performed.
|
|
301
|
+
- <b>`height`</b>: Height to be descaled to. If passed as a float, a fractional descale is performed.
|
|
302
|
+
- <b>`kernel`</b>: Kernel used for the descale operation.
|
|
303
|
+
- <b>`base_width`</b>: Optional integer height to contain the clip within.
|
|
304
|
+
- <b>`base_height`</b>: Optional integer width to contain the clip within.
|
|
305
|
+
- <b>`crop`</b>: Optional crop to apply before descaling. Aspect ratio is preserved.
|
|
306
|
+
- <b>`shift`</b>: Pixel shifts applied during descaling: `(top_shift, left_shift)`.
|
|
307
|
+
- <b>`metric_mode`</b>: Error metric to use: `"MSE"`, `"MAE"`, or `"RMSE"`.
|
|
308
|
+
- <b>`mask`</b>: Optional edge-detection mask to reduce noise influence on the metric.
|
|
309
|
+
- <b>`borders_aware`</b>: Amount (or crop tuple) to ignore at image borders to avoid edge noise when computing the metric.
|
|
310
|
+
- <b>`func`</b>: Function returned for custom error handling.
|
|
311
|
+
- <b>`kwargs`</b>: Additional arguments passed to the Rescale class.
|
|
312
|
+
|
|
313
|
+
**Returns:**
|
|
314
|
+
The computed error as a `float`. Lower values indicate a better descale match.
|
|
315
|
+
|
|
316
|
+
---
|
|
317
|
+
|
|
318
|
+
<a href="src/nativeres/funcs.py#L328"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
|
|
319
|
+
|
|
320
|
+
## <kbd>function</kbd> `get_dct_distribution`
|
|
321
|
+
|
|
322
|
+
```python
|
|
323
|
+
get_dct_distribution(
|
|
324
|
+
clip: VideoNode,
|
|
325
|
+
frame_num: int,
|
|
326
|
+
cull_rate: float = 3.0,
|
|
327
|
+
func: FuncExcept | None = None
|
|
328
|
+
) → tuple[NpFloatArray1D, NpFloatArray1D]
|
|
329
|
+
```
|
|
330
|
+
|
|
331
|
+
Calculate DCT frequency distribution for both horizontal and vertical dimensions of a selected frame.
|
|
332
|
+
|
|
333
|
+
**Args:**
|
|
334
|
+
|
|
335
|
+
- <b>`clip`</b>: Source clip.
|
|
336
|
+
- <b>`frame_num`</b>: Frame index in `clip` to analyze.
|
|
337
|
+
- <b>`cull_rate`</b>: Cull rate for DCT coefficients.
|
|
338
|
+
- <b>`func`</b>: Function returned for custom error handling.
|
|
339
|
+
|
|
340
|
+
**Returns:**
|
|
341
|
+
A tuple of (dct_h, dct_v).
|
|
342
|
+
|
|
343
|
+
---
|
|
344
|
+
|
|
345
|
+
## <kbd>class</kbd> `GetNativeResult`
|
|
346
|
+
|
|
347
|
+
Result for `getnative`, pairing a fractional resolution with an error metric.
|
|
348
|
+
|
|
349
|
+
---
|
|
350
|
+
|
|
351
|
+
## <kbd>class</kbd> `GetScalerResult`
|
|
352
|
+
|
|
353
|
+
Result for `getscaler`, pairing a kernel with its error.
|
|
354
|
+
|
|
355
|
+
---
|
|
356
|
+
|
|
357
|
+
## <kbd>class</kbd> `ResolutionFrac`
|
|
358
|
+
|
|
359
|
+
Fractional resolution expressed as floating-point width and height.
|
|
360
|
+
|
|
361
|
+
## Notes
|
|
362
|
+
|
|
363
|
+
- You should always visually verify the results on multiple frames before committing to a descale setup.
|