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(
hr = encoder_->ProcessMessage(MFT_MESSAGE_NOTIFY_BEGIN_STREAMING, NULL);
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(
FROM_HERE, base::Bind(&Client::RequireBitstreamBuffers, main_client_,
kNumInputBuffers, input_visible_size_,
......@@ -271,7 +264,7 @@ void MediaFoundationVideoEncodeAccelerator::Encode(
const scoped_refptr<VideoFrame>& frame,
bool force_keyframe) {
DVLOG(3) << __func__;
DCHECK(encode_client_task_runner_->BelongsToCurrentThread());
DCHECK(main_client_task_runner_->BelongsToCurrentThread());
encoder_thread_task_runner_->PostTask(
FROM_HERE, base::Bind(&MediaFoundationVideoEncodeAccelerator::EncodeTask,
......@@ -282,7 +275,7 @@ void MediaFoundationVideoEncodeAccelerator::Encode(
void MediaFoundationVideoEncodeAccelerator::UseOutputBitstreamBuffer(
const BitstreamBuffer& buffer) {
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_) {
DLOG(ERROR) << "Output BitstreamBuffer isn't big enough: " << buffer.size()
......@@ -313,7 +306,7 @@ void MediaFoundationVideoEncodeAccelerator::RequestEncodingParametersChange(
uint32_t framerate) {
DVLOG(3) << __func__ << ": bitrate=" << bitrate
<< ": framerate=" << framerate;
DCHECK(encode_client_task_runner_->BelongsToCurrentThread());
DCHECK(main_client_task_runner_->BelongsToCurrentThread());
encoder_thread_task_runner_->PostTask(
FROM_HERE,
......@@ -340,16 +333,6 @@ void MediaFoundationVideoEncodeAccelerator::Destroy() {
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
bool MediaFoundationVideoEncodeAccelerator::PreSandboxInitialization() {
bool result = true;
......@@ -553,7 +536,8 @@ bool MediaFoundationVideoEncodeAccelerator::IsResolutionSupported(
void MediaFoundationVideoEncodeAccelerator::NotifyError(
VideoEncodeAccelerator::Error error) {
DCHECK(encoder_thread_task_runner_->BelongsToCurrentThread() ||
encode_client_task_runner_->BelongsToCurrentThread());
main_client_task_runner_->BelongsToCurrentThread());
main_client_task_runner_->PostTask(
FROM_HERE, base::Bind(&Client::NotifyError, main_client_, error));
}
......@@ -694,8 +678,8 @@ void MediaFoundationVideoEncodeAccelerator::ProcessOutput() {
memcpy(buffer_ref->shm->memory(), scoped_buffer.get(), size);
}
encode_client_task_runner_->PostTask(
FROM_HERE, base::Bind(&Client::BitstreamBufferReady, encode_client_,
main_client_task_runner_->PostTask(
FROM_HERE, base::Bind(&Client::BitstreamBufferReady, main_client_,
buffer_ref->id, size, keyframe, timestamp));
// Keep calling ProcessOutput recursively until MF_E_TRANSFORM_NEED_MORE_INPUT
......@@ -729,9 +713,9 @@ void MediaFoundationVideoEncodeAccelerator::ReturnBitstreamBuffer(
memcpy(buffer_ref->shm->memory(), encode_output->memory(),
encode_output->size());
encode_client_task_runner_->PostTask(
main_client_task_runner_->PostTask(
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->capture_timestamp));
}
......
......@@ -26,9 +26,8 @@ namespace media {
// Media Foundation implementation of the VideoEncodeAccelerator interface for
// Windows.
// This class saves the task runner on which it is constructed and runs client
// callbacks using that same task runner. If TryToSetupEncodeOnSeparateThread()
// is called, it uses the given |encode_task_runner| instead to return encoded
// data. This class has DCHECKs to makes sure that methods are called in the
// callbacks using that same task runner.
// This class has DCHECKs to makes sure that methods are called in the
// correct task runners. It starts an internal encoder thread on which
// VideoEncodeAccelerator implementation tasks are posted.
class MEDIA_GPU_EXPORT MediaFoundationVideoEncodeAccelerator
......@@ -52,10 +51,6 @@ class MEDIA_GPU_EXPORT MediaFoundationVideoEncodeAccelerator
void RequestEncodingParametersChange(uint32_t bitrate,
uint32_t framerate) 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
// correctly loaded.
......@@ -99,7 +94,7 @@ class MEDIA_GPU_EXPORT MediaFoundationVideoEncodeAccelerator
std::unique_ptr<BitstreamBufferRef> buffer_ref);
// Copies EncodeOutput into a BitstreamBuffer and returns it to the
// |encode_client_|.
// |main_client_|.
void ReturnBitstreamBuffer(
std::unique_ptr<EncodeOutput> encode_output,
std::unique_ptr<MediaFoundationVideoEncodeAccelerator::BitstreamBufferRef>
......@@ -153,12 +148,6 @@ class MEDIA_GPU_EXPORT MediaFoundationVideoEncodeAccelerator
std::unique_ptr<base::WeakPtrFactory<Client>> main_client_weak_factory_;
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
// GPU child thread and CompressionCallback() posted from device 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