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

Side by Side Diff: media/cast/sender/external_video_encoder.cc

Issue 1544313002: Convert Pass()→std::move() in //media (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "media/cast/sender/external_video_encoder.h" 5 #include "media/cast/sender/external_video_encoder.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 #include <utility>
8 9
9 #include "base/bind.h" 10 #include "base/bind.h"
10 #include "base/debug/crash_logging.h" 11 #include "base/debug/crash_logging.h"
11 #include "base/debug/dump_without_crashing.h" 12 #include "base/debug/dump_without_crashing.h"
12 #include "base/format_macros.h" 13 #include "base/format_macros.h"
13 #include "base/logging.h" 14 #include "base/logging.h"
14 #include "base/macros.h" 15 #include "base/macros.h"
15 #include "base/memory/scoped_vector.h" 16 #include "base/memory/scoped_vector.h"
16 #include "base/memory/shared_memory.h" 17 #include "base/memory/shared_memory.h"
17 #include "base/message_loop/message_loop.h" 18 #include "base/message_loop/message_loop.h"
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 const scoped_refptr<base::SingleThreadTaskRunner>& encoder_task_runner, 82 const scoped_refptr<base::SingleThreadTaskRunner>& encoder_task_runner,
82 scoped_ptr<media::VideoEncodeAccelerator> vea, 83 scoped_ptr<media::VideoEncodeAccelerator> vea,
83 int max_frame_rate, 84 int max_frame_rate,
84 const StatusChangeCallback& status_change_cb, 85 const StatusChangeCallback& status_change_cb,
85 const CreateVideoEncodeMemoryCallback& create_video_encode_memory_cb) 86 const CreateVideoEncodeMemoryCallback& create_video_encode_memory_cb)
86 : cast_environment_(cast_environment), 87 : cast_environment_(cast_environment),
87 task_runner_(encoder_task_runner), 88 task_runner_(encoder_task_runner),
88 max_frame_rate_(max_frame_rate), 89 max_frame_rate_(max_frame_rate),
89 status_change_cb_(status_change_cb), 90 status_change_cb_(status_change_cb),
90 create_video_encode_memory_cb_(create_video_encode_memory_cb), 91 create_video_encode_memory_cb_(create_video_encode_memory_cb),
91 video_encode_accelerator_(vea.Pass()), 92 video_encode_accelerator_(std::move(vea)),
92 encoder_active_(false), 93 encoder_active_(false),
93 next_frame_id_(0u), 94 next_frame_id_(0u),
94 key_frame_encountered_(false), 95 key_frame_encountered_(false),
95 codec_profile_(media::VIDEO_CODEC_PROFILE_UNKNOWN), 96 codec_profile_(media::VIDEO_CODEC_PROFILE_UNKNOWN),
96 key_frame_quantizer_parsable_(false), 97 key_frame_quantizer_parsable_(false),
97 requested_bit_rate_(-1), 98 requested_bit_rate_(-1),
98 has_seen_zero_length_encoded_frame_(false) {} 99 has_seen_zero_length_encoded_frame_(false) {}
99 100
100 base::SingleThreadTaskRunner* task_runner() const { 101 base::SingleThreadTaskRunner* task_runner() const {
101 return task_runner_.get(); 102 return task_runner_.get();
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 void OnCreateSharedMemory(scoped_ptr<base::SharedMemory> memory) { 362 void OnCreateSharedMemory(scoped_ptr<base::SharedMemory> memory) {
362 task_runner_->PostTask(FROM_HERE, 363 task_runner_->PostTask(FROM_HERE,
363 base::Bind(&VEAClientImpl::OnReceivedSharedMemory, 364 base::Bind(&VEAClientImpl::OnReceivedSharedMemory,
364 this, 365 this,
365 base::Passed(&memory))); 366 base::Passed(&memory)));
366 } 367 }
367 368
368 void OnReceivedSharedMemory(scoped_ptr<base::SharedMemory> memory) { 369 void OnReceivedSharedMemory(scoped_ptr<base::SharedMemory> memory) {
369 DCHECK(task_runner_->RunsTasksOnCurrentThread()); 370 DCHECK(task_runner_->RunsTasksOnCurrentThread());
370 371
371 output_buffers_.push_back(memory.Pass()); 372 output_buffers_.push_back(std::move(memory));
372 373
373 // Wait until all requested buffers are received. 374 // Wait until all requested buffers are received.
374 if (output_buffers_.size() < kOutputBufferCount) 375 if (output_buffers_.size() < kOutputBufferCount)
375 return; 376 return;
376 377
377 // Immediately provide all output buffers to the VEA. 378 // Immediately provide all output buffers to the VEA.
378 for (size_t i = 0; i < output_buffers_.size(); ++i) { 379 for (size_t i = 0; i < output_buffers_.size(); ++i) {
379 video_encode_accelerator_->UseOutputBitstreamBuffer( 380 video_encode_accelerator_->UseOutputBitstreamBuffer(
380 media::BitstreamBuffer(static_cast<int32_t>(i), 381 media::BitstreamBuffer(static_cast<int32_t>(i),
381 output_buffers_[i]->handle(), 382 output_buffers_[i]->handle(),
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
591 // ...flow through to next case... 592 // ...flow through to next case...
592 default: 593 default:
593 cast_environment_->PostTask( 594 cast_environment_->PostTask(
594 CastEnvironment::MAIN, 595 CastEnvironment::MAIN,
595 FROM_HERE, 596 FROM_HERE,
596 base::Bind(status_change_cb, STATUS_UNSUPPORTED_CODEC)); 597 base::Bind(status_change_cb, STATUS_UNSUPPORTED_CODEC));
597 return; 598 return;
598 } 599 }
599 600
600 DCHECK(!client_); 601 DCHECK(!client_);
601 client_ = new VEAClientImpl(cast_environment_, 602 client_ = new VEAClientImpl(cast_environment_, encoder_task_runner,
602 encoder_task_runner, 603 std::move(vea), video_config.max_frame_rate,
603 vea.Pass(), 604 status_change_cb, create_video_encode_memory_cb_);
604 video_config.max_frame_rate,
605 status_change_cb,
606 create_video_encode_memory_cb_);
607 client_->task_runner()->PostTask(FROM_HERE, 605 client_->task_runner()->PostTask(FROM_HERE,
608 base::Bind(&VEAClientImpl::Initialize, 606 base::Bind(&VEAClientImpl::Initialize,
609 client_, 607 client_,
610 frame_size_, 608 frame_size_,
611 codec_profile, 609 codec_profile,
612 bit_rate_, 610 bit_rate_,
613 first_frame_id)); 611 first_frame_id));
614 } 612 }
615 613
616 SizeAdaptableExternalVideoEncoder::SizeAdaptableExternalVideoEncoder( 614 SizeAdaptableExternalVideoEncoder::SizeAdaptableExternalVideoEncoder(
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
787 const double kEntropyAtMaxQuantizer = 7.5; 785 const double kEntropyAtMaxQuantizer = 7.5;
788 const double slope = 786 const double slope =
789 (MAX_VP8_QUANTIZER - MIN_VP8_QUANTIZER) / kEntropyAtMaxQuantizer; 787 (MAX_VP8_QUANTIZER - MIN_VP8_QUANTIZER) / kEntropyAtMaxQuantizer;
790 const double quantizer = std::min<double>( 788 const double quantizer = std::min<double>(
791 MAX_VP8_QUANTIZER, MIN_VP8_QUANTIZER + slope * shannon_entropy); 789 MAX_VP8_QUANTIZER, MIN_VP8_QUANTIZER + slope * shannon_entropy);
792 return quantizer; 790 return quantizer;
793 } 791 }
794 792
795 } // namespace cast 793 } // namespace cast
796 } // namespace media 794 } // namespace media
OLDNEW
« no previous file with comments | « media/cast/sender/audio_sender_unittest.cc ('k') | media/cast/sender/fake_video_encode_accelerator_factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698