Commit 5aa622b0 authored by Ren-Pei Zeng's avatar Ren-Pei Zeng Committed by Commit Bot

media/gpu/vaapi: Remove VaapiPicture from VAAPI VFMapper

When creating VASurface from VideoFrame in VaapiDmaBufVideoFrameMapper,
remove the usage of VaapiPicture to avoid pulling Ozone/EGL specific
codes.

Bug: b:120057531
Test: video_decode_accelerator_tests
Change-Id: Iaad5abb53a84901734d330a341ed265bb9cf8e0b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1701661
Commit-Queue: Ren-Pei Zeng <kamesan@chromium.org>
Reviewed-by: default avatarHirokazu Honda <hiroh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#680453}
parent 461a68da
...@@ -11,10 +11,9 @@ ...@@ -11,10 +11,9 @@
#include "media/gpu/format_utils.h" #include "media/gpu/format_utils.h"
#include "media/gpu/linux/platform_video_frame_utils.h" #include "media/gpu/linux/platform_video_frame_utils.h"
#include "media/gpu/macros.h" #include "media/gpu/macros.h"
#include "media/gpu/vaapi/vaapi_picture_factory.h"
#include "media/gpu/vaapi/vaapi_utils.h" #include "media/gpu/vaapi/vaapi_utils.h"
#include "media/gpu/vaapi/vaapi_wrapper.h" #include "media/gpu/vaapi/vaapi_wrapper.h"
#include "media/video/picture.h" #include "ui/gfx/linux/native_pixmap_dmabuf.h"
namespace media { namespace media {
...@@ -113,15 +112,13 @@ VaapiDmaBufVideoFrameMapper::VaapiDmaBufVideoFrameMapper( ...@@ -113,15 +112,13 @@ VaapiDmaBufVideoFrameMapper::VaapiDmaBufVideoFrameMapper(
: VideoFrameMapper(format), : VideoFrameMapper(format),
vaapi_wrapper_(VaapiWrapper::CreateForVideoCodec(VaapiWrapper::kDecode, vaapi_wrapper_(VaapiWrapper::CreateForVideoCodec(VaapiWrapper::kDecode,
H264PROFILE_MAIN, H264PROFILE_MAIN,
base::DoNothing())), base::DoNothing())) {}
vaapi_picture_factory_(new VaapiPictureFactory()) {}
VaapiDmaBufVideoFrameMapper::~VaapiDmaBufVideoFrameMapper() {} VaapiDmaBufVideoFrameMapper::~VaapiDmaBufVideoFrameMapper() {}
scoped_refptr<VideoFrame> VaapiDmaBufVideoFrameMapper::Map( scoped_refptr<VideoFrame> VaapiDmaBufVideoFrameMapper::Map(
scoped_refptr<const VideoFrame> video_frame) const { scoped_refptr<const VideoFrame> video_frame) const {
DCHECK(vaapi_wrapper_); DCHECK(vaapi_wrapper_);
DCHECK(vaapi_picture_factory_);
if (!video_frame->HasDmaBufs()) { if (!video_frame->HasDmaBufs()) {
return nullptr; return nullptr;
} }
...@@ -130,34 +127,16 @@ scoped_refptr<VideoFrame> VaapiDmaBufVideoFrameMapper::Map( ...@@ -130,34 +127,16 @@ scoped_refptr<VideoFrame> VaapiDmaBufVideoFrameMapper::Map(
return nullptr; return nullptr;
} }
const gfx::Size& coded_size = video_frame->coded_size(); const scoped_refptr<gfx::NativePixmap> pixmap =
constexpr int32_t kDummyPictureBufferId = 0; CreateNativePixmapDmaBuf(video_frame.get());
if (!pixmap) {
// Passing empty callbacks is ok, because given PictureBuffer doesn't have VLOGF(1) << "Failed to create NativePixmap";
// texture id and thus these callbacks will never called.
auto va_picture = vaapi_picture_factory_->Create(
vaapi_wrapper_, MakeGLContextCurrentCallback(), BindGLImageCallback(),
PictureBuffer(kDummyPictureBufferId, coded_size));
if (!va_picture) {
VLOGF(1) << "Failed to create VaapiPicture.";
return nullptr;
}
gfx::GpuMemoryBufferHandle gmb_handle;
gmb_handle = CreateGpuMemoryBufferHandle(video_frame.get());
if (gmb_handle.is_null()) {
VLOGF(1) << "Failed to CreateGMBHandleFromVideoFrame.";
return nullptr; return nullptr;
} }
auto buffer_format = VideoPixelFormatToGfxBufferFormat(video_frame->format()); scoped_refptr<VASurface> va_surface =
if (!buffer_format) { vaapi_wrapper_->CreateVASurfaceForPixmap(pixmap);
VLOGF(1) << "Unsupported format: " << video_frame->format(); if (!va_surface) {
return nullptr; VLOGF(1) << "Failed to create VASurface";
}
if (!va_picture->ImportGpuMemoryBufferHandle(*buffer_format,
std::move(gmb_handle))) {
VLOGF(1) << "Failed in ImportGpuMemoryBufferHandle.";
return nullptr; return nullptr;
} }
...@@ -166,7 +145,7 @@ scoped_refptr<VideoFrame> VaapiDmaBufVideoFrameMapper::Map( ...@@ -166,7 +145,7 @@ scoped_refptr<VideoFrame> VaapiDmaBufVideoFrameMapper::Map(
constexpr VideoPixelFormat kConvertedFormat = PIXEL_FORMAT_NV12; constexpr VideoPixelFormat kConvertedFormat = PIXEL_FORMAT_NV12;
VAImageFormat va_image_format = kImageFormatNV12; VAImageFormat va_image_format = kImageFormatNV12;
auto va_image = vaapi_wrapper_->CreateVaImage( auto va_image = vaapi_wrapper_->CreateVaImage(
va_picture->va_surface_id(), &va_image_format, video_frame->coded_size()); va_surface->id(), &va_image_format, va_surface->size());
if (!va_image || !va_image->IsValid()) { if (!va_image || !va_image->IsValid()) {
VLOGF(1) << "Failed in CreateVaImage."; VLOGF(1) << "Failed in CreateVaImage.";
return nullptr; return nullptr;
......
...@@ -12,7 +12,6 @@ ...@@ -12,7 +12,6 @@
namespace media { namespace media {
class VaapiPictureFactory;
class VaapiWrapper; class VaapiWrapper;
// VideoFrameMapper that provides access to the memory referred by DMABuf-backed // VideoFrameMapper that provides access to the memory referred by DMABuf-backed
...@@ -34,7 +33,6 @@ class MEDIA_GPU_EXPORT VaapiDmaBufVideoFrameMapper : public VideoFrameMapper { ...@@ -34,7 +33,6 @@ class MEDIA_GPU_EXPORT VaapiDmaBufVideoFrameMapper : public VideoFrameMapper {
// Vaapi components for mapping. // Vaapi components for mapping.
const scoped_refptr<VaapiWrapper> vaapi_wrapper_; const scoped_refptr<VaapiWrapper> vaapi_wrapper_;
const std::unique_ptr<VaapiPictureFactory> vaapi_picture_factory_;
DISALLOW_COPY_AND_ASSIGN(VaapiDmaBufVideoFrameMapper); DISALLOW_COPY_AND_ASSIGN(VaapiDmaBufVideoFrameMapper);
}; };
......
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