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

Side by Side Diff: media/cast/sender/video_encoder_unittest.cc

Issue 1100643002: [cast] Handle frame size changes directly in the VideoToolbox encoder (v2). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Set the video frame factory's pool to null before destroying the compression session. Created 5 years, 7 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 | « media/cast/sender/video_encoder.cc ('k') | media/cast/sender/video_frame_factory.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 <vector> 5 #include <vector>
6 #include <utility> 6 #include <utility>
7 7
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 H264VideoToolboxEncoder::IsSupported(video_config_)) || 94 H264VideoToolboxEncoder::IsSupported(video_config_)) ||
95 #endif 95 #endif
96 false; 96 false;
97 } 97 }
98 98
99 bool is_testing_platform_encoder() const { 99 bool is_testing_platform_encoder() const {
100 return video_config_.use_external_encoder || 100 return video_config_.use_external_encoder ||
101 is_testing_video_toolbox_encoder(); 101 is_testing_video_toolbox_encoder();
102 } 102 }
103 103
104 bool encoder_has_resize_delay() const {
105 return is_testing_platform_encoder() && !is_testing_video_toolbox_encoder();
106 }
107
104 VideoEncoder* video_encoder() const { 108 VideoEncoder* video_encoder() const {
105 return video_encoder_.get(); 109 return video_encoder_.get();
106 } 110 }
107 111
108 void DestroyEncoder() { 112 void DestroyEncoder() {
109 video_encoder_.reset(); 113 video_encoder_.reset();
110 } 114 }
111 115
112 base::TimeTicks Now() const { 116 base::TimeTicks Now() const {
113 return testing_clock_->NowTicks(); 117 return testing_clock_->NowTicks();
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 CreateEncoder(false); 279 CreateEncoder(false);
276 SetVEAFactoryAutoRespond(true); 280 SetVEAFactoryAutoRespond(true);
277 281
278 EXPECT_EQ(0, count_frames_delivered()); 282 EXPECT_EQ(0, count_frames_delivered());
279 ExpectVEAResponsesForExternalVideoEncoder(0, 0); 283 ExpectVEAResponsesForExternalVideoEncoder(0, 0);
280 284
281 uint32 frame_id = 0; 285 uint32 frame_id = 0;
282 uint32 reference_frame_id = 0; 286 uint32 reference_frame_id = 0;
283 const gfx::Size frame_size(1280, 720); 287 const gfx::Size frame_size(1280, 720);
284 288
285 // For the platform encoders, the first one or more frames is dropped while 289 // Some encoders drop one or more frames initially while the encoder
286 // the encoder initializes. Then, for all encoders, expect one key frame is 290 // initializes. Then, for all encoders, expect one key frame is delivered.
287 // delivered.
288 bool accepted_first_frame = false; 291 bool accepted_first_frame = false;
289 do { 292 do {
290 accepted_first_frame = EncodeAndCheckDelivery( 293 accepted_first_frame = EncodeAndCheckDelivery(
291 CreateTestVideoFrame(frame_size), frame_id, reference_frame_id); 294 CreateTestVideoFrame(frame_size), frame_id, reference_frame_id);
292 if (!is_testing_platform_encoder()) 295 if (!encoder_has_resize_delay())
293 EXPECT_TRUE(accepted_first_frame); 296 EXPECT_TRUE(accepted_first_frame);
294 RunTasksAndAdvanceClock(); 297 RunTasksAndAdvanceClock();
295 } while (!accepted_first_frame); 298 } while (!accepted_first_frame);
296 ExpectVEAResponsesForExternalVideoEncoder(1, 3); 299 ExpectVEAResponsesForExternalVideoEncoder(1, 3);
297 300
298 // Expect the remaining frames are encoded as delta frames. 301 // Expect the remaining frames are encoded as delta frames.
299 for (++frame_id; frame_id < 10; ++frame_id, ++reference_frame_id) { 302 for (++frame_id; frame_id < 10; ++frame_id, ++reference_frame_id) {
300 EXPECT_TRUE(EncodeAndCheckDelivery(CreateTestVideoFrame(frame_size), 303 EXPECT_TRUE(EncodeAndCheckDelivery(CreateTestVideoFrame(frame_size),
301 frame_id, 304 frame_id,
302 reference_frame_id)); 305 reference_frame_id));
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 frame_sizes.push_back(gfx::Size(600, 400)); // Grow both dimensions. 361 frame_sizes.push_back(gfx::Size(600, 400)); // Grow both dimensions.
359 frame_sizes.push_back(gfx::Size(638, 400)); // Shrink only one dimension. 362 frame_sizes.push_back(gfx::Size(638, 400)); // Shrink only one dimension.
360 frame_sizes.push_back(gfx::Size(638, 398)); // Shrink the other dimension. 363 frame_sizes.push_back(gfx::Size(638, 398)); // Shrink the other dimension.
361 frame_sizes.push_back(gfx::Size(320, 180)); // Shrink both dimensions again. 364 frame_sizes.push_back(gfx::Size(320, 180)); // Shrink both dimensions again.
362 frame_sizes.push_back(gfx::Size(322, 180)); // Grow only one dimension. 365 frame_sizes.push_back(gfx::Size(322, 180)); // Grow only one dimension.
363 frame_sizes.push_back(gfx::Size(322, 182)); // Grow the other dimension. 366 frame_sizes.push_back(gfx::Size(322, 182)); // Grow the other dimension.
364 frame_sizes.push_back(gfx::Size(1920, 1080)); // Grow both dimensions again. 367 frame_sizes.push_back(gfx::Size(1920, 1080)); // Grow both dimensions again.
365 368
366 uint32 frame_id = 0; 369 uint32 frame_id = 0;
367 370
368 // Encode one frame at each size. For the platform encoders, expect no frames 371 // Encode one frame at each size. For encoders with a resize delay, except no
369 // to be delivered since each frame size change will sprun re-initialization 372 // frames to be delivered since each frame size change will sprun
370 // of the underlying encoder. Otherwise, expect all key frames to come out. 373 // re-initialization of the underlying encoder. Otherwise expect all key
374 // frames to come out.
371 for (const auto& frame_size : frame_sizes) { 375 for (const auto& frame_size : frame_sizes) {
372 EXPECT_EQ(!is_testing_platform_encoder(), 376 EXPECT_EQ(!encoder_has_resize_delay(),
373 EncodeAndCheckDelivery(CreateTestVideoFrame(frame_size), 377 EncodeAndCheckDelivery(CreateTestVideoFrame(frame_size), frame_id,
374 frame_id,
375 frame_id)); 378 frame_id));
376 RunTasksAndAdvanceClock(); 379 RunTasksAndAdvanceClock();
377 if (!is_testing_platform_encoder()) 380 if (!encoder_has_resize_delay())
378 ++frame_id; 381 ++frame_id;
379 } 382 }
380 383
381 // Encode 10+ frames at each size. For the platform decoders, expect the 384 // Encode 10+ frames at each size. For encoders with a resize delay, expect
382 // first one or more frames are dropped while the encoder re-inits. Then, for 385 // the first one or more frames are dropped while the encoder re-inits. Then,
383 // all encoders, expect one key frame followed by all delta frames. 386 // for all encoders, expect one key frame followed by all delta frames.
384 for (const auto& frame_size : frame_sizes) { 387 for (const auto& frame_size : frame_sizes) {
385 bool accepted_first_frame = false; 388 bool accepted_first_frame = false;
386 do { 389 do {
387 accepted_first_frame = EncodeAndCheckDelivery( 390 accepted_first_frame = EncodeAndCheckDelivery(
388 CreateTestVideoFrame(frame_size), frame_id, frame_id); 391 CreateTestVideoFrame(frame_size), frame_id, frame_id);
389 if (!is_testing_platform_encoder()) 392 if (!encoder_has_resize_delay())
390 EXPECT_TRUE(accepted_first_frame); 393 EXPECT_TRUE(accepted_first_frame);
391 RunTasksAndAdvanceClock(); 394 RunTasksAndAdvanceClock();
392 } while (!accepted_first_frame); 395 } while (!accepted_first_frame);
393 ++frame_id; 396 ++frame_id;
394 for (int i = 1; i < 10; ++i, ++frame_id) { 397 for (int i = 1; i < 10; ++i, ++frame_id) {
395 EXPECT_TRUE(EncodeAndCheckDelivery(CreateTestVideoFrame(frame_size), 398 EXPECT_TRUE(EncodeAndCheckDelivery(CreateTestVideoFrame(frame_size),
396 frame_id, 399 frame_id,
397 frame_id - 1)); 400 frame_id - 1));
398 RunTasksAndAdvanceClock(); 401 RunTasksAndAdvanceClock();
399 } 402 }
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
445 #endif 448 #endif
446 return values; 449 return values;
447 } 450 }
448 } // namespace 451 } // namespace
449 452
450 INSTANTIATE_TEST_CASE_P( 453 INSTANTIATE_TEST_CASE_P(
451 , VideoEncoderTest, ::testing::ValuesIn(DetermineEncodersToTest())); 454 , VideoEncoderTest, ::testing::ValuesIn(DetermineEncodersToTest()));
452 455
453 } // namespace cast 456 } // namespace cast
454 } // namespace media 457 } // namespace media
OLDNEW
« no previous file with comments | « media/cast/sender/video_encoder.cc ('k') | media/cast/sender/video_frame_factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698