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

Side by Side Diff: content/common/gpu/media/tegra_v4l2_video_device.cc

Issue 839523002: V4L2VDA: Generalize EGLImage import and query driver for output formats. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 months 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 unified diff | Download patch
OLDNEW
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 <fcntl.h> 6 #include <fcntl.h>
7 #include <linux/videodev2.h> 7 #include <linux/videodev2.h>
8 8
9 #include "base/debug/trace_event.h" 9 #include "base/debug/trace_event.h"
10 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 } 163 }
164 device_fd_ = HANDLE_EINTR( 164 device_fd_ = HANDLE_EINTR(
165 TegraV4L2_Open(device_path, O_RDWR | O_NONBLOCK | O_CLOEXEC)); 165 TegraV4L2_Open(device_path, O_RDWR | O_NONBLOCK | O_CLOEXEC));
166 if (device_fd_ == -1) { 166 if (device_fd_ == -1) {
167 DLOG(ERROR) << "Unable to open device " << device_path; 167 DLOG(ERROR) << "Unable to open device " << device_path;
168 return false; 168 return false;
169 } 169 }
170 return true; 170 return true;
171 } 171 }
172 172
173 bool TegraV4L2Device::CanCreateEGLImageFrom(uint32_t v4l2_pixfmt) {
174 return v4l2_pixfmt == V4L2_PIX_FMT_NV12M;
175 }
176
173 EGLImageKHR TegraV4L2Device::CreateEGLImage(EGLDisplay egl_display, 177 EGLImageKHR TegraV4L2Device::CreateEGLImage(EGLDisplay egl_display,
174 EGLContext egl_context, 178 EGLContext egl_context,
175 GLuint texture_id, 179 GLuint texture_id,
176 gfx::Size /* frame_buffer_size */, 180 gfx::Size /* frame_buffer_size */,
177 unsigned int buffer_index, 181 unsigned int buffer_index,
178 size_t /* planes_count */) { 182 uint32_t v4l2_pixfmt,
183 size_t /* num_v4l2_planes */) {
179 DVLOG(3) << "CreateEGLImage()"; 184 DVLOG(3) << "CreateEGLImage()";
185 if (!CanCreateEGLImageFrom(v4l2_pixfmt)) {
186 LOG(ERROR) << "Unsupported V4L2 pixel format";
187 return EGL_NO_IMAGE_KHR;
188 }
189
180 EGLint attr = EGL_NONE; 190 EGLint attr = EGL_NONE;
181 EGLImageKHR egl_image = 191 EGLImageKHR egl_image =
182 eglCreateImageKHR(egl_display, 192 eglCreateImageKHR(egl_display,
183 egl_context, 193 egl_context,
184 EGL_GL_TEXTURE_2D_KHR, 194 EGL_GL_TEXTURE_2D_KHR,
185 reinterpret_cast<EGLClientBuffer>(texture_id), 195 reinterpret_cast<EGLClientBuffer>(texture_id),
186 &attr); 196 &attr);
187 if (egl_image == EGL_NO_IMAGE_KHR) { 197 if (egl_image == EGL_NO_IMAGE_KHR) {
188 LOG(ERROR) << "Unable to create EGL image"; 198 LOG(ERROR) << "Unable to create EGL image";
189 return egl_image; 199 return egl_image;
(...skipping 13 matching lines...) Expand all
203 213
204 GLenum TegraV4L2Device::GetTextureTarget() { return GL_TEXTURE_2D; } 214 GLenum TegraV4L2Device::GetTextureTarget() { return GL_TEXTURE_2D; }
205 215
206 uint32 TegraV4L2Device::PreferredInputFormat() { 216 uint32 TegraV4L2Device::PreferredInputFormat() {
207 // TODO(posciak): We should support "dontcare" returns here once we 217 // TODO(posciak): We should support "dontcare" returns here once we
208 // implement proper handling (fallback, negotiation) for this in users. 218 // implement proper handling (fallback, negotiation) for this in users.
209 CHECK_EQ(type_, kEncoder); 219 CHECK_EQ(type_, kEncoder);
210 return V4L2_PIX_FMT_YUV420M; 220 return V4L2_PIX_FMT_YUV420M;
211 } 221 }
212 222
213 uint32 TegraV4L2Device::PreferredOutputFormat() {
214 // TODO(posciak): We should support "dontcare" returns here once we
215 // implement proper handling (fallback, negotiation) for this in users.
216 CHECK_EQ(type_, kDecoder);
217 return V4L2_PIX_FMT_NV12M;
218 }
219
220 } // namespace content 223 } // namespace content
OLDNEW
« no previous file with comments | « content/common/gpu/media/tegra_v4l2_video_device.h ('k') | content/common/gpu/media/v4l2_video_decode_accelerator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698