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

Side by Side Diff: webrtc/modules/video_coding/codecs/vp8/screenshare_layers_unittest.cc

Issue 1656233002: Avoid undefined behavior in vp8 screenshare_layers (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Test error + brain fartin ConfigureBitrates Created 4 years, 10 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 | « webrtc/modules/video_coding/codecs/vp8/screenshare_layers.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2013 The WebRTC 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
11 #include <vector>
12
11 #include "gtest/gtest.h" 13 #include "gtest/gtest.h"
12 #include "vpx/vpx_encoder.h" 14 #include "vpx/vpx_encoder.h"
13 #include "vpx/vp8cx.h" 15 #include "vpx/vp8cx.h"
14 #include "webrtc/base/scoped_ptr.h" 16 #include "webrtc/base/scoped_ptr.h"
15 #include "webrtc/modules/video_coding/include/video_codec_interface.h" 17 #include "webrtc/modules/video_coding/include/video_codec_interface.h"
16 #include "webrtc/modules/video_coding/codecs/vp8/screenshare_layers.h" 18 #include "webrtc/modules/video_coding/codecs/vp8/screenshare_layers.h"
17 #include "webrtc/modules/video_coding/utility/mock/mock_frame_dropper.h" 19 #include "webrtc/modules/video_coding/utility/mock/mock_frame_dropper.h"
18 20
19 using ::testing::_; 21 using ::testing::_;
20 using ::testing::NiceMock; 22 using ::testing::NiceMock;
(...skipping 13 matching lines...) Expand all
34 class ScreenshareLayerTest : public ::testing::Test { 36 class ScreenshareLayerTest : public ::testing::Test {
35 protected: 37 protected:
36 ScreenshareLayerTest() : min_qp_(2), max_qp_(kDefaultQp), frame_size_(-1) {} 38 ScreenshareLayerTest() : min_qp_(2), max_qp_(kDefaultQp), frame_size_(-1) {}
37 virtual ~ScreenshareLayerTest() {} 39 virtual ~ScreenshareLayerTest() {}
38 40
39 void EncodeFrame(uint32_t timestamp, 41 void EncodeFrame(uint32_t timestamp,
40 bool base_sync, 42 bool base_sync,
41 CodecSpecificInfoVP8* vp8_info, 43 CodecSpecificInfoVP8* vp8_info,
42 int* flags) { 44 int* flags) {
43 *flags = layers_->EncodeFlags(timestamp); 45 *flags = layers_->EncodeFlags(timestamp);
46 if (*flags == -1)
47 return;
44 layers_->PopulateCodecSpecific(base_sync, vp8_info, timestamp); 48 layers_->PopulateCodecSpecific(base_sync, vp8_info, timestamp);
45 ASSERT_NE(-1, frame_size_); 49 ASSERT_NE(-1, frame_size_);
46 layers_->FrameEncoded(frame_size_, timestamp, kDefaultQp); 50 layers_->FrameEncoded(frame_size_, timestamp, kDefaultQp);
47 } 51 }
48 52
49 void ConfigureBitrates() { 53 void ConfigureBitrates() {
50 vpx_codec_enc_cfg_t vpx_cfg; 54 vpx_codec_enc_cfg_t vpx_cfg;
51 memset(&vpx_cfg, 0, sizeof(vpx_codec_enc_cfg_t)); 55 memset(&vpx_cfg, 0, sizeof(vpx_codec_enc_cfg_t));
52 vpx_cfg.rc_min_quantizer = min_qp_; 56 vpx_cfg.rc_min_quantizer = min_qp_;
53 vpx_cfg.rc_max_quantizer = max_qp_; 57 vpx_cfg.rc_max_quantizer = max_qp_;
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after
436 440
437 layers_->EncodeFlags(timestamp); 441 layers_->EncodeFlags(timestamp);
438 timestamp += kTimestampDelta5Fps; 442 timestamp += kTimestampDelta5Fps;
439 EXPECT_TRUE(layers_->UpdateConfiguration(&cfg)); 443 EXPECT_TRUE(layers_->UpdateConfiguration(&cfg));
440 layers_->PopulateCodecSpecific(false, &vp8_info, timestamp); 444 layers_->PopulateCodecSpecific(false, &vp8_info, timestamp);
441 EXPECT_EQ(cfg.rc_max_quantizer, static_cast<unsigned int>(kDefaultQp)); 445 EXPECT_EQ(cfg.rc_max_quantizer, static_cast<unsigned int>(kDefaultQp));
442 layers_->FrameEncoded(frame_size_, timestamp, kDefaultQp); 446 layers_->FrameEncoded(frame_size_, timestamp, kDefaultQp);
443 } 447 }
444 448
445 } // namespace webrtc 449 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/video_coding/codecs/vp8/screenshare_layers.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698