| Index: media/gpu/v4l2_slice_video_decode_accelerator.cc
|
| diff --git a/content/common/gpu/media/v4l2_slice_video_decode_accelerator.cc b/media/gpu/v4l2_slice_video_decode_accelerator.cc
|
| similarity index 96%
|
| rename from content/common/gpu/media/v4l2_slice_video_decode_accelerator.cc
|
| rename to media/gpu/v4l2_slice_video_decode_accelerator.cc
|
| index 80c570b861bc879980630fa54d27b3ffb037d8df..1b4cce7b48ce7ff45f58c41109a2c508bd619dd6 100644
|
| --- a/content/common/gpu/media/v4l2_slice_video_decode_accelerator.cc
|
| +++ b/media/gpu/v4l2_slice_video_decode_accelerator.cc
|
| @@ -2,7 +2,7 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| -#include "content/common/gpu/media/v4l2_slice_video_decode_accelerator.h"
|
| +#include "media/gpu/v4l2_slice_video_decode_accelerator.h"
|
|
|
| #include <errno.h>
|
| #include <fcntl.h>
|
| @@ -24,9 +24,9 @@
|
| #include "base/memory/ptr_util.h"
|
| #include "base/numerics/safe_conversions.h"
|
| #include "base/strings/stringprintf.h"
|
| -#include "content/common/gpu/media/shared_memory_region.h"
|
| #include "media/base/bind_to_current_loop.h"
|
| #include "media/base/media_switches.h"
|
| +#include "media/gpu/shared_memory_region.h"
|
| #include "ui/gl/gl_context.h"
|
| #include "ui/gl/scoped_binders.h"
|
|
|
| @@ -39,12 +39,12 @@
|
| SetErrorState(x); \
|
| } while (0)
|
|
|
| -#define IOCTL_OR_ERROR_RETURN_VALUE(type, arg, value, type_str) \
|
| - do { \
|
| - if (device_->Ioctl(type, arg) != 0) { \
|
| - PLOG(ERROR) << __FUNCTION__ << "(): ioctl() failed: " << type_str; \
|
| - return value; \
|
| - } \
|
| +#define IOCTL_OR_ERROR_RETURN_VALUE(type, arg, value, type_str) \
|
| + do { \
|
| + if (device_->Ioctl(type, arg) != 0) { \
|
| + PLOG(ERROR) << __FUNCTION__ << "(): ioctl() failed: " << type_str; \
|
| + return value; \
|
| + } \
|
| } while (0)
|
|
|
| #define IOCTL_OR_ERROR_RETURN(type, arg) \
|
| @@ -59,7 +59,7 @@
|
| PLOG(ERROR) << __FUNCTION__ << "(): ioctl() failed: " << #type; \
|
| } while (0)
|
|
|
| -namespace content {
|
| +namespace media {
|
|
|
| // static
|
| const uint32_t V4L2SliceVideoDecodeAccelerator::supported_input_fourccs_[] = {
|
| @@ -159,8 +159,7 @@ V4L2SliceVideoDecodeAccelerator::InputRecord::InputRecord()
|
| address(nullptr),
|
| length(0),
|
| bytes_used(0),
|
| - at_device(false) {
|
| -}
|
| + at_device(false) {}
|
|
|
| V4L2SliceVideoDecodeAccelerator::OutputRecord::OutputRecord()
|
| : at_device(false),
|
| @@ -216,8 +215,7 @@ struct V4L2SliceVideoDecodeAccelerator::EGLSyncKHRRef {
|
| V4L2SliceVideoDecodeAccelerator::EGLSyncKHRRef::EGLSyncKHRRef(
|
| EGLDisplay egl_display,
|
| EGLSyncKHR egl_sync)
|
| - : egl_display(egl_display), egl_sync(egl_sync) {
|
| -}
|
| + : egl_display(egl_display), egl_sync(egl_sync) {}
|
|
|
| V4L2SliceVideoDecodeAccelerator::EGLSyncKHRRef::~EGLSyncKHRRef() {
|
| // We don't check for eglDestroySyncKHR failures, because if we get here
|
| @@ -237,11 +235,9 @@ struct V4L2SliceVideoDecodeAccelerator::PictureRecord {
|
| V4L2SliceVideoDecodeAccelerator::PictureRecord::PictureRecord(
|
| bool cleared,
|
| const media::Picture& picture)
|
| - : cleared(cleared), picture(picture) {
|
| -}
|
| + : cleared(cleared), picture(picture) {}
|
|
|
| -V4L2SliceVideoDecodeAccelerator::PictureRecord::~PictureRecord() {
|
| -}
|
| +V4L2SliceVideoDecodeAccelerator::PictureRecord::~PictureRecord() {}
|
|
|
| class V4L2SliceVideoDecodeAccelerator::V4L2H264Accelerator
|
| : public H264Decoder::H264Accelerator {
|
| @@ -327,8 +323,9 @@ class V4L2SliceVideoDecodeAccelerator::V4L2VP8Accelerator
|
| // This allows us to keep decoders oblivious of our implementation details.
|
| class V4L2H264Picture : public H264Picture {
|
| public:
|
| - V4L2H264Picture(const scoped_refptr<
|
| - V4L2SliceVideoDecodeAccelerator::V4L2DecodeSurface>& dec_surface);
|
| + V4L2H264Picture(
|
| + const scoped_refptr<V4L2SliceVideoDecodeAccelerator::V4L2DecodeSurface>&
|
| + dec_surface);
|
|
|
| V4L2H264Picture* AsV4L2H264Picture() override { return this; }
|
| scoped_refptr<V4L2SliceVideoDecodeAccelerator::V4L2DecodeSurface>
|
| @@ -345,18 +342,18 @@ class V4L2H264Picture : public H264Picture {
|
| DISALLOW_COPY_AND_ASSIGN(V4L2H264Picture);
|
| };
|
|
|
| -V4L2H264Picture::V4L2H264Picture(const scoped_refptr<
|
| - V4L2SliceVideoDecodeAccelerator::V4L2DecodeSurface>& dec_surface)
|
| - : dec_surface_(dec_surface) {
|
| -}
|
| +V4L2H264Picture::V4L2H264Picture(
|
| + const scoped_refptr<V4L2SliceVideoDecodeAccelerator::V4L2DecodeSurface>&
|
| + dec_surface)
|
| + : dec_surface_(dec_surface) {}
|
|
|
| -V4L2H264Picture::~V4L2H264Picture() {
|
| -}
|
| +V4L2H264Picture::~V4L2H264Picture() {}
|
|
|
| class V4L2VP8Picture : public VP8Picture {
|
| public:
|
| - V4L2VP8Picture(const scoped_refptr<
|
| - V4L2SliceVideoDecodeAccelerator::V4L2DecodeSurface>& dec_surface);
|
| + V4L2VP8Picture(
|
| + const scoped_refptr<V4L2SliceVideoDecodeAccelerator::V4L2DecodeSurface>&
|
| + dec_surface);
|
|
|
| V4L2VP8Picture* AsV4L2VP8Picture() override { return this; }
|
| scoped_refptr<V4L2SliceVideoDecodeAccelerator::V4L2DecodeSurface>
|
| @@ -373,13 +370,12 @@ class V4L2VP8Picture : public VP8Picture {
|
| DISALLOW_COPY_AND_ASSIGN(V4L2VP8Picture);
|
| };
|
|
|
| -V4L2VP8Picture::V4L2VP8Picture(const scoped_refptr<
|
| - V4L2SliceVideoDecodeAccelerator::V4L2DecodeSurface>& dec_surface)
|
| - : dec_surface_(dec_surface) {
|
| -}
|
| +V4L2VP8Picture::V4L2VP8Picture(
|
| + const scoped_refptr<V4L2SliceVideoDecodeAccelerator::V4L2DecodeSurface>&
|
| + dec_surface)
|
| + : dec_surface_(dec_surface) {}
|
|
|
| -V4L2VP8Picture::~V4L2VP8Picture() {
|
| -}
|
| +V4L2VP8Picture::~V4L2VP8Picture() {}
|
|
|
| V4L2SliceVideoDecodeAccelerator::V4L2SliceVideoDecodeAccelerator(
|
| const scoped_refptr<V4L2Device>& device,
|
| @@ -517,7 +513,8 @@ bool V4L2SliceVideoDecodeAccelerator::Initialize(const Config& config,
|
| IOCTL_OR_ERROR_RETURN_FALSE(VIDIOC_QUERYCAP, &caps);
|
| if ((caps.capabilities & kCapsRequired) != kCapsRequired) {
|
| LOG(ERROR) << "Initialize(): ioctl() failed: VIDIOC_QUERYCAP"
|
| - ", caps check failed: 0x" << std::hex << caps.capabilities;
|
| + ", caps check failed: 0x"
|
| + << std::hex << caps.capabilities;
|
| return false;
|
| }
|
|
|
| @@ -701,10 +698,8 @@ bool V4L2SliceVideoDecodeAccelerator::CreateInputBuffers() {
|
| buffer.m.planes = planes;
|
| buffer.length = input_planes_count_;
|
| IOCTL_OR_ERROR_RETURN_FALSE(VIDIOC_QUERYBUF, &buffer);
|
| - void* address = device_->Mmap(nullptr,
|
| - buffer.m.planes[0].length,
|
| - PROT_READ | PROT_WRITE,
|
| - MAP_SHARED,
|
| + void* address = device_->Mmap(nullptr, buffer.m.planes[0].length,
|
| + PROT_READ | PROT_WRITE, MAP_SHARED,
|
| buffer.m.planes[0].m.mem_offset);
|
| if (address == MAP_FAILED) {
|
| PLOG(ERROR) << "CreateInputBuffers(): mmap() failed";
|
| @@ -863,13 +858,11 @@ void V4L2SliceVideoDecodeAccelerator::SchedulePollIfNeeded() {
|
|
|
| DVLOGF(2) << "buffer counts: "
|
| << "INPUT[" << decoder_input_queue_.size() << "]"
|
| - << " => DEVICE["
|
| - << free_input_buffers_.size() << "+"
|
| - << input_buffer_queued_count_ << "/"
|
| - << input_buffer_map_.size() << "]->["
|
| - << free_output_buffers_.size() << "+"
|
| - << output_buffer_queued_count_ << "/"
|
| - << output_buffer_map_.size() << "]"
|
| + << " => DEVICE[" << free_input_buffers_.size() << "+"
|
| + << input_buffer_queued_count_ << "/" << input_buffer_map_.size()
|
| + << "]->[" << free_output_buffers_.size() << "+"
|
| + << output_buffer_queued_count_ << "/" << output_buffer_map_.size()
|
| + << "]"
|
| << " => DISPLAYQ[" << decoder_display_queue_.size() << "]"
|
| << " => CLIENT[" << surfaces_at_display_.size() << "]";
|
| }
|
| @@ -895,8 +888,9 @@ void V4L2SliceVideoDecodeAccelerator::Enqueue(
|
| }
|
|
|
| bool inserted =
|
| - surfaces_at_device_.insert(std::make_pair(dec_surface->output_record(),
|
| - dec_surface)).second;
|
| + surfaces_at_device_
|
| + .insert(std::make_pair(dec_surface->output_record(), dec_surface))
|
| + .second;
|
| DCHECK(inserted);
|
|
|
| if (old_inputs_queued == 0 && old_outputs_queued == 0)
|
| @@ -958,8 +952,8 @@ void V4L2SliceVideoDecodeAccelerator::Dequeue() {
|
| DCHECK(output_record.at_device);
|
| output_record.at_device = false;
|
| output_buffer_queued_count_--;
|
| - DVLOGF(3) << "Dequeued output=" << dqbuf.index
|
| - << " count " << output_buffer_queued_count_;
|
| + DVLOGF(3) << "Dequeued output=" << dqbuf.index << " count "
|
| + << output_buffer_queued_count_;
|
|
|
| V4L2DecodeSurfaceByOutputId::iterator it =
|
| surfaces_at_device_.find(dqbuf.index);
|
| @@ -1032,8 +1026,9 @@ void V4L2SliceVideoDecodeAccelerator::ReuseInputBuffer(int index) {
|
| input_record.input_id = -1;
|
| input_record.bytes_used = 0;
|
|
|
| - DCHECK_EQ(std::count(free_input_buffers_.begin(), free_input_buffers_.end(),
|
| - index), 0);
|
| + DCHECK_EQ(
|
| + std::count(free_input_buffers_.begin(), free_input_buffers_.end(), index),
|
| + 0);
|
| free_input_buffers_.push_back(index);
|
| }
|
|
|
| @@ -1047,7 +1042,8 @@ void V4L2SliceVideoDecodeAccelerator::ReuseOutputBuffer(int index) {
|
| DCHECK(!output_record.at_client);
|
|
|
| DCHECK_EQ(std::count(free_output_buffers_.begin(), free_output_buffers_.end(),
|
| - index), 0);
|
| + index),
|
| + 0);
|
| free_output_buffers_.push_back(index);
|
|
|
| ScheduleDecodeBufferTaskIfNeeded();
|
| @@ -1508,8 +1504,8 @@ void V4L2SliceVideoDecodeAccelerator::AssignPictureBuffersTask(
|
|
|
| if (buffers.size() < req_buffer_count) {
|
| DLOG(ERROR) << "Failed to provide requested picture buffers. "
|
| - << "(Got " << buffers.size()
|
| - << ", requested " << req_buffer_count << ")";
|
| + << "(Got " << buffers.size() << ", requested "
|
| + << req_buffer_count << ")";
|
| NOTIFY_ERROR(INVALID_ARGUMENT);
|
| return;
|
| }
|
| @@ -1996,8 +1992,7 @@ V4L2SliceVideoDecodeAccelerator::V4L2H264Accelerator::V4L2H264Accelerator(
|
| DCHECK(v4l2_dec_);
|
| }
|
|
|
| -V4L2SliceVideoDecodeAccelerator::V4L2H264Accelerator::~V4L2H264Accelerator() {
|
| -}
|
| +V4L2SliceVideoDecodeAccelerator::V4L2H264Accelerator::~V4L2H264Accelerator() {}
|
|
|
| scoped_refptr<H264Picture>
|
| V4L2SliceVideoDecodeAccelerator::V4L2H264Accelerator::CreateH264Picture() {
|
| @@ -2065,12 +2060,19 @@ bool V4L2SliceVideoDecodeAccelerator::V4L2H264Accelerator::SubmitFrameMetadata(
|
| struct v4l2_ctrl_h264_sps v4l2_sps;
|
| memset(&v4l2_sps, 0, sizeof(v4l2_sps));
|
| v4l2_sps.constraint_set_flags =
|
| - sps->constraint_set0_flag ? V4L2_H264_SPS_CONSTRAINT_SET0_FLAG : 0 |
|
| - sps->constraint_set1_flag ? V4L2_H264_SPS_CONSTRAINT_SET1_FLAG : 0 |
|
| - sps->constraint_set2_flag ? V4L2_H264_SPS_CONSTRAINT_SET2_FLAG : 0 |
|
| - sps->constraint_set3_flag ? V4L2_H264_SPS_CONSTRAINT_SET3_FLAG : 0 |
|
| - sps->constraint_set4_flag ? V4L2_H264_SPS_CONSTRAINT_SET4_FLAG : 0 |
|
| - sps->constraint_set5_flag ? V4L2_H264_SPS_CONSTRAINT_SET5_FLAG : 0;
|
| + sps->constraint_set0_flag
|
| + ? V4L2_H264_SPS_CONSTRAINT_SET0_FLAG
|
| + : 0 | sps->constraint_set1_flag
|
| + ? V4L2_H264_SPS_CONSTRAINT_SET1_FLAG
|
| + : 0 | sps->constraint_set2_flag
|
| + ? V4L2_H264_SPS_CONSTRAINT_SET2_FLAG
|
| + : 0 | sps->constraint_set3_flag
|
| + ? V4L2_H264_SPS_CONSTRAINT_SET3_FLAG
|
| + : 0 | sps->constraint_set4_flag
|
| + ? V4L2_H264_SPS_CONSTRAINT_SET4_FLAG
|
| + : 0 | sps->constraint_set5_flag
|
| + ? V4L2_H264_SPS_CONSTRAINT_SET5_FLAG
|
| + : 0;
|
| #define SPS_TO_V4L2SPS(a) v4l2_sps.a = sps->a
|
| SPS_TO_V4L2SPS(profile_idc);
|
| SPS_TO_V4L2SPS(level_idc);
|
| @@ -2086,7 +2088,7 @@ bool V4L2SliceVideoDecodeAccelerator::V4L2H264Accelerator::SubmitFrameMetadata(
|
| SPS_TO_V4L2SPS(num_ref_frames_in_pic_order_cnt_cycle);
|
|
|
| static_assert(arraysize(v4l2_sps.offset_for_ref_frame) ==
|
| - arraysize(sps->offset_for_ref_frame),
|
| + arraysize(sps->offset_for_ref_frame),
|
| "offset_for_ref_frame arrays must be same size");
|
| for (size_t i = 0; i < arraysize(v4l2_sps.offset_for_ref_frame); ++i)
|
| v4l2_sps.offset_for_ref_frame[i] = sps->offset_for_ref_frame[i];
|
| @@ -2160,13 +2162,13 @@ bool V4L2SliceVideoDecodeAccelerator::V4L2H264Accelerator::SubmitFrameMetadata(
|
| struct v4l2_ctrl_h264_scaling_matrix v4l2_scaling_matrix;
|
| memset(&v4l2_scaling_matrix, 0, sizeof(v4l2_scaling_matrix));
|
| static_assert(arraysize(v4l2_scaling_matrix.scaling_list_4x4) <=
|
| - arraysize(pps->scaling_list4x4) &&
|
| - arraysize(v4l2_scaling_matrix.scaling_list_4x4[0]) <=
|
| - arraysize(pps->scaling_list4x4[0]) &&
|
| - arraysize(v4l2_scaling_matrix.scaling_list_8x8) <=
|
| - arraysize(pps->scaling_list8x8) &&
|
| - arraysize(v4l2_scaling_matrix.scaling_list_8x8[0]) <=
|
| - arraysize(pps->scaling_list8x8[0]),
|
| + arraysize(pps->scaling_list4x4) &&
|
| + arraysize(v4l2_scaling_matrix.scaling_list_4x4[0]) <=
|
| + arraysize(pps->scaling_list4x4[0]) &&
|
| + arraysize(v4l2_scaling_matrix.scaling_list_8x8) <=
|
| + arraysize(pps->scaling_list8x8) &&
|
| + arraysize(v4l2_scaling_matrix.scaling_list_8x8[0]) <=
|
| + arraysize(pps->scaling_list8x8[0]),
|
| "scaling_lists must be of correct size");
|
| for (size_t i = 0; i < arraysize(v4l2_scaling_matrix.scaling_list_4x4); ++i) {
|
| for (size_t j = 0; j < arraysize(v4l2_scaling_matrix.scaling_list_4x4[i]);
|
| @@ -2423,8 +2425,7 @@ V4L2SliceVideoDecodeAccelerator::V4L2VP8Accelerator::V4L2VP8Accelerator(
|
| DCHECK(v4l2_dec_);
|
| }
|
|
|
| -V4L2SliceVideoDecodeAccelerator::V4L2VP8Accelerator::~V4L2VP8Accelerator() {
|
| -}
|
| +V4L2SliceVideoDecodeAccelerator::V4L2VP8Accelerator::~V4L2VP8Accelerator() {}
|
|
|
| scoped_refptr<VP8Picture>
|
| V4L2SliceVideoDecodeAccelerator::V4L2VP8Accelerator::CreateVP8Picture() {
|
| @@ -2506,8 +2507,7 @@ static void FillV4L2EntropyHeader(
|
| vp8_entropy_hdr.y_mode_probs);
|
| ARRAY_MEMCPY_CHECKED(v4l2_entropy_hdr->uv_mode_probs,
|
| vp8_entropy_hdr.uv_mode_probs);
|
| - ARRAY_MEMCPY_CHECKED(v4l2_entropy_hdr->mv_probs,
|
| - vp8_entropy_hdr.mv_probs);
|
| + ARRAY_MEMCPY_CHECKED(v4l2_entropy_hdr->mv_probs, vp8_entropy_hdr.mv_probs);
|
| }
|
|
|
| bool V4L2SliceVideoDecodeAccelerator::V4L2VP8Accelerator::SubmitDecode(
|
| @@ -2565,10 +2565,11 @@ bool V4L2SliceVideoDecodeAccelerator::V4L2VP8Accelerator::SubmitDecode(
|
| v4l2_frame_hdr.num_dct_parts = frame_hdr->num_of_dct_partitions;
|
|
|
| static_assert(arraysize(v4l2_frame_hdr.dct_part_sizes) ==
|
| - arraysize(frame_hdr->dct_partition_sizes),
|
| + arraysize(frame_hdr->dct_partition_sizes),
|
| "DCT partition size arrays must have equal number of elements");
|
| for (size_t i = 0; i < frame_hdr->num_of_dct_partitions &&
|
| - i < arraysize(v4l2_frame_hdr.dct_part_sizes); ++i)
|
| + i < arraysize(v4l2_frame_hdr.dct_part_sizes);
|
| + ++i)
|
| v4l2_frame_hdr.dct_part_sizes[i] = frame_hdr->dct_partition_sizes[i];
|
|
|
| scoped_refptr<V4L2DecodeSurface> dec_surface =
|
| @@ -2682,8 +2683,9 @@ void V4L2SliceVideoDecodeAccelerator::OutputSurface(
|
| output_buffer_map_[dec_surface->output_record()];
|
|
|
| bool inserted =
|
| - surfaces_at_display_.insert(std::make_pair(output_record.picture_id,
|
| - dec_surface)).second;
|
| + surfaces_at_display_
|
| + .insert(std::make_pair(output_record.picture_id, dec_surface))
|
| + .second;
|
| DCHECK(inserted);
|
|
|
| DCHECK(!output_record.at_client);
|
| @@ -2809,4 +2811,4 @@ V4L2SliceVideoDecodeAccelerator::GetSupportedProfiles() {
|
| supported_input_fourccs_);
|
| }
|
|
|
| -} // namespace content
|
| +} // namespace media
|
|
|