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