| 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..1d681cb7facc9ab7bdbde21260cebc25fb4fc3a0 100644
|
| --- a/content/common/gpu/media/vaapi_wrapper.h
|
| +++ b/content/common/gpu/media/vaapi_wrapper.h
|
| @@ -20,8 +20,12 @@
|
| #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 content {
|
|
|
| @@ -35,7 +39,7 @@ 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::RefCounted<VaapiWrapper> {
|
| public:
|
| enum CodecMode {
|
| kDecode,
|
| @@ -44,19 +48,15 @@ class CONTENT_EXPORT VaapiWrapper {
|
|
|
| // |report_error_to_uma_cb| will be called independently from reporting
|
| // errors to clients via method return values.
|
| - static scoped_ptr<VaapiWrapper> Create(
|
| + static scoped_refptr<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 +64,23 @@ 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);
|
| +
|
| // 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 +107,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 +143,49 @@ 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:
|
| + friend class base::RefCounted<VaapiWrapper>;
|
| VaapiWrapper();
|
| + ~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 +210,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 +228,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);
|
| };
|
|
|
|
|