Commit graph

62 commits

Author SHA1 Message Date
Víctor Manuel Jáquez Leal
e42ec3ad3c libs: context: use attribs index instead pointers
Coverity scan bug:

Out-of-bounds write. This could cause an immediate crash or incorrect
computations.

Coverity basically found that it is possible to assign more than 4
attribs in the array.

In my opinion this was produced because code pattern used pointer
arithmetic, which is not readable nor maintainable.

This patch refactors config_create() to use an array index rather than
pointer arithmetic. Also a run-time check for index size was added.
2017-08-08 18:52:37 +02:00
Hyunjun Ko
b41d72b7c5 libs: encoder/context: query region of interest support
Queries if the driver supports "Region of Interest" (ROI) during the config
creation.

  This attribute conveys whether the driver supports region-of-interest (ROI)
  encoding, based on user provided ROI rectangles.  The attribute value is
  partitioned into fields as defined in the VAConfigAttribValEncROI union.

  If ROI encoding is supported, the ROI information is passed to the driver
  using VAEncMiscParameterTypeROI.

https://bugzilla.gnome.org/show_bug.cgi?id=768248

Signed-off-by: Víctor Manuel Jáquez Leal <vjaquez@igalia.com>
2017-05-12 11:12:56 +02:00
Hyunjun Ko
41d27b5e2e libs: context: skip VAContext if no frame size
If GstVaapiContextInfo has just initial information, without frame's
width and height, skip the creation of the VAContext, just keep the
VAConfig.

https://bugzilla.gnome.org/show_bug.cgi?id=769266

Signed-off-by: Víctor Manuel Jáquez Leal <victorx.jaquez@intel.com>
2016-12-07 16:47:01 +01:00
Hyunjun Ko
059cc59a29 libs: context: split context_create()
Split the funcion context_create() into context_create() and
config_create().

Decoupling VAConfig and VAContext during context creation, we could
query the VAConfig for the supported surface's formats without creating
a VAContext.

https://bugzilla.gnome.org/show_bug.cgi?id=769266
2016-12-07 10:21:46 +01:00
Víctor Manuel Jáquez Leal
71264ede6f libs: context: ensure context formats
This patch ensures to get the formats, as filter does, available in the
decoder / encoder context.

The context fills up the array as soon it is created, otherwise the pipeline
could get stalled (perhaps this is a bug in my HSW backend).

https://bugzilla.gnome.org/show_bug.cgi?id=752958
2016-11-03 13:04:09 +01:00
Víctor Manuel Jáquez Leal
b1f6da98de libs: fix code style for errors 2016-11-03 12:51:44 +01:00
Scott D Phillips
ad9fcb9386 gstvaapicontext: control reset_on_resize with option
Signed-off-by: Scott D Phillips <scott.d.phillips@intel.com>

https://bugzilla.gnome.org/show_bug.cgi?id=767474
2016-06-15 20:50:20 +02:00
Víctor Manuel Jáquez Leal
4b5be5973e libs: small refactors to enhance the code style
As gst-indent generated ugly code in these cases, this patch changes the used
idiomatic into other one.

No functional changes were introduced.

Signed-off-by: Víctor Manuel Jáquez Leal <victorx.jaquez@intel.com>
2016-02-03 20:03:47 +01:00
Sreerenj Balachandran
61045041c4 Add 10 HEVC 10 bit decoding support
Only supporting vaapidecode ! vaapisink combination for now.

Missing dependencies:
1: No support for P010 video format in GStreamer
2: No support for P010 vaGetImage()/vaPutimage() in vaapi-intel-driver
3: As a result of 1&2 , we have no support for Vaapi Video memory mapping
   through GstVideoMeta.

Right now we only set chroma format (YUV420 with more than 8 bits per channel)
for surface pool and keeping GST_VIDEO_FORMAT as ENCODED. The underlying format
of the surfaces is implementation (driver) defined, which is P010.
2015-12-08 16:14:11 +02:00
Víctor Manuel Jáquez Leal
1e8610fc95 gstvaapicontext: fix the JPEG encoder attribs value
When we query for the VAConfigAttribEncJPEG, we get a value which packs the
VAConfigAttribValEncJPEG structure, but we did not assign it. This patch
assigns the returned value to the attribute.

Signed-off-by: Víctor Manuel Jáquez Leal <victorx.jaquez@intel.com>

https://bugzilla.gnome.org/show_bug.cgi?id=744042
2015-08-04 19:42:48 +02:00
Sreerenj Balachandran
4c7c858374 gstvaapicontext: Add VAConfigAttribValEncJPEG to the attribute list using for VAConfig creation. 2015-02-04 11:17:58 +02:00
Sreerenj Balachandran
7a84b06097 gstvaapicontext: Don't use the unsupported Ratecontrol attributes for vaCreateConfig
Don't add the VAConfigAttribRateControl to the attribute list using
for the vaCreateConfig if it is not supported by the driver.
2015-02-04 11:17:27 +02:00
Gwenole Beauchesne
96ce1bc761 videopool: add optional flags for surface pool allocation.
Reword surface pool allocation helpers so that to allow for a simple
form, e.g. gst_vaapi_surface_pool_new(format, width, height); and a
somewhat more elaborated/flexible form with optional allocation flags
and precise GstVideoInfo specification.

This is an API/ABI change, and SONAME version needs to be bumped.
2015-01-27 18:11:45 +01:00
Gwenole Beauchesne
446aa9acf8 context: allow dynamic growth of VA surfaces pool.
Add support for dynamic growth of the VA surfaces pool. For decoding,
this implies the recreation of the underlying VA context, as per the
requirement from VA-API. Besides, only increases are supported, not
shrinks.
2014-05-21 19:59:52 +02:00
Gwenole Beauchesne
906a561c26 context: reset VA context if VA surfaces set changed.
It is a requirement from VA-API specification that the VA context got
from vaCreateContext(), for decoding purposes, binds the supplied set
of VA surfaces. This means that if the set of VA surfaces is to be
changed for the current decode session, then the VA context needs to
be recreated with the new set of VA surfaces.
2014-05-21 19:59:52 +02:00
Gwenole Beauchesne
85a60441fa decoder: h264: properly support grayscale formats.
Request the correct chroma format for decoding grayscale streams.
i.e. make lookups of the VA chroma format more generic, thus possibly
supporting more formats in the future.

This means that, if a VA driver doesn't support grayscale formats,
it is now going to fail. We cannot safely assume that maybe grayscale
was implemented on top of some YUV 4:2:0 with the chroma components
all set to 0x80.
2014-05-10 06:29:25 +02:00
Gwenole Beauchesne
519f0e6b8a context: add support for non-YUV 4:2:0 formats.
Don't force allocation of VA surfaces in YUV 4:2:0 format. Rather, allow
for the upper layer to specify the desired chroma type. If the chroma
type field is not set (or yields zero), then YUV 4:2:0 format is used
by default.
2014-04-25 19:24:07 +02:00
Gwenole Beauchesne
614aa4ac95 build: fix for older versions of VA-API (< 0.34.0).
Fix build with older versions of VA-API (< 0.34.0), or versions without
good enough headers for encoding support for instance.
2014-01-23 22:44:09 +01:00
Gwenole Beauchesne
db7a3b8d3e libs: factor out usages of vaGetConfigAttributes().
Add gst_vaapi_get_config_attribute() helper function that takes a
GstVaapiDisplay and the rest of the arguments with VA types. The aim
is to have thread-safe VA helpers by default.
2014-01-23 18:51:59 +01:00
Gwenole Beauchesne
4481c155b8 encoder: notify the encoder of the submitted packed headers.
Make sure to configure the encoder with the set of packed headers we
intend to generate and submit. i.e. make selection of packed headers
to submit more robust.
2014-01-23 15:48:58 +01:00
Gwenole Beauchesne
14ad694fdc context: move rate-control mode to encoder specific config.
Move usage-specific config out of the common GstVaapiContextInfo.
Create a specialized config for encoding and move rate-control mode
to there.
2014-01-23 14:29:09 +01:00
Gwenole Beauchesne
0eb4070977 context: introduce concept of usage.
Introduce GstVaapiContextUsage so that to explicitly determine the
usage of a VA context. This is useful in view to simplifying the
creation of VA context for VPP too.
2014-01-23 14:29:09 +01:00
Gwenole Beauchesne
e3ed05bc52 context: fix get_attribute() value result.
Unknown attributes, or attributes that are not supported for the given
profile/entrypoint pair have a return value of VA_ATTRIB_NOT_SUPPORTED.
So, return failure in this case.
2014-01-23 14:29:09 +01:00
Gwenole Beauchesne
3b714c8913 context: move overlay composition to separate files.
Move GstVideoOverlayComposition handling to separate source files.
This helps keeing GstVaapiContext core implementation to the bare
minimal, i.e. simpy helpers to create a VA context and handle pool
of associated VA surfaces.
2014-01-23 14:29:09 +01:00
Gwenole Beauchesne
c85b080688 context: clean-ups. Strip down APIs.
Improve documentation and debug messages. Clean-up APIs, i.e. strip
them down to the minimal set of interfaces. They are private, so no
need expose getters for instance.
2014-01-23 14:29:09 +01:00
Gwenole Beauchesne
1ffdc010ad context: re-indent all GstVaapiContext related source code. 2014-01-23 14:29:09 +01:00
Gwenole Beauchesne
6bf3c1863c legal: update copyright notice dates. 2014-01-22 19:02:35 +01:00
Gwenole Beauchesne
71113e4999 encoder: h264: only submit packed headers when required.
Make sure to submit the packed headers only if the underlying VA driver
requires those. Currently, only handle packed sequence and picture
headers.

https://bugzilla.gnome.org/show_bug.cgi?id=722737
2014-01-22 18:30:26 +01:00
Wind Yuan
02e174c8bc libs: add support for rate-control to GstVaapiContext.
Extend GstVaapiContextInfo structure to hold the desired rate control
mode for encoding purposes. For decoding purposes, this field is not
used and it is initialized to GST_VAAPI_RATECONTROL_NONE.

Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
2013-11-24 16:45:35 +01:00
Gwenole Beauchesne
15519ebe3d legal: add per-file authorship information.
Credit original authors on a per-file basis as we cannot expect people
to know all country-specific rules, or bother browsing through the git
history.
2013-11-22 06:39:15 +01:00
Gwenole Beauchesne
4ca7922f4b Use GstVideoInfo for video pools.
Get rid of GstCaps to create surface/image pool, and use GstVideoInfo
structures instead. Those are smaller, and allows for streamlining
libgstvaapi more.
2013-07-10 17:03:47 +02:00
Gwenole Beauchesne
67eea92044 libs: drop GST_VAAPI_IS_xxx() helper macros.
Drop obsolete GST_VAAPI_IS_xxx() helper macros since we are no longer
deriving from GObject and so those were only checking for whether the
argument was NULL or not. This is now irrelevant, and even confusing
to some extent, because we no longer have type checking.

Note: this incurs more type checking (review) but the libgstvaapi is
rather small, so this is manageable.
2013-05-23 18:15:48 +02:00
Gwenole Beauchesne
2e6ff64a34 libs: use GstVaapiMiniObject for video object pools.
Port GstVaapiVideoPool, GstVaapiSurfacePool and GstVaapiImagePool to
GstVaapiMiniObject. Drop gst_vaapi_video_pool_get_caps() since it was
no longer used for a long time. Make object allocators static, i.e.
local to the shared library.
2013-05-07 17:51:27 +02:00
Gwenole Beauchesne
6c46179709 libs: use GstVaapiObject for VA objects. 2013-05-07 17:51:27 +02:00
Sreerenj Balachandran
51151e7aa1 Add initial support for GStreamer 1.0.
This integrates support for GStreamer API >= 1.0 only in the libgstvaapi
core decoding library. The changes are kept rather minimal here so that
the library retains as little dependency as possible on core GStreamer
functionality.

Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
2013-04-10 14:58:16 +02:00
Gwenole Beauchesne
e65726de8d decoder: drop obsolete functions.
Drop the following functions that are now obsolete:
- gst_vaapi_context_get_surface()
- gst_vaapi_context_put_surface()
- gst_vaapi_context_find_surface_by_id()
- gst_vaapi_surface_proxy_new()
- gst_vaapi_surface_proxy_get_context()
- gst_vaapi_surface_proxy_set_context()
- gst_vaapi_surface_proxy_set_surface()

This is an API change.
2013-04-03 13:34:59 +02:00
Gwenole Beauchesne
e22a863084 decoder: simplify acquisition/release of spare surface.
Introduce gst_vaapi_surface_proxy_new_from_pool() to allocate a new surface
proxy from the context surface pool. This change also makes sure to retain
the parent surface pool in the proxy.

Besides, it was also totally useless to attach/detach parent context to
VA surface each time we acquire/release it. Since the whole context owns
all associated VA surfaces, we can mark this as such only once and for all.
2013-04-03 13:34:59 +02:00
Gwenole Beauchesne
0ad846e68d subpicture: use gst_video_overlay_rectangle_get_pixels_unscaled_raw().
Use newer gst_video_overlay_rectangle_get_pixels_unscaled_raw() helper
function with GStreamer 0.10 compatible semantics, or that tries to
approach the current meaning. Basically, this is also just about moving
the helper to gstcompat.h.
2013-03-20 18:30:09 +01:00
Gwenole Beauchesne
0c99f351fc legal: fix year for some copyright notices (2013). 2013-01-29 14:37:02 +01:00
Holger Kaelberer
082a56599b overlay: fix build without advanced GstVideoOverlayFormatFlags.
Check for global-alpha support in GstVideoOverlayComposition API.

Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
2013-01-11 15:47:46 +01:00
Gwenole Beauchesne
7e1a8eabfe overlay: fix ordering of composition layers.
Make sure to maintain the association order of composition layers when
GstVideoOverlayRectangle objects are kept around (cached).
2013-01-11 15:32:17 +01:00
Holger Kaelberer
2ecb955626 overlay: fix support for global-alpha.
Fix support for global-alpha subpictures. The previous changes brought
the ability to check for GstVideoOverlayRectangle changes by comparing
the underlying pixel buffer pointers. If sequence number and pixel data
did not change, then this is an indication that only the global-alpha
value changed. Now, try to update the underlying VA subpicture global-alpha
value.

Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
2013-01-11 15:29:12 +01:00
Gwenole Beauchesne
e6390d6e5f overlay: detect render-rect changes.
Don't re-upload VA subpicture if only the render rectangle changed.
Rather deassociate the subpicture and re-associate it with the new
render rectangle.
2013-01-11 15:29:12 +01:00
Gwenole Beauchesne
e876d9a581 overlay: fix check for pixels buffer change.
A GstVideoOverlayRectangle is created whenever the underlying pixels data
change. However, when global-alpha is supported, it is possible to re-use
the same GstVideoOverlayRectangle but with a change to the global-alpha
value. This process causes a change of sequence number, so we can no longer
check for that.

Still, if sequence numbers did not change, then there was no change in
global-alpha either. So, we need a way to compare the underlying GstBuffer
pointers. There is no API to retrieve the original pixels buffer from
a GstVideoOverlayRectangle. So, we use the following heuristics:

1. Use gst_video_overlay_rectangle_get_pixels_unscaled_argb() with the same
   format flags from which the GstVideoOverlayRectangle was created. This
   will work if there was no prior consumer of the GstVideoOverlayRectangle
   with alternate (non-"native") format flags.

2. In overlay_rectangle_has_changed_pixels(), we have to use the same
   gst_video_overlay_rectangle_get_pixels_unscaled_argb() function but
   with flags that match the subpicture. This is needed to cope with
   platforms that don't support global-alpha in HW, so the gst-video
   layer takes care of that and fixes this up with a possibly new
   GstBuffer, and hence pixels data (or) in-place by caching the current
   global-alpha value applied. So we have to determine the rectangle
   was previously used, based on what previous flags were used to
   retrieve the ARGB pixels buffer.
2013-01-11 15:29:12 +01:00
Gwenole Beauchesne
a14d259060 overlay: optimize cache at the GstVideoOverlayRectangle level.
We previously assumed that an overlay composition changed if the number
of overlay rectangles in there actually changed, or that the rectangle
was updated, and thus its seqnum was also updated.

Now, we can cope with cases where the GstVideoOverlayComposition grew
by one or a few more overlay rectangles, and the initial overlay rectangles
are kept as is.
2013-01-11 15:29:11 +01:00
Gwenole Beauchesne
ad6cdc0b52 overlay: simplify caching of GstVideoOverlayComposition objects.
Create the GPtrArray once in the _init() function and destroy it only
in the _finalize() function. Then use overlay_clear() to remove all
subpicture associations for intermediate updates, don't recreate the
GPtrArray.

Make GstVaapiOverlayRectangle a reference counted object. Also make
sure that overlay_rectangle_new() actually creates and associates the
VA subpicture.
2013-01-11 15:28:25 +01:00
Gwenole Beauchesne
893e45ecb5 context: JPEG codec does not need any reference frame. 2012-09-10 18:17:10 +02:00
Gwenole Beauchesne
4ca1f3f47c context: allow number of reference frames to be set.
Make it possible to specify the maximum number of references to use within
a single VA context. This helps reducing GPU memory allocations to the useful
number of references to be used.
2012-09-10 18:15:02 +02:00
Gwenole Beauchesne
61cc02f54b libs: fix build in strict ISO C mode. 2012-09-07 16:23:42 +02:00
Javier Jardón
30024b3f8e libs: use g_clear_object() wherever applicable.
This is a preferred thread-safe version. Also add an inline version of
g_clear_object() if compiling with glib < 2.28.

Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
2012-07-19 15:19:17 +02:00