Commit 8b33caf3 authored by Hirokazu Honda's avatar Hirokazu Honda Committed by Commit Bot

MediaFoundationVEA: Deprecate TryToSetupEncodeOnSeparateThread

TryToSetupEncodeOnSeparateThread() in MediaFoundationVEA is not being called at
all and will never be used.
This CL deprecates the function in MediaFoundationVEA. As a result, all the VEA
interface functions are executed by GPU IO thread.

BUG=chromium:828047
TEST=VEA unittest

Cq-Include-Trybots: luci.chromium.try:android_optional_gpu_tests_rel;luci.chromium.try:linux_optional_gpu_tests_rel;luci.chromium.try:mac_optional_gpu_tests_rel;master.tryserver.chromium.win:win_optional_gpu_tests_rel
Change-Id: Ie6b236b637ce99a29116dba9fffda89562830067
Reviewed-on: https://chromium-review.googlesource.com/997035Reviewed-by: default avatarEmircan Uysaler <emircan@chromium.org>
Reviewed-by: default avatarDan Sanders <sandersd@chromium.org>
Commit-Queue: Hirokazu Honda <hiroh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#548605}
parent 429a4252
...@@ -253,13 +253,6 @@ bool MediaFoundationVideoEncodeAccelerator::Initialize( ...@@ -253,13 +253,6 @@ bool MediaFoundationVideoEncodeAccelerator::Initialize(
hr = encoder_->ProcessMessage(MFT_MESSAGE_NOTIFY_BEGIN_STREAMING, NULL); hr = encoder_->ProcessMessage(MFT_MESSAGE_NOTIFY_BEGIN_STREAMING, NULL);
RETURN_ON_HR_FAILURE(hr, "Couldn't set ProcessMessage", false); RETURN_ON_HR_FAILURE(hr, "Couldn't set ProcessMessage", false);
// Pin all client callbacks to the main task runner initially. It can be
// reassigned by TryToSetupEncodeOnSeparateThread().
if (!encode_client_task_runner_) {
encode_client_task_runner_ = main_client_task_runner_;
encode_client_ = main_client_;
}
main_client_task_runner_->PostTask( main_client_task_runner_->PostTask(
FROM_HERE, base::Bind(&Client::RequireBitstreamBuffers, main_client_, FROM_HERE, base::Bind(&Client::RequireBitstreamBuffers, main_client_,
kNumInputBuffers, input_visible_size_, kNumInputBuffers, input_visible_size_,
...@@ -271,7 +264,7 @@ void MediaFoundationVideoEncodeAccelerator::Encode( ...@@ -271,7 +264,7 @@ void MediaFoundationVideoEncodeAccelerator::Encode(
const scoped_refptr<VideoFrame>& frame, const scoped_refptr<VideoFrame>& frame,
bool force_keyframe) { bool force_keyframe) {
DVLOG(3) << __func__; DVLOG(3) << __func__;
DCHECK(encode_client_task_runner_->BelongsToCurrentThread()); DCHECK(main_client_task_runner_->BelongsToCurrentThread());
encoder_thread_task_runner_->PostTask( encoder_thread_task_runner_->PostTask(
FROM_HERE, base::Bind(&MediaFoundationVideoEncodeAccelerator::EncodeTask, FROM_HERE, base::Bind(&MediaFoundationVideoEncodeAccelerator::EncodeTask,
...@@ -282,7 +275,7 @@ void MediaFoundationVideoEncodeAccelerator::Encode( ...@@ -282,7 +275,7 @@ void MediaFoundationVideoEncodeAccelerator::Encode(
void MediaFoundationVideoEncodeAccelerator::UseOutputBitstreamBuffer( void MediaFoundationVideoEncodeAccelerator::UseOutputBitstreamBuffer(
const BitstreamBuffer& buffer) { const BitstreamBuffer& buffer) {
DVLOG(3) << __func__ << ": buffer size=" << buffer.size(); DVLOG(3) << __func__ << ": buffer size=" << buffer.size();
DCHECK(encode_client_task_runner_->BelongsToCurrentThread()); DCHECK(main_client_task_runner_->BelongsToCurrentThread());
if (buffer.size() < bitstream_buffer_size_) { if (buffer.size() < bitstream_buffer_size_) {
DLOG(ERROR) << "Output BitstreamBuffer isn't big enough: " << buffer.size() DLOG(ERROR) << "Output BitstreamBuffer isn't big enough: " << buffer.size()
...@@ -313,7 +306,7 @@ void MediaFoundationVideoEncodeAccelerator::RequestEncodingParametersChange( ...@@ -313,7 +306,7 @@ void MediaFoundationVideoEncodeAccelerator::RequestEncodingParametersChange(
uint32_t framerate) { uint32_t framerate) {
DVLOG(3) << __func__ << ": bitrate=" << bitrate DVLOG(3) << __func__ << ": bitrate=" << bitrate
<< ": framerate=" << framerate; << ": framerate=" << framerate;
DCHECK(encode_client_task_runner_->BelongsToCurrentThread()); DCHECK(main_client_task_runner_->BelongsToCurrentThread());
encoder_thread_task_runner_->PostTask( encoder_thread_task_runner_->PostTask(
FROM_HERE, FROM_HERE,
...@@ -340,16 +333,6 @@ void MediaFoundationVideoEncodeAccelerator::Destroy() { ...@@ -340,16 +333,6 @@ void MediaFoundationVideoEncodeAccelerator::Destroy() {
delete this; delete this;
} }
bool MediaFoundationVideoEncodeAccelerator::TryToSetupEncodeOnSeparateThread(
const base::WeakPtr<Client>& encode_client,
const scoped_refptr<base::SingleThreadTaskRunner>& encode_task_runner) {
DVLOG(3) << __func__;
DCHECK(main_client_task_runner_->BelongsToCurrentThread());
encode_client_ = encode_client;
encode_client_task_runner_ = encode_task_runner;
return true;
}
// static // static
bool MediaFoundationVideoEncodeAccelerator::PreSandboxInitialization() { bool MediaFoundationVideoEncodeAccelerator::PreSandboxInitialization() {
bool result = true; bool result = true;
...@@ -553,7 +536,8 @@ bool MediaFoundationVideoEncodeAccelerator::IsResolutionSupported( ...@@ -553,7 +536,8 @@ bool MediaFoundationVideoEncodeAccelerator::IsResolutionSupported(
void MediaFoundationVideoEncodeAccelerator::NotifyError( void MediaFoundationVideoEncodeAccelerator::NotifyError(
VideoEncodeAccelerator::Error error) { VideoEncodeAccelerator::Error error) {
DCHECK(encoder_thread_task_runner_->BelongsToCurrentThread() || DCHECK(encoder_thread_task_runner_->BelongsToCurrentThread() ||
encode_client_task_runner_->BelongsToCurrentThread()); main_client_task_runner_->BelongsToCurrentThread());
main_client_task_runner_->PostTask( main_client_task_runner_->PostTask(
FROM_HERE, base::Bind(&Client::NotifyError, main_client_, error)); FROM_HERE, base::Bind(&Client::NotifyError, main_client_, error));
} }
...@@ -694,8 +678,8 @@ void MediaFoundationVideoEncodeAccelerator::ProcessOutput() { ...@@ -694,8 +678,8 @@ void MediaFoundationVideoEncodeAccelerator::ProcessOutput() {
memcpy(buffer_ref->shm->memory(), scoped_buffer.get(), size); memcpy(buffer_ref->shm->memory(), scoped_buffer.get(), size);
} }
encode_client_task_runner_->PostTask( main_client_task_runner_->PostTask(
FROM_HERE, base::Bind(&Client::BitstreamBufferReady, encode_client_, FROM_HERE, base::Bind(&Client::BitstreamBufferReady, main_client_,
buffer_ref->id, size, keyframe, timestamp)); buffer_ref->id, size, keyframe, timestamp));
// Keep calling ProcessOutput recursively until MF_E_TRANSFORM_NEED_MORE_INPUT // Keep calling ProcessOutput recursively until MF_E_TRANSFORM_NEED_MORE_INPUT
...@@ -729,9 +713,9 @@ void MediaFoundationVideoEncodeAccelerator::ReturnBitstreamBuffer( ...@@ -729,9 +713,9 @@ void MediaFoundationVideoEncodeAccelerator::ReturnBitstreamBuffer(
memcpy(buffer_ref->shm->memory(), encode_output->memory(), memcpy(buffer_ref->shm->memory(), encode_output->memory(),
encode_output->size()); encode_output->size());
encode_client_task_runner_->PostTask( main_client_task_runner_->PostTask(
FROM_HERE, FROM_HERE,
base::Bind(&Client::BitstreamBufferReady, encode_client_, buffer_ref->id, base::Bind(&Client::BitstreamBufferReady, main_client_, buffer_ref->id,
encode_output->size(), encode_output->keyframe, encode_output->size(), encode_output->keyframe,
encode_output->capture_timestamp)); encode_output->capture_timestamp));
} }
......
...@@ -26,9 +26,8 @@ namespace media { ...@@ -26,9 +26,8 @@ namespace media {
// Media Foundation implementation of the VideoEncodeAccelerator interface for // Media Foundation implementation of the VideoEncodeAccelerator interface for
// Windows. // Windows.
// This class saves the task runner on which it is constructed and runs client // This class saves the task runner on which it is constructed and runs client
// callbacks using that same task runner. If TryToSetupEncodeOnSeparateThread() // callbacks using that same task runner.
// is called, it uses the given |encode_task_runner| instead to return encoded // This class has DCHECKs to makes sure that methods are called in the
// data. This class has DCHECKs to makes sure that methods are called in the
// correct task runners. It starts an internal encoder thread on which // correct task runners. It starts an internal encoder thread on which
// VideoEncodeAccelerator implementation tasks are posted. // VideoEncodeAccelerator implementation tasks are posted.
class MEDIA_GPU_EXPORT MediaFoundationVideoEncodeAccelerator class MEDIA_GPU_EXPORT MediaFoundationVideoEncodeAccelerator
...@@ -52,10 +51,6 @@ class MEDIA_GPU_EXPORT MediaFoundationVideoEncodeAccelerator ...@@ -52,10 +51,6 @@ class MEDIA_GPU_EXPORT MediaFoundationVideoEncodeAccelerator
void RequestEncodingParametersChange(uint32_t bitrate, void RequestEncodingParametersChange(uint32_t bitrate,
uint32_t framerate) override; uint32_t framerate) override;
void Destroy() override; void Destroy() override;
bool TryToSetupEncodeOnSeparateThread(
const base::WeakPtr<Client>& encode_client,
const scoped_refptr<base::SingleThreadTaskRunner>& encode_task_runner)
override;
// Preload dlls required for encoding. Returns true if all required dlls are // Preload dlls required for encoding. Returns true if all required dlls are
// correctly loaded. // correctly loaded.
...@@ -99,7 +94,7 @@ class MEDIA_GPU_EXPORT MediaFoundationVideoEncodeAccelerator ...@@ -99,7 +94,7 @@ class MEDIA_GPU_EXPORT MediaFoundationVideoEncodeAccelerator
std::unique_ptr<BitstreamBufferRef> buffer_ref); std::unique_ptr<BitstreamBufferRef> buffer_ref);
// Copies EncodeOutput into a BitstreamBuffer and returns it to the // Copies EncodeOutput into a BitstreamBuffer and returns it to the
// |encode_client_|. // |main_client_|.
void ReturnBitstreamBuffer( void ReturnBitstreamBuffer(
std::unique_ptr<EncodeOutput> encode_output, std::unique_ptr<EncodeOutput> encode_output,
std::unique_ptr<MediaFoundationVideoEncodeAccelerator::BitstreamBufferRef> std::unique_ptr<MediaFoundationVideoEncodeAccelerator::BitstreamBufferRef>
...@@ -153,12 +148,6 @@ class MEDIA_GPU_EXPORT MediaFoundationVideoEncodeAccelerator ...@@ -153,12 +148,6 @@ class MEDIA_GPU_EXPORT MediaFoundationVideoEncodeAccelerator
std::unique_ptr<base::WeakPtrFactory<Client>> main_client_weak_factory_; std::unique_ptr<base::WeakPtrFactory<Client>> main_client_weak_factory_;
scoped_refptr<base::SingleThreadTaskRunner> main_client_task_runner_; scoped_refptr<base::SingleThreadTaskRunner> main_client_task_runner_;
// Used to run client callback BitstreamBufferReady() on
// |encode_client_task_runner_| if given by
// TryToSetupEncodeOnSeparateThread().
base::WeakPtr<Client> encode_client_;
scoped_refptr<base::SingleThreadTaskRunner> encode_client_task_runner_;
// This thread services tasks posted from the VEA API entry points by the // This thread services tasks posted from the VEA API entry points by the
// GPU child thread and CompressionCallback() posted from device thread. // GPU child thread and CompressionCallback() posted from device thread.
base::Thread encoder_thread_; base::Thread encoder_thread_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment