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 for decode, | 6 // VaapiVideoDecodeAccelerator and VaapiH264Decoder for decode, |
7 // and VaapiVideoEncodeAccelerator for encode, to interface | 7 // and VaapiVideoEncodeAccelerator for encode, to interface |
8 // with libva (VA-API library for hardware video codec). | 8 // with libva (VA-API library for hardware video codec). |
9 | 9 |
10 #ifndef CONTENT_COMMON_GPU_MEDIA_VAAPI_WRAPPER_H_ | 10 #ifndef CONTENT_COMMON_GPU_MEDIA_VAAPI_WRAPPER_H_ |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 }; | 43 }; |
44 | 44 |
45 // |report_error_to_uma_cb| will be called independently from reporting | 45 // |report_error_to_uma_cb| will be called independently from reporting |
46 // errors to clients via method return values. | 46 // errors to clients via method return values. |
47 static scoped_ptr<VaapiWrapper> Create( | 47 static scoped_ptr<VaapiWrapper> Create( |
48 CodecMode mode, | 48 CodecMode mode, |
49 media::VideoCodecProfile profile, | 49 media::VideoCodecProfile profile, |
50 Display* x_display, | 50 Display* x_display, |
51 const base::Closure& report_error_to_uma_cb); | 51 const base::Closure& report_error_to_uma_cb); |
52 | 52 |
| 53 // Return the supported encode profiles. |
| 54 static std::vector<media::VideoCodecProfile> GetSupportedEncodeProfiles( |
| 55 Display* x_display, |
| 56 const base::Closure& report_error_to_uma_cb); |
| 57 |
53 ~VaapiWrapper(); | 58 ~VaapiWrapper(); |
54 | 59 |
55 // Create |num_surfaces| backing surfaces in driver for VASurfaces, each | 60 // Create |num_surfaces| backing surfaces in driver for VASurfaces, each |
56 // of size |size|. Returns true when successful, with the created IDs in | 61 // of size |size|. Returns true when successful, with the created IDs in |
57 // |va_surfaces| to be managed and later wrapped in VASurfaces. | 62 // |va_surfaces| to be managed and later wrapped in VASurfaces. |
58 // The client must DestroySurfaces() each time before calling this method | 63 // The client must DestroySurfaces() each time before calling this method |
59 // again to free the allocated surfaces first, but is not required to do so | 64 // again to free the allocated surfaces first, but is not required to do so |
60 // at destruction time, as this will be done automatically from | 65 // at destruction time, as this will be done automatically from |
61 // the destructor. | 66 // the destructor. |
62 bool CreateSurfaces(gfx::Size size, | 67 bool CreateSurfaces(gfx::Size size, |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 | 138 |
134 // Destroy all previously-allocated (and not yet destroyed) coded buffers. | 139 // Destroy all previously-allocated (and not yet destroyed) coded buffers. |
135 void DestroyCodedBuffers(); | 140 void DestroyCodedBuffers(); |
136 | 141 |
137 private: | 142 private: |
138 VaapiWrapper(); | 143 VaapiWrapper(); |
139 | 144 |
140 bool Initialize(CodecMode mode, | 145 bool Initialize(CodecMode mode, |
141 media::VideoCodecProfile profile, | 146 media::VideoCodecProfile profile, |
142 Display* x_display, | 147 Display* x_display, |
143 const base::Closure& report_error__to_uma_cb); | 148 const base::Closure& report_error_to_uma_cb); |
144 void Deinitialize(); | 149 void Deinitialize(); |
| 150 bool VaInitialize(Display* x_display, |
| 151 const base::Closure& report_error_to_uma_cb); |
| 152 bool GetSupportedVaProfiles(std::vector<VAProfile>* profiles); |
| 153 |
| 154 // Return true if |profile| is supported with given VA profiles, entrypoint, |
| 155 // and the required attributes. |va_profile| will be set to the corresponding |
| 156 // VA profile. |
| 157 bool IsProfileSupported(media::VideoCodecProfile profile, |
| 158 const std::vector<VAProfile>& supported_profiles, |
| 159 VAEntrypoint entrypoint, |
| 160 const std::vector<VAConfigAttrib>& required_attribs, |
| 161 VAProfile* va_profile); |
145 | 162 |
146 // Execute pending job in hardware and destroy pending buffers. Return false | 163 // Execute pending job in hardware and destroy pending buffers. Return false |
147 // if vaapi driver refuses to accept parameter or slice buffers submitted | 164 // if vaapi driver refuses to accept parameter or slice buffers submitted |
148 // by client, or if execution fails in hardware. | 165 // by client, or if execution fails in hardware. |
149 bool Execute(VASurfaceID va_surface_id); | 166 bool Execute(VASurfaceID va_surface_id); |
150 | 167 |
151 // Attempt to set render mode to "render to texture.". Failure is non-fatal. | 168 // Attempt to set render mode to "render to texture.". Failure is non-fatal. |
152 void TryToSetVADisplayAttributeToLocalGPU(); | 169 void TryToSetVADisplayAttributeToLocalGPU(); |
153 | 170 |
154 // Lazily initialize static data after sandbox is enabled. Return false on | 171 // Lazily initialize static data after sandbox is enabled. Return false on |
(...skipping 29 matching lines...) Expand all Loading... |
184 // Called to report codec errors to UMA. Errors to clients are reported via | 201 // Called to report codec errors to UMA. Errors to clients are reported via |
185 // return values from public methods. | 202 // return values from public methods. |
186 base::Closure report_error_to_uma_cb_; | 203 base::Closure report_error_to_uma_cb_; |
187 | 204 |
188 DISALLOW_COPY_AND_ASSIGN(VaapiWrapper); | 205 DISALLOW_COPY_AND_ASSIGN(VaapiWrapper); |
189 }; | 206 }; |
190 | 207 |
191 } // namespace content | 208 } // namespace content |
192 | 209 |
193 #endif // CONTENT_COMMON_GPU_MEDIA_VAAPI_WRAPPER_H_ | 210 #endif // CONTENT_COMMON_GPU_MEDIA_VAAPI_WRAPPER_H_ |
OLD | NEW |