OLD | NEW |
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 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 codec_inst_.height = kHeight; | 140 codec_inst_.height = kHeight; |
141 const int kFramerate = 30; | 141 const int kFramerate = 30; |
142 codec_inst_.maxFramerate = kFramerate; | 142 codec_inst_.maxFramerate = kFramerate; |
143 // Setting aligned stride values. | 143 // Setting aligned stride values. |
144 int stride_uv; | 144 int stride_uv; |
145 int stride_y; | 145 int stride_y; |
146 Calc16ByteAlignedStride(codec_inst_.width, &stride_y, &stride_uv); | 146 Calc16ByteAlignedStride(codec_inst_.width, &stride_y, &stride_uv); |
147 EXPECT_EQ(stride_y, 176); | 147 EXPECT_EQ(stride_y, 176); |
148 EXPECT_EQ(stride_uv, 96); | 148 EXPECT_EQ(stride_uv, 96); |
149 | 149 |
150 rtc::scoped_refptr<I420Buffer> buffer = I420Buffer::Create( | 150 input_frame_.CreateEmptyFrame(codec_inst_.width, codec_inst_.height, |
151 codec_inst_.width, codec_inst_.height, stride_y, stride_uv, stride_uv); | 151 stride_y, stride_uv, stride_uv); |
| 152 input_frame_.set_timestamp(kTestTimestamp); |
152 // Using ConvertToI420 to add stride to the image. | 153 // Using ConvertToI420 to add stride to the image. |
153 EXPECT_EQ( | 154 EXPECT_EQ(0, ConvertToI420(kI420, source_buffer_.get(), 0, 0, |
154 0, ConvertToI420(kI420, source_buffer_.get(), 0, 0, codec_inst_.width, | 155 codec_inst_.width, codec_inst_.height, 0, |
155 codec_inst_.height, 0, kVideoRotation_0, | 156 kVideoRotation_0, &input_frame_)); |
156 buffer.get())); | |
157 input_frame_.reset( | |
158 new VideoFrame(buffer, kTestTimestamp, 0, webrtc::kVideoRotation_0)); | |
159 } | 157 } |
160 | 158 |
161 void SetUpEncodeDecode() { | 159 void SetUpEncodeDecode() { |
162 codec_inst_.startBitrate = 300; | 160 codec_inst_.startBitrate = 300; |
163 codec_inst_.maxBitrate = 4000; | 161 codec_inst_.maxBitrate = 4000; |
164 codec_inst_.qpMax = 56; | 162 codec_inst_.qpMax = 56; |
165 codec_inst_.codecSpecific.VP8.denoisingOn = true; | 163 codec_inst_.codecSpecific.VP8.denoisingOn = true; |
166 | 164 |
167 EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, | 165 EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, |
168 encoder_->InitEncode(&codec_inst_, 1, 1440)); | 166 encoder_->InitEncode(&codec_inst_, 1, 1440)); |
(...skipping 21 matching lines...) Expand all Loading... |
190 return 0; | 188 return 0; |
191 } | 189 } |
192 | 190 |
193 const int kWidth = 172; | 191 const int kWidth = 172; |
194 const int kHeight = 144; | 192 const int kHeight = 144; |
195 | 193 |
196 std::unique_ptr<Vp8UnitTestEncodeCompleteCallback> encode_complete_callback_; | 194 std::unique_ptr<Vp8UnitTestEncodeCompleteCallback> encode_complete_callback_; |
197 std::unique_ptr<Vp8UnitTestDecodeCompleteCallback> decode_complete_callback_; | 195 std::unique_ptr<Vp8UnitTestDecodeCompleteCallback> decode_complete_callback_; |
198 std::unique_ptr<uint8_t[]> source_buffer_; | 196 std::unique_ptr<uint8_t[]> source_buffer_; |
199 FILE* source_file_; | 197 FILE* source_file_; |
200 std::unique_ptr<VideoFrame> input_frame_; | 198 VideoFrame input_frame_; |
201 std::unique_ptr<VideoEncoder> encoder_; | 199 std::unique_ptr<VideoEncoder> encoder_; |
202 std::unique_ptr<VideoDecoder> decoder_; | 200 std::unique_ptr<VideoDecoder> decoder_; |
203 EncodedImage encoded_frame_; | 201 EncodedImage encoded_frame_; |
204 VideoFrame decoded_frame_; | 202 VideoFrame decoded_frame_; |
205 size_t length_source_frame_; | 203 size_t length_source_frame_; |
206 VideoCodec codec_inst_; | 204 VideoCodec codec_inst_; |
207 }; | 205 }; |
208 | 206 |
209 TEST_F(TestVp8Impl, EncoderParameterTest) { | 207 TEST_F(TestVp8Impl, EncoderParameterTest) { |
210 strncpy(codec_inst_.plName, "VP8", 31); | 208 strncpy(codec_inst_.plName, "VP8", 31); |
(...skipping 21 matching lines...) Expand all Loading... |
232 EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, decoder_->InitDecode(&codec_inst_, 1)); | 230 EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, decoder_->InitDecode(&codec_inst_, 1)); |
233 } | 231 } |
234 | 232 |
235 #if defined(WEBRTC_ANDROID) | 233 #if defined(WEBRTC_ANDROID) |
236 #define MAYBE_AlignedStrideEncodeDecode DISABLED_AlignedStrideEncodeDecode | 234 #define MAYBE_AlignedStrideEncodeDecode DISABLED_AlignedStrideEncodeDecode |
237 #else | 235 #else |
238 #define MAYBE_AlignedStrideEncodeDecode AlignedStrideEncodeDecode | 236 #define MAYBE_AlignedStrideEncodeDecode AlignedStrideEncodeDecode |
239 #endif | 237 #endif |
240 TEST_F(TestVp8Impl, MAYBE_AlignedStrideEncodeDecode) { | 238 TEST_F(TestVp8Impl, MAYBE_AlignedStrideEncodeDecode) { |
241 SetUpEncodeDecode(); | 239 SetUpEncodeDecode(); |
242 encoder_->Encode(*input_frame_, NULL, NULL); | 240 encoder_->Encode(input_frame_, NULL, NULL); |
243 EXPECT_GT(WaitForEncodedFrame(), 0u); | 241 EXPECT_GT(WaitForEncodedFrame(), 0u); |
244 // First frame should be a key frame. | 242 // First frame should be a key frame. |
245 encoded_frame_._frameType = kVideoFrameKey; | 243 encoded_frame_._frameType = kVideoFrameKey; |
246 encoded_frame_.ntp_time_ms_ = kTestNtpTimeMs; | 244 encoded_frame_.ntp_time_ms_ = kTestNtpTimeMs; |
247 EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, | 245 EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, |
248 decoder_->Decode(encoded_frame_, false, NULL)); | 246 decoder_->Decode(encoded_frame_, false, NULL)); |
249 EXPECT_GT(WaitForDecodedFrame(), 0u); | 247 EXPECT_GT(WaitForDecodedFrame(), 0u); |
250 // Compute PSNR on all planes (faster than SSIM). | 248 // Compute PSNR on all planes (faster than SSIM). |
251 EXPECT_GT(I420PSNR(input_frame_.get(), &decoded_frame_), 36); | 249 EXPECT_GT(I420PSNR(&input_frame_, &decoded_frame_), 36); |
252 EXPECT_EQ(kTestTimestamp, decoded_frame_.timestamp()); | 250 EXPECT_EQ(kTestTimestamp, decoded_frame_.timestamp()); |
253 EXPECT_EQ(kTestNtpTimeMs, decoded_frame_.ntp_time_ms()); | 251 EXPECT_EQ(kTestNtpTimeMs, decoded_frame_.ntp_time_ms()); |
254 } | 252 } |
255 | 253 |
256 #if defined(WEBRTC_ANDROID) | 254 #if defined(WEBRTC_ANDROID) |
257 #define MAYBE_DecodeWithACompleteKeyFrame DISABLED_DecodeWithACompleteKeyFrame | 255 #define MAYBE_DecodeWithACompleteKeyFrame DISABLED_DecodeWithACompleteKeyFrame |
258 #else | 256 #else |
259 #define MAYBE_DecodeWithACompleteKeyFrame DecodeWithACompleteKeyFrame | 257 #define MAYBE_DecodeWithACompleteKeyFrame DecodeWithACompleteKeyFrame |
260 #endif | 258 #endif |
261 TEST_F(TestVp8Impl, MAYBE_DecodeWithACompleteKeyFrame) { | 259 TEST_F(TestVp8Impl, MAYBE_DecodeWithACompleteKeyFrame) { |
262 SetUpEncodeDecode(); | 260 SetUpEncodeDecode(); |
263 encoder_->Encode(*input_frame_, NULL, NULL); | 261 encoder_->Encode(input_frame_, NULL, NULL); |
264 EXPECT_GT(WaitForEncodedFrame(), 0u); | 262 EXPECT_GT(WaitForEncodedFrame(), 0u); |
265 // Setting complete to false -> should return an error. | 263 // Setting complete to false -> should return an error. |
266 encoded_frame_._completeFrame = false; | 264 encoded_frame_._completeFrame = false; |
267 EXPECT_EQ(WEBRTC_VIDEO_CODEC_ERROR, | 265 EXPECT_EQ(WEBRTC_VIDEO_CODEC_ERROR, |
268 decoder_->Decode(encoded_frame_, false, NULL)); | 266 decoder_->Decode(encoded_frame_, false, NULL)); |
269 // Setting complete back to true. Forcing a delta frame. | 267 // Setting complete back to true. Forcing a delta frame. |
270 encoded_frame_._frameType = kVideoFrameDelta; | 268 encoded_frame_._frameType = kVideoFrameDelta; |
271 encoded_frame_._completeFrame = true; | 269 encoded_frame_._completeFrame = true; |
272 EXPECT_EQ(WEBRTC_VIDEO_CODEC_ERROR, | 270 EXPECT_EQ(WEBRTC_VIDEO_CODEC_ERROR, |
273 decoder_->Decode(encoded_frame_, false, NULL)); | 271 decoder_->Decode(encoded_frame_, false, NULL)); |
274 // Now setting a key frame. | 272 // Now setting a key frame. |
275 encoded_frame_._frameType = kVideoFrameKey; | 273 encoded_frame_._frameType = kVideoFrameKey; |
276 EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, | 274 EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, |
277 decoder_->Decode(encoded_frame_, false, NULL)); | 275 decoder_->Decode(encoded_frame_, false, NULL)); |
278 EXPECT_GT(I420PSNR(input_frame_.get(), &decoded_frame_), 36); | 276 EXPECT_GT(I420PSNR(&input_frame_, &decoded_frame_), 36); |
279 } | 277 } |
280 | 278 |
281 } // namespace webrtc | 279 } // namespace webrtc |
OLD | NEW |