def encode_one_yuv(exe_path, one_yuv, usage_type=0, qp=24): name = ((one_yuv.split(os.sep))[-1]) width, height, frame_rate = CodecUtil.get_resolution_from_name(name) if frame_rate == 0: frame_rate = 30 # encoding current_path = os.getcwd() os.chdir(exe_path) print("current path is %s\n" % exe_path) bs_name, log_name = CodecUtil.call_encoder_qp(one_yuv, usage_type, width, height, qp, ' -threadIdc 4 ') #deal with log file fps = CodecUtil.encoder_log_file(log_name) if fps == -1: return OneTestPoint(qp, 0, 0, 0, 0, 0) if not PERFORMANCE_ONLY: # decoding rec_yuv = bs_name + '_dec.yuv' CodecUtil.decode(bs_name, rec_yuv) # psnr ing bitrate, psnr_y, psnr_u, psnr_v = CodecUtil.calculate_psnr( width, height, one_yuv, rec_yuv, rec_yuv + '.log', bs_name, frame_rate) current_test_point = OneTestPoint(qp, fps, bitrate, psnr_y, psnr_u, psnr_v) os.remove(rec_yuv) else: current_test_point = OneTestPoint(qp, fps, 0, 0, 0, 0) os.chdir(current_path) return current_test_point