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

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: remove two header files, fix comment style 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
62 int width, 62 // version >= 0.34, vaCreateSurface has 8 parameters.
63 int height, 63 // TODO(chihchung): Remove the old path once ChromeOS updates to 1.2.1.
chihchung 2013/11/21 06:45:19 TODO Added.
64 int format, 64 typedef void *VaapiCreateSurfaces;
65 int num_surfaces, 65 typedef VAStatus (*VaapiCreateSurfaces6)(VADisplay dpy,
66 VASurfaceID *surfaces); 66 int width,
67 int height,
68 int format,
69 int num_surfaces,
70 VASurfaceID *surfaces);
71 typedef VAStatus (*VaapiCreateSurfaces8)(VADisplay dpy,
72 unsigned int format,
73 unsigned int width,
74 unsigned int height,
75 VASurfaceID *surfaces,
76 unsigned int num_surfaces,
77 VASurfaceAttrib *attrib_list,
78 unsigned int num_attribs);
67 typedef VAStatus (*VaapiDestroyBuffer)(VADisplay dpy, VABufferID buffer_id); 79 typedef VAStatus (*VaapiDestroyBuffer)(VADisplay dpy, VABufferID buffer_id);
68 typedef VAStatus (*VaapiDestroyConfig)(VADisplay dpy, VAConfigID config_id); 80 typedef VAStatus (*VaapiDestroyConfig)(VADisplay dpy, VAConfigID config_id);
69 typedef VAStatus (*VaapiDestroyContext)(VADisplay dpy, VAContextID context); 81 typedef VAStatus (*VaapiDestroyContext)(VADisplay dpy, VAContextID context);
70 typedef VAStatus (*VaapiDestroySurfaces)(VADisplay dpy, 82 typedef VAStatus (*VaapiDestroySurfaces)(VADisplay dpy,
71 VASurfaceID *surfaces, 83 VASurfaceID *surfaces,
72 int num_surfaces); 84 int num_surfaces);
73 typedef int (*VaapiDisplayIsValid)(VADisplay dpy); 85 typedef int (*VaapiDisplayIsValid)(VADisplay dpy);
74 typedef VAStatus (*VaapiEndPicture)(VADisplay dpy, VAContextID context); 86 typedef VAStatus (*VaapiEndPicture)(VADisplay dpy, VAContextID context);
75 typedef const char* (*VaapiErrorStr)(VAStatus error_status); 87 typedef const char* (*VaapiErrorStr)(VAStatus error_status);
76 typedef VAStatus (*VaapiGetConfigAttributes)(VADisplay dpy, 88 typedef VAStatus (*VaapiGetConfigAttributes)(VADisplay dpy,
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 DVLOG(1) << "Unsupported profile"; 212 DVLOG(1) << "Unsupported profile";
201 return false; 213 return false;
202 } 214 }
203 215
204 va_display_ = VAAPI_GetDisplay(x_display); 216 va_display_ = VAAPI_GetDisplay(x_display);
205 if (!VAAPI_DisplayIsValid(va_display_)) { 217 if (!VAAPI_DisplayIsValid(va_display_)) {
206 DVLOG(1) << "Could not get a valid VA display"; 218 DVLOG(1) << "Could not get a valid VA display";
207 return false; 219 return false;
208 } 220 }
209 221
210 int major_version, minor_version;
211 VAStatus va_res; 222 VAStatus va_res;
212 va_res = VAAPI_Initialize(va_display_, &major_version, &minor_version); 223 va_res = VAAPI_Initialize(va_display_, &major_version_, &minor_version_);
213 VA_SUCCESS_OR_RETURN(va_res, "vaInitialize failed", false); 224 VA_SUCCESS_OR_RETURN(va_res, "vaInitialize failed", false);
214 DVLOG(1) << "VAAPI version: " << major_version << "." << minor_version; 225 DVLOG(1) << "VAAPI version: " << major_version_ << "." << minor_version_;
215 226
216 VAConfigAttrib attrib = {VAConfigAttribRTFormat, 0}; 227 VAConfigAttrib attrib = {VAConfigAttribRTFormat, 0};
217 228
218 const VAEntrypoint kEntrypoint = VAEntrypointVLD; 229 const VAEntrypoint kEntrypoint = VAEntrypointVLD;
219 va_res = VAAPI_GetConfigAttributes(va_display_, va_profile, kEntrypoint, 230 va_res = VAAPI_GetConfigAttributes(va_display_, va_profile, kEntrypoint,
220 &attrib, 1); 231 &attrib, 1);
221 VA_SUCCESS_OR_RETURN(va_res, "vaGetConfigAttributes failed", false); 232 VA_SUCCESS_OR_RETURN(va_res, "vaGetConfigAttributes failed", false);
222 233
223 if (!(attrib.value & VA_RT_FORMAT_YUV420)) { 234 if (!(attrib.value & VA_RT_FORMAT_YUV420)) {
224 DVLOG(1) << "YUV420 not supported by this VAAPI implementation"; 235 DVLOG(1) << "YUV420 not supported by this VAAPI implementation";
(...skipping 17 matching lines...) Expand all
242 253
243 if (va_display_) { 254 if (va_display_) {
244 VAStatus va_res = VAAPI_Terminate(va_display_); 255 VAStatus va_res = VAAPI_Terminate(va_display_);
245 VA_LOG_ON_ERROR(va_res, "vaTerminate failed"); 256 VA_LOG_ON_ERROR(va_res, "vaTerminate failed");
246 } 257 }
247 258
248 va_config_id_ = VA_INVALID_ID; 259 va_config_id_ = VA_INVALID_ID;
249 va_display_ = NULL; 260 va_display_ = NULL;
250 } 261 }
251 262
263 bool VaapiWrapper::VAAPIVersionLessThan(int major, int minor) {
264 return (major_version_ < major) ||
265 (major_version_ == major && minor_version_ < minor);
266 }
267
252 bool VaapiWrapper::CreateSurfaces(gfx::Size size, 268 bool VaapiWrapper::CreateSurfaces(gfx::Size size,
253 size_t num_surfaces, 269 size_t num_surfaces,
254 std::vector<VASurfaceID>* va_surfaces) { 270 std::vector<VASurfaceID>* va_surfaces) {
255 base::AutoLock auto_lock(va_lock_); 271 base::AutoLock auto_lock(va_lock_);
256 DVLOG(2) << "Creating " << num_surfaces << " surfaces"; 272 DVLOG(2) << "Creating " << num_surfaces << " surfaces";
257 273
258 DCHECK(va_surfaces->empty()); 274 DCHECK(va_surfaces->empty());
259 DCHECK(va_surface_ids_.empty()); 275 DCHECK(va_surface_ids_.empty());
260 va_surface_ids_.resize(num_surfaces); 276 va_surface_ids_.resize(num_surfaces);
261 277
262 // Allocate surfaces in driver. 278 // Allocate surfaces in driver.
263 VAStatus va_res = VAAPI_CreateSurfaces(va_display_, 279 VAStatus va_res;
264 size.width(), size.height(), 280 if (VAAPIVersionLessThan(0, 34)) {
265 VA_RT_FORMAT_YUV420, 281 va_res = reinterpret_cast<VaapiCreateSurfaces6>(VAAPI_CreateSurfaces)(
266 va_surface_ids_.size(), 282 va_display_,
267 &va_surface_ids_[0]); 283 size.width(), size.height(),
284 VA_RT_FORMAT_YUV420,
285 va_surface_ids_.size(),
286 &va_surface_ids_[0]);
287 } else {
288 va_res = reinterpret_cast<VaapiCreateSurfaces8>(VAAPI_CreateSurfaces)(
289 va_display_,
290 VA_RT_FORMAT_YUV420,
291 size.width(), size.height(),
292 &va_surface_ids_[0],
293 va_surface_ids_.size(),
294 NULL, 0);
295 }
296
268 VA_LOG_ON_ERROR(va_res, "vaCreateSurfaces failed"); 297 VA_LOG_ON_ERROR(va_res, "vaCreateSurfaces failed");
269 if (va_res != VA_STATUS_SUCCESS) { 298 if (va_res != VA_STATUS_SUCCESS) {
270 va_surface_ids_.clear(); 299 va_surface_ids_.clear();
271 return false; 300 return false;
272 } 301 }
273 302
274 // And create a context associated with them. 303 // And create a context associated with them.
275 va_res = VAAPI_CreateContext(va_display_, va_config_id_, 304 va_res = VAAPI_CreateContext(va_display_, va_config_id_,
276 size.width(), size.height(), VA_PROGRESSIVE, 305 size.width(), size.height(), VA_PROGRESSIVE,
277 &va_surface_ids_[0], va_surface_ids_.size(), 306 &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); 475 VAAPI_DLSYM_OR_RETURN_ON_ERROR(PutSurface, vaapi_x11_handle);
447 VAAPI_DLSYM_OR_RETURN_ON_ERROR(RenderPicture, vaapi_handle); 476 VAAPI_DLSYM_OR_RETURN_ON_ERROR(RenderPicture, vaapi_handle);
448 VAAPI_DLSYM_OR_RETURN_ON_ERROR(SyncSurface, vaapi_handle); 477 VAAPI_DLSYM_OR_RETURN_ON_ERROR(SyncSurface, vaapi_handle);
449 VAAPI_DLSYM_OR_RETURN_ON_ERROR(Terminate, vaapi_handle); 478 VAAPI_DLSYM_OR_RETURN_ON_ERROR(Terminate, vaapi_handle);
450 #undef VAAPI_DLSYM 479 #undef VAAPI_DLSYM
451 480
452 return true; 481 return true;
453 } 482 }
454 483
455 } // namespace content 484 } // 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