Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / third_party / libvpx / source / libvpx / test / decode_perf_test.cc
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
20 using std::tr1::make_tuple;
21
22 namespace {
23
24 #define VIDEO_NAME 0
25 #define THREADS 1
26
27 const double kUsecsInSec = 1000000.0;
28
29 /*
30  DecodePerfTest takes a tuple of filename + number of threads to decode with
31  */
32 typedef std::tr1::tuple<const char *, unsigned> DecodePerfParam;
33
34 const DecodePerfParam 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_854x356_tile_1x2_fpm_546kbps.webm", 2),
51   make_tuple("vp90-2-tos_1280x534_tile_1x4_1306kbps.webm", 4),
52   make_tuple("vp90-2-tos_1280x534_tile_1x4_fpm_952kbps.webm", 4),
53   make_tuple("vp90-2-tos_1920x800_tile_1x4_fpm_2335kbps.webm", 4),
54 };
55
56 /*
57  In order to reflect real world performance as much as possible, Perf tests
58  *DO NOT* do any correctness checks. Please run them alongside correctness
59  tests to ensure proper codec integrity. Furthermore, in this test we
60  deliberately limit the amount of system calls we make to avoid OS
61  preemption.
62
63  TODO(joshualitt) create a more detailed perf measurement test to collect
64    power/temp/min max frame decode times/etc
65  */
66
67 class DecodePerfTest : public ::testing::TestWithParam<DecodePerfParam> {
68 };
69
70 TEST_P(DecodePerfTest, PerfTest) {
71   const char *const video_name = GET_PARAM(VIDEO_NAME);
72   const unsigned threads = GET_PARAM(THREADS);
73
74   libvpx_test::WebMVideoSource video(video_name);
75   video.Init();
76
77   vpx_codec_dec_cfg_t cfg = vpx_codec_dec_cfg_t();
78   cfg.threads = threads;
79   libvpx_test::VP9Decoder decoder(cfg, 0);
80
81   vpx_usec_timer t;
82   vpx_usec_timer_start(&t);
83
84   for (video.Begin(); video.cxdata() != NULL; video.Next()) {
85     decoder.DecodeFrame(video.cxdata(), video.frame_size());
86   }
87
88   vpx_usec_timer_mark(&t);
89   const double elapsed_secs = double(vpx_usec_timer_elapsed(&t))
90                               / kUsecsInSec;
91   const unsigned frames = video.frame_number();
92   const double fps = double(frames) / elapsed_secs;
93
94   printf("{\n");
95   printf("\t\"type\" : \"decode_perf_test\",\n");
96   printf("\t\"version\" : \"%s\",\n", VERSION_STRING_NOSP);
97   printf("\t\"videoName\" : \"%s\",\n", video_name);
98   printf("\t\"threadCount\" : %u,\n", threads);
99   printf("\t\"decodeTimeSecs\" : %f,\n", elapsed_secs);
100   printf("\t\"totalFrames\" : %u,\n", frames);
101   printf("\t\"framesPerSecond\" : %f\n", fps);
102   printf("}\n");
103 }
104
105 INSTANTIATE_TEST_CASE_P(VP9, DecodePerfTest,
106                         ::testing::ValuesIn(kVP9DecodePerfVectors));
107
108 }  // namespace