Commit 43b45aee authored by Chih-Yu Huang's avatar Chih-Yu Huang Committed by Commit Bot

VEA: Remove "--disable_flush" argument at VEA unittest.

Originally, we need to add "--disable_flush" argument when running
the VEA unittest if the encoder does not support flush. This CL added
a method IsFlushSupported() to check if the encoder support flush.

BUG=820313
TEST=Run vea unittest at eve and nyan_big without
     "--disable_flush" argument

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;luci.chromium.try:win_optional_gpu_tests_rel
Change-Id: Id6a59546b0a13df15ca4ff2825eb70c848eaf704
Reviewed-on: https://chromium-review.googlesource.com/1170671Reviewed-by: default avatarChrome Cunningham <chcunningham@chromium.org>
Reviewed-by: default avatarPawel Osciak <posciak@chromium.org>
Reviewed-by: default avatarHirokazu Honda <hiroh@chromium.org>
Commit-Queue: Chih-Yu Huang <akahuang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#588457}
parent 7b688020
...@@ -134,6 +134,7 @@ V4L2VideoEncodeAccelerator::V4L2VideoEncodeAccelerator( ...@@ -134,6 +134,7 @@ V4L2VideoEncodeAccelerator::V4L2VideoEncodeAccelerator(
input_memory_type_(V4L2_MEMORY_USERPTR), input_memory_type_(V4L2_MEMORY_USERPTR),
output_streamon_(false), output_streamon_(false),
output_buffer_queued_count_(0), output_buffer_queued_count_(0),
is_flush_supported_(false),
encoder_thread_("V4L2EncoderThread"), encoder_thread_("V4L2EncoderThread"),
device_poll_thread_("V4L2EncoderDevicePollThread"), device_poll_thread_("V4L2EncoderDevicePollThread"),
weak_this_ptr_factory_(this) { weak_this_ptr_factory_(this) {
...@@ -176,6 +177,13 @@ bool V4L2VideoEncodeAccelerator::Initialize(const Config& config, ...@@ -176,6 +177,13 @@ bool V4L2VideoEncodeAccelerator::Initialize(const Config& config,
return false; return false;
} }
// Ask if V4L2_ENC_CMD_STOP (Flush) is supported.
struct v4l2_encoder_cmd cmd = {};
cmd.cmd = V4L2_ENC_CMD_STOP;
is_flush_supported_ = (device_->Ioctl(VIDIOC_TRY_ENCODER_CMD, &cmd) == 0);
if (!is_flush_supported_)
VLOGF(2) << "V4L2_ENC_CMD_STOP is not supported.";
struct v4l2_capability caps; struct v4l2_capability caps;
memset(&caps, 0, sizeof(caps)); memset(&caps, 0, sizeof(caps));
const __u32 kCapsRequired = V4L2_CAP_VIDEO_M2M_MPLANE | V4L2_CAP_STREAMING; const __u32 kCapsRequired = V4L2_CAP_VIDEO_M2M_MPLANE | V4L2_CAP_STREAMING;
...@@ -395,6 +403,10 @@ void V4L2VideoEncodeAccelerator::FlushTask(FlushCallback flush_callback) { ...@@ -395,6 +403,10 @@ void V4L2VideoEncodeAccelerator::FlushTask(FlushCallback flush_callback) {
EncodeTask(nullptr, false); EncodeTask(nullptr, false);
} }
bool V4L2VideoEncodeAccelerator::IsFlushSupported() {
return is_flush_supported_;
}
VideoEncodeAccelerator::SupportedProfiles VideoEncodeAccelerator::SupportedProfiles
V4L2VideoEncodeAccelerator::GetSupportedProfiles() { V4L2VideoEncodeAccelerator::GetSupportedProfiles() {
scoped_refptr<V4L2Device> device = V4L2Device::Create(); scoped_refptr<V4L2Device> device = V4L2Device::Create();
......
...@@ -55,6 +55,7 @@ class MEDIA_GPU_EXPORT V4L2VideoEncodeAccelerator ...@@ -55,6 +55,7 @@ class MEDIA_GPU_EXPORT V4L2VideoEncodeAccelerator
uint32_t framerate) override; uint32_t framerate) override;
void Destroy() override; void Destroy() override;
void Flush(FlushCallback flush_callback) override; void Flush(FlushCallback flush_callback) override;
bool IsFlushSupported() override;
private: private:
// Auto-destroy reference for BitstreamBuffer, for tracking buffers passed to // Auto-destroy reference for BitstreamBuffer, for tracking buffers passed to
...@@ -291,6 +292,10 @@ class MEDIA_GPU_EXPORT V4L2VideoEncodeAccelerator ...@@ -291,6 +292,10 @@ class MEDIA_GPU_EXPORT V4L2VideoEncodeAccelerator
// The completion callback of the Flush() function. // The completion callback of the Flush() function.
FlushCallback flush_callback_; FlushCallback flush_callback_;
// Indicates whether the V4L2 device supports flush.
// This is set in Initialize().
bool is_flush_supported_;
// Image processor, if one is in use. // Image processor, if one is in use.
std::unique_ptr<ImageProcessor> image_processor_; std::unique_ptr<ImageProcessor> image_processor_;
// Indexes of free image processor output buffers. Only accessed on child // Indexes of free image processor output buffers. Only accessed on child
......
...@@ -626,6 +626,10 @@ void VaapiVideoEncodeAccelerator::FlushTask() { ...@@ -626,6 +626,10 @@ void VaapiVideoEncodeAccelerator::FlushTask() {
EncodePendingInputs(); EncodePendingInputs();
} }
bool VaapiVideoEncodeAccelerator::IsFlushSupported() {
return true;
}
void VaapiVideoEncodeAccelerator::Destroy() { void VaapiVideoEncodeAccelerator::Destroy() {
DVLOGF(2); DVLOGF(2);
DCHECK(child_task_runner_->BelongsToCurrentThread()); DCHECK(child_task_runner_->BelongsToCurrentThread());
......
...@@ -45,6 +45,7 @@ class MEDIA_GPU_EXPORT VaapiVideoEncodeAccelerator ...@@ -45,6 +45,7 @@ class MEDIA_GPU_EXPORT VaapiVideoEncodeAccelerator
uint32_t framerate) override; uint32_t framerate) override;
void Destroy() override; void Destroy() override;
void Flush(FlushCallback flush_callback) override; void Flush(FlushCallback flush_callback) override;
bool IsFlushSupported() override;
private: private:
class H264Accelerator; class H264Accelerator;
......
...@@ -172,11 +172,6 @@ bool g_verify_all_output = false; ...@@ -172,11 +172,6 @@ bool g_verify_all_output = false;
bool g_fake_encoder = false; bool g_fake_encoder = false;
// Skip checking the flush functionality. Currently only Chrome OS devices
// support flush, so we need this to skip the check. This is set by the
// command line switch "--disable_flush".
bool g_disable_flush = false;
// Environment to store test stream data for all test cases. // Environment to store test stream data for all test cases.
class VideoEncodeAcceleratorTestEnvironment; class VideoEncodeAcceleratorTestEnvironment;
VideoEncodeAcceleratorTestEnvironment* g_env; VideoEncodeAcceleratorTestEnvironment* g_env;
...@@ -1691,8 +1686,10 @@ void VEAClient::BitstreamBufferReady( ...@@ -1691,8 +1686,10 @@ void VEAClient::BitstreamBufferReady(
static_cast<int>(metadata.payload_size_bytes))); static_cast<int>(metadata.payload_size_bytes)));
quality_validator_->AddDecodeBuffer(buffer); quality_validator_->AddDecodeBuffer(buffer);
} }
// If flush is disabled, pretend flush is done when all frames are received. // If the encoder does not support flush, pretend flush is done when all
if (g_disable_flush && num_encoded_frames_ == num_frames_to_encode_) { // frames are received.
if (!encoder_->IsFlushSupported() &&
num_encoded_frames_ == num_frames_to_encode_) {
FlushEncoderSuccessfully(); FlushEncoderSuccessfully();
} }
...@@ -1967,7 +1964,7 @@ void VEAClient::FlushEncoder() { ...@@ -1967,7 +1964,7 @@ void VEAClient::FlushEncoder() {
DCHECK(thread_checker_.CalledOnValidThread()); DCHECK(thread_checker_.CalledOnValidThread());
LOG_ASSERT(num_frames_submitted_to_encoder_ == num_frames_to_encode_); LOG_ASSERT(num_frames_submitted_to_encoder_ == num_frames_to_encode_);
if (g_disable_flush) if (!encoder_->IsFlushSupported())
return; return;
encoder_->Flush( encoder_->Flush(
...@@ -2598,13 +2595,6 @@ int main(int argc, char** argv) { ...@@ -2598,13 +2595,6 @@ int main(int argc, char** argv) {
const base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); const base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess();
DCHECK(cmd_line); DCHECK(cmd_line);
#if defined(OS_CHROMEOS)
// Currently only ARC++ uses flush function, we only verify it on Chrome OS.
media::g_disable_flush = false;
#else
media::g_disable_flush = true;
#endif
base::CommandLine::SwitchMap switches = cmd_line->GetSwitches(); base::CommandLine::SwitchMap switches = cmd_line->GetSwitches();
for (base::CommandLine::SwitchMap::const_iterator it = switches.begin(); for (base::CommandLine::SwitchMap::const_iterator it = switches.begin();
it != switches.end(); ++it) { it != switches.end(); ++it) {
...@@ -2635,10 +2625,6 @@ int main(int argc, char** argv) { ...@@ -2635,10 +2625,6 @@ int main(int argc, char** argv) {
media::g_run_at_fps = true; media::g_run_at_fps = true;
continue; continue;
} }
if (it->first == "disable_flush") {
media::g_disable_flush = true;
continue;
}
if (it->first == "verify_all_output") { if (it->first == "verify_all_output") {
media::g_verify_all_output = true; media::g_verify_all_output = true;
continue; continue;
......
...@@ -87,6 +87,10 @@ void VideoEncodeAccelerator::Flush(FlushCallback flush_callback) { ...@@ -87,6 +87,10 @@ void VideoEncodeAccelerator::Flush(FlushCallback flush_callback) {
std::move(flush_callback).Run(false); std::move(flush_callback).Run(false);
} }
bool VideoEncodeAccelerator::IsFlushSupported() {
return false;
}
void VideoEncodeAccelerator::RequestEncodingParametersChange( void VideoEncodeAccelerator::RequestEncodingParametersChange(
const VideoBitrateAllocation& bitrate_allocation, const VideoBitrateAllocation& bitrate_allocation,
uint32_t framerate) { uint32_t framerate) {
......
...@@ -254,6 +254,10 @@ class MEDIA_EXPORT VideoEncodeAccelerator { ...@@ -254,6 +254,10 @@ class MEDIA_EXPORT VideoEncodeAccelerator {
// previous Flush() is not finished yet. // previous Flush() is not finished yet.
virtual void Flush(FlushCallback flush_callback); virtual void Flush(FlushCallback flush_callback);
// Returns true if the encoder support flush. This method must be called after
// VEA has been initialized.
virtual bool IsFlushSupported();
protected: protected:
// Do not delete directly; use Destroy() or own it with a scoped_ptr, which // Do not delete directly; use Destroy() or own it with a scoped_ptr, which
// will Destroy() it properly by default. // will Destroy() it properly by default.
......
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