From b5e665f4289c7f4d965ca2713b145a152a476a76 Mon Sep 17 00:00:00 2001 From: Zen <46526140+master-of-zen@users.noreply.github.com> Date: Wed, 22 Jul 2020 20:35:59 +0300 Subject: [PATCH] optimized target_vmaf --- Av1an/target_vmaf.py | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/Av1an/target_vmaf.py b/Av1an/target_vmaf.py index 12b31d8..763dcc6 100644 --- a/Av1an/target_vmaf.py +++ b/Av1an/target_vmaf.py @@ -94,7 +94,6 @@ def plot_probes(args, vmaf_cq, vmaf_target, probe, frames): plt.title(f'Chunk: {probe.stem}, Frames: {frames}') plt.tight_layout() temp = args.temp / probe.stem - plt.tight_layout() plt.savefig(f'{temp}.png', dpi=200, format='png') plt.close() @@ -160,23 +159,17 @@ def target_vmaf_search(probe, source, frames, args): vmaf_cq = [] q_list = [args.min_cq, args.max_cq] - vmaf_steps = args.vmaf_steps - 2 score = 0 + last_q = args.min_cq + next_q = args.max_cq + for _ in range(args.vmaf_steps - 2 ): - for i in range(vmaf_steps): - if i == 0: - middle_point = (args.min_cq + args.max_cq) // 2 - score = vmaf_probe(probe, middle_point, args ) - vmaf_cq.append((score, middle_point)) - q_list.append(middle_point) - continue - - last_q = vmaf_cq[-1][1] - next_q = get_closest(q_list, last_q, positive=score >= args.vmaf_target) - new_point = get_q(last_q, next_q) + new_point= get_q(last_q, next_q) + last_q = new_point q_list.append(new_point) score = vmaf_probe(probe, new_point, args) + next_q = get_closest(q_list, last_q, positive=score >= args.vmaf_target) vmaf_cq.append((score, new_point)) return vmaf_cq