1/*
2 *  Copyright (c) 2013 The WebM project authors. All Rights Reserved.
3 *
4 *  Use of this source code is governed by a BSD-style license
5 *  that can be found in the LICENSE file in the root of the source
6 *  tree. An additional intellectual property rights grant can be found
7 *  in the file PATENTS.  All contributing project authors may
8 *  be found in the AUTHORS file in the root of the source tree.
9 */
10
11#include "test/codec_factory.h"
12#include "test/decode_test_driver.h"
13#include "test/ivf_video_source.h"
14#include "test/md5_helper.h"
15#include "test/util.h"
16#include "test/webm_video_source.h"
17#include "vpx_ports/vpx_timer.h"
18#include "./vpx_version.h"
19
20using std::tr1::make_tuple;
21
22namespace {
23
24#define VIDEO_NAME 0
25#define THREADS 1
26
27const double kUsecsInSec = 1000000.0;
28
29/*
30 DecodePerfTest takes a tuple of filename + number of threads to decode with
31 */
32typedef std::tr1::tuple<const char *, unsigned> decode_perf_param_t;
33
34const decode_perf_param_t kVP9DecodePerfVectors[] = {
35  make_tuple("vp90-2-bbb_426x240_tile_1x1_180kbps.webm", 1),
36  make_tuple("vp90-2-bbb_640x360_tile_1x2_337kbps.webm", 2),
37  make_tuple("vp90-2-bbb_854x480_tile_1x2_651kbps.webm", 2),
38  make_tuple("vp90-2-bbb_1280x720_tile_1x4_1310kbps.webm", 4),
39  make_tuple("vp90-2-bbb_1920x1080_tile_1x1_2581kbps.webm", 1),
40  make_tuple("vp90-2-bbb_1920x1080_tile_1x4_2586kbps.webm", 4),
41  make_tuple("vp90-2-bbb_1920x1080_tile_1x4_fpm_2304kbps.webm", 4),
42  make_tuple("vp90-2-sintel_426x182_tile_1x1_171kbps.webm", 1),
43  make_tuple("vp90-2-sintel_640x272_tile_1x2_318kbps.webm", 2),
44  make_tuple("vp90-2-sintel_854x364_tile_1x2_621kbps.webm", 2),
45  make_tuple("vp90-2-sintel_1280x546_tile_1x4_1257kbps.webm", 4),
46  make_tuple("vp90-2-sintel_1920x818_tile_1x4_fpm_2279kbps.webm", 4),
47  make_tuple("vp90-2-tos_426x178_tile_1x1_181kbps.webm", 1),
48  make_tuple("vp90-2-tos_640x266_tile_1x2_336kbps.webm", 2),
49  make_tuple("vp90-2-tos_854x356_tile_1x2_656kbps.webm", 2),
50  make_tuple("vp90-2-tos_1280x534_tile_1x4_1306kbps.webm", 4),
51  make_tuple("vp90-2-tos_1920x800_tile_1x4_fpm_2335kbps.webm", 4),
52};
53
54/*
55 In order to reflect real world performance as much as possible, Perf tests
56 *DO NOT* do any correctness checks. Please run them alongside correctness
57 tests to ensure proper codec integrity. Furthermore, in this test we
58 deliberately limit the amount of system calls we make to avoid OS
59 preemption.
60
61 TODO(joshualitt) create a more detailed perf measurement test to collect
62   power/temp/min max frame decode times/etc
63 */
64
65class DecodePerfTest : public ::testing::TestWithParam<decode_perf_param_t> {
66};
67
68TEST_P(DecodePerfTest, PerfTest) {
69  const char *const video_name = GET_PARAM(VIDEO_NAME);
70  const unsigned threads = GET_PARAM(THREADS);
71
72  libvpx_test::WebMVideoSource video(video_name);
73  video.Init();
74
75  vpx_codec_dec_cfg_t cfg = {0};
76  cfg.threads = threads;
77  libvpx_test::VP9Decoder decoder(cfg, 0);
78
79  vpx_usec_timer t;
80  vpx_usec_timer_start(&t);
81
82  for (video.Begin(); video.cxdata() != NULL; video.Next()) {
83    decoder.DecodeFrame(video.cxdata(), video.frame_size());
84  }
85
86  vpx_usec_timer_mark(&t);
87  const double elapsed_secs = double(vpx_usec_timer_elapsed(&t))
88                              / kUsecsInSec;
89  const unsigned frames = video.frame_number();
90  const double fps = double(frames) / elapsed_secs;
91
92  printf("{\n");
93  printf("\t\"version\" : \"%s\",\n", VERSION_STRING_NOSP);
94  printf("\t\"videoName\" : \"%s\",\n", video_name);
95  printf("\t\"threadCount\" : %u,\n", threads);
96  printf("\t\"decodeTimeSecs\" : %f,\n", elapsed_secs);
97  printf("\t\"totalFrames\" : %u,\n", frames);
98  printf("\t\"framesPerSecond\" : %f\n", fps);
99  printf("}\n");
100}
101
102INSTANTIATE_TEST_CASE_P(VP9, DecodePerfTest,
103                        ::testing::ValuesIn(kVP9DecodePerfVectors));
104
105}  // namespace
106