Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(318)

Side by Side Diff: source/libvpx/test/vp9_encoder_parms_get_to_decoder.cc

Issue 812033011: libvpx: Pull from upstream (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/third_party/libvpx/
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « source/libvpx/test/vp8_fragments_test.cc ('k') | source/libvpx/test/vp9_end_to_end_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright (c) 2014 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/encode_test_driver.h"
13 #include "test/y4m_video_source.h"
14 #include "test/yuv_video_source.h"
15 #include "test/util.h"
16 #include "third_party/googletest/src/include/gtest/gtest.h"
17 #include "vp9/decoder/vp9_decoder.h"
18
19 typedef vpx_codec_stream_info_t vp9_stream_info_t;
20 struct vpx_codec_alg_priv {
21 vpx_codec_priv_t base;
22 vpx_codec_dec_cfg_t cfg;
23 vp9_stream_info_t si;
24 struct VP9Decoder *pbi;
25 int postproc_cfg_set;
26 vp8_postproc_cfg_t postproc_cfg;
27 vpx_decrypt_cb decrypt_cb;
28 void *decrypt_state;
29 vpx_image_t img;
30 int img_avail;
31 int flushed;
32 int invert_tile_order;
33 int frame_parallel_decode;
34
35 // External frame buffer info to save for VP9 common.
36 void *ext_priv; // Private data associated with the external frame buffers.
37 vpx_get_frame_buffer_cb_fn_t get_ext_fb_cb;
38 vpx_release_frame_buffer_cb_fn_t release_ext_fb_cb;
39 };
40
41 static vpx_codec_alg_priv_t *get_alg_priv(vpx_codec_ctx_t *ctx) {
42 return (vpx_codec_alg_priv_t *)ctx->priv;
43 }
44
45 namespace {
46
47 const unsigned int kFramerate = 50;
48 const int kCpuUsed = 2;
49
50 struct EncodePerfTestVideo {
51 const char *name;
52 uint32_t width;
53 uint32_t height;
54 uint32_t bitrate;
55 int frames;
56 };
57
58 const EncodePerfTestVideo kVP9EncodePerfTestVectors[] = {
59 {"niklas_1280_720_30.yuv", 1280, 720, 600, 10},
60 };
61
62 struct EncodeParameters {
63 int32_t tile_rows;
64 int32_t tile_cols;
65 int32_t lossless;
66 int32_t error_resilient;
67 int32_t frame_parallel;
68 // TODO(JBB): quantizers / bitrate
69 };
70
71 const EncodeParameters kVP9EncodeParameterSet[] = {
72 {0, 0, 0, 1, 0},
73 {0, 0, 0, 0, 0},
74 {0, 0, 1, 0, 0},
75 {0, 2, 0, 0, 1},
76 // TODO(JBB): Test profiles (requires more work).
77 };
78
79 int is_extension_y4m(const char *filename) {
80 const char *dot = strrchr(filename, '.');
81 if (!dot || dot == filename)
82 return 0;
83 else
84 return !strcmp(dot, ".y4m");
85 }
86
87 class Vp9EncoderParmsGetToDecoder
88 : public ::libvpx_test::EncoderTest,
89 public ::libvpx_test::CodecTestWith2Params<EncodeParameters, \
90 EncodePerfTestVideo> {
91 protected:
92 Vp9EncoderParmsGetToDecoder()
93 : EncoderTest(GET_PARAM(0)),
94 encode_parms(GET_PARAM(1)) {
95 }
96
97 virtual ~Vp9EncoderParmsGetToDecoder() {}
98
99 virtual void SetUp() {
100 InitializeConfig();
101 SetMode(::libvpx_test::kTwoPassGood);
102 cfg_.g_lag_in_frames = 25;
103 cfg_.g_error_resilient = encode_parms.error_resilient;
104 dec_cfg_.threads = 4;
105 test_video_ = GET_PARAM(2);
106 cfg_.rc_target_bitrate = test_video_.bitrate;
107 }
108
109 virtual void PreEncodeFrameHook(::libvpx_test::VideoSource *video,
110 ::libvpx_test::Encoder *encoder) {
111 if (video->frame() == 1) {
112 encoder->Control(VP9E_SET_LOSSLESS, encode_parms.lossless);
113 encoder->Control(VP9E_SET_FRAME_PARALLEL_DECODING,
114 encode_parms.frame_parallel);
115 encoder->Control(VP9E_SET_TILE_ROWS, encode_parms.tile_rows);
116 encoder->Control(VP9E_SET_TILE_COLUMNS, encode_parms.tile_cols);
117 encoder->Control(VP8E_SET_CPUUSED, kCpuUsed);
118 encoder->Control(VP8E_SET_ENABLEAUTOALTREF, 1);
119 encoder->Control(VP8E_SET_ARNR_MAXFRAMES, 7);
120 encoder->Control(VP8E_SET_ARNR_STRENGTH, 5);
121 encoder->Control(VP8E_SET_ARNR_TYPE, 3);
122 }
123 }
124
125 virtual bool HandleDecodeResult(const vpx_codec_err_t res_dec,
126 const libvpx_test::VideoSource& video,
127 libvpx_test::Decoder *decoder) {
128 vpx_codec_ctx_t* vp9_decoder = decoder->GetDecoder();
129 vpx_codec_alg_priv_t* priv =
130 (vpx_codec_alg_priv_t*) get_alg_priv(vp9_decoder);
131
132 VP9Decoder* pbi = priv->pbi;
133 VP9_COMMON* common = &pbi->common;
134
135 if (encode_parms.lossless) {
136 EXPECT_EQ(common->base_qindex, 0);
137 EXPECT_EQ(common->y_dc_delta_q, 0);
138 EXPECT_EQ(common->uv_dc_delta_q, 0);
139 EXPECT_EQ(common->uv_ac_delta_q, 0);
140 EXPECT_EQ(common->tx_mode, ONLY_4X4);
141 }
142 EXPECT_EQ(common->error_resilient_mode, encode_parms.error_resilient);
143 if (encode_parms.error_resilient) {
144 EXPECT_EQ(common->frame_parallel_decoding_mode, 1);
145 EXPECT_EQ(common->use_prev_frame_mvs, 0);
146 } else {
147 EXPECT_EQ(common->frame_parallel_decoding_mode,
148 encode_parms.frame_parallel);
149 }
150
151 EXPECT_EQ(common->log2_tile_cols, encode_parms.tile_cols);
152 EXPECT_EQ(common->log2_tile_rows, encode_parms.tile_rows);
153
154 EXPECT_EQ(VPX_CODEC_OK, res_dec) << decoder->DecodeError();
155 return VPX_CODEC_OK == res_dec;
156 }
157
158 EncodePerfTestVideo test_video_;
159
160 private:
161 EncodeParameters encode_parms;
162 };
163
164 TEST_P(Vp9EncoderParmsGetToDecoder, BitstreamParms) {
165 init_flags_ = VPX_CODEC_USE_PSNR;
166
167 libvpx_test::VideoSource *video;
168 if (is_extension_y4m(test_video_.name)) {
169 video = new libvpx_test::Y4mVideoSource(test_video_.name,
170 0, test_video_.frames);
171 } else {
172 video = new libvpx_test::YUVVideoSource(test_video_.name,
173 VPX_IMG_FMT_I420,
174 test_video_.width,
175 test_video_.height,
176 kFramerate, 1, 0,
177 test_video_.frames);
178 }
179
180 ASSERT_NO_FATAL_FAILURE(RunLoop(video));
181 delete(video);
182 }
183
184 VP9_INSTANTIATE_TEST_CASE(
185 Vp9EncoderParmsGetToDecoder,
186 ::testing::ValuesIn(kVP9EncodeParameterSet),
187 ::testing::ValuesIn(kVP9EncodePerfTestVectors));
188
189 } // namespace
OLDNEW
« no previous file with comments | « source/libvpx/test/vp8_fragments_test.cc ('k') | source/libvpx/test/vp9_end_to_end_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698