Commit graph

1506 commits

Author SHA1 Message Date
Gwenole Beauchesne
8788ea99a8 encoder: improve codec reconfiguration.
Improve codec reconfiguration to be performed only through a single
function. That is, remove the _set_context_info() hook as subclass
should not alter the parent GstVaapiContextInfo itself. Besides, the
VA context is constructed only at the final stages of reconfigure().
2014-01-13 17:31:55 +01:00
Gwenole Beauchesne
20ab910d15 encoder: fix possible memory leak of coded buffer pools.
Fix gst_vaapi_encoder_reconfigure_internal() to re-/allocate the coded
buffer pool only if the coded buffer size actually changed.
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
dcc7a94408 encoder: add properties API.
Add interface to communicate configurable properties to the encoder.
This covers both the common ones (rate-control, bitrate), and the
codec specific properties.

https://bugzilla.gnome.org/show_bug.cgi?id=719529
2014-01-13 17:31:54 +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
Gwenole Beauchesne
9548e32cf4 utils: add new MPEG-2 helper functions.
Add various helper functions to convert profile, level, chroma formats
from gstreamer-vaapi world and the MPEG-2 specification world.
2014-01-13 16:25:49 +01:00
Gwenole Beauchesne
4a650e8e62 utils: h264: don't use fatal asserts.
Replace g_assert() with a g_debug() so that to not make the program
abort when an unsupported value is supplied.
2014-01-10 19:52:50 +01:00
Gwenole Beauchesne
b0c2ac4159 utils: h264: add helpers for profile and level string mappings.
Add profile and level helper functions to convert to/from strings.
2014-01-10 19:52:50 +01:00
Gwenole Beauchesne
589078f2a4 utils: h264: expose levels in public header.
Instal <gst/vaapi/gstvaapiutils_h264.h> header but only expose the
H.264 levels in there. The additional helper functions are meant
to be private for now.
2014-01-10 19:52:50 +01:00
Gwenole Beauchesne
39dda15f5f codec: add helper macros to maintain object refcount.
Add gst_vaapi_mini_object_{ref,unref,replace}() helper macros so that
to avoid explicit casts to GstVaapiMiniObject in all caller sites.
2014-01-09 09:59:17 +01:00
Gwenole Beauchesne
caf13671bb codec: re-indent decoder objects. 2014-01-09 09:46:46 +01:00
Gwenole Beauchesne
c010ce2340 codec: re-indent base codec objects. 2014-01-09 09:46:46 +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
dd2ca582a1 tests: simple-decoder: don't use deprecated g_thread_create().
Use g_thread_try_new() instead of the deprecated g_thread_create()
function. Provide compatibility glue for any GLib version < 2.31.2.
2014-01-06 10:04:08 +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
4902df0e40 utils: format: drop unused helper functions.
The following helper functions are no longer used, thus are removed:
- gst_vaapi_video_format_from_structure()
- gst_vaapi_video_format_from_caps()
- gst_vaapi_video_format_to_caps()
2013-12-21 12:35:24 +01:00
Gwenole Beauchesne
52b6fc57d4 utils: re-indent GstVideoFormat related helpers. 2013-12-21 12:35:24 +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
446b060c7a display: allocate queried resources on-demand.
Allocate the set of decoders or encoders on-demand, when they are
queried. Likewise for VA display attributes, image and subpicture
formats.
2013-12-20 17:16:12 +01:00
Gwenole Beauchesne
ff0642efad display: re-indent all GstVaapiDisplay related source code. 2013-12-20 17:16:12 +01:00
Gwenole Beauchesne
a6fe7698bc utils: add helper functions to get codec or profile name. 2013-12-20 17:16:12 +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
6fe54964bb h264: improve robustness when packets are missing.
Improve robustness when some expected packets where not received yet
or that were not correctly decoded. For example, don't try to decode
a picture if there was no valid frame headers parsed so far.

https://bugs.freedesktop.org/show_bug.cgi?id=57902
2013-12-10 16:14:27 +01:00
Gwenole Beauchesne
1dd89800b0 decoder: h264: fix decoding of BA3_SVA_C.264.
Conformance test Base_Ext_Main_profiles/BA3_SVA_C.264 complys with
extended profile specifications. However, the SPS header has the
constraint_set1_flag syntax element set to 1. This means that, if
a Main profile compliant decoder is available, then it should be
able to decode this stream.

This changes makes it possible to fall-back from Extended profile
to Main profile if constraint_set1_flag is set to 1.

https://bugzilla.gnome.org/show_bug.cgi?id=720190
2013-12-10 15:22:40 +01:00