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

Side by Side Diff: remoting/codec/codec_test.cc

Issue 2329653002: Add WebrtcVideoEncoder interface (Closed)
Patch Set: win Created 4 years, 3 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
« no previous file with comments | « remoting/client/software_video_renderer_unittest.cc ('k') | remoting/codec/video_encoder.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "remoting/codec/codec_test.h" 5 #include "remoting/codec/codec_test.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 #include <stdlib.h> 9 #include <stdlib.h>
10 10
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 } 212 }
213 213
214 return frame; 214 return frame;
215 } 215 }
216 216
217 static void TestEncodingRects(VideoEncoder* encoder, 217 static void TestEncodingRects(VideoEncoder* encoder,
218 VideoEncoderTester* tester, 218 VideoEncoderTester* tester,
219 DesktopFrame* frame, 219 DesktopFrame* frame,
220 const DesktopRegion& region) { 220 const DesktopRegion& region) {
221 *frame->mutable_updated_region() = region; 221 *frame->mutable_updated_region() = region;
222 tester->DataAvailable(encoder->Encode(*frame, 0)); 222 tester->DataAvailable(encoder->Encode(*frame));
223 } 223 }
224 224
225 void TestVideoEncoder(VideoEncoder* encoder, bool strict) { 225 void TestVideoEncoder(VideoEncoder* encoder, bool strict) {
226 const int kSizes[] = {80, 79, 77, 54}; 226 const int kSizes[] = {80, 79, 77, 54};
227 227
228 VideoEncoderTester tester; 228 VideoEncoderTester tester;
229 229
230 for (size_t xi = 0; xi < arraysize(kSizes); ++xi) { 230 for (size_t xi = 0; xi < arraysize(kSizes); ++xi) {
231 for (size_t yi = 0; yi < arraysize(kSizes); ++yi) { 231 for (size_t yi = 0; yi < arraysize(kSizes); ++yi) {
232 DesktopSize size(kSizes[xi], kSizes[yi]); 232 DesktopSize size(kSizes[xi], kSizes[yi]);
(...skipping 10 matching lines...) Expand all
243 } 243 }
244 } 244 }
245 245
246 void TestVideoEncoderEmptyFrames(VideoEncoder* encoder, 246 void TestVideoEncoderEmptyFrames(VideoEncoder* encoder,
247 int max_topoff_frames) { 247 int max_topoff_frames) {
248 const DesktopSize kSize(100, 100); 248 const DesktopSize kSize(100, 100);
249 std::unique_ptr<DesktopFrame> frame(PrepareFrame(kSize)); 249 std::unique_ptr<DesktopFrame> frame(PrepareFrame(kSize));
250 250
251 frame->mutable_updated_region()->SetRect( 251 frame->mutable_updated_region()->SetRect(
252 webrtc::DesktopRect::MakeSize(kSize)); 252 webrtc::DesktopRect::MakeSize(kSize));
253 EXPECT_TRUE(encoder->Encode(*frame, 0)); 253 EXPECT_TRUE(encoder->Encode(*frame));
254 254
255 int topoff_frames = 0; 255 int topoff_frames = 0;
256 frame->mutable_updated_region()->Clear(); 256 frame->mutable_updated_region()->Clear();
257 for (int i = 0; i < max_topoff_frames + 1; ++i) { 257 for (int i = 0; i < max_topoff_frames + 1; ++i) {
258 if (!encoder->Encode(*frame, 0)) 258 if (!encoder->Encode(*frame))
259 break; 259 break;
260 topoff_frames++; 260 topoff_frames++;
261 } 261 }
262 262
263 // If top-off is enabled then our random frame contents should always 263 // If top-off is enabled then our random frame contents should always
264 // trigger it, so expect at least one top-off frame - strictly, though, 264 // trigger it, so expect at least one top-off frame - strictly, though,
265 // an encoder may not always need to top-off. 265 // an encoder may not always need to top-off.
266 EXPECT_GE(topoff_frames, max_topoff_frames ? 1 : 0); 266 EXPECT_GE(topoff_frames, max_topoff_frames ? 1 : 0);
267 EXPECT_LE(topoff_frames, max_topoff_frames); 267 EXPECT_LE(topoff_frames, max_topoff_frames);
268 } 268 }
(...skipping 12 matching lines...) Expand all
281 const int row_size = DesktopFrame::kBytesPerPixel * i.rect().width(); 281 const int row_size = DesktopFrame::kBytesPerPixel * i.rect().width();
282 uint8_t* memory = frame->data() + frame->stride() * i.rect().top() + 282 uint8_t* memory = frame->data() + frame->stride() * i.rect().top() +
283 DesktopFrame::kBytesPerPixel * i.rect().left(); 283 DesktopFrame::kBytesPerPixel * i.rect().left();
284 for (int y = 0; y < i.rect().height(); ++y) { 284 for (int y = 0; y < i.rect().height(); ++y) {
285 for (int x = 0; x < row_size; ++x) 285 for (int x = 0; x < row_size; ++x)
286 memory[x] = rand() % 256; 286 memory[x] = rand() % 256;
287 memory += frame->stride(); 287 memory += frame->stride();
288 } 288 }
289 } 289 }
290 290
291 encoder_tester->DataAvailable(encoder->Encode(*frame, 0)); 291 encoder_tester->DataAvailable(encoder->Encode(*frame));
292 decoder_tester->VerifyResults(); 292 decoder_tester->VerifyResults();
293 decoder_tester->Reset(); 293 decoder_tester->Reset();
294 } 294 }
295 295
296 void TestVideoEncoderDecoder(VideoEncoder* encoder, 296 void TestVideoEncoderDecoder(VideoEncoder* encoder,
297 VideoDecoder* decoder, 297 VideoDecoder* decoder,
298 bool strict) { 298 bool strict) {
299 DesktopSize kSize = DesktopSize(160, 120); 299 DesktopSize kSize = DesktopSize(160, 120);
300 300
301 VideoEncoderTester encoder_tester; 301 VideoEncoderTester encoder_tester;
(...skipping 29 matching lines...) Expand all
331 const DesktopSize& screen_size, 331 const DesktopSize& screen_size,
332 double max_error_limit, 332 double max_error_limit,
333 double mean_error_limit) { 333 double mean_error_limit) {
334 std::unique_ptr<BasicDesktopFrame> frame(new BasicDesktopFrame(screen_size)); 334 std::unique_ptr<BasicDesktopFrame> frame(new BasicDesktopFrame(screen_size));
335 FillWithGradient(frame.get()); 335 FillWithGradient(frame.get());
336 frame->mutable_updated_region()->SetRect(DesktopRect::MakeSize(screen_size)); 336 frame->mutable_updated_region()->SetRect(DesktopRect::MakeSize(screen_size));
337 337
338 VideoDecoderTester decoder_tester(decoder, screen_size); 338 VideoDecoderTester decoder_tester(decoder, screen_size);
339 decoder_tester.set_expected_frame(frame.get()); 339 decoder_tester.set_expected_frame(frame.get());
340 decoder_tester.AddRegion(frame->updated_region()); 340 decoder_tester.AddRegion(frame->updated_region());
341 decoder_tester.ReceivedPacket(encoder->Encode(*frame, 0)); 341 decoder_tester.ReceivedPacket(encoder->Encode(*frame));
342 342
343 decoder_tester.VerifyResultsApprox(max_error_limit, mean_error_limit); 343 decoder_tester.VerifyResultsApprox(max_error_limit, mean_error_limit);
344 } 344 }
345 345
346 } // namespace remoting 346 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/client/software_video_renderer_unittest.cc ('k') | remoting/codec/video_encoder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698