def ScoreCpuPsnr(target_bitrate, result):
  """Returns the score relevant to interactive usage.

  The constraints are:
  - Stay within the requested bitrate
  - Encode time needs to stay below clip length
  - Decode time needs to stay below clip length
  Otherwise, PSNR rules."""
  score = result['psnr']
  # We penalize bitrates that exceed the target bitrate.
  if result['bitrate'] > int(target_bitrate):
    score -= (result['bitrate'] - int(target_bitrate)) * 0.1
  # We penalize CPU usage that exceeds clip time.
  used_time = result['encode_cputime']
  available_time = result['cliptime']
  
  if used_time > available_time:
    badness = (used_time - available_time) / available_time
    score -= badness * 100
  return score