diff --git a/.slashrc b/.slashrc index eedec6fe..cf97d5fa 100644 --- a/.slashrc +++ b/.slashrc @@ -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) @@ -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" @@ -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 diff --git a/lib/caps/DG2/info b/lib/caps/DG2/info index a809063f..6da6885c 100644 --- a/lib/caps/DG2/info +++ b/lib/caps/DG2/info @@ -10,4 +10,5 @@ info = dict( gpu = dict(gen = 12.7), + stringapi = dict(enable = True), ) diff --git a/lib/ffmpeg/qsv/encoder.py b/lib/ffmpeg/qsv/encoder.py index 99de3fbd..c3a7cc88 100644 --- a/lib/ffmpeg/qsv/encoder.py +++ b/lib/ffmpeg/qsv/encoder.py @@ -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}" @@ -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}" @@ -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}"