summaryrefslogtreecommitdiffstats
path: root/dynamic-layers/chromium-browser-layer/recipes-browser/chromium/chromium-ozone-wayland/0106-V4L2VDA-Create-videoframe-according-to-v4l2buffer.patch
diff options
context:
space:
mode:
Diffstat (limited to 'dynamic-layers/chromium-browser-layer/recipes-browser/chromium/chromium-ozone-wayland/0106-V4L2VDA-Create-videoframe-according-to-v4l2buffer.patch')
-rw-r--r--dynamic-layers/chromium-browser-layer/recipes-browser/chromium/chromium-ozone-wayland/0106-V4L2VDA-Create-videoframe-according-to-v4l2buffer.patch150
1 files changed, 150 insertions, 0 deletions
diff --git a/dynamic-layers/chromium-browser-layer/recipes-browser/chromium/chromium-ozone-wayland/0106-V4L2VDA-Create-videoframe-according-to-v4l2buffer.patch b/dynamic-layers/chromium-browser-layer/recipes-browser/chromium/chromium-ozone-wayland/0106-V4L2VDA-Create-videoframe-according-to-v4l2buffer.patch
new file mode 100644
index 00000000..f210fe57
--- /dev/null
+++ b/dynamic-layers/chromium-browser-layer/recipes-browser/chromium/chromium-ozone-wayland/0106-V4L2VDA-Create-videoframe-according-to-v4l2buffer.patch
@@ -0,0 +1,150 @@
1From 0e5dd1497ff0764dc28ef9bbd3f9249617f8af59 Mon Sep 17 00:00:00 2001
2From: Hou Qi <qi.hou@nxp.com>
3Date: Fri, 2 Sep 2022 17:30:16 +0800
4Subject: [PATCH 06/17] V4L2VDA: Create videoframe according to v4l2buffer
5
6Upstream-Status: Inappropriate [NXP specific]
7---
8 media/gpu/v4l2/v4l2_device.cc | 70 ++++++++++++++++++++++++-----------
9 1 file changed, 48 insertions(+), 22 deletions(-)
10
11diff --git a/media/gpu/v4l2/v4l2_device.cc b/media/gpu/v4l2/v4l2_device.cc
12index 9614eb8e71668..a9462c9a2fb2d 100644
13--- a/media/gpu/v4l2/v4l2_device.cc
14+++ b/media/gpu/v4l2/v4l2_device.cc
15@@ -305,7 +305,7 @@ scoped_refptr<VideoFrame> V4L2Buffer::CreateVideoFrame() {
16 }
17
18 std::vector<base::ScopedFD> dmabuf_fds = device_->GetDmabufsForV4L2Buffer(
19- v4l2_buffer_.index, v4l2_buffer_.length,
20+ v4l2_buffer_.index, V4L2_TYPE_IS_MULTIPLANAR(v4l2_buffer_.type) ? v4l2_buffer_.length : 1,
21 static_cast<enum v4l2_buf_type>(v4l2_buffer_.type));
22 if (dmabuf_fds.empty()) {
23 VLOGF(1) << "Failed to get DMABUFs of V4L2 buffer";
24@@ -332,7 +332,10 @@ scoped_refptr<VideoFrame> V4L2Buffer::CreateVideoFrame() {
25 dmabuf_fds.emplace_back(duped_fd);
26 }
27
28- gfx::Size size(format_.fmt.pix_mp.width, format_.fmt.pix_mp.height);
29+ if (V4L2_TYPE_IS_MULTIPLANAR(v4l2_buffer_.type))
30+ gfx::Size size(format_.fmt.pix_mp.width, format_.fmt.pix_mp.height);
31+ else
32+ gfx::Size size(format_.fmt.pix.width, format_.fmt.pix.height);
33
34 return VideoFrame::WrapExternalDmabufs(
35 *layout, gfx::Rect(size), size, std::move(dmabuf_fds), base::TimeDelta());
36@@ -1897,13 +1900,9 @@ gfx::Size V4L2Device::AllocatedSizeFromV4L2Format(
37 // static
38 absl::optional<VideoFrameLayout> V4L2Device::V4L2FormatToVideoFrameLayout(
39 const struct v4l2_format& format) {
40- if (!V4L2_TYPE_IS_MULTIPLANAR(format.type)) {
41- VLOGF(1) << "v4l2_buf_type is not multiplanar: " << std::hex << "0x"
42- << format.type;
43- return absl::nullopt;
44- }
45 const v4l2_pix_format_mplane& pix_mp = format.fmt.pix_mp;
46- const uint32_t& pix_fmt = pix_mp.pixelformat;
47+ const v4l2_pix_format& pix = format.fmt.pix;
48+ const uint32_t& pix_fmt = V4L2_TYPE_IS_MULTIPLANAR(format.type) ? pix_mp.pixelformat : pix.pixelformat;
49 const auto video_fourcc = Fourcc::FromV4L2PixFmt(pix_fmt);
50 if (!video_fourcc) {
51 VLOGF(1) << "Failed to convert pixel format to VideoPixelFormat: "
52@@ -1911,7 +1910,7 @@ absl::optional<VideoFrameLayout> V4L2Device::V4L2FormatToVideoFrameLayout(
53 return absl::nullopt;
54 }
55 const VideoPixelFormat video_format = video_fourcc->ToVideoPixelFormat();
56- const size_t num_buffers = pix_mp.num_planes;
57+ const size_t num_buffers = V4L2_TYPE_IS_MULTIPLANAR(format.type) ? format.fmt.pix_mp.num_planes : 1;
58 const size_t num_color_planes = VideoFrame::NumPlanes(video_format);
59 if (num_color_planes == 0) {
60 VLOGF(1) << "Unsupported video format for NumPlanes(): "
61@@ -1929,9 +1928,17 @@ absl::optional<VideoFrameLayout> V4L2Device::V4L2FormatToVideoFrameLayout(
62 std::vector<ColorPlaneLayout> planes;
63 planes.reserve(num_color_planes);
64 for (size_t i = 0; i < num_buffers; ++i) {
65- const v4l2_plane_pix_format& plane_format = pix_mp.plane_fmt[i];
66- planes.emplace_back(static_cast<int32_t>(plane_format.bytesperline), 0u,
67- plane_format.sizeimage);
68+ if (V4L2_TYPE_IS_MULTIPLANAR(format.type)) {
69+ if(i==0)
70+ planes.emplace_back(static_cast<int32_t>(pix_mp.width), 0u,
71+ pix_mp.width*pix_mp.height);
72+ else
73+ planes.emplace_back(static_cast<int32_t>(pix_mp.width), 0u,
74+ pix_mp.width*pix_mp.height/2);
75+ } else {
76+ planes.emplace_back(static_cast<int32_t>(pix.bytesperline), 0u,
77+ pix.sizeimage);
78+ }
79 }
80 // For the case that #color planes > #buffers, it fills stride of color
81 // plane which does not map to buffer.
82@@ -1945,8 +1952,12 @@ absl::optional<VideoFrameLayout> V4L2Device::V4L2FormatToVideoFrameLayout(
83 case V4L2_PIX_FMT_NV12:
84 // The stride of UV is the same as Y in NV12.
85 // The height is half of Y plane.
86- planes.emplace_back(y_stride, y_stride_abs * pix_mp.height,
87- y_stride_abs * pix_mp.height / 2);
88+ if (V4L2_TYPE_IS_MULTIPLANAR(format.type))
89+ planes.emplace_back(y_stride, y_stride_abs * pix_mp.height,
90+ y_stride_abs * pix_mp.height / 2);
91+ else
92+ planes.emplace_back(y_stride, y_stride_abs * pix.height,
93+ y_stride_abs * pix.height / 2);
94 DCHECK_EQ(2u, planes.size());
95 break;
96 case V4L2_PIX_FMT_YUV420:
97@@ -1954,13 +1965,18 @@ absl::optional<VideoFrameLayout> V4L2Device::V4L2FormatToVideoFrameLayout(
98 // The spec claims that two Cx rows (including padding) is exactly as
99 // long as one Y row (including padding). So stride of Y must be even
100 // number.
101- if (y_stride % 2 != 0 || pix_mp.height % 2 != 0) {
102+ if (V4L2_TYPE_IS_MULTIPLANAR(format.type) && (y_stride % 2 != 0 || pix_mp.height % 2 != 0)) {
103 VLOGF(1) << "Plane-Y stride and height should be even; stride: "
104 << y_stride << ", height: " << pix_mp.height;
105 return absl::nullopt;
106 }
107+ else if (!V4L2_TYPE_IS_MULTIPLANAR(format.type) && (y_stride % 2 != 0 || pix.height % 2 != 0)){
108+ VLOGF(1) << "Plane-Y stride and height should be even; stride: "
109+ << y_stride << ", height: " << pix.height;
110+ return absl::nullopt;
111+ }
112 const int32_t half_stride = y_stride / 2;
113- const size_t plane_0_area = y_stride_abs * pix_mp.height;
114+ const size_t plane_0_area = y_stride_abs * (V4L2_TYPE_IS_MULTIPLANAR(format.type) ? pix_mp.height : pix.height);
115 const size_t plane_1_area = plane_0_area / 4;
116 planes.emplace_back(half_stride, plane_0_area, plane_1_area);
117 planes.emplace_back(half_stride, plane_0_area + plane_1_area,
118@@ -1979,13 +1995,23 @@ absl::optional<VideoFrameLayout> V4L2Device::V4L2FormatToVideoFrameLayout(
119 // such devices individually, so set this as a video frame layout property.
120 constexpr size_t buffer_alignment = 0x1000;
121 if (num_buffers == 1) {
122- return VideoFrameLayout::CreateWithPlanes(
123- video_format, gfx::Size(pix_mp.width, pix_mp.height), std::move(planes),
124- buffer_alignment);
125+ if (V4L2_TYPE_IS_MULTIPLANAR(format.type))
126+ return VideoFrameLayout::CreateWithPlanes(
127+ video_format, gfx::Size(pix_mp.width, pix_mp.height), std::move(planes),
128+ buffer_alignment);
129+ else
130+ return VideoFrameLayout::CreateWithPlanes(
131+ video_format, gfx::Size(pix.width, pix.height), std::move(planes),
132+ buffer_alignment);
133 } else {
134- return VideoFrameLayout::CreateMultiPlanar(
135- video_format, gfx::Size(pix_mp.width, pix_mp.height), std::move(planes),
136- buffer_alignment);
137+ if (V4L2_TYPE_IS_MULTIPLANAR(format.type))
138+ return VideoFrameLayout::CreateMultiPlanar(
139+ video_format, gfx::Size(pix_mp.width, pix_mp.height), std::move(planes),
140+ buffer_alignment);
141+ else
142+ return VideoFrameLayout::CreateMultiPlanar(
143+ video_format, gfx::Size(pix.width, pix.height), std::move(planes),
144+ buffer_alignment);
145 }
146 }
147
148--
1492.17.1
150