Commit graph

576 commits

Author SHA1 Message Date
Gwenole Beauchesne
a26df804a6 vaapisink: always keep the last displayed buffer around.
Always record the VA surface that is currently being rendered, no matter
the fact we are using texturedblit or overlay. That's because in some
occasions, we need to refresh or resize the displayed contents based on
new events. e.g. user-resized window.

Besides, it's simpler to track the last video buffer in GstVaapiSink than
through the base sink "last-sample".
2014-07-28 10:12:49 +02:00
Gwenole Beauchesne
5ffa82b64c vaapisink: add support for "display-name" property.
Add a "display-name" property to vaapisink so that the end user could
select the desired output. Keep "display-name" in-line with the existing
"display" (GstVaapiDisplayXXX type).

So, for X11 or GLX, the "display-name" is the usual display name as we
know for XOpenDisplay(); for Wayland, the "display-name" is the name used
for wl_display_connect(); and for DRM, the "display-name" is actually the
DRI device name.

https://bugzilla.gnome.org/show_bug.cgi?id=722247
2014-07-25 17:36:12 +02:00
Gwenole Beauchesne
cafb25c4d1 vaapidecode: add support for VideoAlignment bufferpool option.
Always add VideoAlignment bufferpool option if the downstream element
expects its own pool to be used but does not offer it through a proper
propose_allocation() implementation for instance, and that the ALLOCATION
query does not expose the availability of the Video Meta API.

This fixes propagation of video buffer stride information to Firefox.
2014-07-25 15:52:06 +02:00
Gwenole Beauchesne
1d1be0ae76 vaapivideomemory: always prefer native VA surface formats.
Make sure to always prefer native internal formats for the VA surfaces
that get allocated. Also disable "direct-rendering" mode in this case.

This is needed so that to make sure that anything that gets out of the
decoder, or anything that gets into the encoder, is in native format
for the hardware, and thus the driver doesn't need to perform implicit
conversions in there. Interop with SW elements is still available with
fast implementations of VA imaging APIs.
2014-07-25 15:44:58 +02:00
Gwenole Beauchesne
e0e869f536 vaapivideomemory: disallow memory shares across buffers, use a copy.
Forbid shares of GstMemory instances, and rather make copy of it. This
effectively copies the GstMemory structure and enclosed metadata, but
this does not copy the VA surface contents itself. It should though.

This fixes preroll and makes sure to not download garbage for the first
frame when a SW rendering sink is used.
2014-07-24 11:58:29 +02:00
Gwenole Beauchesne
3a762284a2 vaapivideomemory: use an image pool to cache objects.
Use an image pool to hold VA images to be used for downloads/uploads
of contents for the associated surface.

This is an optmization for size. So, instead of creating as many VA
images as there are buffers (then VA surfaces) allocated, we only
maintain a minimal set of live VA images, thus preserving memory
resources.
2014-07-24 06:55:26 +02:00
Gwenole Beauchesne
c3643b42a4 vaapivideomemory: forbid R/W mappings if non direct-rendering mode.
Disable read-write mappings if "direct-rendering" is not supported.
Since the ordering of read and write operations is not specified,
this would require to always download the VA surface on _map(), then
commit the temporary VA image back to the VA surface on _unmap().

Some SW decoding plug-in elements still use R/W mappings though.

https://bugzilla.gnome.org/show_bug.cgi?id=733242
2014-07-24 00:14:09 +02:00
Gwenole Beauchesne
f2ce28e4b7 vaapivideomemory: minor code clean-ups.
Fix error messages introduced in the previous commit for the _map()
imaplementation. Also use the new get_image_data() helper function
to determine the base pixels data buffer from a GstVaapiImage when
updating the video info structure from it.
2014-07-23 23:53:15 +02:00
Gwenole Beauchesne
9cad85a936 vaapivideomemory: add support for raw pixels mappings.
Allow raw pixels of the whole frame to be mapped read-only. i.e. in
cases where the buffer pool is allocated without VideoMeta API, thus
individual planes cannot be mapped.

This is initial support for Firefox >= 30.

https://bugzilla.gnome.org/show_bug.cgi?id=731886
2014-07-23 19:14:47 +02:00
Sreerenj Balachandran
9cb3acc813 vaapivideomemory: fix determination of the surface pool format.
While creating the vaapi video allocator, make sure the associated
surface pool has correct format instead of defaulting to NV12 video
format even though there is no direct rendering support.

https://bugzilla.gnome.org/show_bug.cgi?id=732691
2014-07-23 18:48:32 +02:00
Gwenole Beauchesne
b07de8a7f9 vaapivideomemory: fix association of surface to proxy.
Make sure to always update the VA surface pointer whenever the proxy
changes. This used to only work when the VA surface is written to, in
interop with SW element ("upload" feature), and this now fixes cases
when the VA surface is needed for reading, in interop with SW element
("download" feature).
2014-07-23 18:01:21 +02:00
Gwenole Beauchesne
dac20cecb4 plugins: expose I420 format for interop with SW elements.
Always expose I420 format by default when the VA surface could be
mapped for interoperability with non harware accelerated elements.
However, the default behaviour remains the auto-plugging of vaapi
elements, down to the sink.

Side effect: "direct-rendering" mode is also disabled most of the
times as plain memcpy() from uncached speculative write combining
memory is not going to be efficient enough.
2014-07-23 16:25:08 +02:00
Gwenole Beauchesne
dc6d529830 plugins: allow download capability to vaapidecode element.
Fix support for VA surface download capability in vaapidecode element
for GStreamer >= 1.2. This is a fix to supporting libva-vdpau-driver,
but also the libva-intel-driver while performing hardware accelerated
conversions from the native VA surface format (NV12) to the desired
output VA image format.

For instance, this fixes pipelines involving vaapidecode ! xvimagesink.

https://bugzilla.gnome.org/show_bug.cgi?id=733243
2014-07-22 19:06:52 +02:00
Lionel Landwerlin
334a0ca8bd vaapidecode: make decoder work with playbin
When playbin/decodebin builds the pipeline, it puts decoders and sinks
into different bins and forwards the queries from bins to bins. So in
the initials steps the pipeline is built iteratively by playbin and
looks like this :

[filesrc]

[filesrc] -> [typefind]

[filesrc] -> [typefind] -> [demuxer]

[filesrc] -> [typefind] -> [demuxer] -> [decoder]

At this point the decoder is asked for its SRC caps and it will make a
choice based on what gst_pad_peer_query_caps() returns. The problem is
that the caps returns at that point includes caps features like ANY,
essentially because playbin can plug in additional elements like
videoscale, videoconv or deinterlace.

This patch adds a another call to
gst_vaapi_find_preferred_caps_feature() when the decoder decides its
allocation, to make sure we asks the downstream elements when the
entire pipeline has been built.

https://bugzilla.gnome.org/show_bug.cgi?id=731645
2014-07-03 23:07:51 +02:00
Simon Farnsworth
4d2de696a9 vaapipostproc: don't let tmp_rect go out of scope.
A compiler change showed me that tmp_rect went out of scope before
it was used. Move it to the beginning of the function instead.

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

Signed-off-by: Simon Farnsworth <simon.farnsworth@onelan.co.uk>
[added guards for GStreamer 0.10 builds]
Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
2014-07-03 22:59:36 +02:00
Gwenole Beauchesne
700fd242cc build: fix for GStreamer 0.10. 2014-07-03 19:43:04 +02:00
Sreerenj Balachandran
cb9f98f0d5 decoder: h264: add support for NALU "alignment" optimization.
We can avoid scanning for start codes again if the bitstream is fed
in NALU chunks. Currently, we always scan for start codes, and keep
track of remaining bits in a GstAdapter, even if, in practice, we
are likely receiving one GstBuffer per NAL unit. i.e. h264parse with
"nal" alignment.

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

[use gst_adapter_available_fast() to determine the top buffer size]
Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
2014-06-19 15:29:12 +02:00
Gwenole Beauchesne
9d417815ab vaapipostproc: don't crash with dynamic framerate (0/1).
Avoid reaching an assert if dynamic framerates (0/1) are used. One
way to solve this problem is to just stick field_duration to zero.
However, this means that, in presence of interlaced streams, the
very first field will never be displayed if precise presentation
timestamps are honoured.

https://bugzilla.gnome.org/show_bug.cgi?id=729604
2014-06-19 14:51:01 +02:00
Simon Farnsworth
1a2c06a81c vaapipostproc: create filter surface pool if it does not exist yet.
ensure_srcpad_buffer_pool() tries to avoid unnecessarily deleting and
recreating filter_pool. Unfortunately, this also meant it didn't create
it if it did not exist.

Fix it to always create the buffer pool if it does not exist.

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

Signed-off-by: Simon Farnsworth <simon.farnsworth@onelan.co.uk>
2014-06-18 17:30:12 +02:00
Zhao, Halley
faefd62e9b vaapipostproc: reset deinterlacer state when there is a discontinuity.
Reset deinterlacer state, i.e. past reference frames used for advanced
deinterlacing, when there is some discontinuity detected in the course
of processing source buffers.

This fixes support for advanced deinterlacing when a seek occurred.

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

[fixed type of pts_diff variable, fetch previous buffer PTS from the
 history buffer, reduce heuristic for detecting discontinuity]
Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
2014-06-18 17:24:48 +02:00
Gwenole Beauchesne
b3401dbb29 vaapipostproc: add support for crop regions in VPP mode.
Apply video cropping regions stored in GstVideoCropMeta, or in older
GstVaapiSurfaceProxy representation, to VPP pipelines. In non-VPP modes,
the crop meta are already propagated to the output buffers.

https://bugzilla.gnome.org/show_bug.cgi?id=720730
2014-06-18 16:24:52 +02:00
Simon Farnsworth
927fd2e1a8 vaapipostproc: make deinterlace-mode behave as expected.
deinterlace-mode didn't behave in the way you'd expect if you have
past experience of the deinterlace element. There were two bugs:

 1. "auto" mode wouldn't deinterlace "interleaved" buffers, only "mixed".
 2. "force" mode wouldn't deinterlace "mixed" buffers flagged as progressive.

Fix these up, and add assertions and error messages to detect cases that
aren't handled.

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

Signed-off-by: Simon Farnsworth <simon.farnsworth@onelan.co.uk>
Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
2014-06-18 16:24:23 +02:00
Matthieu Bouron
ead38a4d77 vaapidecode: do not discard video info props when the format changed.
gst_video_info_set_format() does not preserve video info properties. In
order to keep important information in the caps such as interlace mode,
framerate, pixel aspect ratio, ... we need to manually copy back those
properties after setting the new video format.

https://bugzilla.gnome.org/show_bug.cgi?id=722276
2014-06-18 13:59:09 +02:00
Matthew Waters
3fbef25e13 vaapidecode: plug a memory leak.
It can happen that there is a pool provided that does not advertise
the vappivideometa. We should unref that pool before using our own.

Discovered with vaapidecode ! {glimagesink,cluttersink}

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

[fixed compilation by adding the missing semi-colon]
Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
2014-06-18 13:58:49 +02:00
Gwenole Beauchesne
abfb5dd06c vaapidecode: parse source data until a frame is obtained.
Parse any pending data until a complete frame is obtained. This is a
memory optimization to avoid expansion of video packets stuffed into
the GstAdapter, and a fix to EOS condition to detect there is actually
pending data that needs to be decoded, and subsequently output.

https://bugzilla.gnome.org/show_bug.cgi?id=731831
2014-06-18 13:47:36 +02:00
Gwenole Beauchesne
5e5d62cac7 vaapisink: fix initialization with "drm" display type.
Force early initializatin of the GstVaapiDisplay so that to make sure
that the sink element display object is presented first to upstream
elements, as it will be correctly featuring the requested display type
by the user.

Otherwise, we might end up in situations where a VA/X11 display is
initialized in vaapidecode, then we try VA/DRM display in vaapisink
(as requested by the "display" property), but this would cause a failure
because we cannot acquire a DRM display that was previously acquired
through another backend (e.g. VA/X11).
2014-06-13 17:42:35 +02:00
Gwenole Beauchesne
eef863f82f plugins: fix initialization with foreign context.
When a new display is settled through GstElement::set_context() (>= 1.2),
or GstVideoContext::set_context() (<= 1.0), then we shall also update the
associated display type.
2014-06-13 17:42:29 +02:00
Gwenole Beauchesne
3af6b0b8a0 plugins: add built-in video parsers as "vaapiparse" element.
The built-in video parsers elements are built into a single DSO named
libgstvaapi_parse.so. The various video parsers could be accessed as
vaapiparse_CODEC.

For now, this only includes a modified version of h264parse so that to
support H.264 MVC encoded streams.
2014-06-13 17:17:07 +02:00
Li Xiaowei
7bdf3fa177 encoder: h264: add initial support for H.264 Stereo High profile.
Add initial support for Subset SPS, Prefix NAL and Slice Extension NAL
for non-base-view streams encoding, and the usual SPS, PPS and Slice
NALs for base-view encoding.

The H.264 Stereo High profile encoding mode will be turned on when the
"num-views" parameter is set to 2. The source (raw) YUV frames will be
considered as Left/Right view, alternatively.

Each of the two views has its own frames reordering pool and reference
frames list management system. Inter-view references are not supported
yet, so the views are encoded independently from each other.

Signed-off-by: Li Xiaowei <xiaowei.a.li@intel.com>
[limited to Stereo High profile per the definition of MAX_NUM_VIEWS]
Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
2014-06-02 18:25:13 +02:00
Sreerenj Balachandran
ee6d1b7bd1 build: fix conditional compilation of VP8 decoder.
https://bugzilla.gnome.org/show_bug.cgi?id=729170

[added check for VASliceParameterBufferBase fields]
Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
2014-05-09 14:41:52 +02:00
Gwenole Beauchesne
de02a5c190 build: fix make dist with certain conditionals not met.
Fix generation of source tarballs when certain conditionals are not
met. e.g. always include all buildable codecparsers sources in the
distribution tarball, fix plug-in element sources set to include X11
and encoder bits.
2014-04-21 18:02:21 +02:00
Zhao, Halley
029bae0b6a Add initial VP8 decoder.
https://bugzilla.gnome.org/show_bug.cgi?id=722761

[complete overhaul, fixed support for resolution changes]
Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
2014-04-18 20:03:44 +02:00
Gwenole Beauchesne
6bf3c1863c legal: update copyright notice dates. 2014-01-22 19:02:35 +01:00
Gwenole Beauchesne
1c95903b98 legal: add per-file authorship information. 2014-01-22 18:49:20 +01:00
Holger Kaelberer
b1d3f7d4c0 vaapisink: set csc render flags from sinkpad caps.
This maps GstVideoColorimetry information in vaapisink's sinkpad caps
to GST_VAAPI_COLOR_STANDARD_* flags, if per-buffer information was not
available.

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

[factored out code, added SMPTE240M, handle per-buffer flags]
Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
2014-01-15 14:24:32 +01:00
Gwenole Beauchesne
751aa05937 surface: rework render flags.
Pack render flags per category and provide more flags into the color
standard category. In particular, cover for SMPTE-240M.
2014-01-15 13:53:42 +01:00
Zhao, Halley
467bf95c09 vaapipostproc: add support for colorbalance filters.
Add support for hue, saturation, brightness and constrat adjustments.
Also fix cap info local copy to match the really expected cap subtype
of interest.

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

Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
2014-01-15 11:49:49 +01:00
Zhao, Halley
db5465c2d6 vaapipostproc: fix support for "sharpen" filter.
Fix copy/paste error when submitting the "sharpen" value to the
GstVaapiFilter instance.

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

Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
2014-01-15 11:42:15 +01:00
Holger Kaelberer
f8666e2cae vaapisink: fix display initialization in GstVideoOverlay implementation.
When gst_vaapisink_video_overlay_set_window_handle() is called early,
before the pipeline has been set to PLAYING, the display has not yet
been initialized and _PLUGIN_BASE_DISPLAY_TYPE() is not yet
up-to-date. For this reason the foreign XID is not attached.

Now _ensure_display() is called earlier.

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

Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
2014-01-15 11:07:05 +01:00
Sreerenj Balachandran
dd6751ed47 vaapisink: expose the raw video formats in static caps template.
Expose all raw video formats in the static caps template since the
vaapisink is supporting raw data. We will get the exact set of formats
supported by the driver dynamically through the _get_caps() routine.

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

Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
2014-01-15 11:06:01 +01:00
Matthieu Bouron
a674d9eff2 vaapidecode: query downstream caps features like GLTextureUploadMeta.
Fix vaapidecode to correctly report caps features downstream, when
a custom pipeline is built manually.

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

Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
2014-01-14 19:14:41 +01:00
Matthieu Bouron
cb81acd48c vaapidecode: add system memory caps to template caps.
Since vaapidecode provides buffer that can be mapped as regular memory,
those caps should be added to the template caps. That only applies to
GStreamer >= 1.2.

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

Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
2014-01-14 19:14:41 +01:00
Wind Yuan
d2f6274f31 vaapidecode: fix hang on SIGINT.
vaapidecode hangs when pipeline is stopped without any EOS, e.g. when
<Ctrl>+C is pressed, thus causing the srcpad task to keep running and
locked. This fixes a deadlock on state change from PAUSED to READY.

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

Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
2014-01-14 19:14:41 +01:00
Wind Yuan
830566c17e vaapiencode: fix possible hang on SIGINT.
vaapiencode might hang when the pipeline is stopped without any EOS,
e.g. when <Ctrl>+C is pressed, thus causing the srcpad task to keep
running and locked. This fixes a possible deadlock on state change
from PAUSED to READY.

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

Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
2014-01-14 19:14:41 +01:00
Gwenole Beauchesne
d3b672411d vaapiencode: fix typo in error message.
Fix incomplete error message in gst_vaapiencode_push_frame().
2014-01-14 19:14:41 +01:00
Gwenole Beauchesne
ef9819ecf4 plugins: add helpers to create video caps with features.
Add gst_vaapi_video_format_new_template_caps_with_features() helper
function to add the supplied caps feature string on GStreamer >= 1.2.

Add gst_vaapi_find_preferred_caps_feature() helper function to discover
the "best" caps feature to use for the supplied pad. In practice, we
will always favor memory:VASurface first, then meta:GLTextureUploadMeta,
and finally the system memory caps.

https://bugzilla.gnome.org/show_bug.cgi?id=719372
2014-01-14 19:14:41 +01:00
Matthieu Bouron
b065ae7d7f plugins: don't apply overlay composition in GLTextureUpload function.
The GLTextureUpload function is not in charge of doing the overlay
composition if any.

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

Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
2014-01-14 19:14:41 +01:00
Gwenole Beauchesne
bdf91aa765 encoder: h264: allow target decoder constraints.
Allow user to precise the largest profile to use for encoding due
to target decoder constraints. For instance, if CABAC entropy coding
mode is requested by "constrained-baseline" profile only is desired,
then an error is returned during codec configuration.

Also make sure that the suitable profile we derived actually matches
what the HW can cope with.

https://bugzilla.gnome.org/show_bug.cgi?id=719694
2014-01-13 17:31:55 +01:00
Gwenole Beauchesne
45732dcc83 encoder: h264: clean-ups.
Various clean-ups to improve consistency and readability: rename some
variables, drop unused macro definitions, drop initialization of vars
that are zero-initialized from the base class, drop un-necessary casts.
2014-01-13 17:31:55 +01:00
Gwenole Beauchesne
5394c75461 encoder: add video codec-state API.
Add interface to communicate the encoder resolution and related info
like framerate, interlaced vs. progressive, etc. This new interface
supersedes gst_vaapi_encoder_set_format() and doesn't use any GstCaps
but rather use GstVideoCodecState.

Note that gst_vaapi_encoder_set_codec_state() is also a synchronization
point for codec config. This means that the encoder is reconfigured
there to match the latest properties.
2014-01-13 17:31:55 +01:00
Gwenole Beauchesne
2c4fde0eae vaapiencode: don't crash on NULL encoder on _finish().
Don't try to destroy an encoder, in GstVideoEncoder::finish() handler,
if it was not created in the first place. Return "not-negotiated" error
since this means we did not even reach GstVideoEncoder::set_format(),
where the encoder could have been created.

This fixes a crash when the vaapiencode_* plug-in elements get deallocated
and that we failed to negotiate either pad.

https://bugzilla.gnome.org/show_bug.cgi?id=719704
2014-01-13 17:31:55 +01:00
Gwenole Beauchesne
ea7c1d87c5 vaapiencode: use more GstVaapiPluginBase facilities.
Avoid duplication of pad references or query functions since they are
provided through the GstVaapiPluginBase object.
2014-01-13 17:31:55 +01:00
Gwenole Beauchesne
449ac54348 vaapiencode: fix negotiation process of output caps.
The specified caps in gst_video_encoder_set_output_state() function
arguments should not contain any resolution, pixel-aspect-ratio,
framerate, codec-data et al. Those rather should be set through the
returned GstVideoCodecState. This means that output caps creation
could be delayed until before gst_video_encoder_finish_frame() is
called.

This greatly simplifies the GstVideoEncoder::set_format() callback
by the way.
2014-01-13 17:31:55 +01:00
Gwenole Beauchesne
37fa6a8a3d vaapiencode: make GstVaapiEncode an abstract type.
Make base GstVaapiEncode class an abstract type so that we cannot
create an instance from it without going through any of the codec
specific derived class.
2014-01-13 17:31:55 +01:00
Gwenole Beauchesne
85ce893faa vaapiencode: rename a few member functions.
Rename a few member functions to make them more consistent:
- alloc_encoder(): now reduced to allocate the encoder object only;
- alloc_buffer(): allocate buffer from srcpad, and copy bitstream.
2014-01-13 17:31:55 +01:00
Gwenole Beauchesne
a43d06dcf5 vaapiencode: update for new properties API.
Update MPEG-2 and H.264 encode elements to cope with the new core
libgstvaapi properties API. i.e. all configurable properties are now
directly handled at the GstVaapiEncoder level.

Besides, this also makes sure to not use or modify the GstVaapiEncoder
private definitions directly. Private data need to remain private.

https://bugzilla.gnome.org/show_bug.cgi?id=719529
2014-01-13 17:31:55 +01:00
Gwenole Beauchesne
70b3600f11 encoder: add bitrate API.
Add gst_vaapi_encoder_set_bitrate() interface to allow the user control
the bitrate for encoding. Currently, changing this parameter is only
valid before the first frame is encoded. Should the value be modified
afterwards, then GST_VAAPI_ENCODER_STATUS_ERROR_OPERATION_FAILED is
returned.

https://bugzilla.gnome.org/show_bug.cgi?id=719529
2014-01-13 17:31:54 +01:00
Gwenole Beauchesne
a24c52e4d0 encoder: add rate control API.
Add gst_vaapi_encoder_set_rate_control() interface to request a new
rate control mode for encoding. Changing the rate control mode is
only valid prior to encoding the very first frame. Afterwards, an
error ("operation-failed") is issued.

https://bugzilla.gnome.org/show_bug.cgi?id=719529
2014-01-13 17:31:54 +01:00
Gwenole Beauchesne
076d75aeb8 vaapiencode: fix indentation. 2014-01-13 17:31:54 +01:00
Gwenole Beauchesne
01af353116 encoder: fix indentation. 2014-01-13 17:31:54 +01:00
Matthieu Bouron
231a067cdd plugins: do not free debug category in finalize method.
Fixes a crash when multiple vaapidecode elements are finalized since
the debug category is created once in the class init method.

This is a regression from git commit 7e58d60.

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

Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
2014-01-06 10:11:54 +01:00
Gwenole Beauchesne
33bb859228 Fix printf()-like formats.
Fix formts for various GST_DEBUG et al. invocations. More precisely,
make size_t arguments use the %zu format specifier accordingly; force
XID formats to be a 32-bit unsigned integer; and fix the format used
for gst_vaapi_create_surface_with_format() error cases since we have
been using strings nowadays.
2014-01-06 10:04:05 +01:00
Gwenole Beauchesne
7f88fdcc03 download: use GstVideoInfo facilities to build output caps.
Use standard GstVideoInfo related functions to build the output caps,
thus directly preserving additional fields as needed, instead of
manually copying them over through gst_vaapi_append_surface_caps().

Also ensure that the input caps are fixated first.
2013-12-21 12:35:24 +01:00
Gwenole Beauchesne
113bd3a5f2 plugins: factor out construction of template caps.
Add new helper functions to build video template caps.
- gst_vaapi_video_format_new_template_caps():
  create GstCaps with size, frame rate and PAR to full range
- gst_vaapi_video_format_new_template_caps_from_list():
  try to create a "simplified" list from the supplied formats
2013-12-21 12:35:24 +01:00
Gwenole Beauchesne
528b5adc5a plugins: factor out construction of GValue from GstVideoFormat.
Add new helper functions to build GValues from GstVideoFormat:
- gst_vaapi_value_set_format():
  build a GValue from the supplied video format
- gst_vaapi_value_set_format_list():
  build a GValue list from the supplied array of video formats
2013-12-21 12:35:24 +01:00
Gwenole Beauchesne
b80257389d plugins: re-indent common and video context creation utils. 2013-12-21 12:35:23 +01:00
Gwenole Beauchesne
c5581298fb display: don't use GstCaps for decode or encode profiles list.
Replace gst_vaapi_display_get_{decode,encode}_caps() APIs with more
more convenient APIs that return an array of GstVaapiProfile instead
of GstCaps: gst_vaapi_display_get_{decode,encode}_profiles().
2013-12-20 17:16:58 +01:00
Gwenole Beauchesne
c4ca08a8d6 display: don't use GstCaps for image or subpicture formats list.
Replace gst_vaapi_display_get_{image,subpicture}_caps() APIs, that
returned GstCaps, with more convenient APIs that return an array of
GstVideoFormat: gst_vaapi_display_get_{image,subpicture}_formats().
2013-12-20 17:16:58 +01:00
Gwenole Beauchesne
690e85ff8e plugins: fix permissions for certain files.
Drop the execute bit for gstvaapiuploader.c and gstvaapipostproc.[ch]
files.
2013-12-20 17:16:12 +01:00
Matthieu Bouron
bf8f244de3 plugins: implement GLTextureUploadMeta user data copy.
Makes the copies of a buffer reference their own GLTextureUploadMeta
user data and prevent the original buffer accessing already freed
memory if its copies has been released and freed.

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

[Propagate the original meta texture to the copy too]
Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
2013-12-18 18:34:10 +01:00
Gwenole Beauchesne
e3dcd33114 plugins: factor out support for raw YUV buffers on sink pads.
Factor out propose_allocation() hooks, creation of video buffer pool
for the sink pad, conversion from raw YUV buffers to VA surface backed
buffers. Update vaapidecode, vaapiencode and vaapipostproc to cope
with the new GstVaapiPluginBase abilities.
2013-12-18 16:38:57 +01:00
Gwenole Beauchesne
b324fc6add plugins: factor out pad caps. 2013-12-18 16:38:57 +01:00
Gwenole Beauchesne
01a3fc44c0 plugins: factor out video context sharing code. 2013-12-18 16:38:57 +01:00
Gwenole Beauchesne
e5f066b719 plugins: factor out GstImplementsInterface. 2013-12-18 16:38:57 +01:00
Gwenole Beauchesne
fad3f538bc plugins: check type of display obtained from neighbours.
Fix display creation code to check that any display obtained from a
neighbour actually has the type we expect. Note: if display type is
set to "any", we can then accept any VA display type.
2013-12-18 16:38:57 +01:00
Gwenole Beauchesne
6f2dfb71e6 plugins: factor out display creation process.
Move common VA display creation code to GstVaapiPluginBase, with the
default display type remaining "any". Also add a "display-changed"
hook so that subclasses could perform additional tasks when/if the
VA display changed, due to a new display type request for instance.

All plug-ins are updated to cope with the new internal APIs.
2013-12-18 16:38:57 +01:00
Gwenole Beauchesne
7e58d60854 plugins: add new base object, store display in there.
Introduce a new GstVaapiPluginBase object that will contain all common
data structures and perform all common tasks. First step is to have a
single place to hold VA displays.

While we are at it, also make sure to store and subsequently release
the appropriate debug category for the subclasses.
2013-12-18 16:38:57 +01:00
Gwenole Beauchesne
61f6cbffc6 plugins: fix GLTextureUploadMeta to work with different texture ids.
The GLTextureUploadMeta implementation assumed that for each upload()
sequence, the supplied texture id is always the same as the one that
was previously cached into the underlying GstVaapiTexture. Cope with
any texture id change the expense to recreate the underlying VA/GLX
resources.

https://bugzilla.gnome.org/show_bug.cgi?id=719643
2013-12-11 15:30:51 +01:00
Gwenole Beauchesne
c2eabc17dd plugins: allow builds without GLX enabled for GStreamer 1.2.
Don't try to build GLTextureUploadMeta related code if GLX is not
enabled during GStreamer >= 1.2 builds.
2013-12-11 15:30:51 +01:00
Matthieu Bouron
6b6c10d94d plugins: request GLTextureUpload meta on buffers in the buffer pool.
Requesting the GLTextureUpload meta on buffers in the bufferpool
prevents such metas from being de-allocated when buffers are released
in the sink.

This is particulary useful in terms of performance when using the
GLTextureUploadMeta API since the GstVaapiTexture associated with
the target texture is stored in the meta.

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

Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
2013-12-11 15:30:51 +01:00
Gwenole Beauchesne
c7673f1cd6 plugins: robustify GstVideoGLTextureUploadMeta implementation.
Make GstVideoGLTextureUploadMeta::upload() implementation more robust
when the GstVaapiTexture associated with the supplied texture id could
not be created.
2013-12-11 15:30:51 +01:00
Gwenole Beauchesne
2f5e5f0784 encoder: clean-ups and document public APIs.
Clean public APIs up so that to better align with the decoder APIs.
Most importantly, gst_vaapi_encoder_get_buffer() is changed to only
return the VA coded buffer proxy. Also provide useful documentation
for the public APIs.
2013-12-04 19:14:38 +01:00
Gwenole Beauchesne
038149b69b encoder: refactor status codes.
Drop obsolete or unused status codes. Align some status codes with the
decoder counterparts.
2013-12-04 19:14:38 +01:00
Gwenole Beauchesne
0fb7c60508 encoder: rework GstVaapiCodedBuffer and related proxy.
Refactor the GstVaapiCodedBuffer APIs so that to more clearly separate
public and private interfaces. Besides, the map/unmap APIs should not
be exposed as is but appropriate accessors should be provided instead.

* GstVaapiCodedBuffer: VA coded buffer abstraction
- gst_vaapi_coded_buffer_get_size(): get coded buffer size.
- gst_vaapi_coded_buffer_copy_into(): copy coded buffer into GstBuffer

* GstVaapiCodedBufferPool: pool of VA coded buffer objects
- gst_vaapi_coded_buffer_pool_new(): create a pool of coded buffers of
  the specified max size, and bound to the supplied encoder

* GstVaapiCodedBufferProxy: pool-allocated VA coded buffer object proxy
- gst_vaapi_coded_buffer_proxy_new_from_pool(): create coded buf from pool
- gst_vaapi_coded_buffer_proxy_get_buffer(): get underlying coded buffer
- gst_vaapi_coded_buffer_proxy_get_buffer_size(): get coded buffer size

Rationale: more optimized transfer functions might be provided in the
future, thus rendering the map/unmap mechanism obsolete or sub-optimal.

https://bugzilla.gnome.org/show_bug.cgi?id=719775
2013-12-04 19:14:38 +01:00
Gwenole Beauchesne
7a33165436 plugins: fix reference leaks of VA display objects.
Fix GstElement::set_context() implementation for all plug-in elements
to avoid leaking an extra reference to the VA display, thus preventing
correct cleanup of VA resources in GStreamer 1.2 builds.
2013-11-29 14:02:52 +01:00
Gwenole Beauchesne
16751205a2 plugins: simplify gst_vaapi_ensure_display().
Return earlier if the creation of a VA display failed. Likewise, simplify
gst_vaapi_video_context_propagate() now that we are guaranteed to have a
valid VA display.
2013-11-29 13:56:12 +01:00
Gwenole Beauchesne
84b3f84925 plugins: fix memory leaks through GstVideoMeta maps.
When GstVideoMeta maps were used, the supporting functions incorrectly
used gst_buffer_get_memory() instead of gst_buffer_peek_memory(), thus
always increasing the associated GstMemory reference count and giving
zero chance to actually release that, and subsequently the VA display.
2013-11-28 19:08:28 +01:00
Gwenole Beauchesne
9ab6037847 plugins: use G_PARAM_STATIC_STRINGS.
This avoids a few string copies during initialization.
2013-11-28 17:35:44 +01:00
Gwenole Beauchesne
3324cdfb61 plugins: simplify VA video meta to only reference surface proxies.
Simplify GstVaapiVideoMeta to only hold a surface proxy, which is
now allocated from a surface pool. This also means that the local
reference to the VA surface is also gone, as it could be extracted
from the associated surface proxy.
2013-11-28 17:32:18 +01:00
Gwenole Beauchesne
d45658ba5a plugins: drop obsolete functions.
Drop the following functions that are not longer used:
- gst_vaapi_video_buffer_new_with_surface()
- gst_vaapi_video_meta_new_with_surface()
- gst_vaapi_video_meta_set_surface()
- gst_vaapi_video_meta_set_surface_from_pool()
2013-11-28 17:32:18 +01:00
Gwenole Beauchesne
b04c75848a plugins: allow VA video meta to be allocated from surface proxy pools.
Fix gst_vaapi_video_meta_new_from_pool() to allocate VA surface proxies
from surface pools instead of plain VA surfaces. This is to simplify
allocations now that surface proxies are created from a surface pool.
2013-11-28 17:32:18 +01:00
Gwenole Beauchesne
30f382fcdf vaapiencode: optimize _handle_frame() to avoid extra allocation.
Optimize gst_vaapiencode_handle_frame() to avoid extra memory allocation,
and in particular the GstVaapiEncObjUserData object. i.e. directly use
the VA surface proxy from the source buffer. This also makes the user
data attached to the GstVideoCodecFrame more consistent between both
the decoder and encoder plug-in elements.
2013-11-28 17:32:18 +01:00
Gwenole Beauchesne
081ff63f9a vaapiencode: fix memory leaks in _push_frame() on error.
Simplify gst_vaapiencode_push_frame(), while also removing the call
to gst_video_encoder_negotiate() since this is implicit in _finish()
if caps changed. Also fixed memory leaks that occured on error.
2013-11-28 17:32:17 +01:00
Gwenole Beauchesne
8116d8a50e vaapiencode: additional clean-ups.
Constify pointers wherever possible. Drop unused variables, and use
consistent variable names. Fix gst_vaapiencode_h264_allocate_buffer()
to correctly report errors, especially when in-place conversion from
bytestream to avcC format failed.
2013-11-28 15:17:42 +01:00
Gwenole Beauchesne
d759fe34e6 vaapiencode: move common properties to base class.
Move "rate-control" mode and "bitrate" properties to the GstVaapiEncode
base class. The actual range of supported rate control modes is currently
implemented as a plug-in element hook. This ought to be determined from
the GstVaapiEncoder object instead, i.e. from libgstvaapi.
2013-11-28 14:05:33 +01:00
Gwenole Beauchesne
1a4b3c3b22 vaapiencode: fix plugin description and debug name.
Align the plug-in debug category to its actual name. i.e. enable debug
logs through vaapiencode_<CODEC> where <CODEC> is mpeg2, h264, etc. Fix
the plug-in element description to make it more consistent with other
VA-API plug-ins.
2013-11-28 10:54:36 +01:00
Gwenole Beauchesne
bc020c05f9 vaapiencode: add initial support for GStreamer 0.10. 2013-11-27 17:23:56 +01:00
Gwenole Beauchesne
207264abc4 vaapiencode: fix error handling while allocating output buffers.
Fix default GstVideoEncoder::allocate_buffer() implementation to properly
unmap the coded buffer prior to returning an error.
2013-11-26 17:26:44 +01:00
Gwenole Beauchesne
a6b8f94470 vaapiencode: fix error handling in _finish() hook.
Fix GstVideoEncoder::finish() implementation to really return possible
errors instead of GST_FLOW_OK. That is, fix check for timeout status.
2013-11-26 17:11:22 +01:00
Gwenole Beauchesne
e01d48feba vaapiencode: minor clean-ups.
Add a GST_VAAPIENCODE_CAST() helper to avoid run-time checks against
the GObject type system. We are guaranteed to only deal with the same
plug-in element object.
2013-11-26 17:08:31 +01:00
Gwenole Beauchesne
84af151796 vaapiencode: fix support for raw YUV sink buffers.
Allow vaapiencode plug-in elements to encode from raw YUV buffers.
The most efficient way to do so is to let the vaapiencode elements
allocate a buffer pool, and subsequently buffers from it. This means
that upstream elements are expected to honour downstream pools.

If upstream elements insist on providing their own allocated buffers
to the vaapiencode elements, then it possibly would be more efficient
to insert a vaapipostproc element before the vaapiencode element.
This is because vaapipostproc currently has better support than other
elements for "foreign" raw YUV buffers.
2013-11-26 15:55:09 +01:00
Gwenole Beauchesne
139c99bb77 vaapiencode: fix support for GStreamer 1.2. 2013-11-26 15:12:59 +01:00
Wind Yuan
3e96f10cf2 vaapiencode: initial port to GStreamer 1.2.
Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
2013-11-26 14:32:21 +01:00
XuGuangxin
2e356b0f7e plugins: add mpeg2 encoder element.
Add GstVaapiEncodeMPEG2 element object. The actual plug-in element
is called "vaapiencode_mpeg2".

Valid properties:
- rate-control: rate control mode (default: cqp - constant QP)
- bitrate: desired bitrate in kbps (default: auto-calculated)
- key-period: maximal distance between two key frames (default: 30)
- max-bframes: number of B-frames between I and P (default: 2)
- quantizer: constant quantizer (default: 8)

Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
2013-11-24 16:52:05 +01:00
Wind Yuan
f1c33feef9 plugins: add h264 encoder element.
Add GstVaapiEncodeH264 element object. The actual plug-in element
is called "vaapiencode_h264".

Valid properties:
- rate-control: rate control mode (default: none)
- bitrate: desired bitrate in kbps (default: auto-calculated)
- key-period: maximal distance between two key frames (default: 30)
- num-slices: number of slices per frame (default: 1)
- max-bframes: number of B-frames between I and P (default: 0)
- min-qp: minimal quantizer (default: 1)
- init-qp: initial quantizer (default: 26)

Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
2013-11-24 16:52:05 +01:00
Wind Yuan
06ea8ba92b plugins: add base encoder element.
vaapiencode element is based on GstVideoEncoder APIs.

Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
2013-11-24 16:52:05 +01:00
Gwenole Beauchesne
e713d43379 build: fix for Wayland headers not in standard include dirs.
Fix build when Wayland headers don't live in plain system include dirs
like /usr/include but rather in /usr/include/wayland for instance.

Original patch written by Dominique Leuenberger <dimstar@opensuse.org>

https://bugzilla.gnome.org/show_bug.cgi?id=712282
2013-11-22 11:28:09 +01:00
Gwenole Beauchesne
922a04b734 vaapostproc: fix memory leaks.
Destroy VPP output surface pool on exit. Also avoid a possible crash
in double-free situation caused by insufficiently reference counted
array of formats returned during initialization.
2013-11-22 11:15:57 +01:00
Gwenole Beauchesne
7a464ba015 vaapipostproc: fix and optimize advanced deinterlacing mode.
Fix advanced deinterlacing modes with VPP to track only up to 2 past
reference buffers. This used to be 3 past reference buffers but this
doesn't fit with the existing decode pipeline that only has 4 extra
scratch surfaces.

Also optimize references tracking to be only enabled when needed, i.e.
when advanced deinterlacing mode is used. This means that we don't
need to track past references for basic bob or weave deinterlacing.
2013-11-22 10:27:19 +01:00
Gwenole Beauchesne
1d1f18bcbe vaapipostproc: fix "mixed" mode deinterlacing.
In "mixed" interlaced streams, the buffer contains additional flags that
specify whether the frame contained herein is interlaced or not. This means
that we can alternatively get progressive or interlaced frames. Make sure
to disable deinterlacing at the VPP level when the source buffer is no longer
interlaced.
2013-11-22 10:04:45 +01:00
Gwenole Beauchesne
98ac557e87 vaapipostproc: fix memory leaks with advanced deinterlacing.
Fix memory leaks with advanced deinterlacing, i.e. when we keep track
of past buffers. Completely reset the deinterlace state, thus destroying
any buffer currently held, on _start(), _stop() and _destroy().
2013-11-22 09:49:30 +01:00
Gwenole Beauchesne
c516311a1a legal: update copyright notice dates. 2013-11-22 06:39:20 +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
9968661ffd vaapipostproc: add initial support for GStreamer 1.2.
Port vaapipostproc element to GStreamer 1.2. Support is quite minimal
right now so that to cope with auto-plugging issues/regressions. e.g.
this happens when the correct set of expected caps are being exposed.
This means that, currently, the proposed caps are not fully accurate.
2013-11-21 23:08:02 +01:00
Halley Zhao
ef8f5defd2 vaapipostproc: add support for denoise and sharpen filters.
Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
2013-11-21 23:08:02 +01:00
Gwenole Beauchesne
c8bea66d33 vaapipostproc: add support for advanced deinterlacing.
Add initial support for advanced deinterlacing. The history buffer
size is arbitrarily set to 3 references for now.
2013-11-21 23:08:02 +01:00
Gwenole Beauchesne
49e2d040fa vaapipostproc: fix deinterlacing with VPP.
Fix basic deinterlacing flags provided to gst_vaapi_set_deinterlacing()
for the first field. Render flags were supplied instead of the actual
deinterlacing flags (deint_flags).
2013-11-21 23:08:02 +01:00
Gwenole Beauchesne
a3af786c78 vaapipostproc: fix transform caps.
Fix GstBaseTransform::transform_caps() implementation to always return
the complete set of allowed sink pad caps (unfixated) even if the src
pad caps we are getting are fixated. Rationale: there are just so many
possible combinations, and it was wrong to provide a unique set anyway.

As a side effect, this greatly simplifies the ability to derive src pad
caps from fixated sink pad caps.
2013-11-21 23:08:02 +01:00
Gwenole Beauchesne
06c7fde8e0 filter: fix semantics of deinterlacing flags.
Fix deinterlacing flags to make more sense. The TFF (top-field-first)
flag is meant to specify the organization of reference frames used in
advanced deinterlacing modes. Introduce the more explicit flag TOPFIELD
to specify that the top-field of the supplied input surface is to be
used for deinterlacing. Conversely, if not set, this means that the
bottom field of the supplied input surface will be used instead.
2013-11-21 23:08:02 +01:00
Gwenole Beauchesne
a6436f27d5 vaapidecode: fix decoder flush.
There are situations where gst_video_decoder_flush() is called, and
this subsequently produces a gst_video_decoder_reset() that kills the
currently active GstVideoCodecFrame. This means that it no longer
exists by the time we reach GstVideoDecoder::finish() callback, thus
possibly resulting in a crash if we assumed spare data was still
available for decode (current_frame_size > 0).

Try to honour GstVideoDecoder::reset() behaviour from GStreamer 1.0
that means a flush, thus performing the actual operations there like
calling gst_video_decoder_have_frame() if pending data is available.
2013-11-21 11:08:23 +01:00
Gwenole Beauchesne
af4785b722 vaapidecode: fix dead-locks with decoder task.
Review all interactions between the main video decoder stream thread
and the decode task to derive a correct sequence of operations for
decoding. Also avoid extra atomic operations that become implicit under
the GstVideoDecoder stream lock.
2013-11-21 11:08:23 +01:00
XuGuangxin
6e85f08e33 vaapidecode: fix hard reset for seek cases.
Fix hard reset for seek cases by flushing the GstVaapiDecoder queue
and completely purge any decoded output frame that may come out from
it. At this stage, the GstVaapiDecoder shall be in a complete clean
state to start decoding over new buffers.

Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
2013-11-21 11:08:23 +01:00
XuGuangxin
367944ba32 vaapidecode: drop decode timeout, always wait for a free surface.
vaapidecode used to wait up to one second past the expected time of
presentation for the last decoded frame. This is not realistic in
practice when it comes to video pause/resume. Changed behaviour to
unconditionnally wait for a free VA surface prior to continuing the
decoding. The decode task will continue pushing the output frames to
the downstream element while also reporting errors at the same time
to the main thread.

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

Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
2013-11-21 11:08:23 +01:00
Gwenole Beauchesne
7e8470e1ec vaapidecode: fix srcpad caps for GStreamer 1.2.
The srcpad caps exposed for GStreamer 1.2 were missing any useful info
like framerate, pixel-aspect-ratio, interlace-mode et al. Not to mention
that it relied on possibly un-initialized data. Fix srcpad caps to be
initialized from a sanitized copy of GstVideoDecoder output state caps.

Note: the correct way to expose the srcpad caps triggers an additional
issue in core GStreamer auto-plugging capabilities as the correct caps
to be exposed should be format=ENCODED with memory:VASurface caps feature
at the minimum. In some situations, we could determine the underlying
VA surface format, but this is not always possible. e.g. cases where it
is not allowed to expose the underlying VA surface data, or when the
VA driver implementation cannot actually provide such information.
2013-11-21 11:08:23 +01:00
Gwenole Beauchesne
d556c0a37a plugins: streamline VA formats exposed in caps to a realistic set.
Currently, the decoder only supports YUV 4:2:0 output. So, expose the
output formats for GStreamer 1.2 in caps to a realistic subset. This
means NV12, I420 or YV12 but also ENCODED if we cannot determine the
underlying VA surface format, or if it is actually not allowed to get
access to the surface contents.
2013-11-21 11:08:23 +01:00
Gwenole Beauchesne
b4eb1dcd42 plugins: expose the expected format for GstVideoGLTextureUploadMeta.
Fix vaapidecode srcpad caps to only expose RGBA video format for the
meta:GstVideoGLTextureUploadMeta feature. That's only what is supported
so far. Besides, drop this meta from the vaapisink sinkpad caps since
we really don't support that for rendering.

https://bugzilla.gnome.org/show_bug.cgi?id=711828
2013-11-21 11:08:23 +01:00
Wind Yuan
b62bd57bda vaapipostproc: fix support for raw YUV data upload on GStreamer 1.0.
Fix raw YUV data uploaded as in the following pipeline:
$ gst-launch-1.0 filesrc video.yuv ! videoparse ! vaapipostproc ! vaapisink

The main reason why it failed was that the videoparse element simply
allocates GstBuffer with raw data chunk'ed off the sink pad without
any prior knowledge of the actual frame info. i.e. it basically just
calls gst_adapter_take_buffer().

We could avoid the extra copy performed in vaapipostproc if the videoparse
element was aware of the downstream pool and bothers copying line by
line, for each plane. This means that, for a single frame per buffer,
the optimizatin will be to allocate the video buffer downstream, map
it, and copy each line that is coming through until we need to fills
in the successive planes.

Still, optimized raw YUV uploads already worked with the following:
$ gst-launch-1.0 videotestsrc ! vaapipostproc ! vaapisink

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

[clean-ups, fixed error cases to unmap and unref outbuf]
Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
2013-11-18 15:05:25 +01:00
Gwenole Beauchesne
cc055b72ce vaapipostproc: try to downgrade deinterlace-method when needed.
If the currently selected deinterlacing method is not supported by the
underlying hardware, then try to downgrade the method to a supported one.
At the minimum, basic bob-deinterlacing shall always be supported.
2013-11-16 07:02:24 +01:00
Gwenole Beauchesne
be7a2ed64c vaapipostproc: add initial support for deinterlacing with VPP.
Allow basic bob-deinterlacing to work when VPP is enabled. Currently,
this only covers bob-deinterlacing when the output pixel format is
explicitly set.
2013-11-15 19:36:50 +01:00
Gwenole Beauchesne
2aab27b8de vaapipostproc: fix build on 64-bit platforms with GStreamer 0.10.
The size argument for GstBaseTransform::transform_size() hook is a
guint in GStreamer 0.10 APIs but a gsize in GStreamer >= 1.0.X APIs.
2013-11-15 19:36:50 +01:00
Gwenole Beauchesne
e7544dc57e vaapipostproc: add initial support for scaling.
Add initial support for basic scaling with size specified through the
"width" and "height" properties. If either user-provided dimension is
zero and "force-aspect-ratio" is set to true (the default), then the
other dimension is scaled to preserve the aspect ratio.
2013-11-15 19:36:50 +01:00
Gwenole Beauchesne
cf69e7269c vaapipostproc: add initial support for color conversion.
If VPP is available, we always try to implicitly convert the source
buffer to the "native" surface format for the underlying accelerator.
This means that no optimization is performed yet to propagate raw YUV
buffers to the downstream element as is, if VPP is available. i.e. it
will always cause a color conversion.
2013-11-15 19:36:50 +01:00
Gwenole Beauchesne
6d86caa9d1 vaapipostproc: fix bug when user disabled deinterlacing.
Fix pipeline error / hang when the user disabled deinterlacing through
the deinterlace-mode=disabled property setting.
2013-11-15 19:36:50 +01:00
Gwenole Beauchesne
d71008210d vaapipostproc: factor out operations to be applied into flags.
Even if we only support deinterlacing for now, use flags to specify
which filters are to be applied to each frame we receive in transform().
This is preparatory work for integrating new filters.
2013-11-15 19:36:50 +01:00
Gwenole Beauchesne
ae5e5be80b vaapipostproc: add support for raw YUV video source buffers.
Allow video processing from raw YUV buffers coming from the sink pad,
while still producing a VA surface for the downstream elements.
2013-10-09 18:30:06 +02:00
Gwenole Beauchesne
f0d50cfbc2 vaapipostproc: add support for "mixed" interlace mode.
Add support for "mixed" interlace-mode, whereby the video frame buffer
shall be deinterlaced only if its flags mention that's actually an
interlaced frame buffer.
2013-10-09 18:30:06 +02:00
Gwenole Beauchesne
f6f24bfc55 vaapipostproc: rework plug-in element.
Rewrite the vaapipostproc plug-in element so that it derives from
GstBaseTransform, thus simplifying the caps negotiation process.
2013-10-09 18:30:06 +02:00
Gwenole Beauchesne
399e887c4f plugins: fix and optimize check for buffer pool allocator params.
Reset the buffer pool allocator only if the config caps changed in a
sensible way: format or resolution change. i.e. don't bother with
other caps like colorimetry et al. as this doesn't affect the way to
allocate VA surfaces or images.
2013-10-09 18:30:06 +02:00
Gwenole Beauchesne
77b2d88452 plugins: enable memory maps for read & write with direct-rendering.
Enable read and write mappings only if direct-rendering is supported.
Otherwise, this means that we may need to download data from the VA
surface first for correctness, even if the VA surface doesn't need to
be read at all. i.e. sometimes, READWRITE mappings are meant for
surfaces that are written to first, and read afterwards for further
processing.

https://bugzilla.gnome.org/show_bug.cgi?id=704078
2013-10-09 18:30:06 +02:00
Gwenole Beauchesne
847e3efb4d plugins: fix check for direct-rendering support.
Fix check for direct-rendering if the creation of VA surfaces with
an explicit pixel format is not support, e.g. VA-API < 0.34.0, and
that we tried to allocate a VA surface based on the corresponding
chroma type. i.e. in that particular case, we have to make sure that
the derived image has actually the expected format.
2013-10-09 18:30:06 +02:00
Gwenole Beauchesne
f361d4a23d plugins: fix buffer pool reset_buffer() to reset memory resources.
Fix GstVaapiVideoBufferPool::reset_buffer() to reset the underlying
memory resources, and more particularly the VA surface proxy. Most
importantly, the GstVaapiVideoMeta is retained. Cached surface in
memory are released, thus triggering a new allocation the next time
we need to map the buffer.
2013-10-09 18:30:06 +02:00
Gwenole Beauchesne
4df68163dc plugins: fix GstVaapiVideoMemory to allocate VA surface proxies.
Make sure GstVaapiVideoMemory allocates VA surface proxies from a
pool stored in the parent VA memory allocator.

This fixes the following scenario:
- VA video buffer 1 is allocated from a buffer pool
- Another video buffer is created, and inherits info from buffer 1
- Buffer 1 is released, thus pushing it back to the buffer pool
- New buffer alloc request comes it, this yields buffer 1 back
- At this stage, buffers 1 and 2 still share the same underlying VA
  surface, but buffer 2 was already submitted downstream for further
  processing, thus conflicting with additional processing we were
  about to perform on buffer 1.

Maybe the core GstBufferPool implementation should have been fixed
instead to actually make sure that the returned GstBuffer memory we
found from the pool is writable?
2013-10-09 18:30:06 +02:00
Gwenole Beauchesne
cc9afca3ed plugins: create a proxy for GstVaapiUploader allocated buffers.
Always make sure to allocate a VA surface proxy for GstVaapiUploader
allocated buffers, i.e. make gst_vaapi_uploader_get_buffer() allocate
a proxy surface.

This fixes cases where we want to retain the underlying surface longer,
instead of releasing it back to the surface pool right away.
2013-10-04 19:34:32 +02:00
Gwenole Beauchesne
393e86e3d0 plugins: add helper function to disable deinterlacing in caps.
Add gst_caps_set_interlaced() helper function that would reset the
interlace-mode field to "progressive" for GStreamer >= 1.0, or the
interlaced field to "false" for GStreamer 0.10.
2013-10-04 19:30:36 +02:00
Víctor Manuel Jáquez Leal
395260f24b plugins: hanle the context query in any pad.
Also this patch simplifies the code, since now the query is common for the
decoder and the sink.

https://bugzilla.gnome.org/show_bug.cgi?id=709200
2013-10-01 18:41:16 +02:00
Víctor Manuel Jáquez Leal
b56144e924 plugins: query upstream element for a GstContext.
Fix gst_vaapi_video_context_prepare() to also query upstream elements
for a valid GstContext. Improve comments regarding the steps used to
lookup or build that context, thus conforming to the GstContext API
recommendations.

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

Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
2013-10-01 17:55:43 +02:00
Víctor Manuel Jáquez Leal
41c4da5571 plugins: add support for GstVideoGLTextureUploadMeta.
If the allocation meta GST_VIDEO_GL_TEXTURE_UPLOAD_META_API_TYPE is
requested, and more specifically under a GLX configuration, then add
the GstVideoGLTextureUploadMeta to the output buffer.

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

Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
2013-09-27 14:17:20 +02:00
Sreerenj Balachandran
8fe3bb0b14 plugins: add support for GstCaps features.
Move VA video buffer memory from "video/x-surface,type=vaapi" format,
as expressed in caps, to the more standard use of caps features. i.e.
add "memory:VASurface" feature attribute to the associated caps.

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

Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
2013-09-27 14:17:16 +02:00
Víctor Manuel Jáquez Leal
21aa850eb4 plugins: improve ::query() debugging messages.
Fix gst_vaapidecode_query() to correctly display the query type name,
instead of randomly displaying that we shared the underlying display.
Also add debug info for the GstVaapiSink::query() handler, i.e. the
supplied query type name actually.

Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
2013-09-27 14:17:12 +02:00
Víctor Manuel Jáquez Leal
9e3d24c669 plugins: add support for GstContext API.
Add support for the new GstContext API from GStreamer 1.2.x.
- implement the GstElement::set_context() hook ;
- reply to the `context' query from downstream elements.

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

Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
2013-09-27 14:17:07 +02:00
Víctor Manuel Jáquez Leal
c67b783275 plugins: add compat layer for GstVideoContext.
Add thin compatibility layer for the deprecated GstVideoContext API.
For GStreamer API >= 1.2, this involves the following two functions:
- gst_vaapi_video_context_prepare(): queries if a context is already
  set in the pipeline ;
- gst_vaapi_video_context_propagate(): propagates the newly-created
  context to the rest of the pipeline.

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

Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
2013-09-27 14:16:52 +02:00
Víctor Manuel Jáquez Leal
f75762d910 plugins: initial port to GStreamer 1.2.
Port vaapidecode and vaapisink plugins to GStreamer API >= 1.2. This
is rather minimalistic so that to test the basic functionality.

Disable vaapipostproc plugin for now as further polishing is needed.
Also disable GstVideoContext interface support since this API is now
gone in 1.2.x. This is preparatory work for GstContext support.

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

Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
2013-09-27 14:15:51 +02:00
Zhao Halley
45b4ba7df7 vaapisink: ensure the uploader is setup for upstream allocated buffers.
In GStreamer 0.10 builds, make sure that the GstVaapiUploader helper
is setup in case upstream elements allocate buffers themselves without
honouring our GstVaapiSink::bufer_alloc() hook.

In particular, this fixes support for OGG video streams with WebKit.

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

Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
2013-08-29 19:36:06 +02:00
Gwenole Beauchesne
6d7b5eef7d vaapisink: simplify get_render_buffer() for GStreamer 0.10 builds.
Implement and use gst_vaapisink_get_render_buffer() for GStreamer 0.10
builds as well.
2013-08-29 19:36:06 +02:00
Gwenole Beauchesne
d2648afa32 vaapisink: handle raw buffers not created from VA video buffer pool.
Handle raw video buffers that were not created from a VA video buffer
pool. Use the generic GstVideo API to copy buffers in GStreamer 1.0.x
builds instead of the GstVaapiUploader.

https://bugs.freedesktop.org/show_bug.cgi?id=55818
2013-08-29 19:36:06 +02:00
Gwenole Beauchesne
1be80e791c vaapidecode: remove extraneous size information from allowed caps.
Fix _getcaps() implementation to not report codecs with size information
filled in the returned caps. That's totally useless nowadays. Ideally,
this is a hint to insert a video parser element, thus allowing future
optimizations, but this is not a strict requirement for gstreamer-vaapi,
which is able to parse the elementary bitstreams itself.

https://bugzilla.gnome.org/show_bug.cgi?id=704734
2013-08-29 19:36:06 +02:00
Guangxin.Xu
111d7d4fa4 vaapidecode: submit the last frame from output adapter to decoder.
If there is no frame delimiter at the end of the stream, e.g. no
end-of-stream or end-of-sequence marker, and that the current frame
was fully parsed correctly, then assume that last frame is complete
and submit it to the decoder.

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

Signed-off-by: Guangxin.Xu <Guangxin.Xu@intel.com>
Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
2013-08-29 14:47:40 +02:00
Gwenole Beauchesne
91736b3a60 vaapidecode: push all decoded frames from within the task.
Make sure to push all decoded frames from the task so that the unlying
VA surfaces could all be rendered from the same thread.
2013-08-29 11:55:05 +02:00
Gwenole Beauchesne
771071a4e5 decode: fix creation of GLX video buffers for GStreamer 0.10.
Fix creation of GstVaapiVideoBuffer objects (i) to have that type for real;
and (ii) to correctly extract the GstSurfaceConverter from the video buffer
object meta.

This fixes support for cluttersink with GStreamer 0.10 builds.
2013-08-26 17:14:33 +02:00
Simon Farnsworth
0ef5979d77 vaapisink: allow scaling to ignore aspect ratio.
Other GStreamer sinks, like xvimagesink, have a force-aspect-ratio property,
which allows you to say that you don't want the sink to respect aspect
ratio. Add the same property to vaapisink.

http://lists.freedesktop.org/archives/libva/2012-September/001298.html

Signed-off-by: Simon Farnsworth <simon.farnsworth at onelan.co.uk>
2013-08-26 13:10:33 +02:00
Wind Yuan
e5a50af2ae vaapisink: fix memory leak of GstVaapiUploader instance.
Make sure gst_vaapisink_ensure_uploader() checks for the existence
of a former GstVaapiUploader instance prior to forcibly creating a
new one.

https://bugzilla.gnome.org/show_bug.cgi?id=703980
2013-08-26 13:01:26 +02:00
Guangxin.Xu
92a124f306 vaapisink: fix get_caps() implementation for GStreamer 1.0.
Fix GstBaseSink::get_caps() implementation for GStreamer 1.0.X builds
by honouring the filter caps argument. More precisely, this fixes the
following pipeline: gst-launch-1.0 videotestsrc ! vaapisink

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

Signed-off-by: Guangxin.Xu <Guangxin.Xu@intel.com>
Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
2013-08-26 12:56:06 +02:00
Zhao Halley
944a7bd077 filter: add initial support for deinterlacing.
Add basic deinterlacing support, i.e. bob-deinterlacing whereby only
the selected field from the input surface is kept for the target surface.
Setting gst_vaapi_filter_set_deinterlacing() method argument to
GST_VAAPI_DEINTERLACE_METHOD_NONE means to disable deinterlacing.

Also move GstVaapiDeinterlaceMethod definition from vaapipostproc plug-in
to libgstvaapi core library.

Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
2013-08-23 19:00:38 +02:00
Gwenole Beauchesne
0b1a97cbf9 plugins: handle video cropping in X11 pixmap converter.
Use GstVideoCropMeta in GStreamer 1.0 or any other render rectangle
we could decode from the stream.
2013-07-22 15:45:10 +02:00
Gwenole Beauchesne
6f04a52905 plugins: add support for "x11-pixmap" video converter type.
Install a new video converter that supports X11 pixmap targets for X11
backends only, or make the GLX converter creation function chain up to
the X11 converter whenever requested.
2013-07-22 15:45:10 +02:00
Emilio López
b868c6d888 plugins: fix display type comparison in gst_vaapi_create_display().
After the code got moved to create the gst_vaapi_create_display() helper,
this comparison was not updated to dereference the newly-created
pointer, so the code was comparing the pointer itself to the type, and
therefore failing to retrieve the VA display.

This fixes the following error (and gets gst-vaapi decoding again):

    ERROR vaapidecode gstvaapidecode.c:807:gst_vaapidecode_ensure_allowed_caps: failed to retrieve VA display

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

Signed-off-by: Emilio López <emilio@elopez.com.ar>
2013-07-18 08:41:28 +02:00
Gwenole Beauchesne
7fa4973f8a Fix new video format API.
Fix new internal video format API, based on GstVideoFormat, to not
clobber with system symbols. So replace the gst_video_format_* prefix
with gst_vaapi_video_format_ prefix, even if the format type remains
GstVideoFormat.
2013-07-15 14:42:33 +02:00
Gwenole Beauchesne
cee9101dd8 plugins: simlpify gst_vaapi_create_display() helper.
Simplify gst_vaapi_create_display() helper as gst_vaapi_display_XXX_new()
performs the necessary validation checks for the underlying VA display
prior to returning to the caller. So, if an error occurred, then NULL is
really returned in that case.
2013-07-15 11:58:31 +02:00
Víctor Manuel Jáquez Leal
3d290a162c plugins: add gst_vaapi_create_display() helper.
https://bugzilla.gnome.org/show_bug.cgi?id=703235

Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
2013-07-15 11:54:44 +02:00
Gwenole Beauchesne
5e18a5b1bd plugins: don't reallocate pool allocator for the same caps.
If the video buffer pool config doesn't have new caps, then it's not
necessary to reinstantiate the allocator. That could be a costly
operation as we could do some extra heavy checking in there.
2013-07-12 17:55:37 +02:00
Gwenole Beauchesne
c82a1bc0ff plugins: fix ref counting of GstVaapiVideoMemory allocator.
Fix reference counting issue whereby gst_memory_init() does not hold
an extra reference to the GstAllocator. So, there could be situations
where the last instance of GstVaapiVideoAllocator gets released before
a dangling GstVaapiVideoMemory object, thus possibly leading to a crash.
2013-07-12 17:14:49 +02:00
Gwenole Beauchesne
d79d561819 vaapiupload: use implicit color conversion to NV12.
Always perform conversion of sources buffers to NV12 since this is
the way we tested for this capability in ensure_allowed_caps(). This
also saves memory bandwidth for further rendering. However, this may
not preserve quality since the YUV buffers are down-sampled to 4:2:0.
2013-07-12 15:15:07 +02:00
Wind Yuan
9b3ad4daad vaapidownload: fix src caps format error.
This fixes direct linking of vaapidownload element to xvimagesink with
VA drivers supporting vaGetImage() from the native VA surface format to
a different VA image format. i.e. color conversion during download.

http://bugzilla.gnome.org/show_bug.cgi?id=703937

Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
2013-07-11 19:09:53 +02:00
Gwenole Beauchesne
4668e59bf6 vaapidownload: fix debug string for image formats.
The image is now expressed as a standard GstVideoFormat, which is not
a FOURCC but rather a regular enum value.

This is a regression introduced in commit 09397fa.
2013-07-11 19:09:53 +02:00
Gwenole Beauchesne
ed1bec1e43 plugins: clean-up video uploader helper.
Fix gst_vaapi_uploader_get_buffer() to not assign caps since they
were already negotiated beforehand, and they are not used from the
buffer in upstream elements.

Clean-up gst_vaapi_uploader_ensure_caps() to use the new image caps
represented as a GstVideoInfo.
2013-07-10 17:03:47 +02:00
Gwenole Beauchesne
419af50009 plugins: use GstVideoInfo in video uploader helper. 2013-07-10 17:03:47 +02:00
Gwenole Beauchesne
1cfe03ee52 plugins: allow creation of VA surfaces with explicit pixel format.
Adapt GstVaapiVideoMemory allocator to support creation of VA surfaces
with an explicit pixel format. This allows for direct rendering to
VA surface memory from a software decoder.
2013-07-10 17:03:47 +02: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
09397fa0d8 plugins: port to new video format API. 2013-07-09 17:16:35 +02:00
Gwenole Beauchesne
40b6832b82 vaapisink: fix creation of GLX texture.
Fix creation of GLX texture, to not depend on the GstCaps video size that
could be wrong, especially in presence of frame cropping. So, use the size
from the source VA surfaces.

An optimization could be to reduce the texture size to the actual visible
size on screen. i.e. scale down the texture size to match the screen dimensions,
while preserving the VA surface aspect ratio. However, some VA drivers don't
honour that.
2013-07-08 18:54:15 +02:00
Gwenole Beauchesne
5bbab30859 plugins: add support for video cropping.
Add support for GstVideoCropMeta in GStreamer >= 1.0.x builds and gst-vaapi
specific meta information to hold video cropping details. Make the sink
support video cropping in X11 and GLX modes.
2013-07-08 18:52:56 +02:00
Sreerenj Balachandran
dbb58f4152 plugins: add helper functions to set the render rectangle.
Some video clips may have a clipping region that needs to propogate to
the renderer. These helper functions make it possible to attach that
clipping region, as a GstVaapiRectangle, the the video meta associated
with the buffer.

Signed-off-by: Sreerenj Balachandran <sreerenj.balachandran@intel.com>
signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
2013-07-08 18:52:56 +02:00
Sreerenj Balachandran
769f33cab2 vaapisink: expose the raw video formats in static caps template.
Expose all raw video formats in the static caps template since the
vaapisink is supporting raw data. We will get the exact set of formats
supported by the driver dynamically through the _get_caps() routine.

This also fixes an inconsistency wrt. GStreamer 0.10 builds.

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

Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
2013-06-27 14:01:26 +02:00
Gwenole Beauchesne
ece5cb2d83 vaapisink: add "use-glx" property for OpenGL rendering.
Now that VA/GLX capable buffers are generated by default on X11, thus
depending on a VA/GLX display, we stil want to use vaPutSurface() for
rendering since it is faster.

Anyway, OpenGL rendering in vaapisink was only meant for testing and
enabling "fancy" effects to play with. This has no real value. So,
disable OpenGL rendering by default.
2013-06-27 13:53:46 +02:00
Víctor Manuel Jáquez Leal
2fafbd7b64 plugins: try to allocate a GLX display first over an X11 one.
If the gstreamer-vaapi plug-in elements are built with GLX support, then
try to allocate a GstVaapiDisplayGLX first before resorting to a VA/X11
display next.

https://bugzilla.gnome.org/show_bug.cgi?id=701742
2013-06-27 10:19:37 +02:00
Zhao Halley
bbd7a130e2 vaapisink: fix build without VA/GLX support. 2013-06-05 11:09:37 +02:00
Gwenole Beauchesne
e712abba11 plugins: allow buffer mappings to GstVaapiSurfaceProxy.
Allow plain gst_buffer_map() interface to work with gstreamer-vaapi
video buffers, i.e. expose the underlying GstVaapiSurfaceProxy to the
caller. This is the only sensible enough thing to do in this mode as
the underlying surface pixels need to be extracted through an explicit
call to the gst_video_frame_map() function instead.

A possible use-case of this is to implement a "handoff" signal handler
to fakesink or identity element for further processing.
2013-06-05 11:09:37 +02:00
Gwenole Beauchesne
eb9dd361f8 plugins: silence check for direct-rendering mode in video memory.
Fix gst_vaapi_video_allocator_new() to silently check for direct-rendering
mode support, and not trigger fatal-criticals if either test surface or
image could not be created. Typical case: pixel format mismatch, e.g. NV12
supported by most hardware vs. I420 supported by most software decoders.
2013-06-05 11:09:37 +02:00
Gwenole Beauchesne
33f6415696 plugins: improve video memory flags safety checks.
On map, ensure we have GST_MAP_WRITE flags since this is only what we
support for now. Likewise, on unmap, make sure that the VA image is
unmapped for either read or write, while still committing it to the
VA surface if write was requested.
2013-06-05 11:09:37 +02:00
Gwenole Beauchesne
c12dc19b8b vaapisink: fix one-time initialization when display property is set.
Fix gst_vaapisink_ensure_display() to perform one-time initialization
tasks even if the `display' property was explicitly set.
2013-05-27 17:21:11 +02:00
Zhao Halley
dadf0ef978 uploader: fix memory leak in GStreamer 0.10 builds.
In GStreamer 0.10 builds, gst_vaapi_uploader_get_buffer() was used
but it exhibited a memory leak because the surface generated for the
GstVaapiVideoMeta totally lost its parent video pool. So, it was not
possible to release that surface back to the parent pool when the meta
gets released, and the memory consumption kept growing.

Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
2013-05-23 19:22:48 +02:00
Gwenole Beauchesne
35eaa9e763 plugins: fix gst_vaapi_video_meta_new_from_pool().
Since GST_VAAPI_IS_xxx_VIDEO_POOL() was only testing for NULL and not
the underlying object type, the gst_vaapi_video_meta_new_from_pool()
was hereby totally broken. Fixed this regression by using the newly
provided gst_vaapi_video_pool_get_object_type() function.
2013-05-23 19:01:34 +02:00
Gwenole Beauchesne
e52ea35b11 plugins: cope with GST_VAAPI_IS_xxx() macros removal. 2013-05-23 19:01:34 +02:00
Gwenole Beauchesne
9535bb9950 plugins: cope with new GstVaapiMiniObject objects. 2013-05-07 18:19:03 +02:00
Gwenole Beauchesne
c43a2d497a decoder: add gst_vaapi_decoder_get_frame_with_timeout().
Add gst_vaapi_decoder_get_frame_with_timeout() helper function that will
wait for a frame to be decoded, until the specified timeout in microseconds,
prior to returning to the caller.

This is a fix to performance regression from 851cc0, whereby the vaapidecode
loop executed on the srcpad task was called to often, thus starving all CPU
resources.
2013-04-25 14:18:00 +02:00
Gwenole Beauchesne
d2bf4ffd97 vaapidecode: rework heuristics to detect decode timeout.
Rework heuristics to detect when downstream element ran into errors,
and thus failing to release any VA surface in due time for the current
frame to get decoded. In particular, recalibrate the render time base
when the first frame gets submitted downstream, or when there is no
timestamp that could be inferred.
2013-04-18 18:54:40 +02:00
Gwenole Beauchesne
851cc000c2 vaapidecode: rework GstVideoDecoder::handle_frame() with a task.
Rework GstVideoDecoder::handle_frame() to decode the current frame,
while possibly waiting for a free surface, and separately submit all
decoded frames from a task. This makes it possible to pop and render
decoded frames as soon as possible.
2013-04-18 18:46:01 +02:00
Gwenole Beauchesne
9d8bac313f plugins: use gst_object_unref() wherever applicable.
Use gst_object_unref() wherever applicable, e.g. objects derived from
GstElement, GstVideoPool, etc.
2013-04-18 17:16:43 +02:00
Gwenole Beauchesne
a0e587667a vaapipostproc: minor clean-ups.
Use g_clear_object() wherever appropriate and remove dead-code.
2013-04-17 10:58:04 +02:00
Gwenole Beauchesne
6b259abc02 vaapipostproc: fix reference counting buf for passthrough mode.
Fix reference counting bug for passthrough mode, whereby the input buffer
was propagated as is downstream through gst_pad_push() without increasing
its reference count before. The was a problem when gst_pad_push() returns
an error and we further decrease the reference count of the input buffer.
2013-04-17 10:53:03 +02:00