OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2014 The WebM project authors. All Rights Reserved. | 2 * Copyright (c) 2014 The WebM project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 11 matching lines...) Expand all Loading... |
22 #include "test/webm_video_source.h" | 22 #include "test/webm_video_source.h" |
23 #endif | 23 #endif |
24 #include "vpx_mem/vpx_mem.h" | 24 #include "vpx_mem/vpx_mem.h" |
25 | 25 |
26 namespace { | 26 namespace { |
27 | 27 |
28 using std::string; | 28 using std::string; |
29 | 29 |
30 #if CONFIG_WEBM_IO | 30 #if CONFIG_WEBM_IO |
31 | 31 |
32 struct FileList { | 32 struct PauseFileList { |
33 const char *name; | 33 const char *name; |
34 // md5 sum for decoded frames which does not include skipped frames. | 34 // md5 sum for decoded frames which does not include skipped frames. |
35 const char *expected_md5; | 35 const char *expected_md5; |
36 const int pause_frame_num; | 36 const int pause_frame_num; |
37 }; | 37 }; |
38 | 38 |
39 // Decodes |filename| with |num_threads|. Pause at the specified frame_num, | 39 // Decodes |filename| with |num_threads|. Pause at the specified frame_num, |
40 // seek to next key frame and then continue decoding until the end. Return | 40 // seek to next key frame and then continue decoding until the end. Return |
41 // the md5 of the decoded frames which does not include skipped frames. | 41 // the md5 of the decoded frames which does not include skipped frames. |
42 string DecodeFile(const string &filename, int num_threads, int pause_num) { | 42 string DecodeFileWithPause(const string &filename, int num_threads, |
| 43 int pause_num) { |
43 libvpx_test::WebMVideoSource video(filename); | 44 libvpx_test::WebMVideoSource video(filename); |
44 video.Init(); | 45 video.Init(); |
45 int in_frames = 0; | 46 int in_frames = 0; |
46 int out_frames = 0; | 47 int out_frames = 0; |
47 | 48 |
48 vpx_codec_dec_cfg_t cfg = {0}; | 49 vpx_codec_dec_cfg_t cfg = {0}; |
49 cfg.threads = num_threads; | 50 cfg.threads = num_threads; |
50 vpx_codec_flags_t flags = 0; | 51 vpx_codec_flags_t flags = 0; |
51 flags |= VPX_CODEC_USE_FRAME_THREADING; | 52 flags |= VPX_CODEC_USE_FRAME_THREADING; |
52 libvpx_test::VP9Decoder decoder(cfg, flags, 0); | 53 libvpx_test::VP9Decoder decoder(cfg, flags, 0); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 md5.Add(img); | 86 md5.Add(img); |
86 } | 87 } |
87 } while (video.cxdata() != NULL); | 88 } while (video.cxdata() != NULL); |
88 | 89 |
89 EXPECT_EQ(in_frames, out_frames) << | 90 EXPECT_EQ(in_frames, out_frames) << |
90 "Input frame count does not match output frame count"; | 91 "Input frame count does not match output frame count"; |
91 | 92 |
92 return string(md5.Get()); | 93 return string(md5.Get()); |
93 } | 94 } |
94 | 95 |
95 void DecodeFiles(const FileList files[]) { | 96 void DecodeFilesWithPause(const PauseFileList files[]) { |
96 for (const FileList *iter = files; iter->name != NULL; ++iter) { | 97 for (const PauseFileList *iter = files; iter->name != NULL; ++iter) { |
97 SCOPED_TRACE(iter->name); | 98 SCOPED_TRACE(iter->name); |
98 for (int t = 2; t <= 8; ++t) { | 99 for (int t = 2; t <= 8; ++t) { |
99 EXPECT_EQ(iter->expected_md5, | 100 EXPECT_EQ(iter->expected_md5, |
100 DecodeFile(iter->name, t, iter->pause_frame_num)) | 101 DecodeFileWithPause(iter->name, t, iter->pause_frame_num)) |
101 << "threads = " << t; | 102 << "threads = " << t; |
102 } | 103 } |
103 } | 104 } |
104 } | 105 } |
105 | 106 |
106 TEST(VP9MultiThreadedFrameParallel, PauseSeekResume) { | 107 TEST(VP9MultiThreadedFrameParallel, PauseSeekResume) { |
107 // vp90-2-07-frame_parallel-1.webm is a 40 frame video file with | 108 // vp90-2-07-frame_parallel-1.webm is a 40 frame video file with |
108 // one key frame for every ten frames. | 109 // one key frame for every ten frames. |
109 static const FileList files[] = { | 110 static const PauseFileList files[] = { |
110 { "vp90-2-07-frame_parallel-1.webm", | 111 { "vp90-2-07-frame_parallel-1.webm", |
111 "6ea7c3875d67252e7caf2bc6e75b36b1", 6}, | 112 "6ea7c3875d67252e7caf2bc6e75b36b1", 6 }, |
112 { "vp90-2-07-frame_parallel-1.webm", | 113 { "vp90-2-07-frame_parallel-1.webm", |
113 "4bb634160c7356a8d7d4299b6dc83a45", 12}, | 114 "4bb634160c7356a8d7d4299b6dc83a45", 12 }, |
114 { "vp90-2-07-frame_parallel-1.webm", | 115 { "vp90-2-07-frame_parallel-1.webm", |
115 "89772591e6ef461f9fa754f916c78ed8", 26}, | 116 "89772591e6ef461f9fa754f916c78ed8", 26 }, |
116 { NULL, NULL, 0}, | 117 { NULL, NULL, 0 }, |
117 }; | 118 }; |
118 DecodeFiles(files); | 119 DecodeFilesWithPause(files); |
119 } | 120 } |
120 | 121 |
121 struct InvalidFileList { | 122 struct FileList { |
122 const char *name; | 123 const char *name; |
123 // md5 sum for decoded frames which does not include corrupted frames. | 124 // md5 sum for decoded frames which does not include corrupted frames. |
124 const char *expected_md5; | 125 const char *expected_md5; |
125 // Expected number of decoded frames which does not include corrupted frames. | 126 // Expected number of decoded frames which does not include corrupted frames. |
126 const int expected_frame_count; | 127 const int expected_frame_count; |
127 }; | 128 }; |
128 | 129 |
129 // Decodes |filename| with |num_threads|. Return the md5 of the decoded | 130 // Decodes |filename| with |num_threads|. Return the md5 of the decoded |
130 // frames which does not include corrupted frames. | 131 // frames which does not include corrupted frames. |
131 string DecodeInvalidFile(const string &filename, int num_threads, | 132 string DecodeFile(const string &filename, int num_threads, |
132 int expected_frame_count) { | 133 int expected_frame_count) { |
133 libvpx_test::WebMVideoSource video(filename); | 134 libvpx_test::WebMVideoSource video(filename); |
134 video.Init(); | 135 video.Init(); |
135 | 136 |
136 vpx_codec_dec_cfg_t cfg = vpx_codec_dec_cfg_t(); | 137 vpx_codec_dec_cfg_t cfg = vpx_codec_dec_cfg_t(); |
137 cfg.threads = num_threads; | 138 cfg.threads = num_threads; |
138 const vpx_codec_flags_t flags = VPX_CODEC_USE_FRAME_THREADING; | 139 const vpx_codec_flags_t flags = VPX_CODEC_USE_FRAME_THREADING; |
139 libvpx_test::VP9Decoder decoder(cfg, flags, 0); | 140 libvpx_test::VP9Decoder decoder(cfg, flags, 0); |
140 | 141 |
141 libvpx_test::MD5 md5; | 142 libvpx_test::MD5 md5; |
142 video.Begin(); | 143 video.Begin(); |
(...skipping 23 matching lines...) Expand all Loading... |
166 md5.Add(img); | 167 md5.Add(img); |
167 } | 168 } |
168 } while (video.cxdata() != NULL); | 169 } while (video.cxdata() != NULL); |
169 | 170 |
170 EXPECT_EQ(expected_frame_count, out_frames) << | 171 EXPECT_EQ(expected_frame_count, out_frames) << |
171 "Input frame count does not match expected output frame count"; | 172 "Input frame count does not match expected output frame count"; |
172 | 173 |
173 return string(md5.Get()); | 174 return string(md5.Get()); |
174 } | 175 } |
175 | 176 |
176 void DecodeInvalidFiles(const InvalidFileList files[]) { | 177 void DecodeFiles(const FileList files[]) { |
177 for (const InvalidFileList *iter = files; iter->name != NULL; ++iter) { | 178 for (const FileList *iter = files; iter->name != NULL; ++iter) { |
178 SCOPED_TRACE(iter->name); | 179 SCOPED_TRACE(iter->name); |
179 for (int t = 2; t <= 8; ++t) { | 180 for (int t = 2; t <= 8; ++t) { |
180 EXPECT_EQ(iter->expected_md5, | 181 EXPECT_EQ(iter->expected_md5, |
181 DecodeInvalidFile(iter->name, t, iter->expected_frame_count)) | 182 DecodeFile(iter->name, t, iter->expected_frame_count)) |
182 << "threads = " << t; | 183 << "threads = " << t; |
183 } | 184 } |
184 } | 185 } |
185 } | 186 } |
186 | 187 |
187 TEST(VP9MultiThreadedFrameParallel, InvalidFileTest) { | 188 TEST(VP9MultiThreadedFrameParallel, InvalidFileTest) { |
188 static const InvalidFileList files[] = { | 189 static const FileList files[] = { |
189 // invalid-vp90-2-07-frame_parallel-1.webm is a 40 frame video file with | 190 // invalid-vp90-2-07-frame_parallel-1.webm is a 40 frame video file with |
190 // one key frame for every ten frames. The 11th frame has corrupted data. | 191 // one key frame for every ten frames. The 11th frame has corrupted data. |
191 { "invalid-vp90-2-07-frame_parallel-1.webm", | 192 { "invalid-vp90-2-07-frame_parallel-1.webm", |
192 "0549d0f45f60deaef8eb708e6c0eb6cb", 30}, | 193 "0549d0f45f60deaef8eb708e6c0eb6cb", 30 }, |
193 // invalid-vp90-2-07-frame_parallel-2.webm is a 40 frame video file with | 194 // invalid-vp90-2-07-frame_parallel-2.webm is a 40 frame video file with |
194 // one key frame for every ten frames. The 1st and 31st frames have | 195 // one key frame for every ten frames. The 1st and 31st frames have |
195 // corrupted data. | 196 // corrupted data. |
196 { "invalid-vp90-2-07-frame_parallel-2.webm", | 197 { "invalid-vp90-2-07-frame_parallel-2.webm", |
197 "6a1f3cf6f9e7a364212fadb9580d525e", 20}, | 198 "6a1f3cf6f9e7a364212fadb9580d525e", 20 }, |
198 // invalid-vp90-2-07-frame_parallel-3.webm is a 40 frame video file with | 199 // invalid-vp90-2-07-frame_parallel-3.webm is a 40 frame video file with |
199 // one key frame for every ten frames. The 5th and 13th frames have | 200 // one key frame for every ten frames. The 5th and 13th frames have |
200 // corrupted data. | 201 // corrupted data. |
201 { "invalid-vp90-2-07-frame_parallel-3.webm", | 202 { "invalid-vp90-2-07-frame_parallel-3.webm", |
202 "8256544308de926b0681e04685b98677", 27}, | 203 "8256544308de926b0681e04685b98677", 27 }, |
203 { NULL, NULL, 0}, | 204 { NULL, NULL, 0 }, |
204 }; | 205 }; |
205 DecodeInvalidFiles(files); | 206 DecodeFiles(files); |
206 } | 207 } |
207 | 208 |
| 209 TEST(VP9MultiThreadedFrameParallel, ValidFileTest) { |
| 210 static const FileList files[] = { |
| 211 #if CONFIG_VP9_HIGHBITDEPTH |
| 212 { "vp92-2-20-10bit-yuv420.webm", |
| 213 "a16b99df180c584e8db2ffeda987d293", 10 }, |
| 214 #endif |
| 215 { NULL, NULL, 0 }, |
| 216 }; |
| 217 DecodeFiles(files); |
| 218 } |
208 #endif // CONFIG_WEBM_IO | 219 #endif // CONFIG_WEBM_IO |
209 } // namespace | 220 } // namespace |
OLD | NEW |