Home | History | Annotate | Download | only in native_Benchmarks
      1 # Copyright (c) 2015 The Chromium OS Authors. All rights reserved.
      2 # Use of this source code is governed by a BSD-style license that can be
      3 # found in the LICENSE file.
      4 
      5 from native_Benchmarks_common import *
      6 from webm import webm
      7 
      8 class vp8(object):
      9     """Build webm codec (vpxenc/vpxdec) and run them on client"""
     10     def __init__(self, scratch_srv, scratch_cli, client, args):
     11         # Instantiating webm builds the codec.
     12         self.webm = webm(scratch_srv, scratch_cli, client, args)
     13         self.client = client
     14         self.scratch_cli = scratch_cli
     15 
     16         # download
     17         src = '%s/vp8.webm' % SERVER_TEST_ROOT
     18         dst = '%s/vp8.webm' % scratch_cli
     19         rcp_check(client, src, dst,
     20                   'Error occurred while sending vp8.webm to client.\n')
     21 
     22     def run(self):
     23         """Returns perf_value tuples"""
     24         # run decoder
     25         cmd = ('%s --summary %s/vp8.webm -o %s/vp8.yuv 2>&1' %
     26                (self.webm.vpxdec, self.scratch_cli, self.scratch_cli))
     27         declog = run_check(self.client, cmd, "Error occurred while running vp8")
     28         # run encoder
     29         cmd = (('%s %s/vp8.yuv -o /dev/null --codec=vp8 --i420 -w 1280' +
     30                 ' -h 720 --good --cpu-used=0 --target-bitrate=2000 2>&1') %
     31                (self.webm.vpxenc, self.scratch_cli))
     32         enclog = run_check(self.client, cmd,
     33                            "Error occurred while running vp8enc")
     34         return self.parse(declog, enclog)
     35 
     36     def parse(self, dec, enc):
     37         """Translate logs into perf_values tuples.
     38         @param dec: logs from decoder
     39         @param enc: logs from encoder
     40         """
     41         return [{'description': 'VP8',
     42                  'graph': 'decode',
     43                  'value': dec.split()[-2][1:],
     44                  'units': 'fps'},
     45                 {'description': 'VP8',
     46                  'graph': 'encode',
     47                  'value': enc.split()[-2][1:],
     48                  'units': 'fps'}]
     49 
     50     def __del__(self):
     51         run_check(self.client, 'rm -f %s/vp8.yuv' % self.scratch_cli,
     52                   "Error occurred while cleaning up")
     53