| 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_ |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 | 74 |
| 75 // Put data from |va_surface_id| into |x_pixmap| of size |size|, | 75 // Put data from |va_surface_id| into |x_pixmap| of size |size|, |
| 76 // converting/scaling to it. | 76 // converting/scaling to it. |
| 77 bool PutSurfaceIntoPixmap(VASurfaceID va_surface_id, | 77 bool PutSurfaceIntoPixmap(VASurfaceID va_surface_id, |
| 78 Pixmap x_pixmap, | 78 Pixmap x_pixmap, |
| 79 gfx::Size dest_size); | 79 gfx::Size dest_size); |
| 80 | 80 |
| 81 // Do any necessary initialization before the sandbox is enabled. | 81 // Do any necessary initialization before the sandbox is enabled. |
| 82 static void PreSandboxInitialization(); | 82 static void PreSandboxInitialization(); |
| 83 | 83 |
| 84 // Returns true if the VAAPI version is less than the specified version. |
| 85 bool VAAPIVersionLessThan(int major, int minor); |
| 86 |
| 84 private: | 87 private: |
| 85 VaapiWrapper(); | 88 VaapiWrapper(); |
| 86 | 89 |
| 87 bool Initialize(media::VideoCodecProfile profile, | 90 bool Initialize(media::VideoCodecProfile profile, |
| 88 Display* x_display, | 91 Display* x_display, |
| 89 const base::Closure& report_error__to_uma_cb); | 92 const base::Closure& report_error__to_uma_cb); |
| 90 void Deinitialize(); | 93 void Deinitialize(); |
| 91 | 94 |
| 92 // Execute decode in hardware and destroy pending buffers. Return false if | 95 // Execute decode in hardware and destroy pending buffers. Return false if |
| 93 // vaapi driver refuses to accept parameter or slice buffers submitted | 96 // vaapi driver refuses to accept parameter or slice buffers submitted |
| 94 // by client or if decode fails in hardware. | 97 // by client or if decode fails in hardware. |
| 95 bool SubmitDecode(VASurfaceID va_surface_id); | 98 bool SubmitDecode(VASurfaceID va_surface_id); |
| 96 | 99 |
| 97 // Lazily initialize static data after sandbox is enabled. Return false on | 100 // Lazily initialize static data after sandbox is enabled. Return false on |
| 98 // init failure. | 101 // init failure. |
| 99 static bool PostSandboxInitialization(); | 102 static bool PostSandboxInitialization(); |
| 100 | 103 |
| 101 // Libva is not thread safe, so we have to do locking for it ourselves. | 104 // Libva is not thread safe, so we have to do locking for it ourselves. |
| 102 // This lock is to be taken for the duration of all VA-API calls and for | 105 // This lock is to be taken for the duration of all VA-API calls and for |
| 103 // the entire decode execution sequence in DecodeAndDestroyPendingBuffers(). | 106 // the entire decode execution sequence in DecodeAndDestroyPendingBuffers(). |
| 104 base::Lock va_lock_; | 107 base::Lock va_lock_; |
| 105 | 108 |
| 106 // Allocated ids for VASurfaces. | 109 // Allocated ids for VASurfaces. |
| 107 std::vector<VASurfaceID> va_surface_ids_; | 110 std::vector<VASurfaceID> va_surface_ids_; |
| 108 | 111 |
| 112 // The VAAPI version. |
| 113 int major_version_, minor_version_; |
| 114 |
| 109 // VA handles. | 115 // VA handles. |
| 110 // Both valid after successful Initialize() and until Deinitialize(). | 116 // Both valid after successful Initialize() and until Deinitialize(). |
| 111 VADisplay va_display_; | 117 VADisplay va_display_; |
| 112 VAConfigID va_config_id_; | 118 VAConfigID va_config_id_; |
| 113 // Created for the current set of va_surface_ids_ in CreateSurfaces() and | 119 // Created for the current set of va_surface_ids_ in CreateSurfaces() and |
| 114 // valid until DestroySurfaces(). | 120 // valid until DestroySurfaces(). |
| 115 VAContextID va_context_id_; | 121 VAContextID va_context_id_; |
| 116 | 122 |
| 117 // Data queued up for HW decoder, to be committed on next HW decode. | 123 // Data queued up for HW decoder, to be committed on next HW decode. |
| 118 std::vector<VABufferID> pending_slice_bufs_; | 124 std::vector<VABufferID> pending_slice_bufs_; |
| 119 std::vector<VABufferID> pending_va_bufs_; | 125 std::vector<VABufferID> pending_va_bufs_; |
| 120 | 126 |
| 121 // Called to report decoding errors to UMA. Errors to clients are reported via | 127 // Called to report decoding errors to UMA. Errors to clients are reported via |
| 122 // return values from public methods. | 128 // return values from public methods. |
| 123 base::Closure report_error_to_uma_cb_; | 129 base::Closure report_error_to_uma_cb_; |
| 124 | 130 |
| 125 // Has static initialization of pre-sandbox components completed successfully? | 131 // Has static initialization of pre-sandbox components completed successfully? |
| 126 static bool pre_sandbox_init_done_; | 132 static bool pre_sandbox_init_done_; |
| 127 | 133 |
| 128 DISALLOW_COPY_AND_ASSIGN(VaapiWrapper); | 134 DISALLOW_COPY_AND_ASSIGN(VaapiWrapper); |
| 129 }; | 135 }; |
| 130 | 136 |
| 131 } // namespace content | 137 } // namespace content |
| 132 | 138 |
| 133 #endif // CONTENT_COMMON_GPU_MEDIA_VAAPI_WRAPPER_H_ | 139 #endif // CONTENT_COMMON_GPU_MEDIA_VAAPI_WRAPPER_H_ |
| OLD | NEW |