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

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

Issue 62273006: Update libva headers to the latest release (1.2.1). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lkgr
Patch Set: Created 7 years, 1 month 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
« no previous file with comments | « content/common/gpu/media/vaapi_wrapper.h ('k') | third_party/libva/README.chromium » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "content/common/gpu/media/vaapi_wrapper.h" 9 #include "content/common/gpu/media/vaapi_wrapper.h"
10 10
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 int num_attribs, 51 int num_attribs,
52 VAConfigID *config_id); 52 VAConfigID *config_id);
53 typedef VAStatus (*VaapiCreateContext)(VADisplay dpy, 53 typedef VAStatus (*VaapiCreateContext)(VADisplay dpy,
54 VAConfigID config_id, 54 VAConfigID config_id,
55 int picture_width, 55 int picture_width,
56 int picture_height, 56 int picture_height,
57 int flag, 57 int flag,
58 VASurfaceID *render_targets, 58 VASurfaceID *render_targets,
59 int num_render_targets, 59 int num_render_targets,
60 VAContextID *context); 60 VAContextID *context);
61 typedef VAStatus (*VaapiCreateSurfaces)(VADisplay dpy, 61 /* In VAAPI version < 0.34, vaCreateSurface has 6 parameters, but in VAAPI
Pawel Osciak 2013/11/21 05:36:36 Please use // style comments (both are allowed, bu
chihchung 2013/11/21 06:45:18 Done.
62 int width, 62 * version >= 0.34, vaCreateSurface has 8 parameters. */
63 int height, 63 typedef void *VaapiCreateSurfaces;
64 int format, 64 typedef VAStatus (*VaapiCreateSurfaces6)(VADisplay dpy,
65 int num_surfaces, 65 int width,
66 VASurfaceID *surfaces); 66 int height,
67 int format,
68 int num_surfaces,
69 VASurfaceID *surfaces);
70 typedef VAStatus (*VaapiCreateSurfaces8)(VADisplay dpy,
71 unsigned int format,
72 unsigned int width,
73 unsigned int height,
74 VASurfaceID *surfaces,
75 unsigned int num_surfaces,
76 VASurfaceAttrib *attrib_list,
77 unsigned int num_attribs);
67 typedef VAStatus (*VaapiDestroyBuffer)(VADisplay dpy, VABufferID buffer_id); 78 typedef VAStatus (*VaapiDestroyBuffer)(VADisplay dpy, VABufferID buffer_id);
68 typedef VAStatus (*VaapiDestroyConfig)(VADisplay dpy, VAConfigID config_id); 79 typedef VAStatus (*VaapiDestroyConfig)(VADisplay dpy, VAConfigID config_id);
69 typedef VAStatus (*VaapiDestroyContext)(VADisplay dpy, VAContextID context); 80 typedef VAStatus (*VaapiDestroyContext)(VADisplay dpy, VAContextID context);
70 typedef VAStatus (*VaapiDestroySurfaces)(VADisplay dpy, 81 typedef VAStatus (*VaapiDestroySurfaces)(VADisplay dpy,
71 VASurfaceID *surfaces, 82 VASurfaceID *surfaces,
72 int num_surfaces); 83 int num_surfaces);
73 typedef int (*VaapiDisplayIsValid)(VADisplay dpy); 84 typedef int (*VaapiDisplayIsValid)(VADisplay dpy);
74 typedef VAStatus (*VaapiEndPicture)(VADisplay dpy, VAContextID context); 85 typedef VAStatus (*VaapiEndPicture)(VADisplay dpy, VAContextID context);
75 typedef const char* (*VaapiErrorStr)(VAStatus error_status); 86 typedef const char* (*VaapiErrorStr)(VAStatus error_status);
76 typedef VAStatus (*VaapiGetConfigAttributes)(VADisplay dpy, 87 typedef VAStatus (*VaapiGetConfigAttributes)(VADisplay dpy,
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 DVLOG(1) << "Unsupported profile"; 211 DVLOG(1) << "Unsupported profile";
201 return false; 212 return false;
202 } 213 }
203 214
204 va_display_ = VAAPI_GetDisplay(x_display); 215 va_display_ = VAAPI_GetDisplay(x_display);
205 if (!VAAPI_DisplayIsValid(va_display_)) { 216 if (!VAAPI_DisplayIsValid(va_display_)) {
206 DVLOG(1) << "Could not get a valid VA display"; 217 DVLOG(1) << "Could not get a valid VA display";
207 return false; 218 return false;
208 } 219 }
209 220
210 int major_version, minor_version;
211 VAStatus va_res; 221 VAStatus va_res;
212 va_res = VAAPI_Initialize(va_display_, &major_version, &minor_version); 222 va_res = VAAPI_Initialize(va_display_, &major_version_, &minor_version_);
213 VA_SUCCESS_OR_RETURN(va_res, "vaInitialize failed", false); 223 VA_SUCCESS_OR_RETURN(va_res, "vaInitialize failed", false);
214 DVLOG(1) << "VAAPI version: " << major_version << "." << minor_version; 224 DVLOG(1) << "VAAPI version: " << major_version_ << "." << minor_version_;
215 225
216 VAConfigAttrib attrib = {VAConfigAttribRTFormat, 0}; 226 VAConfigAttrib attrib = {VAConfigAttribRTFormat, 0};
217 227
218 const VAEntrypoint kEntrypoint = VAEntrypointVLD; 228 const VAEntrypoint kEntrypoint = VAEntrypointVLD;
219 va_res = VAAPI_GetConfigAttributes(va_display_, va_profile, kEntrypoint, 229 va_res = VAAPI_GetConfigAttributes(va_display_, va_profile, kEntrypoint,
220 &attrib, 1); 230 &attrib, 1);
221 VA_SUCCESS_OR_RETURN(va_res, "vaGetConfigAttributes failed", false); 231 VA_SUCCESS_OR_RETURN(va_res, "vaGetConfigAttributes failed", false);
222 232
223 if (!(attrib.value & VA_RT_FORMAT_YUV420)) { 233 if (!(attrib.value & VA_RT_FORMAT_YUV420)) {
224 DVLOG(1) << "YUV420 not supported by this VAAPI implementation"; 234 DVLOG(1) << "YUV420 not supported by this VAAPI implementation";
(...skipping 17 matching lines...) Expand all
242 252
243 if (va_display_) { 253 if (va_display_) {
244 VAStatus va_res = VAAPI_Terminate(va_display_); 254 VAStatus va_res = VAAPI_Terminate(va_display_);
245 VA_LOG_ON_ERROR(va_res, "vaTerminate failed"); 255 VA_LOG_ON_ERROR(va_res, "vaTerminate failed");
246 } 256 }
247 257
248 va_config_id_ = VA_INVALID_ID; 258 va_config_id_ = VA_INVALID_ID;
249 va_display_ = NULL; 259 va_display_ = NULL;
250 } 260 }
251 261
262 bool VaapiWrapper::VAAPIVersionLessThan(int major, int minor) {
263 return (major_version_ < major) ||
264 (major_version_ == major && minor_version_ < minor);
265 }
266
252 bool VaapiWrapper::CreateSurfaces(gfx::Size size, 267 bool VaapiWrapper::CreateSurfaces(gfx::Size size,
253 size_t num_surfaces, 268 size_t num_surfaces,
254 std::vector<VASurfaceID>* va_surfaces) { 269 std::vector<VASurfaceID>* va_surfaces) {
255 base::AutoLock auto_lock(va_lock_); 270 base::AutoLock auto_lock(va_lock_);
256 DVLOG(2) << "Creating " << num_surfaces << " surfaces"; 271 DVLOG(2) << "Creating " << num_surfaces << " surfaces";
257 272
258 DCHECK(va_surfaces->empty()); 273 DCHECK(va_surfaces->empty());
259 DCHECK(va_surface_ids_.empty()); 274 DCHECK(va_surface_ids_.empty());
260 va_surface_ids_.resize(num_surfaces); 275 va_surface_ids_.resize(num_surfaces);
261 276
262 // Allocate surfaces in driver. 277 // Allocate surfaces in driver.
263 VAStatus va_res = VAAPI_CreateSurfaces(va_display_, 278 VAStatus va_res;
264 size.width(), size.height(), 279 if (VAAPIVersionLessThan(0, 34)) {
265 VA_RT_FORMAT_YUV420, 280 va_res = reinterpret_cast<VaapiCreateSurfaces6>(VAAPI_CreateSurfaces)(
266 va_surface_ids_.size(), 281 va_display_,
267 &va_surface_ids_[0]); 282 size.width(), size.height(),
283 VA_RT_FORMAT_YUV420,
284 va_surface_ids_.size(),
285 &va_surface_ids_[0]);
286 } else {
287 va_res = reinterpret_cast<VaapiCreateSurfaces8>(VAAPI_CreateSurfaces)(
288 va_display_,
289 VA_RT_FORMAT_YUV420,
290 size.width(), size.height(),
291 &va_surface_ids_[0],
292 va_surface_ids_.size(),
293 NULL, 0);
294 }
295
268 VA_LOG_ON_ERROR(va_res, "vaCreateSurfaces failed"); 296 VA_LOG_ON_ERROR(va_res, "vaCreateSurfaces failed");
269 if (va_res != VA_STATUS_SUCCESS) { 297 if (va_res != VA_STATUS_SUCCESS) {
270 va_surface_ids_.clear(); 298 va_surface_ids_.clear();
271 return false; 299 return false;
272 } 300 }
273 301
274 // And create a context associated with them. 302 // And create a context associated with them.
275 va_res = VAAPI_CreateContext(va_display_, va_config_id_, 303 va_res = VAAPI_CreateContext(va_display_, va_config_id_,
276 size.width(), size.height(), VA_PROGRESSIVE, 304 size.width(), size.height(), VA_PROGRESSIVE,
277 &va_surface_ids_[0], va_surface_ids_.size(), 305 &va_surface_ids_[0], va_surface_ids_.size(),
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
446 VAAPI_DLSYM_OR_RETURN_ON_ERROR(PutSurface, vaapi_x11_handle); 474 VAAPI_DLSYM_OR_RETURN_ON_ERROR(PutSurface, vaapi_x11_handle);
447 VAAPI_DLSYM_OR_RETURN_ON_ERROR(RenderPicture, vaapi_handle); 475 VAAPI_DLSYM_OR_RETURN_ON_ERROR(RenderPicture, vaapi_handle);
448 VAAPI_DLSYM_OR_RETURN_ON_ERROR(SyncSurface, vaapi_handle); 476 VAAPI_DLSYM_OR_RETURN_ON_ERROR(SyncSurface, vaapi_handle);
449 VAAPI_DLSYM_OR_RETURN_ON_ERROR(Terminate, vaapi_handle); 477 VAAPI_DLSYM_OR_RETURN_ON_ERROR(Terminate, vaapi_handle);
450 #undef VAAPI_DLSYM 478 #undef VAAPI_DLSYM
451 479
452 return true; 480 return true;
453 } 481 }
454 482
455 } // namespace content 483 } // namespace content
OLDNEW
« no previous file with comments | « content/common/gpu/media/vaapi_wrapper.h ('k') | third_party/libva/README.chromium » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698