Extending deinterlace subparams to hex range
This commit is contained in:
@@ -1217,8 +1217,9 @@ def checkUniqueDispositions(context, mediaDescriptor: MediaDescriptor):
|
|||||||
show_default=True,
|
show_default=True,
|
||||||
callback=normalizeDeinterlaceOption,
|
callback=normalizeDeinterlaceOption,
|
||||||
help=(
|
help=(
|
||||||
"Deinterlace with bwdif followed by ordered upN, downN, and tempNNNN "
|
"Deinterlace with bwdif followed by ordered upN, downN, and tempHHHH "
|
||||||
"components, for example up2_temp3366_down2."
|
"components. Scale factors N range from 2 to 8; H is hexadecimal. "
|
||||||
|
"For example: up2_temp3366_down2."
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ class DeinterlaceFilter(Filter):
|
|||||||
|
|
||||||
DEFAULT_SCALE_FACTOR = 2
|
DEFAULT_SCALE_FACTOR = 2
|
||||||
MIN_SCALE_FACTOR = 2
|
MIN_SCALE_FACTOR = 2
|
||||||
MAX_SCALE_FACTOR = 4
|
MAX_SCALE_FACTOR = 8
|
||||||
DEFAULT_TEMP_PARAMETERS = '3366'
|
DEFAULT_TEMP_PARAMETERS = '3366'
|
||||||
|
|
||||||
# DEFAULT_STRENGTH: float = 2.8
|
# DEFAULT_STRENGTH: float = 2.8
|
||||||
@@ -156,7 +156,7 @@ class DeinterlaceFilter(Filter):
|
|||||||
)
|
)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
tempMatch = re.fullmatch(r'temp(\d*)', component)
|
tempMatch = re.fullmatch(r'temp([0-9a-fA-F]*)', component)
|
||||||
if tempMatch:
|
if tempMatch:
|
||||||
parameters = (
|
parameters = (
|
||||||
tempMatch.group(1)
|
tempMatch.group(1)
|
||||||
@@ -164,9 +164,10 @@ class DeinterlaceFilter(Filter):
|
|||||||
)
|
)
|
||||||
if len(parameters) != 4:
|
if len(parameters) != 4:
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
f"Temporal parameters in '{component}' must contain four digits"
|
f"Temporal parameters in '{component}' must contain "
|
||||||
|
+ "four hexadecimal digits"
|
||||||
)
|
)
|
||||||
strengths = [f"{int(digit) / 2:g}" for digit in parameters]
|
strengths = [f"{int(digit, 16) / 2:g}" for digit in parameters]
|
||||||
tokens.append(f"hqdn3d={':'.join(strengths)}")
|
tokens.append(f"hqdn3d={':'.join(strengths)}")
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
|||||||
@@ -84,6 +84,31 @@ class DeinterlaceFilterTest(unittest.TestCase):
|
|||||||
payload['tokens'],
|
payload['tokens'],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def test_temporal_parameters_accept_hexadecimal_digits(self):
|
||||||
|
lowerPayload = self.getPayload('temp00ff')
|
||||||
|
mixedPayload = self.getPayload('tempFf33')
|
||||||
|
|
||||||
|
self.assertEqual(
|
||||||
|
['bwdif=mode=1', 'hqdn3d=0:0:7.5:7.5'],
|
||||||
|
lowerPayload['tokens'],
|
||||||
|
)
|
||||||
|
self.assertEqual(
|
||||||
|
['bwdif=mode=1', 'hqdn3d=7.5:7.5:1.5:1.5'],
|
||||||
|
mixedPayload['tokens'],
|
||||||
|
)
|
||||||
|
|
||||||
|
def test_scale_factors_accept_boundaries_from_two_to_eight(self):
|
||||||
|
payload = self.getPayload('up8_down2')
|
||||||
|
|
||||||
|
self.assertEqual(
|
||||||
|
[
|
||||||
|
'bwdif=mode=1',
|
||||||
|
'scale=iw*8:ih*8:flags=lanczos',
|
||||||
|
'scale=iw/2:ih/2:flags=lanczos',
|
||||||
|
],
|
||||||
|
payload['tokens'],
|
||||||
|
)
|
||||||
|
|
||||||
def test_each_component_uses_its_default_when_parameters_are_omitted(self):
|
def test_each_component_uses_its_default_when_parameters_are_omitted(self):
|
||||||
payload = self.getPayload('up_temp_down')
|
payload = self.getPayload('up_temp_down')
|
||||||
|
|
||||||
@@ -105,7 +130,7 @@ class DeinterlaceFilterTest(unittest.TestCase):
|
|||||||
DeinterlaceFilter(mode='other')
|
DeinterlaceFilter(mode='other')
|
||||||
|
|
||||||
def test_invalid_parameters_are_rejected(self):
|
def test_invalid_parameters_are_rejected(self):
|
||||||
invalidModes = ('up0', 'down5', 'temp123', 'up__down')
|
invalidModes = ('up1', 'down9', 'temp123', 'temp00gg', 'up__down')
|
||||||
|
|
||||||
for mode in invalidModes:
|
for mode in invalidModes:
|
||||||
with self.subTest(mode=mode), self.assertRaises(ValueError):
|
with self.subTest(mode=mode), self.assertRaises(ValueError):
|
||||||
|
|||||||
Reference in New Issue
Block a user