MCPcopy Create free account
hub / github.com/Netflix/vmaf / SpEEDMatlabFeatureExtractor

Class SpEEDMatlabFeatureExtractor

python/vmaf/core/matlab_feature_extractor.py:209–282  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

207
208
209class SpEEDMatlabFeatureExtractor(MatlabFeatureExtractor):
210 TYPE = 'SpEED_Matlab_feature'
211
212 VERSION = '0.1'
213
214 scale_list = [2, 3, 4]
215 ATOM_FEATURES = []
216 DERIVED_ATOM_FEATURES = []
217 for scale_now in scale_list:
218 ATOM_FEATURES.append('sspeed_' + str(scale_now))
219 ATOM_FEATURES.append('tspeed_' + str(scale_now))
220 DERIVED_ATOM_FEATURES.append('speed_' + str(scale_now))
221
222 MATLAB_WORKSPACE = VmafConfig.root_path('matlab', 'SpEED')
223
224 def _generate_result(self, asset):
225
226 # routine to call the command-line executable and generate quality
227 # scores in the log file.
228 ref_procfile_path = asset.ref_procfile_path
229 dis_procfile_path = asset.dis_procfile_path
230 log_file_path = self._get_log_file_path(asset)
231 current_dir = os.getcwd() + '/'
232 ref_procfile_path = make_absolute_path(ref_procfile_path, current_dir)
233 dis_procfile_path = make_absolute_path(dis_procfile_path, current_dir)
234 log_file_path = make_absolute_path(log_file_path, current_dir)
235 quality_width, quality_height = asset.quality_width_height
236 speed_cmd = '''{matlab} -nodisplay -nosplash -nodesktop -r "run_speed('{ref}', '{dis}', {w}, {h}, {bands}, '{yuv_type}'); exit;" >> {log_file_path}'''.format(
237 matlab=VmafExternalConfig.get_and_assert_matlab(),
238 ref=ref_procfile_path,
239 dis=dis_procfile_path,
240 w=quality_width,
241 h=quality_height,
242 bands=self.scale_list,
243 yuv_type=self._get_workfile_yuv_type(asset),
244 log_file_path=log_file_path,
245 )
246 if self.logger:
247 self.logger.info(speed_cmd)
248 os.chdir(self.MATLAB_WORKSPACE)
249 run_process(speed_cmd, shell=True)
250 os.chdir(current_dir)
251
252 @classmethod
253 @override(Executor)
254 def _post_process_result(cls, result):
255
256 def _speed(sspeed_tspeed):
257 sspeed, tspeed = sspeed_tspeed
258 if sspeed is not None and tspeed is not None:
259 return sspeed * tspeed
260 elif sspeed is None:
261 return tspeed
262 elif tspeed is None:
263 return sspeed
264 else:
265 return None
266

Callers

nothing calls this directly

Calls 1

root_pathMethod · 0.80

Tested by

no test coverage detected