OLD | NEW |
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 // This file contains an implementation of VaapiWrapper, used by | 5 // This file contains an implementation of VaapiWrapper, used by |
6 // VaapiVideoDecodeAccelerator and VaapiH264Decoder to interface | 6 // VaapiVideoDecodeAccelerator and VaapiH264Decoder to interface |
7 // with libva (VA-API library for hardware video decode). | 7 // with libva (VA-API library for hardware video decode). |
8 | 8 |
9 #ifndef CONTENT_COMMON_GPU_MEDIA_VAAPI_WRAPPER_H_ | 9 #ifndef CONTENT_COMMON_GPU_MEDIA_VAAPI_WRAPPER_H_ |
10 #define CONTENT_COMMON_GPU_MEDIA_VAAPI_WRAPPER_H_ | 10 #define CONTENT_COMMON_GPU_MEDIA_VAAPI_WRAPPER_H_ |
11 | 11 |
12 #include "base/callback.h" | 12 #include "base/callback.h" |
13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
14 #include "base/synchronization/lock.h" | 14 #include "base/synchronization/lock.h" |
15 #include "content/common/content_export.h" | 15 #include "content/common/content_export.h" |
16 #include "content/common/gpu/media/va_surface.h" | 16 #include "content/common/gpu/media/va_surface.h" |
17 #include "media/base/video_decoder_config.h" | 17 #include "media/base/video_decoder_config.h" |
| 18 #include "media/base/video_frame.h" |
18 #include "third_party/libva/va/va.h" | 19 #include "third_party/libva/va/va.h" |
19 #include "third_party/libva/va/va_x11.h" | 20 #include "third_party/libva/va/va_x11.h" |
20 #include "ui/gfx/size.h" | 21 #include "ui/gfx/size.h" |
21 | 22 |
22 namespace content { | 23 namespace content { |
23 | 24 |
24 // This class handles VA-API calls and ensures proper locking of VA-API calls | 25 // This class handles VA-API calls and ensures proper locking of VA-API calls |
25 // to libva, the userspace shim to the HW decoder driver. libva is not | 26 // to libva, the userspace shim to the HW decoder driver. libva is not |
26 // thread-safe, so we have to perform locking ourselves. This class is fully | 27 // thread-safe, so we have to perform locking ourselves. This class is fully |
27 // synchronous and its methods can be called from any thread and may wait on | 28 // synchronous and its methods can be called from any thread and may wait on |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 | 75 |
75 // Put data from |va_surface_id| into |x_pixmap| of size |size|, | 76 // Put data from |va_surface_id| into |x_pixmap| of size |size|, |
76 // converting/scaling to it. | 77 // converting/scaling to it. |
77 bool PutSurfaceIntoPixmap(VASurfaceID va_surface_id, | 78 bool PutSurfaceIntoPixmap(VASurfaceID va_surface_id, |
78 Pixmap x_pixmap, | 79 Pixmap x_pixmap, |
79 gfx::Size dest_size); | 80 gfx::Size dest_size); |
80 | 81 |
81 // Returns true if the VAAPI version is less than the specified version. | 82 // Returns true if the VAAPI version is less than the specified version. |
82 bool VAAPIVersionLessThan(int major, int minor); | 83 bool VAAPIVersionLessThan(int major, int minor); |
83 | 84 |
| 85 // Get a VAImage from a VASurface and map it into memory. The VAImage should |
| 86 // be released using the ReturnVaImage function. Returns true when successful. |
| 87 // This is intended for testing only. |
| 88 bool GetVaImageForTesting(VASurfaceID va_surface_id, |
| 89 VAImage* image, |
| 90 void** mem); |
| 91 |
| 92 // Release the VAImage (and the associated memory mapping) obtained from |
| 93 // GetVaImage(). This is intended for testing only. |
| 94 void ReturnVaImageForTesting(VAImage* image); |
| 95 |
84 private: | 96 private: |
85 VaapiWrapper(); | 97 VaapiWrapper(); |
86 | 98 |
87 bool Initialize(media::VideoCodecProfile profile, | 99 bool Initialize(media::VideoCodecProfile profile, |
88 Display* x_display, | 100 Display* x_display, |
89 const base::Closure& report_error__to_uma_cb); | 101 const base::Closure& report_error__to_uma_cb); |
90 void Deinitialize(); | 102 void Deinitialize(); |
91 | 103 |
92 // Execute decode in hardware and destroy pending buffers. Return false if | 104 // Execute decode in hardware and destroy pending buffers. Return false if |
93 // vaapi driver refuses to accept parameter or slice buffers submitted | 105 // vaapi driver refuses to accept parameter or slice buffers submitted |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 // Called to report decoding errors to UMA. Errors to clients are reported via | 139 // Called to report decoding errors to UMA. Errors to clients are reported via |
128 // return values from public methods. | 140 // return values from public methods. |
129 base::Closure report_error_to_uma_cb_; | 141 base::Closure report_error_to_uma_cb_; |
130 | 142 |
131 DISALLOW_COPY_AND_ASSIGN(VaapiWrapper); | 143 DISALLOW_COPY_AND_ASSIGN(VaapiWrapper); |
132 }; | 144 }; |
133 | 145 |
134 } // namespace content | 146 } // namespace content |
135 | 147 |
136 #endif // CONTENT_COMMON_GPU_MEDIA_VAAPI_WRAPPER_H_ | 148 #endif // CONTENT_COMMON_GPU_MEDIA_VAAPI_WRAPPER_H_ |
OLD | NEW |