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

Unified Diff: media/gpu/v4l2_jpeg_decode_accelerator.cc

Issue 2559423002: media/gpu: switch v4l2_jpeg_decode_accelerator to use multi-planar APIs (Closed)
Patch Set: let's see if I get the number of patches to upload right this time... Created 4 years 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_jpeg_decode_accelerator.cc
diff --git a/media/gpu/v4l2_jpeg_decode_accelerator.cc b/media/gpu/v4l2_jpeg_decode_accelerator.cc
index ab39a53fdbca2ecfa36ba42311435164a6a9f458..3a6e11f464f714051b259a104e18fe92bbe3fc52 100644
--- a/media/gpu/v4l2_jpeg_decode_accelerator.cc
+++ b/media/gpu/v4l2_jpeg_decode_accelerator.cc
@@ -108,7 +108,10 @@ const uint8_t kDefaultDhtSeg[] = {
0xE8, 0xE9, 0xEA, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, 0xF8, 0xF9, 0xFA};
V4L2JpegDecodeAccelerator::BufferRecord::BufferRecord()
- : address(nullptr), length(0), at_device(false) {}
+ : num_planes(0), at_device(false) {
+ memset(address, 0, sizeof(address));
+ memset(length, 0, sizeof(length));
+}
V4L2JpegDecodeAccelerator::BufferRecord::~BufferRecord() {}
@@ -194,13 +197,21 @@ bool V4L2JpegDecodeAccelerator::Initialize(Client* client) {
// Capabilities check.
struct v4l2_capability caps;
- const __u32 kCapsRequired = V4L2_CAP_STREAMING | V4L2_CAP_VIDEO_M2M;
+ const __u32 kCapsRequiredMplane =
+ V4L2_CAP_STREAMING | V4L2_CAP_VIDEO_M2M_MPLANE;
+ const __u32 kCapsRequiredSplane = V4L2_CAP_STREAMING | V4L2_CAP_VIDEO_M2M;
memset(&caps, 0, sizeof(caps));
if (device_->Ioctl(VIDIOC_QUERYCAP, &caps) != 0) {
PLOG(ERROR) << __func__ << ": ioctl() failed: VIDIOC_QUERYCAP";
return false;
}
- if ((caps.capabilities & kCapsRequired) != kCapsRequired) {
+ if ((caps.capabilities & kCapsRequiredMplane) == kCapsRequiredMplane) {
+ input_buf_type_ = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE;
+ output_buf_type_ = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE;
+ } else if ((caps.capabilities & kCapsRequiredSplane) == kCapsRequiredSplane) {
+ input_buf_type_ = V4L2_BUF_TYPE_VIDEO_OUTPUT;
+ output_buf_type_ = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+ } else {
LOG(ERROR) << __func__ << ": VIDIOC_QUERYCAP, caps check failed: 0x"
<< std::hex << caps.capabilities;
return false;
@@ -297,7 +308,7 @@ bool V4L2JpegDecodeAccelerator::ShouldRecreateInputBuffers() {
// Check input buffer size is enough
return (input_buffer_map_.empty() ||
(job_record->shm.size() + sizeof(kDefaultDhtSeg)) >
- input_buffer_map_.front().length);
+ input_buffer_map_.front().length[0]);
}
bool V4L2JpegDecodeAccelerator::RecreateInputBuffers() {
@@ -344,16 +355,22 @@ bool V4L2JpegDecodeAccelerator::CreateInputBuffers() {
size_t reserve_size = (job_record->shm.size() + sizeof(kDefaultDhtSeg)) * 2;
struct v4l2_format format;
memset(&format, 0, sizeof(format));
- format.type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
- format.fmt.pix.pixelformat = V4L2_PIX_FMT_JPEG;
- format.fmt.pix.sizeimage = reserve_size;
- format.fmt.pix.field = V4L2_FIELD_ANY;
+ format.type = input_buf_type_;
+ if (V4L2_TYPE_IS_MULTIPLANAR(input_buf_type_)) {
+ format.fmt.pix_mp.pixelformat = V4L2_PIX_FMT_JPEG;
+ format.fmt.pix_mp.plane_fmt[0].sizeimage = reserve_size;
+ format.fmt.pix_mp.field = V4L2_FIELD_ANY;
wuchengli 2016/12/16 03:15:15 format.fmt.pix_mp.num_planes = kInputPlanes;
jcliang 2016/12/16 04:19:53 Done.
+ } else {
+ format.fmt.pix.pixelformat = V4L2_PIX_FMT_JPEG;
+ format.fmt.pix.sizeimage = reserve_size;
+ format.fmt.pix.field = V4L2_FIELD_ANY;
+ }
IOCTL_OR_ERROR_RETURN_FALSE(VIDIOC_S_FMT, &format);
struct v4l2_requestbuffers reqbufs;
memset(&reqbufs, 0, sizeof(reqbufs));
reqbufs.count = kBufferCount;
- reqbufs.type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
+ reqbufs.type = input_buf_type_;
reqbufs.memory = V4L2_MEMORY_MMAP;
IOCTL_OR_ERROR_RETURN_FALSE(VIDIOC_REQBUFS, &reqbufs);
@@ -364,20 +381,35 @@ bool V4L2JpegDecodeAccelerator::CreateInputBuffers() {
free_input_buffers_.push_back(i);
struct v4l2_buffer buffer;
+ struct v4l2_plane plane;
memset(&buffer, 0, sizeof(buffer));
+ memset(&plane, 0, sizeof(plane));
buffer.index = i;
- buffer.type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
+ buffer.type = input_buf_type_;
+ if (V4L2_TYPE_IS_MULTIPLANAR(input_buf_type_)) {
+ buffer.m.planes = &plane;
+ buffer.length = kInputPlanes;
+ }
buffer.memory = V4L2_MEMORY_MMAP;
IOCTL_OR_ERROR_RETURN_FALSE(VIDIOC_QUERYBUF, &buffer);
- void* address = device_->Mmap(NULL, buffer.length, PROT_READ | PROT_WRITE,
- MAP_SHARED, buffer.m.offset);
+ input_buffer_map_[i].num_planes = kInputPlanes;
+ uint32_t length, offset;
+ if (V4L2_TYPE_IS_MULTIPLANAR(input_buf_type_)) {
+ length = plane.length;
+ offset = plane.m.mem_offset;
+ } else {
+ length = buffer.length;
+ offset = buffer.m.offset;
+ }
+ void* address =
+ device_->Mmap(NULL, length, PROT_READ | PROT_WRITE, MAP_SHARED, offset);
if (address == MAP_FAILED) {
PLOG(ERROR) << __func__ << ": mmap() failed";
PostNotifyError(kInvalidBitstreamBufferId, PLATFORM_FAILURE);
return false;
}
- input_buffer_map_[i].address = address;
- input_buffer_map_[i].length = buffer.length;
+ input_buffer_map_[i].address[0] = address;
+ input_buffer_map_[i].length[0] = length;
}
return true;
@@ -394,21 +426,36 @@ bool V4L2JpegDecodeAccelerator::CreateOutputBuffers() {
PIXEL_FORMAT_I420, job_record->out_frame->coded_size());
struct v4l2_format format;
memset(&format, 0, sizeof(format));
- format.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
- format.fmt.pix.width = job_record->out_frame->coded_size().width();
- format.fmt.pix.height = job_record->out_frame->coded_size().height();
- format.fmt.pix.sizeimage = frame_size;
- format.fmt.pix.pixelformat = V4L2_PIX_FMT_YUV420;
- format.fmt.pix.field = V4L2_FIELD_ANY;
+ format.type = output_buf_type_;
+ if (V4L2_TYPE_IS_MULTIPLANAR(output_buf_type_)) {
+ format.fmt.pix_mp.width = job_record->out_frame->coded_size().width();
+ format.fmt.pix_mp.height = job_record->out_frame->coded_size().height();
+ format.fmt.pix_mp.num_planes = 1;
+ format.fmt.pix_mp.pixelformat = V4L2_PIX_FMT_YUV420;
+ format.fmt.pix_mp.plane_fmt[0].sizeimage = frame_size;
+ format.fmt.pix_mp.field = V4L2_FIELD_ANY;
+ } else {
+ format.fmt.pix.width = job_record->out_frame->coded_size().width();
+ format.fmt.pix.height = job_record->out_frame->coded_size().height();
+ format.fmt.pix.pixelformat = V4L2_PIX_FMT_YUV420;
+ format.fmt.pix.sizeimage = frame_size;
+ format.fmt.pix.field = V4L2_FIELD_ANY;
+ }
IOCTL_OR_ERROR_RETURN_FALSE(VIDIOC_S_FMT, &format);
- output_buffer_pixelformat_ = format.fmt.pix.pixelformat;
- output_buffer_coded_size_.SetSize(format.fmt.pix.width,
- format.fmt.pix.height);
+ if (V4L2_TYPE_IS_MULTIPLANAR(output_buf_type_)) {
+ output_buffer_pixelformat_ = format.fmt.pix_mp.pixelformat;
+ output_buffer_coded_size_.SetSize(format.fmt.pix_mp.width,
+ format.fmt.pix_mp.height);
+ } else {
+ output_buffer_pixelformat_ = format.fmt.pix.pixelformat;
+ output_buffer_coded_size_.SetSize(format.fmt.pix.width,
+ format.fmt.pix.height);
+ }
struct v4l2_requestbuffers reqbufs;
memset(&reqbufs, 0, sizeof(reqbufs));
reqbufs.count = kBufferCount;
- reqbufs.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+ reqbufs.type = output_buf_type_;
reqbufs.memory = V4L2_MEMORY_MMAP;
IOCTL_OR_ERROR_RETURN_FALSE(VIDIOC_REQBUFS, &reqbufs);
@@ -422,26 +469,60 @@ bool V4L2JpegDecodeAccelerator::CreateOutputBuffers() {
free_output_buffers_.push_back(i);
struct v4l2_buffer buffer;
+ struct v4l2_plane planes[kOutputPlanes];
memset(&buffer, 0, sizeof(buffer));
+ memset(planes, 0, sizeof(planes));
buffer.index = i;
- buffer.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+ buffer.type = output_buf_type_;
buffer.memory = V4L2_MEMORY_MMAP;
+ if (V4L2_TYPE_IS_MULTIPLANAR(output_buf_type_)) {
+ buffer.m.planes = planes;
+ buffer.length = kOutputPlanes;
wuchengli 2016/12/16 03:15:15 Use format.fmt.pix_mp.num_planes returned from S_F
jcliang 2016/12/16 04:19:53 Done.
+ }
IOCTL_OR_ERROR_RETURN_FALSE(VIDIOC_QUERYBUF, &buffer);
- DCHECK_GE(buffer.length,
- VideoFrame::AllocationSize(
- output_format,
- gfx::Size(format.fmt.pix.width, format.fmt.pix.height)));
+ if (V4L2_TYPE_IS_MULTIPLANAR(output_buf_type_)) {
+ uint32_t total_length = 0;
+ for (uint32_t i = 0; i < kOutputPlanes; ++i) {
wuchengli 2016/12/16 03:15:15 s/kOutputPlanes/buffer.length/
jcliang 2016/12/16 04:19:53 Done.
+ total_length += planes[i].length;
+ }
+ DCHECK_GE(total_length,
+ VideoFrame::AllocationSize(
wuchengli 2016/12/16 03:15:15 Use VideoFrame::PlaneSize to check each plane in t
jcliang 2016/12/16 04:19:53 Done.
+ output_format, gfx::Size(format.fmt.pix_mp.width,
+ format.fmt.pix_mp.height)));
+ } else {
+ DCHECK_GE(buffer.length,
+ VideoFrame::AllocationSize(
+ output_format,
+ gfx::Size(format.fmt.pix.width, format.fmt.pix.height)));
+ }
- void* address = device_->Mmap(NULL, buffer.length, PROT_READ | PROT_WRITE,
- MAP_SHARED, buffer.m.offset);
- if (address == MAP_FAILED) {
- PLOG(ERROR) << __func__ << ": mmap() failed";
- PostNotifyError(kInvalidBitstreamBufferId, PLATFORM_FAILURE);
- return false;
+ if (V4L2_TYPE_IS_MULTIPLANAR(output_buf_type_)) {
wuchengli 2016/12/16 03:15:15 if and else clauses can be combined. if (V4L2_TYP
jcliang 2016/12/16 04:19:53 We can't do this because the fields in |buffer| th
wuchengli 2016/12/16 06:50:32 You are right.
+ output_buffer_map_[i].num_planes = buffer.length;
+ for (size_t j = 0; j < buffer.length; ++j) {
+ void* address =
+ device_->Mmap(NULL, planes[j].length, PROT_READ | PROT_WRITE,
+ MAP_SHARED, planes[j].m.mem_offset);
+ if (address == MAP_FAILED) {
+ PLOG(ERROR) << __func__ << ": mmap() failed";
+ PostNotifyError(kInvalidBitstreamBufferId, PLATFORM_FAILURE);
+ return false;
+ }
+ output_buffer_map_[i].address[j] = address;
+ output_buffer_map_[i].length[j] = planes[j].length;
+ }
+ } else {
+ output_buffer_map_[i].num_planes = 1;
+ void* address = device_->Mmap(NULL, buffer.length, PROT_READ | PROT_WRITE,
+ MAP_SHARED, buffer.m.offset);
+ if (address == MAP_FAILED) {
+ PLOG(ERROR) << __func__ << ": mmap() failed";
+ PostNotifyError(kInvalidBitstreamBufferId, PLATFORM_FAILURE);
+ return false;
+ }
+ output_buffer_map_[i].address[0] = address;
+ output_buffer_map_[i].length[0] = buffer.length;
}
- output_buffer_map_[i].address = address;
- output_buffer_map_[i].length = buffer.length;
}
return true;
@@ -456,20 +537,20 @@ void V4L2JpegDecodeAccelerator::DestroyInputBuffers() {
return;
if (input_streamon_) {
- __u32 type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
+ __u32 type = input_buf_type_;
IOCTL_OR_ERROR_RETURN(VIDIOC_STREAMOFF, &type);
input_streamon_ = false;
}
for (size_t i = 0; i < input_buffer_map_.size(); ++i) {
BufferRecord& input_record = input_buffer_map_[i];
- device_->Munmap(input_record.address, input_record.length);
+ device_->Munmap(input_record.address[0], input_record.length[0]);
}
struct v4l2_requestbuffers reqbufs;
memset(&reqbufs, 0, sizeof(reqbufs));
reqbufs.count = 0;
- reqbufs.type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
+ reqbufs.type = input_buf_type_;
reqbufs.memory = V4L2_MEMORY_MMAP;
IOCTL_OR_LOG_ERROR(VIDIOC_REQBUFS, &reqbufs);
@@ -485,20 +566,21 @@ void V4L2JpegDecodeAccelerator::DestroyOutputBuffers() {
return;
if (output_streamon_) {
- __u32 type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+ __u32 type = output_buf_type_;
IOCTL_OR_ERROR_RETURN(VIDIOC_STREAMOFF, &type);
output_streamon_ = false;
}
- for (size_t i = 0; i < output_buffer_map_.size(); ++i) {
- BufferRecord& output_record = output_buffer_map_[i];
- device_->Munmap(output_record.address, output_record.length);
+ for (const auto& output_record : output_buffer_map_) {
+ for (size_t i = 0; i < output_record.num_planes; ++i) {
+ device_->Munmap(output_record.address[i], output_record.length[i]);
+ }
}
struct v4l2_requestbuffers reqbufs;
memset(&reqbufs, 0, sizeof(reqbufs));
reqbufs.count = 0;
- reqbufs.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+ reqbufs.type = output_buf_type_;
reqbufs.memory = V4L2_MEMORY_MMAP;
IOCTL_OR_LOG_ERROR(VIDIOC_REQBUFS, &reqbufs);
@@ -597,7 +679,7 @@ void V4L2JpegDecodeAccelerator::EnqueueInput() {
// Check here because we cannot STREAMON before QBUF in earlier kernel.
// (kernel version < 3.14)
if (!input_streamon_ && InputBufferQueuedCount()) {
- __u32 type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
+ __u32 type = input_buf_type_;
IOCTL_OR_ERROR_RETURN(VIDIOC_STREAMON, &type);
input_streamon_ = true;
}
@@ -615,19 +697,17 @@ void V4L2JpegDecodeAccelerator::EnqueueOutput() {
// Check here because we cannot STREAMON before QBUF in earlier kernel.
// (kernel version < 3.14)
if (!output_streamon_ && OutputBufferQueuedCount()) {
- __u32 type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+ __u32 type = output_buf_type_;
IOCTL_OR_ERROR_RETURN(VIDIOC_STREAMON, &type);
output_streamon_ = true;
}
}
-static bool CopyOutputImage(const uint32_t src_pixelformat,
- const void* src_addr,
- const gfx::Size& src_coded_size,
- const scoped_refptr<VideoFrame>& dst_frame) {
- VideoPixelFormat format =
- V4L2Device::V4L2PixFmtToVideoPixelFormat(src_pixelformat);
- size_t src_size = VideoFrame::AllocationSize(format, src_coded_size);
+bool V4L2JpegDecodeAccelerator::ConvertOutputImage(
+ const uint32_t src_pixelformat,
+ const BufferRecord& src_buffer,
+ const gfx::Size& src_coded_size,
+ const scoped_refptr<VideoFrame>& dst_frame) {
uint8_t* dst_y = dst_frame->data(VideoFrame::kYPlane);
uint8_t* dst_u = dst_frame->data(VideoFrame::kUPlane);
uint8_t* dst_v = dst_frame->data(VideoFrame::kVPlane);
@@ -635,20 +715,50 @@ static bool CopyOutputImage(const uint32_t src_pixelformat,
size_t dst_u_stride = dst_frame->stride(VideoFrame::kUPlane);
size_t dst_v_stride = dst_frame->stride(VideoFrame::kVPlane);
- // If the source format is I420, ConvertToI420 will simply copy the frame.
- if (libyuv::ConvertToI420(static_cast<uint8_t*>(const_cast<void*>(src_addr)),
- src_size,
- dst_y, dst_y_stride,
- dst_u, dst_u_stride,
- dst_v, dst_v_stride,
- 0, 0,
- src_coded_size.width(),
- src_coded_size.height(),
- dst_frame->coded_size().width(),
- dst_frame->coded_size().height(),
- libyuv::kRotate0,
- src_pixelformat)) {
- LOG(ERROR) << "ConvertToI420 failed. Source format: " << src_pixelformat;
+ if (src_buffer.num_planes == 1) {
+ // Use ConvertToI420 to convert all splane buffers.
+ // If the source format is I420, ConvertToI420 will simply copy the frame.
+ VideoPixelFormat format =
+ V4L2Device::V4L2PixFmtToVideoPixelFormat(src_pixelformat);
+ size_t src_size = VideoFrame::AllocationSize(format, src_coded_size);
+ if (libyuv::ConvertToI420(
+ static_cast<uint8_t*>(src_buffer.address[0]), src_size, dst_y,
+ dst_y_stride, dst_u, dst_u_stride, dst_v, dst_v_stride, 0, 0,
+ src_coded_size.width(), src_coded_size.height(),
+ dst_frame->coded_size().width(), dst_frame->coded_size().height(),
+ libyuv::kRotate0, src_pixelformat)) {
+ LOG(ERROR) << "ConvertToI420 failed. Source format: " << src_pixelformat;
+ return false;
+ }
+ } else if (src_pixelformat == V4L2_PIX_FMT_YUV420M ||
+ src_pixelformat == V4L2_PIX_FMT_YUV422M) {
+ uint8_t* src_y = static_cast<uint8_t*>(src_buffer.address[0]);
+ uint8_t* src_u = static_cast<uint8_t*>(src_buffer.address[1]);
+ uint8_t* src_v = static_cast<uint8_t*>(src_buffer.address[2]);
+ size_t src_y_stride = output_buffer_coded_size_.width();
+ size_t src_u_stride = output_buffer_coded_size_.width() / 2;
+ size_t src_v_stride = output_buffer_coded_size_.width() / 2;
+ if (output_buffer_pixelformat_ == V4L2_PIX_FMT_YUV420M) {
+ if (libyuv::I420Copy(src_y, src_y_stride, src_u, src_u_stride, src_v,
+ src_v_stride, dst_y, dst_y_stride, dst_u,
+ dst_u_stride, dst_v, dst_v_stride,
+ output_buffer_coded_size_.width(),
+ output_buffer_coded_size_.height())) {
+ LOG(ERROR) << "I420Copy failed";
+ return false;
+ }
+ } else { // output_buffer_pixelformat_ == V4L2_PIX_FMT_YUV422M
+ if (libyuv::I422ToI420(src_y, src_y_stride, src_u, src_u_stride, src_v,
+ src_v_stride, dst_y, dst_y_stride, dst_u,
+ dst_u_stride, dst_v, dst_v_stride,
+ output_buffer_coded_size_.width(),
+ output_buffer_coded_size_.height())) {
+ LOG(ERROR) << "I422ToI420 failed";
+ return false;
+ }
+ }
+ } else {
+ LOG(ERROR) << "Unsupported source buffer format: " << src_pixelformat;
return false;
}
return true;
@@ -660,11 +770,17 @@ void V4L2JpegDecodeAccelerator::Dequeue() {
// Dequeue completed input (VIDEO_OUTPUT) buffers,
// and recycle to the free list.
struct v4l2_buffer dqbuf;
+ struct v4l2_plane input_plane;
henryhsu 2016/12/16 03:05:27 use input_planes[kInputPlanes]; We don't know the
jcliang 2016/12/16 04:19:53 Done.
while (InputBufferQueuedCount() > 0) {
DCHECK(input_streamon_);
memset(&dqbuf, 0, sizeof(dqbuf));
- dqbuf.type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
+ memset(&input_plane, 0, sizeof(input_plane));
+ dqbuf.type = input_buf_type_;
dqbuf.memory = V4L2_MEMORY_MMAP;
+ if (V4L2_TYPE_IS_MULTIPLANAR(input_buf_type_)) {
+ dqbuf.length = kInputPlanes;
+ dqbuf.m.planes = &input_plane;
+ }
if (device_->Ioctl(VIDIOC_DQBUF, &dqbuf) != 0) {
if (errno == EAGAIN) {
// EAGAIN if we're just out of buffers to dequeue.
@@ -691,14 +807,20 @@ void V4L2JpegDecodeAccelerator::Dequeue() {
// If dequeued input buffer has an error, the error frame has removed from
// |running_jobs_|. We only have to dequeue output buffer when we actually
// have pending frames in |running_jobs_| and also enqueued output buffers.
+ struct v4l2_plane output_planes[kOutputPlanes];
while (!running_jobs_.empty() && OutputBufferQueuedCount() > 0) {
DCHECK(output_streamon_);
memset(&dqbuf, 0, sizeof(dqbuf));
- dqbuf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+ memset(output_planes, 0, sizeof(output_planes));
+ dqbuf.type = output_buf_type_;
// From experiments, using MMAP and memory copy is still faster than
// USERPTR. Also, client doesn't need to consider the buffer alignment and
// JpegDecodeAccelerator API will be simpler.
dqbuf.memory = V4L2_MEMORY_MMAP;
+ if (V4L2_TYPE_IS_MULTIPLANAR(output_buf_type_)) {
+ dqbuf.length = kOutputPlanes;
wuchengli 2016/12/16 03:15:15 I realized the number of planes could be 1 in mpla
jcliang 2016/12/16 04:19:53 I believe this works as long as kOutputPlanes >= k
wuchengli 2016/12/16 06:50:32 I see. Then we need to add a variable to store the
jcliang 2016/12/17 15:35:56 Done.
+ dqbuf.m.planes = output_planes;
+ }
if (device_->Ioctl(VIDIOC_DQBUF, &dqbuf) != 0) {
if (errno == EAGAIN) {
// EAGAIN if we're just out of buffers to dequeue.
@@ -724,12 +846,12 @@ void V4L2JpegDecodeAccelerator::Dequeue() {
// Copy the decoded data from output buffer to the buffer provided by the
// client. Do format conversion when output format is not
// V4L2_PIX_FMT_YUV420.
- if (!CopyOutputImage(output_buffer_pixelformat_, output_record.address,
- output_buffer_coded_size_, job_record->out_frame)) {
+ if (!ConvertOutputImage(output_buffer_pixelformat_, output_record,
+ output_buffer_coded_size_,
+ job_record->out_frame)) {
PostNotifyError(job_record->bitstream_buffer_id, PLATFORM_FAILURE);
return;
}
-
DVLOG(3) << "Decoding finished, returning bitstream buffer, id="
<< job_record->bitstream_buffer_id;
@@ -834,16 +956,23 @@ bool V4L2JpegDecodeAccelerator::EnqueueInputRecord() {
// It will add default huffman segment if it's missing.
if (!AddHuffmanTable(job_record->shm.memory(), job_record->shm.size(),
- input_record.address, input_record.length)) {
+ input_record.address[0], input_record.length[0])) {
PostNotifyError(job_record->bitstream_buffer_id, PARSE_JPEG_FAILED);
return false;
}
struct v4l2_buffer qbuf;
+ struct v4l2_plane plane;
memset(&qbuf, 0, sizeof(qbuf));
+ memset(&plane, 0, sizeof(plane));
qbuf.index = index;
- qbuf.type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
+ qbuf.type = input_buf_type_;
qbuf.memory = V4L2_MEMORY_MMAP;
+ if (V4L2_TYPE_IS_MULTIPLANAR(input_buf_type_)) {
+ qbuf.length = 1;
+ plane.bytesused = input_record.length[0];
+ qbuf.m.planes = &plane;
+ }
wuchengli 2016/12/16 03:15:15 let's also set bytesused for splane. } else { qb
jcliang 2016/12/16 04:19:53 Done.
IOCTL_OR_ERROR_RETURN_FALSE(VIDIOC_QBUF, &qbuf);
input_record.at_device = true;
running_jobs_.push(job_record);
@@ -863,10 +992,16 @@ bool V4L2JpegDecodeAccelerator::EnqueueOutputRecord() {
BufferRecord& output_record = output_buffer_map_[index];
DCHECK(!output_record.at_device);
struct v4l2_buffer qbuf;
+ struct v4l2_plane planes[kOutputPlanes];
memset(&qbuf, 0, sizeof(qbuf));
+ memset(&planes, 0, sizeof(planes));
qbuf.index = index;
- qbuf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+ qbuf.type = output_buf_type_;
qbuf.memory = V4L2_MEMORY_MMAP;
+ if (V4L2_TYPE_IS_MULTIPLANAR(output_buf_type_)) {
+ qbuf.length = output_record.num_planes;
+ qbuf.m.planes = planes;
+ }
IOCTL_OR_ERROR_RETURN_FALSE(VIDIOC_QBUF, &qbuf);
output_record.at_device = true;
free_output_buffers_.pop_back();
« media/gpu/v4l2_jpeg_decode_accelerator.h ('K') | « media/gpu/v4l2_jpeg_decode_accelerator.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698