Skip to content

Commit

Permalink
add stringapi command parameter and platform support
Browse files Browse the repository at this point in the history
Signed-off-by: Focus Luo <[email protected]>
  • Loading branch information
FocusLuo committed Jun 3, 2024
1 parent 0809e7c commit f852a4a
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 29 deletions.
11 changes: 11 additions & 0 deletions .slashrc
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,12 @@ class MediaPlugin(slash.plugins.PluginInterface):
parser.add_argument("--parallel-metrics", action = "store_true")
parser.add_argument("--platform", default = None, type = str, required = True)
parser.add_argument("--device", default = '/dev/dri/renderD128', type = str, help = 'vaapi-fits run with render device')
parser.add_argument("--stringapi", default = 0,
type = int, help = (
f"{int(0)} = default, disabled string api; "
f"{int(1)} = only enabled string api; "
f"{int(2)} = random call parameters with enabling and disabling string api"
" (default: %(default)i)"))

def configure_from_parsed_args(self, args):
self.baseline = Baseline(args.baseline_file, args.rebase)
Expand All @@ -98,6 +104,7 @@ class MediaPlugin(slash.plugins.PluginInterface):
self.ctapr = args.ctapr
self.platform = args.platform
self.render_device = args.device
self.stringapi = args.stringapi

assert not (args.rebase and slash.config.root.parallel.num_workers > 0), "rebase in parallel mode is not supported"
assert not (args.ctapt != -1 and slash.config.root.parallel.num_workers > 0), "ctapt in parallel mode is not supported"
Expand Down Expand Up @@ -209,6 +216,10 @@ class MediaPlugin(slash.plugins.PluginInterface):
from lib.platform import info
return info()["gpu"]["gen"]

def _get_platform_stringapi_enable(self):
from lib.platform import info
return info()["stringapi"]["enable"]

def _get_call_timeout(self):
if self.test_call_timeout > 0:
return self.test_call_timeout
Expand Down
1 change: 1 addition & 0 deletions lib/caps/DG2/info
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@

info = dict(
gpu = dict(gen = 12.7),
stringapi = dict(enable = True),
)
54 changes: 25 additions & 29 deletions lib/ffmpeg/qsv/encoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,32 +65,10 @@ def map_profile_stringapi(self, codec, profile):

@property
def encparams(self):
_enc_params_stringapi = 0
_stringapi_param = 0
_cmdline_stringapi_param = vars(self).get("cmdline_stringapi_param", 0) #passed through from the test cases cmdline option
if _cmdline_stringapi_param == 1: #to call encparams_string_api
_stringapi_param = 1
elif _stringapi_param == 2: #the random is even, then to call encparams_string_api
_randint = random.randint(1,10)
if _randint%2==0: #even
_stringapi_param = 1
else:
_stringapi_param = 0
else:
_enc_params_stringapi = 0

# check whether call encparams_string_api
_enc_params_stringapi = all([
vars(self).get("stringapi_platform_support", 0), #the platform whether support stringapi
_stringapi_param == 1,
])

_enc_params_stringapi = 1
_enc_params_stringapi = vars(self).get("is_enc_params_stringapi", 0)
if _enc_params_stringapi:
vars(self).setdefault("is_enc_params_stringapi", 1)
return (f"{self.encparams_string_api}")
else:
vars(self).setdefault("is_enc_params_stringapi", 0)
return (
f"{super().encparams}{self.ldb}"
f"{self.iqfactor}{self.bqfactor}"
Expand Down Expand Up @@ -200,12 +178,29 @@ def encode(self):
if vars(self).get("_encoded", None) is not None:
get_media().artifacts.purge(self._encoded)
self._encoded = get_media().artifacts.reserve(self.encoded_ext)
_is_enc_params_stringapi = vars(self).get("is_enc_params_stringapi", 0)
_is_enc_params_stringapi=1
if _is_enc_params_stringapi==1:
#if vars(self).get("_encoded", None) is not None:
# get_media().artifacts.purge(self._encoded)
#self._encoded = get_media().artifacts.reserve(self.encoded_ext)

_enc_params_stringapi = 0
_stringapi_param = 0
_cmdline_stringapi_param = get_media().stringapi #passed through from the test cases cmdline option
if _cmdline_stringapi_param == 1: #to call encparams_string_api
_stringapi_param = 1
elif _cmdline_stringapi_param == 2: #the random is even, then to call encparams_string_api
_randint = random.randint(1,10)
if _randint%2==0: #even
_stringapi_param = 1
else:
_stringapi_param = 0
else:
_enc_params_stringapi = 0

# check whether call encparams_string_api
_enc_params_stringapi = all([
get_media()._get_platform_stringapi_enable(), #the platform whether support stringapi
_stringapi_param == 1
])

if _enc_params_stringapi == True:
vars(self).update(is_enc_params_stringapi=1)
return call(
f"{exe2os('ffmpeg')} -v verbose {self.hwinit}"
f" -f rawvideo -pix_fmt {self.format} -s:v {self.width}x{self.height}"
Expand All @@ -215,6 +210,7 @@ def encode(self):
f" -vframes {self.frames} -y {self.ffoutput}"
)
else:
vars(self).update(is_enc_params_stringapi=0)
return call(
f"{exe2os('ffmpeg')} -v verbose {self.hwinit}"
f" -f rawvideo -pix_fmt {self.format} -s:v {self.width}x{self.height}"
Expand Down

0 comments on commit f852a4a

Please sign in to comment.