def CleanIntermediateFiles(): folders = [Path_DecodedYuv, Path_CfgFiles] if not KeepUpscaledOutput: folders += [Path_DecUpScaleYuv, Path_UpScaleYuv] for folder in folders: Cleanfolder(folder)
def CleanUp_workfolders(): folders = [Path_DnScaleYuv, Path_Bitstreams, Path_DecodedYuv, Path_QualityLog, Path_TestLog, Path_CfgFiles] if not KeepUpscaledOutput: folders += [Path_UpScaleYuv, Path_DecUpScaleYuv] for folder in folders: Cleanfolder(folder)
def Run_Scaling_Test(content, dnScalAlgo, upScalAlgo, path_dnscl, path_upscl, path_log, path_cfg, savememory, keepupscaledyuv): logger.info("start running scaling tests with content %s" % os.path.basename(content)) cls, width, height, fr, bitdepth, fmt, totalnum = GetVideoInfo(content, Clips) if totalnum < FrameNum: logger.error("content %s includes total %d frames < specified % frames!" % (content, totalnum, FrameNum)) return DnScaledRes = [(int(width / ratio), int(height / ratio)) for ratio in DnScaleRatio] for i in range(len(DnScaledRes)): if savememory: Cleanfolder(path_cfg) if not keepupscaledyuv: Cleanfolder(path_upscl) DnScaledW = DnScaledRes[i][0] DnScaledH = DnScaledRes[i][1] logger.info("start downscaling content to %dx%d" % (DnScaledW, DnScaledH)) # downscaling dnscalyuv = GetDownScaledOutFile(content, width, height, DnScaledW, DnScaledH, path_dnscl, dnScalAlgo) if not os.path.isfile(dnscalyuv): dnscalyuv = DownScaling(content, FrameNum, width, height, DnScaledW, DnScaledH, path_dnscl, dnScalAlgo) upscaleyuv = UpScaling(dnscalyuv, FrameNum, DnScaledW, DnScaledH, width, height, path_upscl, upScalAlgo) CalculateQualityMetric(content, FrameNum, upscaleyuv, width, height, path_log, path_cfg) if savememory: Cleanfolder(path_dnscl) logger.info("finish running scaling test.")
def Run_ConvexHull_Test(content, dnScalAlgo, upScalAlgo): Utils.Logger.info("%s %s start running xcode tests with %s" % (EncodeMethod, CodecName, os.path.basename(content))) cls, width, height, fr, bitdepth, fmt, totalnum = GetVideoInfo(content, Clips) if totalnum < FrameNum: Utils.Logger.error("content %s includes total %d frames < specified % frames!" % (content, totalnum, FrameNum)) return DnScaledRes = [(int(width / ratio), int(height / ratio)) for ratio in DnScaleRatio] for i in range(len(DnScaledRes)): if SaveMemory: CleanIntermediateFiles() DnScaledW = DnScaledRes[i][0] DnScaledH = DnScaledRes[i][1] #downscaling if the downscaled file does not exist dnscalyuv = GetDownScaledOutFile(content, width, height, DnScaledW, DnScaledH, Path_DnScaleYuv, dnScalAlgo) if not os.path.isfile(dnscalyuv): dnscalyuv = DownScaling(content, FrameNum, width, height, DnScaledW, DnScaledH, Path_DnScaleYuv, dnScalAlgo) for QP in QPs: Utils.Logger.info("start transcode and upscale for %dx%d and QP %d" % (DnScaledW, DnScaledH, QP)) #transcode and upscaling reconyuv = Run_EncDec_Upscale(EncodeMethod, CodecName, EncodePreset, dnscalyuv, QP, FrameNum, fr, DnScaledW, DnScaledH, width, height, Path_Bitstreams, Path_DecodedYuv, Path_DecUpScaleYuv, upScalAlgo) #calcualte quality distortion Utils.Logger.info("start quality metric calculation for %dx%d and QP %d" % (DnScaledW, DnScaledH, QP)) CalculateQualityMetric(content, FrameNum, reconyuv, width, height, Path_QualityLog, Path_CfgFiles) if SaveMemory: Cleanfolder(Path_DnScaleYuv) Utils.Logger.info("finish running encode test.")
def Run_ConvexHull_Test(clip, dnScalAlgo, upScalAlgo, LogCmdOnly=False): Utils.Logger.info("start encode %s" % clip.file_name) DnScaledRes = [(int(clip.width / ratio), int(clip.height / ratio)) for ratio in DnScaleRatio] for i in range(len(DnScaledRes)): if SaveMemory: CleanIntermediateFiles() DnScaledW = DnScaledRes[i][0] DnScaledH = DnScaledRes[i][1] # downscaling if the downscaled file does not exist dnscalyuv = GetDownScaledOutFile(clip, DnScaledW, DnScaledH, Path_DnScaleYuv, dnScalAlgo) if not os.path.isfile(dnscalyuv): dnscalyuv = DownScaling(clip, FrameNum['AS'], DnScaledW, DnScaledH, Path_DnScaleYuv, Path_CfgFiles, dnScalAlgo, LogCmdOnly) ds_clip = Clip( GetShortContentName(dnscalyuv, False) + '.y4m', dnscalyuv, "", DnScaledW, DnScaledH, clip.fmt, clip.fps_num, clip.fps_denom, clip.bit_depth) for QP in QPs['AS']: Utils.Logger.info("start encode and upscale for QP %d" % QP) #encode and upscaling reconyuv = Run_EncDec_Upscale( EncodeMethod, CodecName, EncodePreset, ds_clip, 'AS', QP, FrameNum['AS'], clip.width, clip.height, Path_Bitstreams, Path_DecodedYuv, Path_DecUpScaleYuv, Path_CfgFiles, Path_PerfLog, Path_EncLog, upScalAlgo, LogCmdOnly) #calcualte quality distortion Utils.Logger.info("start quality metric calculation") CalculateQualityMetric(clip.file_path, FrameNum['AS'], reconyuv, clip.fmt, clip.width, clip.height, clip.bit_depth, Path_QualityLog, LogCmdOnly) if SaveMemory: Cleanfolder(Path_DnScaleYuv) Utils.Logger.info("finish running encode test.") Utils.Logger.info("finish running encode test.")