| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <dlfcn.h> | 5 #include <dlfcn.h> |
| 6 #include <errno.h> | 6 #include <errno.h> |
| 7 #include <fcntl.h> | 7 #include <fcntl.h> |
| 8 #include <linux/videodev2.h> | 8 #include <linux/videodev2.h> |
| 9 #include <poll.h> | 9 #include <poll.h> |
| 10 #include <sys/eventfd.h> | 10 #include <sys/eventfd.h> |
| 11 #include <sys/ioctl.h> | 11 #include <sys/ioctl.h> |
| 12 #include <sys/mman.h> | 12 #include <sys/mman.h> |
| 13 | 13 |
| 14 #include "base/bind.h" | 14 #include "base/bind.h" |
| 15 #include "base/command_line.h" |
| 15 #include "base/debug/trace_event.h" | 16 #include "base/debug/trace_event.h" |
| 16 #include "base/memory/shared_memory.h" | 17 #include "base/memory/shared_memory.h" |
| 17 #include "base/message_loop/message_loop.h" | 18 #include "base/message_loop/message_loop.h" |
| 18 #include "base/message_loop/message_loop_proxy.h" | 19 #include "base/message_loop/message_loop_proxy.h" |
| 19 #include "base/numerics/safe_conversions.h" | 20 #include "base/numerics/safe_conversions.h" |
| 20 #include "content/common/gpu/media/v4l2_video_decode_accelerator.h" | 21 #include "content/common/gpu/media/v4l2_video_decode_accelerator.h" |
| 22 #include "media/base/media_switches.h" |
| 21 #include "media/filters/h264_parser.h" | 23 #include "media/filters/h264_parser.h" |
| 22 #include "ui/gl/scoped_binders.h" | 24 #include "ui/gl/scoped_binders.h" |
| 23 | 25 |
| 24 #define NOTIFY_ERROR(x) \ | 26 #define NOTIFY_ERROR(x) \ |
| 25 do { \ | 27 do { \ |
| 26 SetDecoderState(kError); \ | 28 SetDecoderState(kError); \ |
| 27 DLOG(ERROR) << "calling NotifyError(): " << x; \ | 29 DLOG(ERROR) << "calling NotifyError(): " << x; \ |
| 28 NotifyError(x); \ | 30 NotifyError(x); \ |
| 29 } while (0) | 31 } while (0) |
| 30 | 32 |
| (...skipping 1631 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1662 __u32 pixelformat = V4L2Device::VideoCodecProfileToV4L2PixFmt(video_profile_); | 1664 __u32 pixelformat = V4L2Device::VideoCodecProfileToV4L2PixFmt(video_profile_); |
| 1663 if (!pixelformat) { | 1665 if (!pixelformat) { |
| 1664 NOTREACHED(); | 1666 NOTREACHED(); |
| 1665 return false; | 1667 return false; |
| 1666 } | 1668 } |
| 1667 | 1669 |
| 1668 struct v4l2_format format; | 1670 struct v4l2_format format; |
| 1669 memset(&format, 0, sizeof(format)); | 1671 memset(&format, 0, sizeof(format)); |
| 1670 format.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE; | 1672 format.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE; |
| 1671 format.fmt.pix_mp.pixelformat = pixelformat; | 1673 format.fmt.pix_mp.pixelformat = pixelformat; |
| 1672 format.fmt.pix_mp.plane_fmt[0].sizeimage = kInputBufferMaxSize; | 1674 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 1675 switches::kIgnoreResolutionLimitsForAcceleratedVideoDecode)) |
| 1676 format.fmt.pix_mp.plane_fmt[0].sizeimage = kInputBufferMaxSizeFor4k; |
| 1677 else |
| 1678 format.fmt.pix_mp.plane_fmt[0].sizeimage = kInputBufferMaxSizeFor1080p; |
| 1673 format.fmt.pix_mp.num_planes = 1; | 1679 format.fmt.pix_mp.num_planes = 1; |
| 1674 IOCTL_OR_ERROR_RETURN_FALSE(VIDIOC_S_FMT, &format); | 1680 IOCTL_OR_ERROR_RETURN_FALSE(VIDIOC_S_FMT, &format); |
| 1675 | 1681 |
| 1676 struct v4l2_requestbuffers reqbufs; | 1682 struct v4l2_requestbuffers reqbufs; |
| 1677 memset(&reqbufs, 0, sizeof(reqbufs)); | 1683 memset(&reqbufs, 0, sizeof(reqbufs)); |
| 1678 reqbufs.count = kInputBufferCount; | 1684 reqbufs.count = kInputBufferCount; |
| 1679 reqbufs.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE; | 1685 reqbufs.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE; |
| 1680 reqbufs.memory = V4L2_MEMORY_MMAP; | 1686 reqbufs.memory = V4L2_MEMORY_MMAP; |
| 1681 IOCTL_OR_ERROR_RETURN_FALSE(VIDIOC_REQBUFS, &reqbufs); | 1687 IOCTL_OR_ERROR_RETURN_FALSE(VIDIOC_REQBUFS, &reqbufs); |
| 1682 input_buffer_map_.resize(reqbufs.count); | 1688 input_buffer_map_.resize(reqbufs.count); |
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1926 gfx::Size new_size(base::checked_cast<int>(format.fmt.pix_mp.width), | 1932 gfx::Size new_size(base::checked_cast<int>(format.fmt.pix_mp.width), |
| 1927 base::checked_cast<int>(format.fmt.pix_mp.height)); | 1933 base::checked_cast<int>(format.fmt.pix_mp.height)); |
| 1928 if (frame_buffer_size_ != new_size) { | 1934 if (frame_buffer_size_ != new_size) { |
| 1929 DVLOG(3) << "IsResolutionChangeNecessary(): Resolution change detected"; | 1935 DVLOG(3) << "IsResolutionChangeNecessary(): Resolution change detected"; |
| 1930 return true; | 1936 return true; |
| 1931 } | 1937 } |
| 1932 return false; | 1938 return false; |
| 1933 } | 1939 } |
| 1934 | 1940 |
| 1935 } // namespace content | 1941 } // namespace content |
| OLD | NEW |