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

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

Issue 2695653002: Add support for creating HW codecs in VideoProcessor tests. (Closed)
Patch Set: Created 3 years, 10 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
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 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 } 339 }
340 // Check if codec size is different from native/original size, and if so, 340 // Check if codec size is different from native/original size, and if so,
341 // upsample back to original size: needed for PSNR and SSIM computations. 341 // upsample back to original size: needed for PSNR and SSIM computations.
342 if (image.width() != config_.codec_settings->width || 342 if (image.width() != config_.codec_settings->width ||
343 image.height() != config_.codec_settings->height) { 343 image.height() != config_.codec_settings->height) {
344 rtc::scoped_refptr<I420Buffer> up_image( 344 rtc::scoped_refptr<I420Buffer> up_image(
345 I420Buffer::Create(config_.codec_settings->width, 345 I420Buffer::Create(config_.codec_settings->width,
346 config_.codec_settings->height)); 346 config_.codec_settings->height));
347 347
348 // Should be the same aspect ratio, no cropping needed. 348 // Should be the same aspect ratio, no cropping needed.
349 up_image->ScaleFrom(*image.video_frame_buffer()); 349 if (image.video_frame_buffer()->native_handle()) {
350 up_image->ScaleFrom(*image.video_frame_buffer()->NativeToI420Buffer());
351 } else {
352 up_image->ScaleFrom(*image.video_frame_buffer());
353 }
350 354
351 // TODO(mikhal): Extracting the buffer for now - need to update test. 355 // TODO(mikhal): Extracting the buffer for now - need to update test.
352 size_t length = 356 size_t length =
353 CalcBufferSize(kI420, up_image->width(), up_image->height()); 357 CalcBufferSize(kI420, up_image->width(), up_image->height());
354 std::unique_ptr<uint8_t[]> image_buffer(new uint8_t[length]); 358 std::unique_ptr<uint8_t[]> image_buffer(new uint8_t[length]);
355 int extracted_length = ExtractBuffer(up_image, length, image_buffer.get()); 359 int extracted_length = ExtractBuffer(up_image, length, image_buffer.get());
356 RTC_DCHECK_GT(extracted_length, 0); 360 RTC_DCHECK_GT(extracted_length, 0);
357 // Update our copy of the last successful frame: 361 // Update our copy of the last successful frame:
358 memcpy(last_successful_frame_buffer_.get(), image_buffer.get(), 362 memcpy(last_successful_frame_buffer_.get(), image_buffer.get(),
359 extracted_length); 363 extracted_length);
360 bool write_success = frame_writer_->WriteFrame(image_buffer.get()); 364 bool write_success = frame_writer_->WriteFrame(image_buffer.get());
361 RTC_DCHECK(write_success); 365 RTC_DCHECK(write_success);
362 if (!write_success) { 366 if (!write_success) {
363 fprintf(stderr, "Failed to write frame %d to disk!", frame_number); 367 fprintf(stderr, "Failed to write frame %d to disk!", frame_number);
364 } 368 }
365 } else { // No resize. 369 } else { // No resize.
366 // Update our copy of the last successful frame: 370 // Update our copy of the last successful frame:
367 // TODO(mikhal): Add as a member function, so won't be allocated per frame. 371 // TODO(mikhal): Add as a member function, so won't be allocated per frame.
368 size_t length = CalcBufferSize(kI420, image.width(), image.height()); 372 size_t length = CalcBufferSize(kI420, image.width(), image.height());
369 std::unique_ptr<uint8_t[]> image_buffer(new uint8_t[length]); 373 std::unique_ptr<uint8_t[]> image_buffer(new uint8_t[length]);
370 int extracted_length = ExtractBuffer(image, length, image_buffer.get()); 374 int extracted_length;
375 if (image.video_frame_buffer()->native_handle()) {
376 extracted_length =
377 ExtractBuffer(image.video_frame_buffer()->NativeToI420Buffer(),
378 length, image_buffer.get());
379 } else {
380 extracted_length =
381 ExtractBuffer(image.video_frame_buffer(), length, image_buffer.get());
382 }
371 RTC_DCHECK_GT(extracted_length, 0); 383 RTC_DCHECK_GT(extracted_length, 0);
372 memcpy(last_successful_frame_buffer_.get(), image_buffer.get(), 384 memcpy(last_successful_frame_buffer_.get(), image_buffer.get(),
373 extracted_length); 385 extracted_length);
374 386
375 bool write_success = frame_writer_->WriteFrame(image_buffer.get()); 387 bool write_success = frame_writer_->WriteFrame(image_buffer.get());
376 RTC_DCHECK(write_success); 388 RTC_DCHECK(write_success);
377 if (!write_success) { 389 if (!write_success) {
378 fprintf(stderr, "Failed to write frame %d to disk!", frame_number); 390 fprintf(stderr, "Failed to write frame %d to disk!", frame_number);
379 } 391 }
380 } 392 }
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 } 427 }
416 int32_t VideoProcessorImpl::VideoProcessorDecodeCompleteCallback::Decoded( 428 int32_t VideoProcessorImpl::VideoProcessorDecodeCompleteCallback::Decoded(
417 VideoFrame& image) { 429 VideoFrame& image) {
418 // Forward to parent class. 430 // Forward to parent class.
419 video_processor_->FrameDecoded(image); 431 video_processor_->FrameDecoded(image);
420 return 0; 432 return 0;
421 } 433 }
422 434
423 } // namespace test 435 } // namespace test
424 } // namespace webrtc 436 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698