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, |
| 156 buffer.get())); |
| 157 input_frame_.reset( |
| 158 new VideoFrame(buffer, kTestTimestamp, 0, webrtc::kVideoRotation_0)); |
157 } | 159 } |
158 | 160 |
159 void SetUpEncodeDecode() { | 161 void SetUpEncodeDecode() { |
160 codec_inst_.startBitrate = 300; | 162 codec_inst_.startBitrate = 300; |
161 codec_inst_.maxBitrate = 4000; | 163 codec_inst_.maxBitrate = 4000; |
162 codec_inst_.qpMax = 56; | 164 codec_inst_.qpMax = 56; |
163 codec_inst_.codecSpecific.VP8.denoisingOn = true; | 165 codec_inst_.codecSpecific.VP8.denoisingOn = true; |
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)); |
(...skipping 21 matching lines...) Expand all Loading... |
188 return 0; | 190 return 0; |
189 } | 191 } |
190 | 192 |
191 const int kWidth = 172; | 193 const int kWidth = 172; |
192 const int kHeight = 144; | 194 const int kHeight = 144; |
193 | 195 |
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 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 size_t length_source_frame_; | 205 size_t length_source_frame_; |
204 VideoCodec codec_inst_; | 206 VideoCodec codec_inst_; |
205 }; | 207 }; |
206 | 208 |
207 TEST_F(TestVp8Impl, EncoderParameterTest) { | 209 TEST_F(TestVp8Impl, EncoderParameterTest) { |
208 strncpy(codec_inst_.plName, "VP8", 31); | 210 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)); | 232 EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, decoder_->InitDecode(&codec_inst_, 1)); |
231 } | 233 } |
232 | 234 |
233 #if defined(WEBRTC_ANDROID) | 235 #if defined(WEBRTC_ANDROID) |
234 #define MAYBE_AlignedStrideEncodeDecode DISABLED_AlignedStrideEncodeDecode | 236 #define MAYBE_AlignedStrideEncodeDecode DISABLED_AlignedStrideEncodeDecode |
235 #else | 237 #else |
236 #define MAYBE_AlignedStrideEncodeDecode AlignedStrideEncodeDecode | 238 #define MAYBE_AlignedStrideEncodeDecode AlignedStrideEncodeDecode |
237 #endif | 239 #endif |
238 TEST_F(TestVp8Impl, MAYBE_AlignedStrideEncodeDecode) { | 240 TEST_F(TestVp8Impl, MAYBE_AlignedStrideEncodeDecode) { |
239 SetUpEncodeDecode(); | 241 SetUpEncodeDecode(); |
240 encoder_->Encode(input_frame_, NULL, NULL); | 242 encoder_->Encode(*input_frame_, NULL, NULL); |
241 EXPECT_GT(WaitForEncodedFrame(), 0u); | 243 EXPECT_GT(WaitForEncodedFrame(), 0u); |
242 // First frame should be a key frame. | 244 // First frame should be a key frame. |
243 encoded_frame_._frameType = kVideoFrameKey; | 245 encoded_frame_._frameType = kVideoFrameKey; |
244 encoded_frame_.ntp_time_ms_ = kTestNtpTimeMs; | 246 encoded_frame_.ntp_time_ms_ = kTestNtpTimeMs; |
245 EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, | 247 EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, |
246 decoder_->Decode(encoded_frame_, false, NULL)); | 248 decoder_->Decode(encoded_frame_, false, NULL)); |
247 EXPECT_GT(WaitForDecodedFrame(), 0u); | 249 EXPECT_GT(WaitForDecodedFrame(), 0u); |
248 // Compute PSNR on all planes (faster than SSIM). | 250 // Compute PSNR on all planes (faster than SSIM). |
249 EXPECT_GT(I420PSNR(&input_frame_, &decoded_frame_), 36); | 251 EXPECT_GT(I420PSNR(input_frame_.get(), &decoded_frame_), 36); |
250 EXPECT_EQ(kTestTimestamp, decoded_frame_.timestamp()); | 252 EXPECT_EQ(kTestTimestamp, decoded_frame_.timestamp()); |
251 EXPECT_EQ(kTestNtpTimeMs, decoded_frame_.ntp_time_ms()); | 253 EXPECT_EQ(kTestNtpTimeMs, decoded_frame_.ntp_time_ms()); |
252 } | 254 } |
253 | 255 |
254 #if defined(WEBRTC_ANDROID) | 256 #if defined(WEBRTC_ANDROID) |
255 #define MAYBE_DecodeWithACompleteKeyFrame DISABLED_DecodeWithACompleteKeyFrame | 257 #define MAYBE_DecodeWithACompleteKeyFrame DISABLED_DecodeWithACompleteKeyFrame |
256 #else | 258 #else |
257 #define MAYBE_DecodeWithACompleteKeyFrame DecodeWithACompleteKeyFrame | 259 #define MAYBE_DecodeWithACompleteKeyFrame DecodeWithACompleteKeyFrame |
258 #endif | 260 #endif |
259 TEST_F(TestVp8Impl, MAYBE_DecodeWithACompleteKeyFrame) { | 261 TEST_F(TestVp8Impl, MAYBE_DecodeWithACompleteKeyFrame) { |
260 SetUpEncodeDecode(); | 262 SetUpEncodeDecode(); |
261 encoder_->Encode(input_frame_, NULL, NULL); | 263 encoder_->Encode(*input_frame_, NULL, NULL); |
262 EXPECT_GT(WaitForEncodedFrame(), 0u); | 264 EXPECT_GT(WaitForEncodedFrame(), 0u); |
263 // Setting complete to false -> should return an error. | 265 // Setting complete to false -> should return an error. |
264 encoded_frame_._completeFrame = false; | 266 encoded_frame_._completeFrame = false; |
265 EXPECT_EQ(WEBRTC_VIDEO_CODEC_ERROR, | 267 EXPECT_EQ(WEBRTC_VIDEO_CODEC_ERROR, |
266 decoder_->Decode(encoded_frame_, false, NULL)); | 268 decoder_->Decode(encoded_frame_, false, NULL)); |
267 // Setting complete back to true. Forcing a delta frame. | 269 // Setting complete back to true. Forcing a delta frame. |
268 encoded_frame_._frameType = kVideoFrameDelta; | 270 encoded_frame_._frameType = kVideoFrameDelta; |
269 encoded_frame_._completeFrame = true; | 271 encoded_frame_._completeFrame = true; |
270 EXPECT_EQ(WEBRTC_VIDEO_CODEC_ERROR, | 272 EXPECT_EQ(WEBRTC_VIDEO_CODEC_ERROR, |
271 decoder_->Decode(encoded_frame_, false, NULL)); | 273 decoder_->Decode(encoded_frame_, false, NULL)); |
272 // Now setting a key frame. | 274 // Now setting a key frame. |
273 encoded_frame_._frameType = kVideoFrameKey; | 275 encoded_frame_._frameType = kVideoFrameKey; |
274 EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, | 276 EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, |
275 decoder_->Decode(encoded_frame_, false, NULL)); | 277 decoder_->Decode(encoded_frame_, false, NULL)); |
276 EXPECT_GT(I420PSNR(&input_frame_, &decoded_frame_), 36); | 278 EXPECT_GT(I420PSNR(input_frame_.get(), &decoded_frame_), 36); |
277 } | 279 } |
278 | 280 |
279 } // namespace webrtc | 281 } // namespace webrtc |
OLD | NEW |