Commit graph

39 commits

Author SHA1 Message Date
Víctor Manuel Jáquez Leal
c561b8da8a update and move gstcompat.h
The purpose of gstcompat.h is to couple the API differences among
gstreamer-1.0 and gstreamer-0.10. Since gstreamer-0.10 is obsolete, the code
in this compatibility layer shall be removed.

Nevertheless, the gstcompat.h header should be kept, if new incompatibilites
appear in the future, but it shall live in gst/vaapi, not in gst-libs.

This patch removes the crumbs defined gstcompat.h and moves it to gst/vaapi.
In order to avoid layer violations, gstcompat.h includes sysdeps.h and all
the includes in gst/vaapi of sysdeps.h are replaced with gstcompat.h

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

Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
Signed-off-by: Sreerenj Balachandran <sreerenj.balachandran@intel.com>
2015-04-03 17:08:30 +03:00
Víctor Manuel Jáquez Leal
d256f1d283 Removal of gstreamer-0.10 support
This patch removes all the pre-processor conditional code compilation guarded
for gstreamer-0.10.

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

Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
2015-04-03 16:55:27 +03:00
Sreerenj Balachandran
7f3795c9fb encode: Attach the codec-data to out caps only based on negotiated caps
Attach the codec_data to out_caps only if downstream needed.
For eg: h264 encoder doesn't need to stuff codec_data to the
src caps if the negotiated caps has a stream format of byte-stream.

https://bugzilla.gnome.org/show_bug.cgi?id=734902
2014-10-29 15:46:12 +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
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
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
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
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
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
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
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
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
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
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