Commit 5955f245 authored by Hirokazu Honda's avatar Hirokazu Honda Committed by Commit Bot

media/gpu/VFMapper: Return the currently allowed pixel format for Map()

We create VideoFrameMapper with a pixel format. Only this pixel format is when
calling Map(). VFMapper client may want to know the currently allowed pixel
format for Map(). This CL adds the function to VideoFrameMapper interface that
returns the pixel format.

Bug: 952147
Test: video_decode_accelerator_tests
Change-Id: I8a48636a11b898fb39a6bbed6276cebda85e6161
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1609726
Commit-Queue: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: default avatarAlexandre Courbot <acourbot@chromium.org>
Cr-Commit-Position: refs/heads/master@{#661277}
parent 2a816fed
......@@ -109,7 +109,7 @@ GenericDmaBufVideoFrameMapper::Create(VideoPixelFormat format) {
GenericDmaBufVideoFrameMapper::GenericDmaBufVideoFrameMapper(
VideoPixelFormat format)
: format_(format) {}
: VideoFrameMapper(format) {}
scoped_refptr<VideoFrame> GenericDmaBufVideoFrameMapper::Map(
scoped_refptr<const VideoFrame> video_frame) const {
......
......@@ -25,9 +25,6 @@ class MEDIA_GPU_EXPORT GenericDmaBufVideoFrameMapper : public VideoFrameMapper {
private:
explicit GenericDmaBufVideoFrameMapper(VideoPixelFormat format);
// The pixel format of mapped VideoFrame.
VideoPixelFormat format_;
DISALLOW_COPY_AND_ASSIGN(GenericDmaBufVideoFrameMapper);
};
......
......@@ -120,7 +120,12 @@ void VideoFrameValidator::ProcessVideoFrameTask(
VideoFrameMapperFactory::CreateMapper(video_frame->format());
LOG_ASSERT(video_frame_mapper_) << "Failed to create VideoFrameMapper";
}
validated_frame = video_frame_mapper_->Map(std::move(validated_frame));
if (!validated_frame) {
LOG(ERROR) << "Failed to map video frame";
return;
}
}
#endif // defined(OS_CHROMEOS)
......
......@@ -103,7 +103,7 @@ std::unique_ptr<VideoFrameMapper> VaapiDmaBufVideoFrameMapper::Create(
// conversion. Either mode or profile isn't required to create the VaapiWrapper.
VaapiDmaBufVideoFrameMapper::VaapiDmaBufVideoFrameMapper(
VideoPixelFormat format)
: format_(format),
: VideoFrameMapper(format),
vaapi_wrapper_(VaapiWrapper::CreateForVideoCodec(VaapiWrapper::kDecode,
H264PROFILE_MAIN,
base::DoNothing())),
......
......@@ -32,9 +32,6 @@ class MEDIA_GPU_EXPORT VaapiDmaBufVideoFrameMapper : public VideoFrameMapper {
private:
explicit VaapiDmaBufVideoFrameMapper(VideoPixelFormat format);
// The pixel format of mapped VideoFrame.
VideoPixelFormat format_;
// Vaapi components for mapping.
const scoped_refptr<VaapiWrapper> vaapi_wrapper_;
const std::unique_ptr<VaapiPictureFactory> vaapi_picture_factory_;
......
......@@ -8,6 +8,7 @@
#include "base/macros.h"
#include "base/memory/scoped_refptr.h"
#include "media/base/video_frame.h"
#include "media/base/video_types.h"
#include "media/gpu/media_gpu_export.h"
namespace media {
......@@ -24,8 +25,15 @@ class MEDIA_GPU_EXPORT VideoFrameMapper {
virtual scoped_refptr<VideoFrame> Map(
scoped_refptr<const VideoFrame> video_frame) const = 0;
// Returns the allowed pixel format of video frames on Map().
VideoPixelFormat pixel_format() const { return format_; }
protected:
VideoFrameMapper() = default;
explicit VideoFrameMapper(VideoPixelFormat format) : format_(format) {}
// The allowed pixel format of video frames on Map().
VideoPixelFormat format_;
DISALLOW_COPY_AND_ASSIGN(VideoFrameMapper);
};
......
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