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 f600cdfa1d17198d00f4fd67b4b59767ea60795e..430a43235a80e11235a630dc217bee5d2418ede5 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,10 +48,9 @@ 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); |
~VaapiWrapper(); |
@@ -59,13 +62,25 @@ 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 |format|, |size| and using attributes |
Pawel Osciak
2014/10/26 13:06:48
s/format/va_format/
llandwerlin-old
2014/10/29 13:52:48
Acknowledged.
|
+ // |attribs|. The Client must call DestroyOutputSurface() to destroy |
Pawel Osciak
2014/10/26 13:06:48
where |num_va_attribs| is the size of |va_attribs|
llandwerlin-old
2014/10/29 13:52:48
Acknowledged.
|
+ // the created surface. |
Pawel Osciak
2014/10/26 13:06:48
What if we returned a VASurface instead and have D
llandwerlin-old
2014/10/29 13:52:48
Yes, doing this.
|
+ bool CreateOutputSurface(unsigned int va_format, |
Pawel Osciak
2014/10/26 13:06:48
I'd call it CreateUnmanagedSurface, or CreateUnown
llandwerlin-old
2014/10/29 13:52:48
Acknowledged.
|
+ const gfx::Size& size, |
+ VASurfaceAttrib* va_attribs, |
+ size_t num_va_attribs, |
+ VASurfaceID* va_surface); |
Pawel Osciak
2014/10/26 13:06:48
Please document va_surface too.
Also please always
llandwerlin-old
2014/10/29 13:52:49
Acknowledged.
|
+ |
+ // Destroys a |va_surface| created using CreateOutputSurface. |
+ void DestroyOutputSurface(VASurfaceID va_surface); |
+ |
// 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. |
@@ -92,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); |
@@ -134,15 +143,37 @@ class CONTENT_EXPORT VaapiWrapper { |
// Destroy all previously-allocated (and not yet destroyed) coded buffers. |
void DestroyCodedBuffers(); |
+ // Converts a VASurface from decoder preferred format (NV12) to |
+ // output picture format (RGBA) |
Pawel Osciak
2014/10/26 13:06:48
Full stop at the end of sentence please. Also plea
llandwerlin-old
2014/10/29 13:52:49
Acknowledged.
|
+ bool PutSurfaceIntoSurface(VASurfaceID va_surface_id_src, |
Pawel Osciak
2014/10/26 13:06:48
PutSurfaceIntoPixmap() is a download, but this is
llandwerlin-old
2014/10/29 13:52:49
Went with BlitSurface().
|
+ 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, |
+ bool Initialize(VADisplay display, |
+ CodecMode mode, |
media::VideoCodecProfile profile, |
- Display* x_display, |
const base::Closure& report_error__to_uma_cb); |
void Deinitialize(); |
+ // Initialize the video post processing context with the |size| of |
+ // the decoder output pictures. |
Pawel Osciak
2014/10/26 13:06:48
I think we don't want to mention decoder here. We
llandwerlin-old
2014/10/29 13:52:49
Actually looking into the code of the va driver on
|
+ bool InitializeVpp(const gfx::Size& size); |
+ |
+ // Deinitialize the video post processing context |
Pawel Osciak
2014/10/26 13:06:48
Please full stop at the end of sentences.
llandwerlin-old
2014/10/29 13:52:48
Acknowledged.
|
+ void DeinitializeVpp(); |
+ |
// 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. |
@@ -167,7 +198,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 |
@@ -185,6 +216,14 @@ class CONTENT_EXPORT VaapiWrapper { |
// return values from public methods. |
base::Closure report_error_to_uma_cb_; |
+ // VPP context |
+ VAConfigID va_vpp_config_; |
Pawel Osciak
2014/10/26 13:06:48
Please add _id at the end of each of these.
llandwerlin-old
2014/10/29 13:52:49
Acknowledged.
|
+ VAContextID va_vpp_context_; |
+ VABufferID va_vpp_buffer_; |
+ |
+ // Cache of the size of the VPP input pictures |
Pawel Osciak
2014/10/26 13:06:48
"Input surface size, to which VPP is currently con
llandwerlin-old
2014/10/29 13:52:49
Removed.
|
+ gfx::Size vpp_picture_size_; |
+ |
DISALLOW_COPY_AND_ASSIGN(VaapiWrapper); |
}; |