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

Side by Side Diff: content/common/gpu/media/vaapi_wrapper.h

Issue 825163004: Add Vaapi support on Ozone/Freon (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: Fix comment in VaapiWrapper Created 5 years, 11 months 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
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 // 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_
11 #define CONTENT_COMMON_GPU_MEDIA_VAAPI_WRAPPER_H_ 11 #define CONTENT_COMMON_GPU_MEDIA_VAAPI_WRAPPER_H_
12 12
13 #include <set> 13 #include <set>
14 #include <vector> 14 #include <vector>
15 15
16 #include "base/memory/ref_counted.h" 16 #include "base/memory/ref_counted.h"
17 #include "base/synchronization/lock.h" 17 #include "base/synchronization/lock.h"
18 #include "content/common/content_export.h" 18 #include "content/common/content_export.h"
19 #include "content/common/gpu/media/va_surface.h" 19 #include "content/common/gpu/media/va_surface.h"
20 #include "media/base/video_decoder_config.h" 20 #include "media/base/video_decoder_config.h"
21 #include "media/base/video_frame.h" 21 #include "media/base/video_frame.h"
22 #include "third_party/libva/va/va.h" 22 #include "third_party/libva/va/va.h"
23 #include "third_party/libva/va/va_vpp.h"
23 #include "ui/gfx/size.h" 24 #include "ui/gfx/size.h"
24 #if defined(USE_X11) 25 #if defined(USE_X11)
25 #include "third_party/libva/va/va_x11.h" 26 #include "third_party/libva/va/va_x11.h"
26 #endif // USE_X11 27 #endif // USE_X11
27 28
28 namespace content { 29 namespace content {
29 30
30 // This class handles VA-API calls and ensures proper locking of VA-API calls 31 // This class handles VA-API calls and ensures proper locking of VA-API calls
31 // to libva, the userspace shim to the HW codec driver. libva is not 32 // to libva, the userspace shim to the HW codec driver. libva is not
32 // thread-safe, so we have to perform locking ourselves. This class is fully 33 // thread-safe, so we have to perform locking ourselves. This class is fully
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 // again to free the allocated surfaces first, but is not required to do so 65 // again to free the allocated surfaces first, but is not required to do so
65 // at destruction time, as this will be done automatically from 66 // at destruction time, as this will be done automatically from
66 // the destructor. 67 // the destructor.
67 bool CreateSurfaces(const gfx::Size& size, 68 bool CreateSurfaces(const gfx::Size& size,
68 size_t num_surfaces, 69 size_t num_surfaces,
69 std::vector<VASurfaceID>* va_surfaces); 70 std::vector<VASurfaceID>* va_surfaces);
70 71
71 // Free all memory allocated in CreateSurfaces. 72 // Free all memory allocated in CreateSurfaces.
72 void DestroySurfaces(); 73 void DestroySurfaces();
73 74
75 // Create a VASurface of |va_format|, |size| and using |va_attribs|
76 // attributes. The ownership of the surface is transferred to the
77 // caller. It differs from surfaces created using CreateSurfaces(),
78 // where VaapiWrapper is the owner of the surfaces.
79 scoped_refptr<VASurface> CreateUnownedSurface(
80 unsigned int va_format,
81 const gfx::Size& size,
82 const std::vector<VASurfaceAttrib>& va_attribs);
83
74 // Submit parameters or slice data of |va_buffer_type|, copying them from 84 // Submit parameters or slice data of |va_buffer_type|, copying them from
75 // |buffer| of size |size|, into HW codec. The data in |buffer| is no 85 // |buffer| of size |size|, into HW codec. The data in |buffer| is no
76 // longer needed and can be freed after this method returns. 86 // longer needed and can be freed after this method returns.
77 // Data submitted via this method awaits in the HW codec until 87 // Data submitted via this method awaits in the HW codec until
78 // ExecuteAndDestroyPendingBuffers() is called to execute or 88 // ExecuteAndDestroyPendingBuffers() is called to execute or
79 // DestroyPendingBuffers() is used to cancel a pending job. 89 // DestroyPendingBuffers() is used to cancel a pending job.
80 bool SubmitBuffer(VABufferType va_buffer_type, size_t size, void* buffer); 90 bool SubmitBuffer(VABufferType va_buffer_type, size_t size, void* buffer);
81 91
82 // Submit a VAEncMiscParameterBuffer of given |misc_param_type|, copying its 92 // Submit a VAEncMiscParameterBuffer of given |misc_param_type|, copying its
83 // data from |buffer| of size |size|, into HW codec. The data in |buffer| is 93 // data from |buffer| of size |size|, into HW codec. The data in |buffer| is
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 // to the encode job. 144 // to the encode job.
135 bool DownloadAndDestroyCodedBuffer(VABufferID buffer_id, 145 bool DownloadAndDestroyCodedBuffer(VABufferID buffer_id,
136 VASurfaceID sync_surface_id, 146 VASurfaceID sync_surface_id,
137 uint8* target_ptr, 147 uint8* target_ptr,
138 size_t target_size, 148 size_t target_size,
139 size_t* coded_data_size); 149 size_t* coded_data_size);
140 150
141 // Destroy all previously-allocated (and not yet destroyed) coded buffers. 151 // Destroy all previously-allocated (and not yet destroyed) coded buffers.
142 void DestroyCodedBuffers(); 152 void DestroyCodedBuffers();
143 153
154 // Blits a VASurface |va_surface_id_src| into another VASurface
155 // |va_surface_id_dest| applying pixel format conversion and scaling
156 // if needed.
157 bool BlitSurface(VASurfaceID va_surface_id_src,
158 const gfx::Size& src_size,
159 VASurfaceID va_surface_id_dest,
160 const gfx::Size& dest_size);
161
144 private: 162 private:
145 VaapiWrapper(); 163 VaapiWrapper();
146 164
147 bool Initialize(CodecMode mode, 165 bool Initialize(CodecMode mode,
148 media::VideoCodecProfile profile, 166 media::VideoCodecProfile profile,
149 const base::Closure& report_error__to_uma_cb); 167 const base::Closure& report_error__to_uma_cb);
150 void Deinitialize(); 168 void Deinitialize();
151 bool VaInitialize(const base::Closure& report_error_to_uma_cb); 169 bool VaInitialize(const base::Closure& report_error_to_uma_cb);
152 bool GetSupportedVaProfiles(std::vector<VAProfile>* profiles); 170 bool GetSupportedVaProfiles(std::vector<VAProfile>* profiles);
153 bool IsEntrypointSupported(VAProfile va_profile, VAEntrypoint entrypoint); 171 bool IsEntrypointSupported(VAProfile va_profile, VAEntrypoint entrypoint);
154 bool AreAttribsSupported(VAProfile va_profile, 172 bool AreAttribsSupported(VAProfile va_profile,
155 VAEntrypoint entrypoint, 173 VAEntrypoint entrypoint,
156 const std::vector<VAConfigAttrib>& required_attribs); 174 const std::vector<VAConfigAttrib>& required_attribs);
157 175
176 // Destroys a |va_surface| created using CreateUnownedSurface.
177 void DestroyUnownedSurface(VASurfaceID va_surface_id);
178
179 // Initialize the video post processing context with the |size| of
180 // the input pictures to be processed.
181 bool InitializeVpp_Locked();
182
183 // Deinitialize the video post processing context.
184 void DeinitializeVpp();
185
158 // Execute pending job in hardware and destroy pending buffers. Return false 186 // Execute pending job in hardware and destroy pending buffers. Return false
159 // if vaapi driver refuses to accept parameter or slice buffers submitted 187 // if vaapi driver refuses to accept parameter or slice buffers submitted
160 // by client, or if execution fails in hardware. 188 // by client, or if execution fails in hardware.
161 bool Execute(VASurfaceID va_surface_id); 189 bool Execute(VASurfaceID va_surface_id);
162 190
163 // Attempt to set render mode to "render to texture.". Failure is non-fatal. 191 // Attempt to set render mode to "render to texture.". Failure is non-fatal.
164 void TryToSetVADisplayAttributeToLocalGPU(); 192 void TryToSetVADisplayAttributeToLocalGPU();
165 193
166 // Lazily initialize static data after sandbox is enabled. Return false on 194 // Lazily initialize static data after sandbox is enabled. Return false on
167 // init failure. 195 // init failure.
(...skipping 24 matching lines...) Expand all
192 std::vector<VABufferID> pending_slice_bufs_; 220 std::vector<VABufferID> pending_slice_bufs_;
193 std::vector<VABufferID> pending_va_bufs_; 221 std::vector<VABufferID> pending_va_bufs_;
194 222
195 // Bitstream buffers for encode. 223 // Bitstream buffers for encode.
196 std::set<VABufferID> coded_buffers_; 224 std::set<VABufferID> coded_buffers_;
197 225
198 // Called to report codec errors to UMA. Errors to clients are reported via 226 // Called to report codec errors to UMA. Errors to clients are reported via
199 // return values from public methods. 227 // return values from public methods.
200 base::Closure report_error_to_uma_cb_; 228 base::Closure report_error_to_uma_cb_;
201 229
230 // VPP (Video Post Processing) context, this is used to convert
231 // pictures used by the decoder to RGBA pictures usable by GL or the
232 // display hardware.
233 VAConfigID va_vpp_config_id_;
234 VAContextID va_vpp_context_id_;
235 VABufferID va_vpp_buffer_id_;
236
202 DISALLOW_COPY_AND_ASSIGN(VaapiWrapper); 237 DISALLOW_COPY_AND_ASSIGN(VaapiWrapper);
203 }; 238 };
204 239
205 } // namespace content 240 } // namespace content
206 241
207 #endif // CONTENT_COMMON_GPU_MEDIA_VAAPI_WRAPPER_H_ 242 #endif // CONTENT_COMMON_GPU_MEDIA_VAAPI_WRAPPER_H_
OLDNEW
« no previous file with comments | « content/common/gpu/media/vaapi_video_decode_accelerator.cc ('k') | content/common/gpu/media/vaapi_wrapper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698