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

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

Issue 2853463004: Don't reinit encoder when rotation changes. (Closed)
Patch Set: Add trivial unit tests. Created 3 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 | « no previous file | webrtc/modules/video_coding/codecs/vp9/test/vp9_impl_unittest.cc » ('j') | 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) 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
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 encoded_frame_->_buffer = frame_buffer_.get(); 69 encoded_frame_->_buffer = frame_buffer_.get();
70 encoded_frame_->_size = encoded_frame._length; 70 encoded_frame_->_size = encoded_frame._length;
71 } 71 }
72 memcpy(encoded_frame_->_buffer, encoded_frame._buffer, encoded_frame._length); 72 memcpy(encoded_frame_->_buffer, encoded_frame._buffer, encoded_frame._length);
73 encoded_frame_->_length = encoded_frame._length; 73 encoded_frame_->_length = encoded_frame._length;
74 encoded_frame_->_encodedWidth = encoded_frame._encodedWidth; 74 encoded_frame_->_encodedWidth = encoded_frame._encodedWidth;
75 encoded_frame_->_encodedHeight = encoded_frame._encodedHeight; 75 encoded_frame_->_encodedHeight = encoded_frame._encodedHeight;
76 encoded_frame_->_timeStamp = encoded_frame._timeStamp; 76 encoded_frame_->_timeStamp = encoded_frame._timeStamp;
77 encoded_frame_->_frameType = encoded_frame._frameType; 77 encoded_frame_->_frameType = encoded_frame._frameType;
78 encoded_frame_->_completeFrame = encoded_frame._completeFrame; 78 encoded_frame_->_completeFrame = encoded_frame._completeFrame;
79 encoded_frame_->rotation_ = encoded_frame.rotation_;
79 encoded_frame_->qp_ = encoded_frame.qp_; 80 encoded_frame_->qp_ = encoded_frame.qp_;
80 encode_complete_ = true; 81 encode_complete_ = true;
81 return Result(Result::OK, 0); 82 return Result(Result::OK, 0);
82 } 83 }
83 84
84 bool Vp8UnitTestEncodeCompleteCallback::EncodeComplete() { 85 bool Vp8UnitTestEncodeCompleteCallback::EncodeComplete() {
85 if (encode_complete_) { 86 if (encode_complete_) {
86 encode_complete_ = false; 87 encode_complete_ = false;
87 return true; 88 return true;
88 } 89 }
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 codec_inst_.maxFramerate)); 246 codec_inst_.maxFramerate));
246 247
247 EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, encoder_->InitEncode(&codec_inst_, 1, 1440)); 248 EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, encoder_->InitEncode(&codec_inst_, 1, 1440));
248 249
249 // Decoder parameter tests. 250 // Decoder parameter tests.
250 // Calls before InitDecode(). 251 // Calls before InitDecode().
251 EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, decoder_->Release()); 252 EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, decoder_->Release());
252 EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, decoder_->InitDecode(&codec_inst_, 1)); 253 EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, decoder_->InitDecode(&codec_inst_, 1));
253 } 254 }
254 255
256 // We only test the encoder here, since the decoded frame rotation is set based
257 // on the CVO RTP header extension in VCMDecodedFrameCallback::Decoded.
258 // TODO(brandtr): Consider passing through the rotation flag through the decoder
259 // in the same way as done in the encoder.
260 TEST_F(TestVp8Impl, EncodedRotationEqualsInputRotation) {
261 SetUpEncodeDecode();
262
263 input_frame_->set_rotation(kVideoRotation_0);
264 EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK,
265 encoder_->Encode(*input_frame_, nullptr, nullptr));
266 WaitForEncodedFrame();
267 EXPECT_EQ(kVideoRotation_0, encoded_frame_.rotation_);
268
269 input_frame_->set_rotation(kVideoRotation_90);
270 EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK,
271 encoder_->Encode(*input_frame_, nullptr, nullptr));
272 WaitForEncodedFrame();
273 EXPECT_EQ(kVideoRotation_90, encoded_frame_.rotation_);
274 }
275
255 TEST_F(TestVp8Impl, DecodedQpEqualsEncodedQp) { 276 TEST_F(TestVp8Impl, DecodedQpEqualsEncodedQp) {
256 SetUpEncodeDecode(); 277 SetUpEncodeDecode();
257 encoder_->Encode(*input_frame_, nullptr, nullptr); 278 encoder_->Encode(*input_frame_, nullptr, nullptr);
258 EXPECT_GT(WaitForEncodedFrame(), 0u); 279 EXPECT_GT(WaitForEncodedFrame(), 0u);
259 // First frame should be a key frame. 280 // First frame should be a key frame.
260 encoded_frame_._frameType = kVideoFrameKey; 281 encoded_frame_._frameType = kVideoFrameKey;
261 EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, 282 EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK,
262 decoder_->Decode(encoded_frame_, false, nullptr)); 283 decoder_->Decode(encoded_frame_, false, nullptr));
263 EXPECT_GT(WaitForDecodedFrame(), 0u); 284 EXPECT_GT(WaitForDecodedFrame(), 0u);
264 ASSERT_TRUE(decoded_frame_); 285 ASSERT_TRUE(decoded_frame_);
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 decoder_->Decode(encoded_frame_, false, NULL)); 330 decoder_->Decode(encoded_frame_, false, NULL));
310 // Now setting a key frame. 331 // Now setting a key frame.
311 encoded_frame_._frameType = kVideoFrameKey; 332 encoded_frame_._frameType = kVideoFrameKey;
312 EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, 333 EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK,
313 decoder_->Decode(encoded_frame_, false, NULL)); 334 decoder_->Decode(encoded_frame_, false, NULL));
314 ASSERT_TRUE(decoded_frame_); 335 ASSERT_TRUE(decoded_frame_);
315 EXPECT_GT(I420PSNR(input_frame_.get(), &*decoded_frame_), 36); 336 EXPECT_GT(I420PSNR(input_frame_.get(), &*decoded_frame_), 36);
316 } 337 }
317 338
318 } // namespace webrtc 339 } // namespace webrtc
OLDNEW
« no previous file with comments | « no previous file | webrtc/modules/video_coding/codecs/vp9/test/vp9_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698