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 |
11 #include "webrtc/modules/video_coding/codecs/test/videoprocessor.h" | 11 #include "webrtc/modules/video_coding/codecs/test/videoprocessor.h" |
12 | 12 |
13 #include <assert.h> | 13 #include <assert.h> |
14 #include <string.h> | 14 #include <string.h> |
15 | 15 |
16 #include <limits> | 16 #include <limits> |
| 17 #include <memory> |
17 #include <vector> | 18 #include <vector> |
18 | 19 |
19 #include "webrtc/system_wrappers/include/cpu_info.h" | 20 #include "webrtc/system_wrappers/include/cpu_info.h" |
20 | 21 |
21 namespace webrtc { | 22 namespace webrtc { |
22 namespace test { | 23 namespace test { |
23 | 24 |
24 TestConfig::TestConfig() | 25 TestConfig::TestConfig() |
25 : name(""), | 26 : name(""), |
26 description(""), | 27 description(""), |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 exclude_this_frame = true; | 277 exclude_this_frame = true; |
277 break; | 278 break; |
278 default: | 279 default: |
279 assert(false); | 280 assert(false); |
280 } | 281 } |
281 } | 282 } |
282 | 283 |
283 // Make a raw copy of the |encoded_image| buffer. | 284 // Make a raw copy of the |encoded_image| buffer. |
284 size_t copied_buffer_size = encoded_image._length + | 285 size_t copied_buffer_size = encoded_image._length + |
285 EncodedImage::GetBufferPaddingBytes(codec); | 286 EncodedImage::GetBufferPaddingBytes(codec); |
286 rtc::scoped_ptr<uint8_t[]> copied_buffer(new uint8_t[copied_buffer_size]); | 287 std::unique_ptr<uint8_t[]> copied_buffer(new uint8_t[copied_buffer_size]); |
287 memcpy(copied_buffer.get(), encoded_image._buffer, encoded_image._length); | 288 memcpy(copied_buffer.get(), encoded_image._buffer, encoded_image._length); |
288 // The image to feed to the decoder. | 289 // The image to feed to the decoder. |
289 EncodedImage copied_image; | 290 EncodedImage copied_image; |
290 memcpy(&copied_image, &encoded_image, sizeof(copied_image)); | 291 memcpy(&copied_image, &encoded_image, sizeof(copied_image)); |
291 copied_image._size = copied_buffer_size; | 292 copied_image._size = copied_buffer_size; |
292 copied_image._buffer = copied_buffer.get(); | 293 copied_image._buffer = copied_buffer.get(); |
293 | 294 |
294 if (!exclude_this_frame) { | 295 if (!exclude_this_frame) { |
295 stat.packets_dropped = | 296 stat.packets_dropped = |
296 packet_manipulator_->ManipulatePackets(&copied_image); | 297 packet_manipulator_->ManipulatePackets(&copied_image); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
343 frame_number, ret_val); | 344 frame_number, ret_val); |
344 } | 345 } |
345 ret_val = scaler_.Scale(image, &up_image); | 346 ret_val = scaler_.Scale(image, &up_image); |
346 assert(ret_val >= 0); | 347 assert(ret_val >= 0); |
347 if (ret_val < 0) { | 348 if (ret_val < 0) { |
348 fprintf(stderr, "Failed to scale frame: %d, return code: %d\n", | 349 fprintf(stderr, "Failed to scale frame: %d, return code: %d\n", |
349 frame_number, ret_val); | 350 frame_number, ret_val); |
350 } | 351 } |
351 // TODO(mikhal): Extracting the buffer for now - need to update test. | 352 // TODO(mikhal): Extracting the buffer for now - need to update test. |
352 size_t length = CalcBufferSize(kI420, up_image.width(), up_image.height()); | 353 size_t length = CalcBufferSize(kI420, up_image.width(), up_image.height()); |
353 rtc::scoped_ptr<uint8_t[]> image_buffer(new uint8_t[length]); | 354 std::unique_ptr<uint8_t[]> image_buffer(new uint8_t[length]); |
354 int extracted_length = ExtractBuffer(up_image, length, image_buffer.get()); | 355 int extracted_length = ExtractBuffer(up_image, length, image_buffer.get()); |
355 assert(extracted_length > 0); | 356 assert(extracted_length > 0); |
356 // Update our copy of the last successful frame: | 357 // Update our copy of the last successful frame: |
357 memcpy(last_successful_frame_buffer_, image_buffer.get(), extracted_length); | 358 memcpy(last_successful_frame_buffer_, image_buffer.get(), extracted_length); |
358 bool write_success = frame_writer_->WriteFrame(image_buffer.get()); | 359 bool write_success = frame_writer_->WriteFrame(image_buffer.get()); |
359 assert(write_success); | 360 assert(write_success); |
360 if (!write_success) { | 361 if (!write_success) { |
361 fprintf(stderr, "Failed to write frame %d to disk!", frame_number); | 362 fprintf(stderr, "Failed to write frame %d to disk!", frame_number); |
362 } | 363 } |
363 } else { // No resize. | 364 } else { // No resize. |
364 // Update our copy of the last successful frame: | 365 // Update our copy of the last successful frame: |
365 // TODO(mikhal): Add as a member function, so won't be allocated per frame. | 366 // TODO(mikhal): Add as a member function, so won't be allocated per frame. |
366 size_t length = CalcBufferSize(kI420, image.width(), image.height()); | 367 size_t length = CalcBufferSize(kI420, image.width(), image.height()); |
367 rtc::scoped_ptr<uint8_t[]> image_buffer(new uint8_t[length]); | 368 std::unique_ptr<uint8_t[]> image_buffer(new uint8_t[length]); |
368 int extracted_length = ExtractBuffer(image, length, image_buffer.get()); | 369 int extracted_length = ExtractBuffer(image, length, image_buffer.get()); |
369 assert(extracted_length > 0); | 370 assert(extracted_length > 0); |
370 memcpy(last_successful_frame_buffer_, image_buffer.get(), extracted_length); | 371 memcpy(last_successful_frame_buffer_, image_buffer.get(), extracted_length); |
371 | 372 |
372 bool write_success = frame_writer_->WriteFrame(image_buffer.get()); | 373 bool write_success = frame_writer_->WriteFrame(image_buffer.get()); |
373 assert(write_success); | 374 assert(write_success); |
374 if (!write_success) { | 375 if (!write_success) { |
375 fprintf(stderr, "Failed to write frame %d to disk!", frame_number); | 376 fprintf(stderr, "Failed to write frame %d to disk!", frame_number); |
376 } | 377 } |
377 } | 378 } |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
430 } | 431 } |
431 int32_t VideoProcessorImpl::VideoProcessorDecodeCompleteCallback::Decoded( | 432 int32_t VideoProcessorImpl::VideoProcessorDecodeCompleteCallback::Decoded( |
432 VideoFrame& image) { | 433 VideoFrame& image) { |
433 // Forward to parent class. | 434 // Forward to parent class. |
434 video_processor_->FrameDecoded(image); | 435 video_processor_->FrameDecoded(image); |
435 return 0; | 436 return 0; |
436 } | 437 } |
437 | 438 |
438 } // namespace test | 439 } // namespace test |
439 } // namespace webrtc | 440 } // namespace webrtc |
OLD | NEW |