| Index: content/common/gpu/media/vaapi_wrapper.h
|
| diff --git a/content/common/gpu/media/vaapi_wrapper.h b/content/common/gpu/media/vaapi_wrapper.h
|
| index 39906a0f405004b98a68bd7a18347041557dc326..7097eb9e90f260aee7b7c0101497ebcba53f8a3f 100644
|
| --- a/content/common/gpu/media/vaapi_wrapper.h
|
| +++ b/content/common/gpu/media/vaapi_wrapper.h
|
| @@ -14,17 +14,29 @@
|
| #include <vector>
|
|
|
| #include "base/callback.h"
|
| +#include "base/memory/linked_ptr.h"
|
| #include "base/memory/ref_counted.h"
|
| +#include "base/memory/weak_ptr.h"
|
| #include "base/synchronization/lock.h"
|
| #include "content/common/content_export.h"
|
| #include "content/common/gpu/media/va_surface.h"
|
| #include "media/base/video_decoder_config.h"
|
| #include "media/base/video_frame.h"
|
| -#include "third_party/libva/va/va_x11.h"
|
| +#include "third_party/libva/va/va.h"
|
| +#include "third_party/libva/va/va_vpp.h"
|
| #include "ui/gfx/size.h"
|
| +#if defined(USE_X11)
|
| +#include "third_party/libva/va/va_x11.h"
|
| +#endif // USE_X11
|
| +
|
| +namespace gfx {
|
| +class GLContext;
|
| +} // namespace gfx
|
|
|
| namespace content {
|
|
|
| +class VaapiPicture;
|
| +
|
| // This class handles VA-API calls and ensures proper locking of VA-API calls
|
| // to libva, the userspace shim to the HW codec driver. libva is not
|
| // thread-safe, so we have to perform locking ourselves. This class is fully
|
| @@ -35,28 +47,26 @@ namespace content {
|
| // It is also responsible for managing and freeing VABuffers (not VASurfaces),
|
| // which are used to queue parameters and slice data to the HW codec,
|
| // as well as underlying memory for VASurfaces themselves.
|
| -class CONTENT_EXPORT VaapiWrapper {
|
| +class CONTENT_EXPORT VaapiWrapper : public base::SupportsWeakPtr<VaapiWrapper> {
|
| public:
|
| enum CodecMode {
|
| kDecode,
|
| kEncode,
|
| };
|
|
|
| + ~VaapiWrapper();
|
| +
|
| // |report_error_to_uma_cb| will be called independently from reporting
|
| // errors to clients via method return values.
|
| static scoped_ptr<VaapiWrapper> Create(
|
| CodecMode mode,
|
| media::VideoCodecProfile profile,
|
| - Display* x_display,
|
| const base::Closure& report_error_to_uma_cb);
|
|
|
| // Return the supported encode profiles.
|
| static std::vector<media::VideoCodecProfile> GetSupportedEncodeProfiles(
|
| - Display* x_display,
|
| const base::Closure& report_error_to_uma_cb);
|
|
|
| - ~VaapiWrapper();
|
| -
|
| // Create |num_surfaces| backing surfaces in driver for VASurfaces, each
|
| // of size |size|. Returns true when successful, with the created IDs in
|
| // |va_surfaces| to be managed and later wrapped in VASurfaces.
|
| @@ -64,13 +74,33 @@ class CONTENT_EXPORT VaapiWrapper {
|
| // again to free the allocated surfaces first, but is not required to do so
|
| // at destruction time, as this will be done automatically from
|
| // the destructor.
|
| - bool CreateSurfaces(gfx::Size size,
|
| + bool CreateSurfaces(const gfx::Size& size,
|
| size_t num_surfaces,
|
| std::vector<VASurfaceID>* va_surfaces);
|
|
|
| // Free all memory allocated in CreateSurfaces.
|
| void DestroySurfaces();
|
|
|
| + // Create a VASurface of |va_format|, |size| and using
|
| + // |num_va_attribs| attributes from |va_attribs|. The ownership of
|
| + // the surface is transfered to the call. It differs from surfaces
|
| + // created using CreateSurfaces() where VaapiWrapper is the owner of
|
| + // the surfaces.
|
| + scoped_refptr<VASurface> CreateUnownedSurface(unsigned int va_format,
|
| + const gfx::Size& size,
|
| + VASurfaceAttrib* va_attribs,
|
| + size_t num_va_attribs);
|
| +
|
| + // Create a VaapiPicture of |size| to be associated with
|
| + // |picture_buffer_id| and bound to |texture_id|. |gl_context| and
|
| + // |make_context_current| are provided for the GL operations.
|
| + linked_ptr<VaapiPicture> CreatePicture(
|
| + gfx::GLContext* gl_context,
|
| + const base::Callback<bool(void)> make_context_current,
|
| + int32 picture_buffer_id,
|
| + uint32 texture_id,
|
| + const gfx::Size& size);
|
| +
|
| // Submit parameters or slice data of |va_buffer_type|, copying them from
|
| // |buffer| of size |size|, into HW codec. The data in |buffer| is no
|
| // longer needed and can be freed after this method returns.
|
| @@ -97,12 +127,6 @@ class CONTENT_EXPORT VaapiWrapper {
|
| // buffers. Return false if Execute() fails.
|
| bool ExecuteAndDestroyPendingBuffers(VASurfaceID va_surface_id);
|
|
|
| - // Put data from |va_surface_id| into |x_pixmap| of size |size|,
|
| - // converting/scaling to it.
|
| - bool PutSurfaceIntoPixmap(VASurfaceID va_surface_id,
|
| - Pixmap x_pixmap,
|
| - gfx::Size dest_size);
|
| -
|
| // Returns true if the VAAPI version is less than the specified version.
|
| bool VAAPIVersionLessThan(int major, int minor);
|
|
|
| @@ -139,22 +163,47 @@ class CONTENT_EXPORT VaapiWrapper {
|
| // Destroy all previously-allocated (and not yet destroyed) coded buffers.
|
| void DestroyCodedBuffers();
|
|
|
| + // Blits a VASurface |va_surface_id_src| into another VASurface
|
| + // |va_surface_id_dest| applying pixel format conversion and scaling
|
| + // if needed.
|
| + bool BlitSurface(VASurfaceID va_surface_id_src,
|
| + const gfx::Size& src_size,
|
| + VASurfaceID va_surface_id_dest,
|
| + const gfx::Size& dest_size);
|
| +
|
| +#if defined(USE_X11)
|
| + // Put data from |va_surface_id| into |x_pixmap| of size |size|,
|
| + // converting/scaling to it.
|
| + bool PutSurfaceIntoPixmap(VASurfaceID va_surface_id,
|
| + Pixmap x_pixmap,
|
| + gfx::Size dest_size);
|
| +#endif // USE_X11
|
| +
|
| private:
|
| VaapiWrapper();
|
|
|
| bool Initialize(CodecMode mode,
|
| media::VideoCodecProfile profile,
|
| - Display* x_display,
|
| - const base::Closure& report_error_to_uma_cb);
|
| + const base::Closure& report_error__to_uma_cb);
|
| void Deinitialize();
|
| - bool VaInitialize(Display* x_display,
|
| - const base::Closure& report_error_to_uma_cb);
|
| + bool VaInitialize(const base::Closure& report_error_to_uma_cb);
|
| bool GetSupportedVaProfiles(std::vector<VAProfile>* profiles);
|
| bool IsEntrypointSupported(VAProfile va_profile, VAEntrypoint entrypoint);
|
| bool AreAttribsSupported(VAProfile va_profile,
|
| VAEntrypoint entrypoint,
|
| const std::vector<VAConfigAttrib>& required_attribs);
|
|
|
| + // Destroys a |va_surface| created using CreateUnownedSurface.
|
| + void DestroyUnownedSurface(VASurfaceID va_surface);
|
| +
|
| + // Initialize the video post processing context with the |size| of
|
| + // the input pictures to be processed.
|
| + bool InitializeVpp_Locked();
|
| +
|
| + // Deinitialize the video post processing context.
|
| + void DeinitializeVpp();
|
| + void DeinitializeVpp_Locked();
|
| +
|
| // Execute pending job in hardware and destroy pending buffers. Return false
|
| // if vaapi driver refuses to accept parameter or slice buffers submitted
|
| // by client, or if execution fails in hardware.
|
| @@ -179,7 +228,7 @@ class CONTENT_EXPORT VaapiWrapper {
|
| int major_version_, minor_version_;
|
|
|
| // VA handles.
|
| - // Both valid after successful Initialize() and until Deinitialize().
|
| + // All valid after successful Initialize() and until Deinitialize().
|
| VADisplay va_display_;
|
| VAConfigID va_config_id_;
|
| // Created for the current set of va_surface_ids_ in CreateSurfaces() and
|
| @@ -197,6 +246,11 @@ class CONTENT_EXPORT VaapiWrapper {
|
| // return values from public methods.
|
| base::Closure report_error_to_uma_cb_;
|
|
|
| + // VPP context
|
| + VAConfigID va_vpp_config_id_;
|
| + VAContextID va_vpp_context_id_;
|
| + VABufferID va_vpp_buffer_id_;
|
| +
|
| DISALLOW_COPY_AND_ASSIGN(VaapiWrapper);
|
| };
|
|
|
|
|