Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
:param first_time: prevents posting warnings multiple times
:return: best resolutions list and plot matplotlib.pyplot
"""
if type(args) == list:
args = parser.parse_args(args)
output_dir = Path(args.dir).resolve()
if not os.access(output_dir, os.W_OK):
raise PermissionError(f"Missing write permissions: {output_dir}")
output_dir = output_dir.joinpath("results")
if (args.img or args.mask_out) and imwri is None:
raise GetnativeException("imwri not found.")
if scaler is None:
scaler = _DefineScaler(args.kernel, b=args.b, c=args.c, taps=args.taps)
else:
scaler = scaler
if scaler.plugin is None:
if "toggaf.asi.xe" in core.get_plugins():
print("Error: descale_getnative support ended, pls use https://github.com/Irrational-Encoding-Wizardry/vapoursynth-descale")
raise GetnativeException('No descale found!')
if args.steps != 1 and first_time:
print(
"Warning for -steps/--stepping: "
"If you are not completely sure what this parameter does, use the default step size.\n"
)
if args.frame is None:
args.frame = src.num_frames // 3
f"{self.kernel.capitalize()}"
f"{'' if self.kernel != 'bicubic' else f' b {self.b:.2f} c {self.c:.2f}'}"
f"{'' if self.kernel != 'lanczos' else f' taps {self.taps}'}"
)
def __repr__(self):
return (
f"ScalerObject: "
f"{self.kernel.capitalize()}"
f"{'' if self.kernel != 'bicubic' else f' b {self.b:.2f} c {self.c:.2f}'}"
f"{'' if self.kernel != 'lanczos' else f' taps {self.taps}'}"
)
common_scaler = {
"bilinear": [_DefineScaler("bilinear")],
"bicubic": [
_DefineScaler("bicubic", b=1 / 3, c=1 / 3),
_DefineScaler("bicubic", b=.5, c=0),
_DefineScaler("bicubic", b=0, c=.5),
_DefineScaler("bicubic", b=1, c=0),
_DefineScaler("bicubic", b=0, c=1),
_DefineScaler("bicubic", b=.2, c=.5),
_DefineScaler("bicubic", b=.5, c=.5),
],
"lanczos": [
_DefineScaler("lanczos", taps=2),
_DefineScaler("lanczos", taps=3),
_DefineScaler("lanczos", taps=4),
_DefineScaler("lanczos", taps=5),
],
"spline": [
_DefineScaler("bicubic", b=0, c=.5),
_DefineScaler("bicubic", b=1, c=0),
_DefineScaler("bicubic", b=0, c=1),
_DefineScaler("bicubic", b=.2, c=.5),
_DefineScaler("bicubic", b=.5, c=.5),
],
"lanczos": [
_DefineScaler("lanczos", taps=2),
_DefineScaler("lanczos", taps=3),
_DefineScaler("lanczos", taps=4),
_DefineScaler("lanczos", taps=5),
],
"spline": [
_DefineScaler("spline16"),
_DefineScaler("spline36"),
_DefineScaler("spline64"),
]
}
class GetNative:
def __init__(self, src, scaler, ar, min_h, max_h, frame, mask_out, plot_scaling, plot_format, show_plot, no_save,
steps, output_dir):
self.plot_format = plot_format
self.plot_scaling = plot_scaling
self.src = src
self.min_h = min_h
self.max_h = max_h
self.ar = ar
self.scaler = scaler
self.frame = frame
self.mask_out = mask_out
_DefineScaler("bicubic", b=.5, c=0),
_DefineScaler("bicubic", b=0, c=.5),
_DefineScaler("bicubic", b=1, c=0),
_DefineScaler("bicubic", b=0, c=1),
_DefineScaler("bicubic", b=.2, c=.5),
_DefineScaler("bicubic", b=.5, c=.5),
],
"lanczos": [
_DefineScaler("lanczos", taps=2),
_DefineScaler("lanczos", taps=3),
_DefineScaler("lanczos", taps=4),
_DefineScaler("lanczos", taps=5),
],
"spline": [
_DefineScaler("spline16"),
_DefineScaler("spline36"),
_DefineScaler("spline64"),
]
}
class GetNative:
def __init__(self, src, scaler, ar, min_h, max_h, frame, mask_out, plot_scaling, plot_format, show_plot, no_save,
steps, output_dir):
self.plot_format = plot_format
self.plot_scaling = plot_scaling
self.src = src
self.min_h = min_h
self.max_h = max_h
self.ar = ar
self.scaler = scaler
self.frame = frame
return (
f"ScalerObject: "
f"{self.kernel.capitalize()}"
f"{'' if self.kernel != 'bicubic' else f' b {self.b:.2f} c {self.c:.2f}'}"
f"{'' if self.kernel != 'lanczos' else f' taps {self.taps}'}"
)
common_scaler = {
"bilinear": [_DefineScaler("bilinear")],
"bicubic": [
_DefineScaler("bicubic", b=1 / 3, c=1 / 3),
_DefineScaler("bicubic", b=.5, c=0),
_DefineScaler("bicubic", b=0, c=.5),
_DefineScaler("bicubic", b=1, c=0),
_DefineScaler("bicubic", b=0, c=1),
_DefineScaler("bicubic", b=.2, c=.5),
_DefineScaler("bicubic", b=.5, c=.5),
],
"lanczos": [
_DefineScaler("lanczos", taps=2),
_DefineScaler("lanczos", taps=3),
_DefineScaler("lanczos", taps=4),
_DefineScaler("lanczos", taps=5),
],
"spline": [
_DefineScaler("spline16"),
_DefineScaler("spline36"),
_DefineScaler("spline64"),
]
}
)
common_scaler = {
"bilinear": [_DefineScaler("bilinear")],
"bicubic": [
_DefineScaler("bicubic", b=1 / 3, c=1 / 3),
_DefineScaler("bicubic", b=.5, c=0),
_DefineScaler("bicubic", b=0, c=.5),
_DefineScaler("bicubic", b=1, c=0),
_DefineScaler("bicubic", b=0, c=1),
_DefineScaler("bicubic", b=.2, c=.5),
_DefineScaler("bicubic", b=.5, c=.5),
],
"lanczos": [
_DefineScaler("lanczos", taps=2),
_DefineScaler("lanczos", taps=3),
_DefineScaler("lanczos", taps=4),
_DefineScaler("lanczos", taps=5),
],
"spline": [
_DefineScaler("spline16"),
_DefineScaler("spline36"),
_DefineScaler("spline64"),
]
}
class GetNative:
def __init__(self, src, scaler, ar, min_h, max_h, frame, mask_out, plot_scaling, plot_format, show_plot, no_save,
steps, output_dir):
self.plot_format = plot_format