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 the surface data and return it as a VideoFrame. The VideoFrame | |
86 // contains I420 formatted data. Currently it only handles VASurface with | |
87 // NV12 format. | |
Pawel Osciak
2013/11/29 04:25:13
Perhaps it'd be a good idea to add a note that thi
chihchung
2013/11/29 14:06:30
Done.
| |
88 scoped_refptr<media::VideoFrame> VideoFrameFromVASurface( | |
89 VASurfaceID va_surface_id); | |
90 | |
84 private: | 91 private: |
85 VaapiWrapper(); | 92 VaapiWrapper(); |
86 | 93 |
87 bool Initialize(media::VideoCodecProfile profile, | 94 bool Initialize(media::VideoCodecProfile profile, |
88 Display* x_display, | 95 Display* x_display, |
89 const base::Closure& report_error__to_uma_cb); | 96 const base::Closure& report_error__to_uma_cb); |
90 void Deinitialize(); | 97 void Deinitialize(); |
91 | 98 |
92 // Execute decode in hardware and destroy pending buffers. Return false if | 99 // Execute decode in hardware and destroy pending buffers. Return false if |
93 // vaapi driver refuses to accept parameter or slice buffers submitted | 100 // vaapi driver refuses to accept parameter or slice buffers submitted |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
127 | 134 |
128 // Has static initialization of pre-sandbox components completed successfully? | 135 // Has static initialization of pre-sandbox components completed successfully? |
129 static bool pre_sandbox_init_done_; | 136 static bool pre_sandbox_init_done_; |
130 | 137 |
131 DISALLOW_COPY_AND_ASSIGN(VaapiWrapper); | 138 DISALLOW_COPY_AND_ASSIGN(VaapiWrapper); |
132 }; | 139 }; |
133 | 140 |
134 } // namespace content | 141 } // namespace content |
135 | 142 |
136 #endif // CONTENT_COMMON_GPU_MEDIA_VAAPI_WRAPPER_H_ | 143 #endif // CONTENT_COMMON_GPU_MEDIA_VAAPI_WRAPPER_H_ |
OLD | NEW |