Commit e085a7ed authored by Hirokazu Honda's avatar Hirokazu Honda Committed by Commit Bot

media/gpu/VaapiVEA: Retire VaapiPicture

VaapiVEA creates VASurface from DmaBuf backed VideoFrame through
VaapiPictureFactory. There is no reason to create VASurface with
VaapiPicture. This CL retires VaapiPicture in VaapiVEA.

Bug: 1001413
Test: tast run video.EncodeAccel*
Change-Id: Ib0905ee097bde21aeab37081c43641c48fe83b24
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1786707
Commit-Queue: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: default avatarAndres Calderon Jaramillo <andrescj@chromium.org>
Reviewed-by: default avatarMiguel Casas <mcasas@chromium.org>
Cr-Commit-Position: refs/heads/master@{#697498}
parent 002abf27
......@@ -35,7 +35,6 @@
#include "media/gpu/macros.h"
#include "media/gpu/vaapi/h264_encoder.h"
#include "media/gpu/vaapi/vaapi_common.h"
#include "media/gpu/vaapi/vaapi_picture_factory.h"
#include "media/gpu/vaapi/vp8_encoder.h"
#include "media/gpu/vaapi/vp9_encoder.h"
#include "media/gpu/vp8_reference_frame_vector.h"
......@@ -85,7 +84,6 @@ class VaapiEncodeJob : public AcceleratedVideoEncoder::EncodeJob {
base::OnceClosure execute_cb,
scoped_refptr<VASurface> input_surface,
scoped_refptr<VASurface> reconstructed_surface,
std::unique_ptr<VaapiPicture> va_picture,
VABufferID coded_buffer_id);
VaapiEncodeJob* AsVaapiEncodeJob() override { return this; }
......@@ -108,10 +106,6 @@ class VaapiEncodeJob : public AcceleratedVideoEncoder::EncodeJob {
// for subsequent frames.
const scoped_refptr<VASurface> reconstructed_surface_;
// VAPicture associated with |input_surface_|. This member value is to just
// keep VAPicture alive as long as input_surface_ is alive, but not used.
const std::unique_ptr<VaapiPicture> va_picture_;
// Buffer that will contain the output bitstream data for this frame.
VABufferID coded_buffer_id_;
......@@ -286,12 +280,6 @@ bool VaapiVideoEncodeAccelerator::Initialize(const Config& config,
return false;
}
if (native_input_mode_) {
VLOGF(2) << "DMABuf mode: VaapiVEA will accept DMABuf-backed VideoFrame on "
<< "Encode()";
vaapi_picture_factory_ = std::make_unique<VaapiPictureFactory>();
}
if (config.input_visible_size.width() > profile->max_resolution.width() ||
config.input_visible_size.height() > profile->max_resolution.height()) {
VLOGF(1) << "Input size too big: " << config.input_visible_size.ToString()
......@@ -539,48 +527,26 @@ scoped_refptr<VaapiEncodeJob> VaapiVideoEncodeAccelerator::CreateEncodeJob(
return nullptr;
}
VASurfaceID va_input_surface_id = VA_INVALID_ID;
std::unique_ptr<VaapiPicture> va_picture;
scoped_refptr<VASurface> input_surface;
if (native_input_mode_) {
DCHECK(vaapi_picture_factory_);
if (frame->format() != PIXEL_FORMAT_NV12) {
NOTIFY_ERROR(kPlatformFailureError, "Unexpected format, expected NV12");
return nullptr;
}
constexpr int32_t kDummyPictureBufferId = 0;
// Passing empty callbacks is ok, because given PictureBuffer doesn't have
// texture id and thus these callbacks will never called.
va_picture = vaapi_picture_factory_->Create(
vaapi_wrapper_, MakeGLContextCurrentCallback(), BindGLImageCallback(),
PictureBuffer(kDummyPictureBufferId, frame->coded_size()));
gfx::GpuMemoryBufferHandle gmb_handle =
CreateGpuMemoryBufferHandle(frame.get());
DCHECK(!gmb_handle.is_null());
auto buffer_format = VideoPixelFormatToGfxBufferFormat(frame->format());
if (!buffer_format) {
NOTIFY_ERROR(kInvalidArgumentError,
"Unsupported format: " << frame->format());
return nullptr;
}
if (!va_picture->ImportGpuMemoryBufferHandle(*buffer_format,
std::move(gmb_handle))) {
NOTIFY_ERROR(kPlatformFailureError,
"Failed in ImportGpuMemoryBufferHandle");
"Expected NV12, got: " << frame->format());
return nullptr;
}
va_input_surface_id = va_picture->va_surface_id();
input_surface = vaapi_wrapper_->CreateVASurfaceForVideoFrame(frame.get());
if (!input_surface) {
NOTIFY_ERROR(kPlatformFailureError, "Failed to create VASurface");
return nullptr;
}
} else {
va_input_surface_id = available_va_surface_ids_.back();
input_surface =
new VASurface(available_va_surface_ids_.back(), coded_size_,
kVaSurfaceFormat, base::BindOnce(va_surface_release_cb_));
available_va_surface_ids_.pop_back();
}
scoped_refptr<VASurface> input_surface = new VASurface(
va_input_surface_id, coded_size_, kVaSurfaceFormat,
native_input_mode_ ? base::DoNothing()
: base::BindOnce(va_surface_release_cb_));
scoped_refptr<VASurface> reconstructed_surface =
new VASurface(available_va_surface_ids_.back(), coded_size_,
kVaSurfaceFormat, base::BindOnce(va_surface_release_cb_));
......@@ -590,8 +556,7 @@ scoped_refptr<VaapiEncodeJob> VaapiVideoEncodeAccelerator::CreateEncodeJob(
frame, force_keyframe,
base::BindOnce(&VaapiVideoEncodeAccelerator::ExecuteEncode,
base::Unretained(this), input_surface->id()),
input_surface, reconstructed_surface, std::move(va_picture),
coded_buffer_id);
input_surface, std::move(reconstructed_surface), coded_buffer_id);
if (!native_input_mode_) {
job->AddSetupCallback(
......@@ -809,12 +774,10 @@ VaapiEncodeJob::VaapiEncodeJob(scoped_refptr<VideoFrame> input_frame,
base::OnceClosure execute_cb,
scoped_refptr<VASurface> input_surface,
scoped_refptr<VASurface> reconstructed_surface,
std::unique_ptr<VaapiPicture> va_picture,
VABufferID coded_buffer_id)
: EncodeJob(input_frame, keyframe, std::move(execute_cb)),
input_surface_(input_surface),
reconstructed_surface_(reconstructed_surface),
va_picture_(std::move(va_picture)),
coded_buffer_id_(coded_buffer_id) {
DCHECK(input_surface_);
DCHECK(reconstructed_surface_);
......
......@@ -24,7 +24,6 @@
namespace media {
class VaapiEncodeJob;
class VaapiPictureFactory;
// A VideoEncodeAccelerator implementation that uses VA-API
// (https://01.org/vaapi) for HW-accelerated video encode.
......@@ -172,9 +171,6 @@ class MEDIA_GPU_EXPORT VaapiVideoEncodeAccelerator
// Encoder state. Encode tasks will only run in kEncoding state.
State state_;
// Creates VaapiPictures to wrap incoming DmaBufs in |native_input_mode_|.
std::unique_ptr<VaapiPictureFactory> vaapi_picture_factory_;
// Encoder instance managing video codec state and preparing encode jobs.
std::unique_ptr<AcceleratedVideoEncoder> encoder_;
......
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