Further cleanup

This commit is contained in:
Simon Huber 2021-04-05 22:03:31 +02:00
parent 350d8b6a30
commit f14cb122fe

View file

@ -47,21 +47,15 @@ class TargetQuality:
chunk.per_frame_target_quality_q_list = self.per_frame_target_quality(
chunk)
def log_probes(self,
vmaf_cq,
frames,
name,
skip=None,
q=None,
q_vmaf=None):
def log_probes(self, vmaf_cq, frames, name, target_q, target_vmaf, skip=None):
"""
Logs probes result
:type vmaf_cq: list probe measurements (q_vmaf, q)
:type frames: int frame count of chunk
:type name: str chunk name
:type skip: str None if normal results, else "high" or "low"
:type q: int Calculated q to be used if probe procedure finished as planned
:type q_vmaf: float Calculated VMAF that would be achieved by using the q
:type target_q: int Calculated q to be used
:type target_vmaf: float Calculated VMAF that would be achieved by using the q
:return: None
"""
if skip == 'high':
@ -71,12 +65,9 @@ class TargetQuality:
else:
sk = ''
target_q = q if q else vmaf_cq[-1][1]
target_vmaf = q_vmaf if q_vmaf else round(vmaf_cq[-1][0], 2)
log(f"Chunk: {name}, Rate: {self.probing_rate}, Fr: {frames}")
log(f"Probes: {str(sorted(vmaf_cq))[1:-1]}{sk}")
log(f"Target Q: {target_q} VMAF: {target_vmaf}")
log(f"Target Q: {target_q} VMAF: {round(target_vmaf, 2)}")
def per_shot_target_quality(self, chunk: Chunk):
"""
@ -123,7 +114,7 @@ class TargetQuality:
vmaf_cq.append((score, next_q))
if next_q == self.min_q or next_q == self.max_q:
self.log_probes(vmaf_cq, frames, chunk.name, q=next_q, q_vmaf=score,
self.log_probes(vmaf_cq, frames, chunk.name, next_q, score,
skip='low' if score < self.target else 'high')
return next_q
@ -156,7 +147,7 @@ class TargetQuality:
vmaf_cq_upper = new_point
q, q_vmaf = self.get_target_q(vmaf_cq, self.target)
self.log_probes(vmaf_cq, frames, chunk.name, q=q, q_vmaf=q_vmaf)
self.log_probes(vmaf_cq, frames, chunk.name, q, q_vmaf)
# log(f'Scene_score {self.get_scene_scores(chunk, self.ffmpeg_pipe)}')
# Plot Probes
if self.make_plots and len(vmaf_cq) > 3:
@ -197,6 +188,7 @@ class TargetQuality:
# Single probe cq guess or exit to avoid divide by zero
if self.probes == 1 or next_q == last_q:
self.log_probes(vmaf_cq, chunk.frames, chunk.name, next_q, self.target)
return next_q
# Second probe at guessed value
@ -217,7 +209,7 @@ class TargetQuality:
if self.max_q < next_q:
next_q = self.max_q
self.log_probes(vmaf_cq, chunk.frames, chunk.name)
self.log_probes(vmaf_cq, chunk.frames, chunk.name, next_q, self.target)
return next_q