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

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

Issue 2434073003: Extract bitrate allocation of spatial/temporal layers out of codec impl. (Closed)
Patch Set: Updated tl listener registration. Fixed tests. Created 4 years, 2 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
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 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 <stdio.h> 11 #include <stdio.h>
12 12
13 #include <memory> 13 #include <memory>
14 14
15 #include "webrtc/base/checks.h" 15 #include "webrtc/base/checks.h"
16 #include "webrtc/base/timeutils.h" 16 #include "webrtc/base/timeutils.h"
17 #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h" 17 #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h"
18 #include "webrtc/modules/video_coding/codecs/vp8/include/vp8.h" 18 #include "webrtc/modules/video_coding/codecs/vp8/include/vp8.h"
19 #include "webrtc/modules/video_coding/codecs/vp8/temporal_layers.h"
19 #include "webrtc/test/frame_utils.h" 20 #include "webrtc/test/frame_utils.h"
20 #include "webrtc/test/gtest.h" 21 #include "webrtc/test/gtest.h"
21 #include "webrtc/test/testsupport/fileutils.h" 22 #include "webrtc/test/testsupport/fileutils.h"
22 23
23 namespace webrtc { 24 namespace webrtc {
24 25
25 namespace { 26 namespace {
26 void Calc16ByteAlignedStride(int width, int* stride_y, int* stride_uv) { 27 void Calc16ByteAlignedStride(int width, int* stride_y, int* stride_uv) {
27 *stride_y = 16 * ((width + 15) / 16); 28 *stride_y = 16 * ((width + 15) / 16);
28 *stride_uv = 16 * ((width + 31) / 32); 29 *stride_uv = 16 * ((width + 31) / 32);
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 input_frame_.reset( 155 input_frame_.reset(
155 new VideoFrame(stride_buffer, kVideoRotation_0, 0)); 156 new VideoFrame(stride_buffer, kVideoRotation_0, 0));
156 input_frame_->set_timestamp(kTestTimestamp); 157 input_frame_->set_timestamp(kTestTimestamp);
157 } 158 }
158 159
159 void SetUpEncodeDecode() { 160 void SetUpEncodeDecode() {
160 codec_inst_.startBitrate = 300; 161 codec_inst_.startBitrate = 300;
161 codec_inst_.maxBitrate = 4000; 162 codec_inst_.maxBitrate = 4000;
162 codec_inst_.qpMax = 56; 163 codec_inst_.qpMax = 56;
163 codec_inst_.codecSpecific.VP8.denoisingOn = true; 164 codec_inst_.codecSpecific.VP8.denoisingOn = true;
165 codec_inst_.codecSpecific.VP8.tl_factory = &tl_factory_;
164 166
165 EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, 167 EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK,
166 encoder_->InitEncode(&codec_inst_, 1, 1440)); 168 encoder_->InitEncode(&codec_inst_, 1, 1440));
167 EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, decoder_->InitDecode(&codec_inst_, 1)); 169 EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, decoder_->InitDecode(&codec_inst_, 1));
168 } 170 }
169 171
170 size_t WaitForEncodedFrame() const { 172 size_t WaitForEncodedFrame() const {
171 int64_t startTime = rtc::TimeMillis(); 173 int64_t startTime = rtc::TimeMillis();
172 while (rtc::TimeMillis() - startTime < kMaxWaitEncTimeMs) { 174 while (rtc::TimeMillis() - startTime < kMaxWaitEncTimeMs) {
173 if (encode_complete_callback_->EncodeComplete()) { 175 if (encode_complete_callback_->EncodeComplete()) {
(...skipping 20 matching lines...) Expand all
194 std::unique_ptr<Vp8UnitTestEncodeCompleteCallback> encode_complete_callback_; 196 std::unique_ptr<Vp8UnitTestEncodeCompleteCallback> encode_complete_callback_;
195 std::unique_ptr<Vp8UnitTestDecodeCompleteCallback> decode_complete_callback_; 197 std::unique_ptr<Vp8UnitTestDecodeCompleteCallback> decode_complete_callback_;
196 std::unique_ptr<uint8_t[]> source_buffer_; 198 std::unique_ptr<uint8_t[]> source_buffer_;
197 FILE* source_file_; 199 FILE* source_file_;
198 std::unique_ptr<VideoFrame> input_frame_; 200 std::unique_ptr<VideoFrame> input_frame_;
199 std::unique_ptr<VideoEncoder> encoder_; 201 std::unique_ptr<VideoEncoder> encoder_;
200 std::unique_ptr<VideoDecoder> decoder_; 202 std::unique_ptr<VideoDecoder> decoder_;
201 EncodedImage encoded_frame_; 203 EncodedImage encoded_frame_;
202 VideoFrame decoded_frame_; 204 VideoFrame decoded_frame_;
203 VideoCodec codec_inst_; 205 VideoCodec codec_inst_;
206 TemporalLayersFactory tl_factory_;
204 }; 207 };
205 208
206 TEST_F(TestVp8Impl, EncoderParameterTest) { 209 TEST_F(TestVp8Impl, EncoderParameterTest) {
207 strncpy(codec_inst_.plName, "VP8", 31); 210 strncpy(codec_inst_.plName, "VP8", 31);
208 codec_inst_.plType = 126; 211 codec_inst_.plType = 126;
209 codec_inst_.maxBitrate = 0; 212 codec_inst_.maxBitrate = 0;
210 codec_inst_.minBitrate = 0; 213 codec_inst_.minBitrate = 0;
211 codec_inst_.width = 1440; 214 codec_inst_.width = 1440;
212 codec_inst_.height = 1080; 215 codec_inst_.height = 1080;
213 codec_inst_.maxFramerate = 30; 216 codec_inst_.maxFramerate = 30;
214 codec_inst_.startBitrate = 300; 217 codec_inst_.startBitrate = 300;
215 codec_inst_.qpMax = 56; 218 codec_inst_.qpMax = 56;
216 codec_inst_.codecSpecific.VP8.complexity = kComplexityNormal; 219 codec_inst_.codecSpecific.VP8.complexity = kComplexityNormal;
217 codec_inst_.codecSpecific.VP8.numberOfTemporalLayers = 1; 220 codec_inst_.codecSpecific.VP8.numberOfTemporalLayers = 1;
221 codec_inst_.codecSpecific.VP8.tl_factory = &tl_factory_;
222
218 // Calls before InitEncode(). 223 // Calls before InitEncode().
219 EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, encoder_->Release()); 224 EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, encoder_->Release());
220 int bit_rate = 300; 225 int bit_rate = 300;
221 EXPECT_EQ(WEBRTC_VIDEO_CODEC_UNINITIALIZED, 226 EXPECT_EQ(WEBRTC_VIDEO_CODEC_UNINITIALIZED,
222 encoder_->SetRates(bit_rate, codec_inst_.maxFramerate)); 227 encoder_->SetRates(bit_rate, codec_inst_.maxFramerate));
223 228
224 EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, encoder_->InitEncode(&codec_inst_, 1, 1440)); 229 EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, encoder_->InitEncode(&codec_inst_, 1, 1440));
225 230
226 // Decoder parameter tests. 231 // Decoder parameter tests.
227 // Calls before InitDecode(). 232 // Calls before InitDecode().
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 EXPECT_EQ(WEBRTC_VIDEO_CODEC_ERROR, 274 EXPECT_EQ(WEBRTC_VIDEO_CODEC_ERROR,
270 decoder_->Decode(encoded_frame_, false, NULL)); 275 decoder_->Decode(encoded_frame_, false, NULL));
271 // Now setting a key frame. 276 // Now setting a key frame.
272 encoded_frame_._frameType = kVideoFrameKey; 277 encoded_frame_._frameType = kVideoFrameKey;
273 EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, 278 EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK,
274 decoder_->Decode(encoded_frame_, false, NULL)); 279 decoder_->Decode(encoded_frame_, false, NULL));
275 EXPECT_GT(I420PSNR(input_frame_.get(), &decoded_frame_), 36); 280 EXPECT_GT(I420PSNR(input_frame_.get(), &decoded_frame_), 36);
276 } 281 }
277 282
278 } // namespace webrtc 283 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698