You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
1009 B
33 lines
1009 B
5 years ago
|
# -*- coding: utf-8 -*-
|
||
|
from __future__ import unicode_literals
|
||
|
|
||
|
from ...rule import Rule
|
||
|
|
||
|
|
||
|
class DtsHdRule(Rule):
|
||
|
"""DTS-HD rule."""
|
||
|
|
||
|
@classmethod
|
||
|
def _redefine(cls, props, name, index):
|
||
|
actual = props.get(name)
|
||
|
if isinstance(actual, list):
|
||
|
value = actual[index]
|
||
|
if value is None:
|
||
|
del props[name]
|
||
|
else:
|
||
|
props[name] = value
|
||
|
|
||
|
def execute(self, props, pv_props, context):
|
||
|
"""Execute the rule against properties."""
|
||
|
if props.get('codec') == 'DTS-HD':
|
||
|
index = None
|
||
|
for i, profile in enumerate(props.get('profile', [])):
|
||
|
if profile and profile.upper() != 'CORE':
|
||
|
index = i
|
||
|
break
|
||
|
|
||
|
if index is not None:
|
||
|
for name in ('profile', 'channels_count', 'bit_rate',
|
||
|
'bit_rate_mode', 'sampling_rate', 'compression'):
|
||
|
self._redefine(props, name, index)
|