Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1643)

Unified Diff: media/gpu/v4l2_slice_video_decode_accelerator.cc

Issue 2398883002: Add support for multiple V4L2 video devices of the same type. (Closed)
Patch Set: Address comments, reorganize V4L2Device::Type. Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: media/gpu/v4l2_slice_video_decode_accelerator.cc
diff --git a/media/gpu/v4l2_slice_video_decode_accelerator.cc b/media/gpu/v4l2_slice_video_decode_accelerator.cc
index e672f72f68c497cab7dd2c7276a01d6c03667333..d2ec9af63b7784784eb232733251896d8e237974 100644
--- a/media/gpu/v4l2_slice_video_decode_accelerator.cc
+++ b/media/gpu/v4l2_slice_video_decode_accelerator.cc
@@ -472,6 +472,7 @@ V4L2SliceVideoDecodeAccelerator::V4L2SliceVideoDecodeAccelerator(
output_streamon_(false),
output_buffer_queued_count_(0),
video_profile_(VIDEO_CODEC_PROFILE_UNKNOWN),
+ input_format_fourcc_(0),
output_format_fourcc_(0),
state_(kUninitialized),
output_mode_(Config::OutputMode::ALLOCATE),
@@ -517,13 +518,6 @@ bool V4L2SliceVideoDecodeAccelerator::Initialize(const Config& config,
DCHECK(child_task_runner_->BelongsToCurrentThread());
DCHECK_EQ(state_, kUninitialized);
- if (!device_->SupportsDecodeProfileForV4L2PixelFormats(
- config.profile, arraysize(supported_input_fourccs_),
- supported_input_fourccs_)) {
- DVLOGF(1) << "unsupported profile " << config.profile;
- return false;
- }
-
if (config.is_encrypted) {
NOTREACHED() << "Encrypted streams are not supported for this VDA";
return false;
@@ -547,28 +541,6 @@ bool V4L2SliceVideoDecodeAccelerator::Initialize(const Config& config,
decode_client_ = client_;
}
- video_profile_ = config.profile;
-
- if (video_profile_ >= H264PROFILE_MIN && video_profile_ <= H264PROFILE_MAX) {
- h264_accelerator_.reset(new V4L2H264Accelerator(this));
- decoder_.reset(new H264Decoder(h264_accelerator_.get()));
- } else if (video_profile_ >= VP8PROFILE_MIN &&
- video_profile_ <= VP8PROFILE_MAX) {
- vp8_accelerator_.reset(new V4L2VP8Accelerator(this));
- decoder_.reset(new VP8Decoder(vp8_accelerator_.get()));
- } else if (video_profile_ >= VP9PROFILE_MIN &&
- video_profile_ <= VP9PROFILE_MAX) {
- vp9_accelerator_.reset(new V4L2VP9Accelerator(this));
- decoder_.reset(new VP9Decoder(vp9_accelerator_.get()));
- } else {
- NOTREACHED() << "Unsupported profile " << video_profile_;
- return false;
- }
-
- // TODO(posciak): This needs to be queried once supported.
- input_planes_count_ = 1;
- output_planes_count_ = 1;
-
if (egl_display_ == EGL_NO_DISPLAY) {
LOGF(ERROR) << "could not get EGLDisplay";
return false;
@@ -589,6 +561,37 @@ bool V4L2SliceVideoDecodeAccelerator::Initialize(const Config& config,
DVLOGF(1) << "No GL callbacks provided, initializing without GL support";
}
+ video_profile_ = config.profile;
+
+ // TODO(posciak): This needs to be queried once supported.
+ input_planes_count_ = 1;
+ output_planes_count_ = 1;
+
+ input_format_fourcc_ =
+ V4L2Device::VideoCodecProfileToV4L2PixFmt(video_profile_, true);
+
+ if (!device_->Open(V4L2Device::Type::kDecoder, input_format_fourcc_)) {
+ DVLOGF(1) << "Failed to open device for profile: " << config.profile
+ << " fourcc: " << std::hex << input_format_fourcc_;
kcwu 2016/10/07 11:19:05 0x
Pawel Osciak 2016/10/11 06:13:46 Done.
+ return false;
+ }
+
+ if (video_profile_ >= H264PROFILE_MIN && video_profile_ <= H264PROFILE_MAX) {
+ h264_accelerator_.reset(new V4L2H264Accelerator(this));
+ decoder_.reset(new H264Decoder(h264_accelerator_.get()));
+ } else if (video_profile_ >= VP8PROFILE_MIN &&
+ video_profile_ <= VP8PROFILE_MAX) {
+ vp8_accelerator_.reset(new V4L2VP8Accelerator(this));
+ decoder_.reset(new VP8Decoder(vp8_accelerator_.get()));
+ } else if (video_profile_ >= VP9PROFILE_MIN &&
+ video_profile_ <= VP9PROFILE_MAX) {
+ vp9_accelerator_.reset(new V4L2VP9Accelerator(this));
+ decoder_.reset(new VP9Decoder(vp9_accelerator_.get()));
+ } else {
+ NOTREACHED() << "Unsupported profile " << video_profile_;
+ return false;
+ }
+
// Capabilities check.
struct v4l2_capability caps;
const __u32 kCapsRequired = V4L2_CAP_VIDEO_M2M_MPLANE | V4L2_CAP_STREAMING;
@@ -676,16 +679,9 @@ void V4L2SliceVideoDecodeAccelerator::DestroyTask() {
bool V4L2SliceVideoDecodeAccelerator::SetupFormats() {
DCHECK_EQ(state_, kUninitialized);
- __u32 input_format_fourcc =
- V4L2Device::VideoCodecProfileToV4L2PixFmt(video_profile_, true);
- if (!input_format_fourcc) {
- NOTREACHED();
- return false;
- }
-
size_t input_size;
gfx::Size max_resolution, min_resolution;
- device_->GetSupportedResolution(input_format_fourcc, &min_resolution,
+ device_->GetSupportedResolution(input_format_fourcc_, &min_resolution,
&max_resolution);
if (max_resolution.width() > 1920 && max_resolution.height() > 1088)
input_size = kInputBufferMaxSizeFor4k;
@@ -697,7 +693,7 @@ bool V4L2SliceVideoDecodeAccelerator::SetupFormats() {
fmtdesc.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE;
bool is_format_supported = false;
while (device_->Ioctl(VIDIOC_ENUM_FMT, &fmtdesc) == 0) {
- if (fmtdesc.pixelformat == input_format_fourcc) {
+ if (fmtdesc.pixelformat == input_format_fourcc_) {
is_format_supported = true;
break;
}
@@ -705,7 +701,7 @@ bool V4L2SliceVideoDecodeAccelerator::SetupFormats() {
}
if (!is_format_supported) {
- DVLOGF(1) << "Input fourcc " << input_format_fourcc
+ DVLOGF(1) << "Input fourcc " << input_format_fourcc_
<< " not supported by device.";
return false;
}
@@ -713,7 +709,7 @@ bool V4L2SliceVideoDecodeAccelerator::SetupFormats() {
struct v4l2_format format;
memset(&format, 0, sizeof(format));
format.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE;
- format.fmt.pix_mp.pixelformat = input_format_fourcc;
+ format.fmt.pix_mp.pixelformat = input_format_fourcc_;
format.fmt.pix_mp.plane_fmt[0].sizeimage = input_size;
format.fmt.pix_mp.num_planes = input_planes_count_;
IOCTL_OR_ERROR_RETURN_FALSE(VIDIOC_S_FMT, &format);
@@ -869,6 +865,9 @@ void V4L2SliceVideoDecodeAccelerator::DestroyInputBuffers() {
!decoder_thread_.IsRunning());
DCHECK(!input_streamon_);
+ if (input_buffer_map_.empty())
+ return;
+
for (auto& input_record : input_buffer_map_) {
if (input_record.address != nullptr)
device_->Munmap(input_record.address, input_record.length);
@@ -3270,7 +3269,7 @@ bool V4L2SliceVideoDecodeAccelerator::TryToSetupDecodeOnSeparateThread(
// static
VideoDecodeAccelerator::SupportedProfiles
V4L2SliceVideoDecodeAccelerator::GetSupportedProfiles() {
- scoped_refptr<V4L2Device> device = V4L2Device::Create(V4L2Device::kDecoder);
+ scoped_refptr<V4L2Device> device = V4L2Device::Create();
if (!device)
return SupportedProfiles();

Powered by Google App Engine
This is Rietveld 408576698