Chromium Code Reviews| 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 50e6c59503465848a8cc33e62d6957c6f4a8d983..2766a79a6ee94bcddc7b5c4a14a904dca4d21955 100644 |
| --- a/content/common/gpu/media/v4l2_slice_video_decode_accelerator.cc |
| +++ b/media/gpu/v4l2_slice_video_decode_accelerator.cc |
| @@ -19,10 +19,10 @@ |
| #include "base/macros.h" |
| #include "base/numerics/safe_conversions.h" |
| #include "base/strings/stringprintf.h" |
| -#include "content/common/gpu/media/shared_memory_region.h" |
| -#include "content/common/gpu/media/v4l2_slice_video_decode_accelerator.h" |
| #include "media/base/bind_to_current_loop.h" |
| #include "media/base/media_switches.h" |
| +#include "media/gpu/shared_memory_region.h" |
| +#include "media/gpu/v4l2_slice_video_decode_accelerator.h" |
| #include "ui/gl/gl_context.h" |
| #include "ui/gl/scoped_binders.h" |
| @@ -35,12 +35,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) \ |
| @@ -55,7 +55,7 @@ |
| PLOG(ERROR) << __FUNCTION__ << "(): ioctl() failed: " << #type; \ |
| } while (0) |
| -namespace content { |
| +namespace media { |
| // static |
| const uint32_t V4L2SliceVideoDecodeAccelerator::supported_input_fourccs_[] = { |
| @@ -155,8 +155,7 @@ V4L2SliceVideoDecodeAccelerator::InputRecord::InputRecord() |
| address(nullptr), |
| length(0), |
| bytes_used(0), |
| - at_device(false) { |
| -} |
| + at_device(false) {} |
| V4L2SliceVideoDecodeAccelerator::OutputRecord::OutputRecord() |
| : at_device(false), |
| @@ -164,8 +163,7 @@ V4L2SliceVideoDecodeAccelerator::OutputRecord::OutputRecord() |
| picture_id(-1), |
| egl_image(EGL_NO_IMAGE_KHR), |
| egl_sync(EGL_NO_SYNC_KHR), |
| - cleared(false) { |
| -} |
| + cleared(false) {} |
| struct V4L2SliceVideoDecodeAccelerator::BitstreamBufferRef { |
| BitstreamBufferRef( |
| @@ -212,8 +210,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 |
| @@ -233,11 +230,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 { |
| @@ -323,8 +318,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> |
| @@ -341,18 +337,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> |
| @@ -369,13 +365,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, |
| @@ -508,7 +503,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; |
| } |
| @@ -696,10 +692,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"; |
| @@ -855,13 +849,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() << "]"; |
| } |
| @@ -887,8 +879,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) |
| @@ -948,8 +941,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); |
| @@ -991,8 +984,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); |
| } |
| @@ -1006,7 +1000,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(); |
| @@ -1450,8 +1445,8 @@ void V4L2SliceVideoDecodeAccelerator::AssignPictureBuffers( |
| 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; |
| } |
| @@ -1768,8 +1763,7 @@ V4L2SliceVideoDecodeAccelerator::V4L2H264Accelerator::V4L2H264Accelerator( |
| DCHECK(v4l2_dec_); |
| } |
| -V4L2SliceVideoDecodeAccelerator::V4L2H264Accelerator::~V4L2H264Accelerator() { |
| -} |
| +V4L2SliceVideoDecodeAccelerator::V4L2H264Accelerator::~V4L2H264Accelerator() {} |
| scoped_refptr<H264Picture> |
| V4L2SliceVideoDecodeAccelerator::V4L2H264Accelerator::CreateH264Picture() { |
| @@ -1837,12 +1831,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); |
| @@ -1858,7 +1859,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]; |
| @@ -1932,13 +1933,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) && |
|
Pawel Osciak
2016/04/19 09:22:55
Is this correct formatting?
Mark Dittmer
2016/05/02 03:51:23
Done.
|
| + 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]); |
| @@ -2195,8 +2196,7 @@ V4L2SliceVideoDecodeAccelerator::V4L2VP8Accelerator::V4L2VP8Accelerator( |
| DCHECK(v4l2_dec_); |
| } |
| -V4L2SliceVideoDecodeAccelerator::V4L2VP8Accelerator::~V4L2VP8Accelerator() { |
| -} |
| +V4L2SliceVideoDecodeAccelerator::V4L2VP8Accelerator::~V4L2VP8Accelerator() {} |
| scoped_refptr<VP8Picture> |
| V4L2SliceVideoDecodeAccelerator::V4L2VP8Accelerator::CreateVP8Picture() { |
| @@ -2278,8 +2278,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( |
| @@ -2337,10 +2336,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 = |
| @@ -2454,8 +2454,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); |
| @@ -2577,4 +2578,4 @@ V4L2SliceVideoDecodeAccelerator::GetSupportedProfiles() { |
| supported_input_fourccs_); |
| } |
| -} // namespace content |
| +} // namespace media |