platform/upstream/gstreamer-vaapi.git
10 years agovaapiencode: update for new properties API.
Gwenole Beauchesne [Wed, 8 Jan 2014 17:36:46 +0000 (18:36 +0100)]
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

10 years agoencoder: add properties API.
Gwenole Beauchesne [Mon, 6 Jan 2014 16:46:40 +0000 (17:46 +0100)]
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

10 years agoencoder: add bitrate API.
Gwenole Beauchesne [Mon, 6 Jan 2014 17:01:33 +0000 (18:01 +0100)]
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

10 years agoencoder: add rate control API.
Gwenole Beauchesne [Mon, 6 Jan 2014 14:10:36 +0000 (15:10 +0100)]
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

10 years agovaapiencode: fix indentation.
Gwenole Beauchesne [Fri, 3 Jan 2014 15:57:25 +0000 (16:57 +0100)]
vaapiencode: fix indentation.

10 years agoencoder: fix indentation.
Gwenole Beauchesne [Fri, 3 Jan 2014 15:57:09 +0000 (16:57 +0100)]
encoder: fix indentation.

10 years agoutils: add new MPEG-2 helper functions.
Gwenole Beauchesne [Mon, 13 Jan 2014 15:20:06 +0000 (16:20 +0100)]
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.

10 years agoutils: h264: don't use fatal asserts.
Gwenole Beauchesne [Fri, 10 Jan 2014 18:49:52 +0000 (19:49 +0100)]
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.

10 years agoutils: h264: add helpers for profile and level string mappings.
Gwenole Beauchesne [Fri, 10 Jan 2014 18:37:44 +0000 (19:37 +0100)]
utils: h264: add helpers for profile and level string mappings.

Add profile and level helper functions to convert to/from strings.

10 years agoutils: h264: expose levels in public header.
Gwenole Beauchesne [Fri, 10 Jan 2014 17:27:20 +0000 (18:27 +0100)]
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.

10 years agocodec: add helper macros to maintain object refcount.
Gwenole Beauchesne [Thu, 9 Jan 2014 08:27:40 +0000 (09:27 +0100)]
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.

10 years agocodec: re-indent decoder objects.
Gwenole Beauchesne [Thu, 9 Jan 2014 08:30:49 +0000 (09:30 +0100)]
codec: re-indent decoder objects.

10 years agocodec: re-indent base codec objects.
Gwenole Beauchesne [Thu, 9 Jan 2014 08:10:21 +0000 (09:10 +0100)]
codec: re-indent base codec objects.

10 years agoplugins: do not free debug category in finalize method.
Matthieu Bouron [Fri, 3 Jan 2014 12:49:05 +0000 (12:49 +0000)]
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>
10 years agotests: simple-decoder: don't use deprecated g_thread_create().
Gwenole Beauchesne [Thu, 2 Jan 2014 10:35:30 +0000 (11:35 +0100)]
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.

10 years agoFix printf()-like formats.
Gwenole Beauchesne [Thu, 2 Jan 2014 10:17:28 +0000 (11:17 +0100)]
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.

10 years agoutils: format: drop unused helper functions.
Gwenole Beauchesne [Sat, 21 Dec 2013 06:38:14 +0000 (07:38 +0100)]
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()

10 years agoutils: re-indent GstVideoFormat related helpers.
Gwenole Beauchesne [Sat, 21 Dec 2013 06:29:50 +0000 (07:29 +0100)]
utils: re-indent GstVideoFormat related helpers.

10 years agodownload: use GstVideoInfo facilities to build output caps.
Gwenole Beauchesne [Sat, 21 Dec 2013 07:27:30 +0000 (08:27 +0100)]
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.

10 years agoplugins: factor out construction of template caps.
Gwenole Beauchesne [Sat, 21 Dec 2013 09:41:22 +0000 (10:41 +0100)]
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

10 years agoplugins: factor out construction of GValue from GstVideoFormat.
Gwenole Beauchesne [Sat, 21 Dec 2013 05:41:34 +0000 (06:41 +0100)]
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

10 years agoplugins: re-indent common and video context creation utils.
Gwenole Beauchesne [Sat, 21 Dec 2013 05:22:30 +0000 (06:22 +0100)]
plugins: re-indent common and video context creation utils.

10 years agodisplay: don't use GstCaps for decode or encode profiles list.
Gwenole Beauchesne [Fri, 20 Dec 2013 14:31:14 +0000 (15:31 +0100)]
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().

10 years agodisplay: don't use GstCaps for image or subpicture formats list.
Gwenole Beauchesne [Fri, 20 Dec 2013 14:15:05 +0000 (15:15 +0100)]
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().

10 years agodisplay: allocate queried resources on-demand.
Gwenole Beauchesne [Fri, 20 Dec 2013 13:01:45 +0000 (14:01 +0100)]
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.

10 years agodisplay: re-indent all GstVaapiDisplay related source code.
Gwenole Beauchesne [Fri, 20 Dec 2013 12:27:07 +0000 (13:27 +0100)]
display: re-indent all GstVaapiDisplay related source code.

10 years agoutils: add helper functions to get codec or profile name.
Gwenole Beauchesne [Fri, 20 Dec 2013 15:04:19 +0000 (16:04 +0100)]
utils: add helper functions to get codec or profile name.

10 years agoplugins: fix permissions for certain files.
Gwenole Beauchesne [Fri, 20 Dec 2013 16:08:23 +0000 (17:08 +0100)]
plugins: fix permissions for certain files.

Drop the execute bit for gstvaapiuploader.c and gstvaapipostproc.[ch]
files.

10 years agoplugins: implement GLTextureUploadMeta user data copy.
Matthieu Bouron [Thu, 12 Dec 2013 17:01:29 +0000 (17:01 +0000)]
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>
10 years agoplugins: factor out support for raw YUV buffers on sink pads.
Gwenole Beauchesne [Tue, 17 Dec 2013 17:52:23 +0000 (18:52 +0100)]
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.

10 years agoplugins: factor out pad caps.
Gwenole Beauchesne [Tue, 17 Dec 2013 17:46:07 +0000 (18:46 +0100)]
plugins: factor out pad caps.

10 years agoplugins: factor out video context sharing code.
Gwenole Beauchesne [Fri, 13 Dec 2013 15:03:08 +0000 (16:03 +0100)]
plugins: factor out video context sharing code.

10 years agoplugins: factor out GstImplementsInterface.
Gwenole Beauchesne [Fri, 13 Dec 2013 12:24:24 +0000 (13:24 +0100)]
plugins: factor out GstImplementsInterface.

10 years agoplugins: check type of display obtained from neighbours.
Gwenole Beauchesne [Fri, 13 Dec 2013 11:00:35 +0000 (12:00 +0100)]
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.

10 years agoplugins: factor out display creation process.
Gwenole Beauchesne [Fri, 13 Dec 2013 10:52:47 +0000 (11:52 +0100)]
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.

10 years agoplugins: add new base object, store display in there.
Gwenole Beauchesne [Fri, 13 Dec 2013 09:24:26 +0000 (10:24 +0100)]
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.

10 years agoplugins: fix GLTextureUploadMeta to work with different texture ids.
Gwenole Beauchesne [Wed, 11 Dec 2013 13:04:27 +0000 (14:04 +0100)]
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

10 years agoplugins: allow builds without GLX enabled for GStreamer 1.2.
Gwenole Beauchesne [Wed, 11 Dec 2013 12:25:51 +0000 (13:25 +0100)]
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.

10 years agoplugins: request GLTextureUpload meta on buffers in the buffer pool.
Matthieu Bouron [Wed, 20 Nov 2013 17:20:07 +0000 (17:20 +0000)]
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>
10 years agoplugins: robustify GstVideoGLTextureUploadMeta implementation.
Gwenole Beauchesne [Wed, 11 Dec 2013 09:51:03 +0000 (10:51 +0100)]
plugins: robustify GstVideoGLTextureUploadMeta implementation.

Make GstVideoGLTextureUploadMeta::upload() implementation more robust
when the GstVaapiTexture associated with the supplied texture id could
not be created.

10 years agoh264: improve robustness when packets are missing.
Gwenole Beauchesne [Tue, 10 Dec 2013 15:14:27 +0000 (16:14 +0100)]
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

10 years agodecoder: h264: fix decoding of BA3_SVA_C.264.
Gwenole Beauchesne [Tue, 10 Dec 2013 13:20:55 +0000 (14:20 +0100)]
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

10 years agoutils: h264: add more profiles.
Gwenole Beauchesne [Tue, 10 Dec 2013 10:13:01 +0000 (11:13 +0100)]
utils: h264: add more profiles.

Add extended profile (A.2.3), high 4:2:2 profile (A.2.6), high 4:2:2
profiles (A.2.7, A.2.10), scalable profiles (G.10.1.1, G.10.1.2) and
multiview profiles (H.10.1.1, H.10.1.2).

Document "Constrained Baseline" and "High 10" profiles.

10 years agocodecparsers: update to gst-vaapi-branch commit e7d0e18.
Gwenole Beauchesne [Tue, 10 Dec 2013 14:21:51 +0000 (15:21 +0100)]
codecparsers: update to gst-vaapi-branch commit e7d0e18.

e7d0e18 h264: complete set of NAL unit types

10 years agodecoder: h264: add support for constrained baseline profile.
Wind Yuan [Fri, 6 Dec 2013 07:08:26 +0000 (15:08 +0800)]
decoder: h264: add support for constrained baseline profile.

Recognize streams marked as conforming to the "Constrained Baseline
Profile". If VA driver supports that as is, fine. Otherwise, fallback
to baseline, main or high profile.

Constrained Baseline Profile conveys coding tools that are common
to baseline profile and main profile.

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

[Added fallbacks to main and high profiles]
Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
10 years agodecoder: h264: fix decoding of scaling lists.
Gwenole Beauchesne [Mon, 9 Dec 2013 11:46:45 +0000 (12:46 +0100)]
decoder: h264: fix decoding of scaling lists.

The GStreamer codecparser layer now parses the scaling lists in zigzag
scan order, as expected, so that to match the original bitstream layout
and specification. However, further convert the scaling lists into
raster scan order to fit the existing practice in most VA drivers.

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

10 years agocodecparsers: update to gst-vaapi-branch commit 177c73b.
Gwenole Beauchesne [Mon, 9 Dec 2013 11:07:28 +0000 (12:07 +0100)]
codecparsers: update to gst-vaapi-branch commit 177c73b.

a7e3255 add H.265 (HEVC) bitstream parser
177c73b h264: fix picture level scaling lists derivation (rule B)
14733f1 h264: fix parsing of VCL HRD parameters
59a0b47 h264: store quantization matrices in zig-zag order
ffb6e26 h264: add helpers to convert quantization matrices
c78a504 mpeg2: also initialize debug category in parse_sequence_header()
719d1b0 mpeg2: turn internal consistency check into a g_assert()
5241d8e all: remove some unused functions
18eb312 all: fix for GST_DISABLE_GST_DEBUG
963c04a all: make warnings more meaningful

10 years agoutils: add helpers for H.264 levels.
Gwenole Beauchesne [Fri, 6 Dec 2013 18:05:52 +0000 (19:05 +0100)]
utils: add helpers for H.264 levels.

- gst_vaapi_utils_h264_get_level():
  Returns GstVaapiLevelH264 from H.264 level_idc value
- gst_vaapi_utils_h264_get_level_idc():
  Returns H.264 level_idc value from GstVaapiLevelH264
- gst_vaapi_utils_h264_get_level_limits():
  Returns level limits as specified in Table A-1 of the H.264 standard
- gst_vaapi_utils_h264_get_level_limits_table():
  Returns the Table A-1 specification

10 years agoutils: add new H.264 profiles.
Gwenole Beauchesne [Fri, 6 Dec 2013 16:34:52 +0000 (17:34 +0100)]
utils: add new H.264 profiles.

Add "Constrained Baseline Profile" and "High 10 Profile" definitions
and helper functiions.

10 years agoutils: add new H.264 helper functions.
Gwenole Beauchesne [Fri, 6 Dec 2013 16:21:52 +0000 (17:21 +0100)]
utils: add new H.264 helper functions.

* Profiles:
- gst_vaapi_utils_h264_get_profile():
  Returns GstVaapiProfile from H.264 profile_idc value
- gst_vaapi_utils_h264_get_profile_idc():
  Returns H.264 profile_idc value from GstVaapiProfile

* Chroma formats:
- gst_vaapi_utils_h264_get_chroma_type():
  Returns GstVaapiChromaType from H.264 chroma_format_idc value
- gst_vaapi_utils_h264_get_chroma_format_idc():
  Returns H.264 chroma_format_idc value from GstVaapiChromaType

10 years agoFix missing files in distribution tarball.
Matthieu Bouron [Tue, 3 Dec 2013 11:05:17 +0000 (11:05 +0000)]
Fix missing files in distribution tarball.

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

[Additional fixes and clean-ups]
Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
10 years agoencoder: fix computation of max coded buffer size (again).
Gwenole Beauchesne [Thu, 5 Dec 2013 17:13:54 +0000 (18:13 +0100)]
encoder: fix computation of max coded buffer size (again).

The previous fix was only valid to express the maximum size of the
macroblock layer, i.e. without any headers. Now, also account for
the slice headers and top picture header, but also any other header
we might stuff into the VA coded buffer, e.g. sequence headers.

10 years agoencoder: fix computation of max coded buffer size.
Gwenole Beauchesne [Wed, 4 Dec 2013 18:10:13 +0000 (19:10 +0100)]
encoder: fix computation of max coded buffer size.

Fix coded buffer size for each codec. A generic issue was that the
number of macroblocks was incorrectly computed. The second issue was
specific to MPEG-2 were the max number of bits per macroblock, and
as defined by the standard, was incorrectly mapped to the (lower)
H.264 requirement. i.e. 4608 bits vs. 3200 bits limit.

10 years agoencoder: simplify VA context initialization process.
Gwenole Beauchesne [Wed, 4 Dec 2013 17:48:35 +0000 (18:48 +0100)]
encoder: simplify VA context initialization process.

Change get_context_info() into a set_context_info() function that
initializes common defaults into the base class, thus allowing the
subclasses to specialize the context info further on.

The set_context_info() hook is also the location where additional
context specific data could be initialized. At this point, we are
guaranteed to have valid video resolution size and framerate. i.e.
gst_vaapi_encoder_set_format() was called beforehand.

10 years agoencoder: fix mpeg2 compilation error.
Wind Yuan [Tue, 26 Nov 2013 06:38:23 +0000 (14:38 +0800)]
encoder: fix mpeg2 compilation error.

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

Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
10 years agoencoder: clean-ups and document public APIs.
Gwenole Beauchesne [Wed, 4 Dec 2013 16:55:18 +0000 (17:55 +0100)]
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.

10 years agoencoder: avoid extra allocations of GstVaapiEncoderSyncPic objects.
Gwenole Beauchesne [Wed, 4 Dec 2013 16:05:17 +0000 (17:05 +0100)]
encoder: avoid extra allocations of GstVaapiEncoderSyncPic objects.

Kill GstVaapiEncoderSyncPic objects that are internally and temporarily
allocated. Rather, associate a GstVaapiEncPicture to a coded buffer
through GstVaapiCodedBufferProxy user-data facility.

Besides, use a GAsyncQueue to maintain a thread-safe queue object of
coded buffers.

Partial fix for the following report:
https://bugzilla.gnome.org/show_bug.cgi?id=719530

10 years agoencoder: refactor status codes.
Gwenole Beauchesne [Tue, 3 Dec 2013 16:04:43 +0000 (17:04 +0100)]
encoder: refactor status codes.

Drop obsolete or unused status codes. Align some status codes with the
decoder counterparts.

10 years agoencoder: fix subclassing process.
Gwenole Beauchesne [Wed, 4 Dec 2013 10:54:40 +0000 (11:54 +0100)]
encoder: fix subclassing process.

Fix the GstVaapiEncoderClass parent class type. Make sure to validate
subclass hooks as early as possible, i.e. in gst_vaapi_encoder_init(),
thus avoiding useless run-time checks. Also simplify the subclass
initialization process to be less error prone.

10 years agoencoder: rework GstVaapiCodedBuffer and related proxy.
Gwenole Beauchesne [Tue, 3 Dec 2013 15:11:46 +0000 (16:11 +0100)]
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

10 years agoplugins: fix reference leaks of VA display objects.
Gwenole Beauchesne [Fri, 29 Nov 2013 13:02:52 +0000 (14:02 +0100)]
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.

10 years agoplugins: simplify gst_vaapi_ensure_display().
Gwenole Beauchesne [Fri, 29 Nov 2013 12:56:12 +0000 (13:56 +0100)]
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.

10 years agoplugins: fix memory leaks through GstVideoMeta maps.
Gwenole Beauchesne [Thu, 28 Nov 2013 18:08:28 +0000 (19:08 +0100)]
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.

10 years agoplugins: use G_PARAM_STATIC_STRINGS.
Gwenole Beauchesne [Thu, 28 Nov 2013 13:15:44 +0000 (14:15 +0100)]
plugins: use G_PARAM_STATIC_STRINGS.

This avoids a few string copies during initialization.

10 years agoplugins: simplify VA video meta to only reference surface proxies.
Gwenole Beauchesne [Thu, 28 Nov 2013 16:28:11 +0000 (17:28 +0100)]
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.

10 years agoplugins: drop obsolete functions.
Gwenole Beauchesne [Thu, 28 Nov 2013 15:51:37 +0000 (16:51 +0100)]
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()

10 years agoplugins: allow VA video meta to be allocated from surface proxy pools.
Gwenole Beauchesne [Thu, 28 Nov 2013 15:37:31 +0000 (16:37 +0100)]
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.

10 years agosurfaceproxy: add copy function.
Gwenole Beauchesne [Thu, 28 Nov 2013 16:25:05 +0000 (17:25 +0100)]
surfaceproxy: add copy function.

Add gst_vaapi_surface_proxy_copy() function that creates a new surface
proxy with the same information from the parent proxy, except that the
user-defined destroy notify function is not copied over.

The underlying VA surface is pushed back to the video pool only when
the last reference to the parent surface proxy is released.

10 years agovaapiencode: optimize _handle_frame() to avoid extra allocation.
Gwenole Beauchesne [Thu, 28 Nov 2013 14:56:53 +0000 (15:56 +0100)]
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.

10 years agovaapiencode: fix memory leaks in _push_frame() on error.
Gwenole Beauchesne [Thu, 28 Nov 2013 14:14:43 +0000 (15:14 +0100)]
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.

10 years agovaapiencode: additional clean-ups.
Gwenole Beauchesne [Thu, 28 Nov 2013 12:57:54 +0000 (13:57 +0100)]
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.

10 years agovaapiencode: move common properties to base class.
Gwenole Beauchesne [Thu, 28 Nov 2013 12:26:40 +0000 (13:26 +0100)]
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.

10 years agovaapiencode: fix plugin description and debug name.
Gwenole Beauchesne [Thu, 28 Nov 2013 09:54:36 +0000 (10:54 +0100)]
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.

10 years agovaapiencode: add initial support for GStreamer 0.10.
Gwenole Beauchesne [Wed, 27 Nov 2013 15:27:31 +0000 (16:27 +0100)]
vaapiencode: add initial support for GStreamer 0.10.

10 years agolibs: add more GstBuffer compat glue for GStreamer 0.10.
Gwenole Beauchesne [Wed, 27 Nov 2013 15:25:59 +0000 (16:25 +0100)]
libs: add more GstBuffer compat glue for GStreamer 0.10.

Add gst_buffer_new_allocate() and gst_buffer_fill() implementations.
Fix gst_buffer_new_wrapped_full() implementation to handle the destroy
notify function.

10 years agolibs: always use built-in videoutils for GStreamer 0.10.
Gwenole Beauchesne [Wed, 27 Nov 2013 14:56:51 +0000 (15:56 +0100)]
libs: always use built-in videoutils for GStreamer 0.10.

GStreamer 0.10.36 is the latest and ultimate version to be released
from the GStreamer 0.10 branch. i.e. no further releases are to be
made. So, we can safely enable the built-in videoutils replacement
now that they are in sync with the 0.10 branch.

10 years agovideoutils: update to master commit d4a15a5.
Gwenole Beauchesne [Wed, 27 Nov 2013 14:47:38 +0000 (15:47 +0100)]
videoutils: update to master commit d4a15a5.

d4a15a5 video: fix compiler warning in header with C++11 / clang-3.1
86096cc videodecoder: minor cosmetic changes to align a bit more with master
b4b8b52 videodecoder: allow parse function to not use all data on adapter
2145495 videodecoder: warn if frame list gets long
36c3753 videodecoder: Also use the object lock to protect the output_state
518c93d videodecoder: fix seeking again
185fb63 video: Correct usage of the base class stream lock
170e944 videodecoder: Expose _negotiate function

10 years agoFix build with GStreamer >= 1.3.
Matthieu Bouron [Tue, 26 Nov 2013 12:06:07 +0000 (12:06 +0000)]
Fix build with GStreamer >= 1.3.

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

Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
10 years agoconfigure: disable encoders with GStreamer 0.10.
Gwenole Beauchesne [Tue, 26 Nov 2013 16:56:59 +0000 (17:56 +0100)]
configure: disable encoders with GStreamer 0.10.

Don't try to build video encoders for GStreamer 0.10. Support code is
not there yet, and probably will never for such an ancient version.

10 years agovaapiencode: fix error handling while allocating output buffers.
Gwenole Beauchesne [Tue, 26 Nov 2013 16:26:44 +0000 (17:26 +0100)]
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.

10 years agovaapiencode: fix error handling in _finish() hook.
Gwenole Beauchesne [Tue, 26 Nov 2013 16:11:22 +0000 (17:11 +0100)]
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.

10 years agovaapiencode: minor clean-ups.
Gwenole Beauchesne [Tue, 26 Nov 2013 15:34:14 +0000 (16:34 +0100)]
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.

10 years agovaapiencode: fix support for raw YUV sink buffers.
Gwenole Beauchesne [Tue, 26 Nov 2013 14:31:03 +0000 (15:31 +0100)]
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.

10 years agovaapiencode: fix support for GStreamer 1.2.
Gwenole Beauchesne [Tue, 26 Nov 2013 14:12:59 +0000 (15:12 +0100)]
vaapiencode: fix support for GStreamer 1.2.

10 years agovaapiencode: initial port to GStreamer 1.2.
Wind Yuan [Thu, 7 Nov 2013 09:42:21 +0000 (17:42 +0800)]
vaapiencode: initial port to GStreamer 1.2.

Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
10 years agoplugins: add mpeg2 encoder element.
XuGuangxin [Wed, 20 Nov 2013 08:21:32 +0000 (16:21 +0800)]
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>
10 years agoplugins: add h264 encoder element.
Wind Yuan [Mon, 29 Jul 2013 08:02:56 +0000 (16:02 +0800)]
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>
10 years agoplugins: add base encoder element.
Wind Yuan [Mon, 29 Jul 2013 05:44:48 +0000 (13:44 +0800)]
plugins: add base encoder element.

vaapiencode element is based on GstVideoEncoder APIs.

Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
10 years agoencoder: add mpeg2 encoder.
XuGuangxin [Wed, 20 Nov 2013 08:20:15 +0000 (16:20 +0800)]
encoder: add mpeg2 encoder.

Add initial support for MPEG-2 encoding. I/P/B frames are supported.

Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
10 years agoencoder: add h264 encoder.
Wind Yuan [Mon, 29 Jul 2013 07:46:11 +0000 (15:46 +0800)]
encoder: add h264 encoder.

Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
10 years agoAdd initial infrastructure for video encoding.
Wind Yuan [Mon, 29 Jul 2013 05:34:06 +0000 (13:34 +0800)]
Add initial infrastructure for video encoding.

Add initial API for video encoding: only basic interfaces and small
encoder objects are implemented so far.

Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
10 years agolibs: add generic bitstream writer.
Wind Yuan [Mon, 29 Jul 2013 07:41:23 +0000 (15:41 +0800)]
libs: add generic bitstream writer.

GstBitWriter provides a bit writer that can write any number of bits
to a pre-allocated memory buffer. Helper functions are also provided
to write any number of bits from 8, 16, 32 and 64 bit variables.

Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
10 years agolibs: add support for rate-control to GstVaapiContext.
Wind Yuan [Fri, 12 Jul 2013 14:07:59 +0000 (22:07 +0800)]
libs: add support for rate-control to GstVaapiContext.

Extend GstVaapiContextInfo structure to hold the desired rate control
mode for encoding purposes. For decoding purposes, this field is not
used and it is initialized to GST_VAAPI_RATECONTROL_NONE.

Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
10 years agolibs: add rate-control attributes.
Wind Yuan [Fri, 12 Jul 2013 13:33:32 +0000 (21:33 +0800)]
libs: add rate-control attributes.

Add GstVaapiRateControl types and GType values in view to supporting
rate controls for encoding. This is meant to be used for instance in
GstVaapiContext.

Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
10 years agoBump version for development.
Gwenole Beauchesne [Fri, 22 Nov 2013 10:56:51 +0000 (11:56 +0100)]
Bump version for development.

10 years agobuild: fix for Wayland headers not in standard include dirs. 0.5.7
Gwenole Beauchesne [Fri, 22 Nov 2013 10:28:09 +0000 (11:28 +0100)]
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

10 years agobuild: link libgstvaapi-wayland against videoutils.
Ross Burton [Thu, 14 Nov 2013 10:58:37 +0000 (10:58 +0000)]
build: link libgstvaapi-wayland against videoutils.

This library is using symbols that don't exist in GStreamer 0.10 so
it needs to link to built-in implementation (libgstvaapi-videoutils).

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

Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
10 years agovaapostproc: fix memory leaks.
Gwenole Beauchesne [Fri, 22 Nov 2013 10:15:57 +0000 (11:15 +0100)]
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.

10 years agovaapipostproc: fix and optimize advanced deinterlacing mode.
Gwenole Beauchesne [Fri, 22 Nov 2013 09:19:06 +0000 (10:19 +0100)]
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.

10 years agovaapipostproc: fix "mixed" mode deinterlacing.
Gwenole Beauchesne [Fri, 22 Nov 2013 09:04:45 +0000 (10:04 +0100)]
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.