Commit graph

1824 commits

Author SHA1 Message Date
Denis Nagorny
4aae03d3c1 libs: display: lock ensure_profile()
Thread safety patch for ensure_profile() function

Fixes #133
2019-02-11 16:14:27 +01:00
Víctor Manuel Jáquez Leal
7afe5311cc vaapisink: x11: trap WM_DELETE_WINDOW message
Register the WM_DELETE_WINDOW message from window manager and
trap it to stop the pipeline cleanly.

Fixes: https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/issues/130
2019-01-24 21:11:54 +01:00
Víctor Manuel Jáquez Leal
8bdd1bf5f6 libs: window: remove native-id property
native-id property is problematic since the variable that stores it is
gsize, which is platform specific, and in some is bigger than unsigned
long, and there are not way to handle gsize properties.

Also, GST_VAAPI_ID_INVALID is defined in gsize terms, and we would
like to keep using it for this scope.

This patch removes the native-id property and set it manually in
gst_vaapi_window_new_internal().
2019-01-22 09:46:57 +00:00
Víctor Manuel Jáquez Leal
92af6b82fa libs: window: use G_GSIZE_MODIFIER for window id
gsize type is not equal in all platforms, then the 'l' print modifier
shall not be used always.

This issue was found in Debian builds.
2019-01-22 09:46:57 +00:00
Wangfei
e6943d668a encoder: h264/h265: set SPS cbr_flag with correct value.
The flag only set as 1 when the rate-control mode is CBR.
2019-01-22 08:50:46 +00:00
Víctor Manuel Jáquez Leal
f1877628bb libs: encoder: refactor to avoid code duplication
gst_vaapi_encoder_put_frame() and gst_vaapi_encoder_flush() duplicates
the same code segment where the coded buffer is created, the picture
encoded on it and pushed to the async queue.

The function gst_vaapi_encoder_encode_and_queue() refactor this.
2019-01-14 20:09:57 +01:00
Víctor Manuel Jáquez Leal
220016aa6c libs: encoder: h264/h265: flush pending ordered pictures
In order to flush the pending pictures, a new internal encoder vmethod
is used: get_pending_reordered()

This method follows an iterator pattern which will return the next
picture to encode and push.

The base encoder will call this function in a loop when flush() is called.

For now, only H.264 and H.265 encoders implement this flushing mechanism.
2019-01-14 20:09:57 +01:00
Wangfei
f50fb8748f libs: encoder: h264/h265: fix encode lose frame issue.
Instead of dropping all remain frames in reorder_frame_list during
flush, keep encoding.

https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/issues/97
2019-01-14 19:08:29 +00:00
Wangfei
14587eb8e8 vaapipostproc: clean up USE_VA_VPP macro since it already removed from
configure file.
2019-01-11 13:50:22 +08:00
Haihao Xiang
5b447753da meson: build h264 fei encoder if possible 2019-01-07 17:46:42 +00:00
Haihao Xiang
920b1ec7a8 vaapi: bump the minimum vaapi version requirement to 0.39.0
And reduce unnecessary API version and structures check as well.

https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/issues/108
2019-01-07 17:46:42 +00:00
Víctor Manuel Jáquez Leal
e4ae7d9879 libs: window: remove custom ref() and unref()
Use gst_object_ref() and gst_object_unref() instead.
2018-12-24 12:20:00 +00:00
Víctor Manuel Jáquez Leal
8ef95a7dc2 libs: window: use its own debug category 2018-12-24 12:20:00 +00:00
Víctor Manuel Jáquez Leal
6c364cb9a7 libs: window: refactor as gobject
This is another step in the gobjectification of the internal library
of gstreamer-vaapi. Now it is the turn of GstVaapiWindow and its
derivates.

The idea is to minimize the changeset keeping the same design as
much as possible.

GstVaapiWindow is defined as an abstract class with two properties:
the GstVaapiDisplay and the native ID. Thus, many of the
GstVaapiObject macros were copied as GstVaapiWindow macros.

The function gst_vaapi_window_new_internal() is kept as a decorator
of for calling gst_vaapi_window_create() and the possibility of
failure.

The descendant classes, such as glx, still use the private
structures, but through the gobject mechanism.
2018-12-24 12:20:00 +00:00
Víctor Manuel Jáquez Leal
7b782be5dd libs: filter: use its own debug category 2018-12-24 12:20:00 +00:00
Niels De Graef
e73e69a480 Use G_DEFINE_TYPE_WITH_PRIVATE if applicable
This gets rid of the strange `do_init` macro and makes the intent a bit
more clear.
2018-12-10 10:54:53 +01:00
Wangfei
5e7988b2d8 libs: dec: h265: support decode for main-444 10bit streams.
Add 444 10bit yuv format Y410, which can be used to decode
main-444 10bit streams. Currently, this feature is only
supported by media-driver in Icelake.
2018-12-04 13:25:59 +08:00
Wangfei
5d0878b48a libs: dec: h265: support decode for main-444 8bit streams.
Add 444 8bit yuv format AYUV, which can be used to decode
main-444 8bit streams. Currently, this feature is only
supported by media-driver in Icelake.

https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/issues/119
2018-11-14 02:29:54 +00:00
He Junyan
90d8350820 libs: Sync the GstVaapiChromaType to VA header file.
Add more kinds of chrometype which will be used to describe
new video formats. Sync it with 1.4.0 version header file.
Alse delete useless GST_VAAPI_CHROMA_TYPE_YUV410 chrome type.

Signed-off-by: He Junyan <junyan.he@hotmail.com>
2018-11-10 19:57:40 +01:00
Tim-Philipp Müller
de6883f6d0 meson: link with -lm
Fixes #117 hopefully.
2018-11-09 23:55:05 +00:00
Junyan He
14c283f891 libs: Modify the video format of endianness.
We lack some video format because endianness declare.
The video format should not directly relate to endianness. For example,
ARGB on big endian should not be simplely seen as BGRA on little endian
machine. We should provide endianess convert or format convert help
functions if endianness does not match.

https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/issues/112

Signed-off-by: Junyan He <junyan.he@intel.com>
2018-11-07 13:29:15 +01:00
Wangfei
b26f3d989d libs: encoder: h264/h264fei: remove unuseless code.
The variable are set twice, remove previous one.

https://bugzilla.gnome.org/show_bug.cgi?id=797365
2018-11-05 14:11:27 +01:00
Víctor Manuel Jáquez Leal
5171a3d5b1 build: meson: declare headers for libgstvaapi
Thus handling its recompilation if needed.
2018-11-05 13:46:17 +01:00
Wangfei
638004875b libs: dec: h265: support decode for main-10-422 10bit streams.
Add 422 10bit yuv format Y210, which can be used to decode
main-10-422 10bit streams. Currently, this feature is only
supported by media-driver in Icelake.

https://bugzilla.gnome.org/show_bug.cgi?id=797264
2018-11-01 14:03:23 +01:00
Wangfei
d8442e479e libs: context: roi_rc_qp_delta_support should not be checked when CQP.
VA_ROI_RC_QP_DELTA_SUPPORT return value will be ignored when the
rate control mode is set as CQP. In CQP mode, it shouldn't check
roi_rc_qp_delta_support return value from driver backend.

https://bugzilla.gnome.org/show_bug.cgi?id=797087
2018-10-16 13:23:41 +02:00
Wangfei
ecdfc623fd libs: context: create context first before using it to create surface.
In gst_vaapi_context_reset(), if the context has to be destroyed, make
sure to create it first before allocating its associated surfaces.

This patch fixes a regression introduced in commit 82872f4 because
the formats available in the current context now are ensured before
creating the context's surfaces.

https://bugzilla.gnome.org/show_bug.cgi?id=797277
2018-10-15 16:54:02 +02:00
Wangfei
82872f4234 libs: context: query surface format before context to create surface.
Before using context to create surface, the supported surface format
should be checked first.

https://bugzilla.gnome.org/show_bug.cgi?id=797222
2018-10-10 20:13:01 +02:00
Víctor Manuel Jáquez Leal
bcd63f8021 libs: replace g_error with GST_ERROR
And handle those errors rather than halting.
2018-10-09 17:23:55 +02:00
Víctor Manuel Jáquez Leal
9132090182 libs: replace g_warning with GST_WARNING 2018-10-09 17:23:30 +02:00
Matteo Valdina
5567a3d2cd libs: Move from g_debug to GST_DEBUG.
https://bugzilla.gnome.org/show_bug.cgi?id=797202
2018-10-09 16:58:43 +02:00
Matteo Valdina
b1b36a44a4 libs: h264: Update level table to "Recommendation H.264 (04/17)".
Added level 6, 6.1 and 6.2. Reference Table A-1 – Level limits
from T-REC-H.264-201704.

https://bugzilla.gnome.org/show_bug.cgi?id=797202
2018-09-27 12:29:10 +02:00
Wangfei
619abbdeb4 libs: dec: h265: add 422 chroma format support.
Add main-422-10 profile which support 422 chroma format stream.
Currently, this feature is only supported by media-driver in Icelake.

https://bugzilla.gnome.org/show_bug.cgi?id=797143
2018-09-27 11:55:04 +02:00
Víctor Manuel Jáquez Leal
cfbe7cbc44 libs: utils: no need of include config.h 2018-09-25 18:22:51 +02:00
Víctor Manuel Jáquez Leal
ae2fbf951a libs: remove already include string.h
Since sysdeps.h includes string.h there's no need to include it again.
2018-09-25 18:22:35 +02:00
Víctor Manuel Jáquez Leal
0152410c97 libs: object: separation of internal API and plugins
Removed exposed macros GST_VAAPI_OBJECT_DISPLAY() and
GST_VAAPI_OBJECT_ID() to plugins, keeping them only for internal
library usage.

The purpose is readability.

https://bugzilla.gnome.org/show_bug.cgi?id=797139
2018-09-25 17:41:55 +02:00
Víctor Manuel Jáquez Leal
9970e15f67 libs: parser_frame: change macros for inlined functions
https://bugzilla.gnome.org/show_bug.cgi?id=797139
2018-09-25 17:41:55 +02:00
Víctor Manuel Jáquez Leal
0e16691b09 libs: videopool: remove unneeded code
The removed code comes frome the bad practice of copy&paste. Better
move it as internal function.

https://bugzilla.gnome.org/show_bug.cgi?id=797139
2018-09-25 17:41:55 +02:00
Víctor Manuel Jáquez Leal
4505acc522 libs: remove dependency on IN_LIBGSTVAAPI_CORE
This conditional code was when libgstvaapi was intended to be library
used outside GStreamer. This not the case anymore, thus removing it.

https://bugzilla.gnome.org/show_bug.cgi?id=797139
2018-09-25 17:41:55 +02:00
Wangfei
f4f935b6f4 libs: dec: h265: fix the macros used for IDC profile
profile_idc flag in SPS only indicate the IDC profile, which may
need some other flags together to get the real profile.

https://bugzilla.gnome.org/show_bug.cgi?id=797160
2018-09-18 13:16:43 +02:00
Jimmy Ohn
7b077cdcb9 libs: use g_clear_pointer() when possible
https://bugzilla.gnome.org/show_bug.cgi?id=797131
2018-09-13 11:35:27 +02:00
Víctor Manuel Jáquez Leal
148d75c8af libs: filter: add gobject's cleanup function 2018-09-03 17:54:19 +02:00
Víctor Manuel Jáquez Leal
ae46b1a91a libs: filter: remove custom ref() and unref()
Replacing them by gst_object_ref() and gst_object_unref()

https://bugzilla.gnome.org/show_bug.cgi?id=796308
2018-09-03 17:54:19 +02:00
Víctor Manuel Jáquez Leal
99183e0184 libs: filter: refactor filter as gobject
https://bugzilla.gnome.org/show_bug.cgi?id=796308
2018-09-03 17:54:19 +02:00
Víctor Manuel Jáquez Leal
a2f923f9e9 libs: decoder: remove destoy() and create() callbacks
They were all replaced by reset()

https://bugzilla.gnome.org/show_bug.cgi?id=796308
2018-09-03 17:54:19 +02:00
Víctor Manuel Jáquez Leal
60dad9fa02 libs: decoder: vp9: implement reset() callback
remove destroy() and create() callback

https://bugzilla.gnome.org/show_bug.cgi?id=796308
2018-09-03 17:54:19 +02:00
Víctor Manuel Jáquez Leal
e493420375 libs: decoder: vp8: implement reset() callback
remove create() and destroy() callbacks

https://bugzilla.gnome.org/show_bug.cgi?id=796308
2018-09-03 17:54:19 +02:00
Víctor Manuel Jáquez Leal
2b207a47cb libs: decoder: vc1: implement reset() callback
remove destroy() and create() callbacks

use g_clear_pointer for rbdu_buffer

no cast for enum

https://bugzilla.gnome.org/show_bug.cgi?id=796308
2018-09-03 17:54:19 +02:00
Víctor Manuel Jáquez Leal
5b3f6eb285 libs: decoder: mpeg4: implement reset() callback
remove destroy() and create() callback

https://bugzilla.gnome.org/show_bug.cgi?id=796308
2018-09-03 17:54:19 +02:00
Víctor Manuel Jáquez Leal
0374a8c0a5 libs: decoder: mpeg2: implement reset() callback
remove create() and destroy() callbacks

https://bugzilla.gnome.org/show_bug.cgi?id=796308
2018-09-03 17:54:19 +02:00
Víctor Manuel Jáquez Leal
c1d65cf1a4 libs: decoder: jpeg: implement reset() callback
and remove create() and destroy() callbacks.

https://bugzilla.gnome.org/show_bug.cgi?id=796308
2018-09-03 17:54:19 +02:00
Víctor Manuel Jáquez Leal
3dbddfa682 libs: decoder: h265: implement reset() callback
and remove create() and destroy()
and use g_clear_pointer for dpb structure

https://bugzilla.gnome.org/show_bug.cgi?id=796308
2018-09-03 17:54:19 +02:00
Víctor Manuel Jáquez Leal
7a9f7f09c7 libs: decoder: h264: remove create() and destroy() callbacks
https://bugzilla.gnome.org/show_bug.cgi?id=796308
2018-09-03 17:54:19 +02:00
Víctor Manuel Jáquez Leal
4649ac1c38 libs: decoder: remove gst_vaapi_decoder_unref()
Replaced by gst_object_unref() in tests

https://bugzilla.gnome.org/show_bug.cgi?id=796308
2018-09-03 17:54:19 +02:00
Víctor Manuel Jáquez Leal
ad5eb75187 libs: decoder: remove gst_vaapi_decoder_ref()
https://bugzilla.gnome.org/show_bug.cgi?id=796308
2018-09-03 17:54:19 +02:00
Víctor Manuel Jáquez Leal
a75329ca94 libs: decoder: remove gst_vaapi_decoder_new()
https://bugzilla.gnome.org/show_bug.cgi?id=796308
2018-09-03 17:54:19 +02:00
Víctor Manuel Jáquez Leal
0ca49a10f8 libs: decoder: refactor decoders as gobject
https://bugzilla.gnome.org/show_bug.cgi?id=796308
2018-09-03 17:54:19 +02:00
Víctor Manuel Jáquez Leal
1f0b2fb952 libs: display: lock at extracting available image formates
When running several vaapi elements at the concurrently, at
initialization, there is a race condition when extractin the avaible
formats for images and subpictures.

This patch add a lock when the those arrays are filled.

https://bugzilla.gnome.org/show_bug.cgi?id=797039
2018-08-31 13:41:58 +02:00
Víctor Manuel Jáquez Leal
5f718b4f93 libs: encoder: h265: trivial documentation fix 2018-08-29 14:49:49 +02:00
Wangfei
2fce126cc7 libs: encoder: h265: add low delay B frame support.
Low delay B frame provide the function of transforming
P frame into low delay B frame which frame type is B, but
only reference predictive frames. This can be used when P
frame unsupported. Especially for P and B both unsupported,
in this case, I and low delay B frame can be encoded in a
stream.

https://bugzilla.gnome.org/show_bug.cgi?id=796984
2018-08-29 14:49:41 +02:00
Nicolas Dufresne
2922439bc2 libs: decoder: h264: Avoid using picture after it has been free
In some cases, the found_picture ended up being evicted and freed, which
would lead to a use after free when accessing picture->base.poc. In this
fix, we take a ref on the picture before calling dpb_evict.

https://bugzilla.gnome.org/show_bug.cgi?id=787124
2018-08-28 18:05:12 -04:00
Nicolas Dufresne
7a120c7a72 h264decoder: Fail decoding slice with missing inter-view reference
Similarly to previous patch, we have no error concealment. As a side
effect, it's better to skip slices with missing references then passing
NULL pointers to the accelerator. Passing NULL pointer would lead to
major visual artifact, a behaviour that is likely undefined.

https://bugzilla.gnome.org/show_bug.cgi?id=787124
2018-08-01 19:43:58 -04:00
Hyunjun Ko
038c62011f libs: decoder: h264: reset context when the number of view is increased
Usually in case of MVC decoding, dpb size is increasedi if subset sps.
That's why it resets context without this patch.
But for some media it doesn't increase dpb size. Even in this case we
should reset context to deal with MVC decoding.
Otherwise, it leads to assert.

https://bugzilla.gnome.org/show_bug.cgi?id=787124
2018-08-01 19:43:58 -04:00
Nicolas Dufresne
06aa82f989 vaapidecode: Skip unparsable units from adapter
If the unit could not be parsed, just skip this nal and keep parsing
what is left in the adapter. We need to flush the broken unit in the
decoder specific parser because the generic code does not know about
units boundary. This increases error resilliance.

Before this, the broken unit would stay in the adapter and EOS would be
returned. Which stopped the streaming. Just removing the EOS would have
lead to the adapter size growing indefinitely.

https://bugzilla.gnome.org/show_bug.cgi?id=796863
2018-07-25 15:52:54 -04:00
Nicolas Dufresne
b9ecf3b40d h265decoder: Don't scan empty buffer
Same as what we did for H264 decoder, this is to avoid an assertion
in the adapter.

https://bugzilla.gnome.org/show_bug.cgi?id=796832
2018-07-25 15:49:51 -04:00
Víctor Manuel Jáquez Leal
9eaff17c30 libs: h264: renable the vaapi category for logging
h264 log messages were logged in default category because a regression
in code. This patch renable the usage of vaapi logging category.

This regression was introduced in commit 7c365bdd.
2018-07-25 20:28:03 +02:00
Nicolas Dufresne
7c365bdddc h264decoder: Fail decoding slice if modification process failed
This patch chains up failure to executing the modification process. The
end result is that we now fail decoding the slice if this process fails.
This avoid sending a corrupted state to the accelerator. In some special
cases, this could lead to unrecoverable errors.

https://bugzilla.gnome.org/show_bug.cgi?id=796832
2018-07-19 16:37:39 -04:00
Nicolas Dufresne
927536b791 h264decoder: Don't scan empty buffer
gst_adapter_masked_scan_uint32_peek() asserts if size is 0. Don't
try and scan in that case. This fixes assertion that would some times
happen when the stream is corrupted.

https://bugzilla.gnome.org/show_bug.cgi?id=796832
2018-07-19 16:37:39 -04:00
Tianhao Liu
f5eb4faa59 libs: encoder: jpeg: set component id and Tqi
This change is due a problem encoding JPEGs with Intel's
media-driver: green/black image when playback jpeg

This patch sets component identifier and quantization table
destination selector in frame header to support packing headers
by Intel's media-driver that does not accept packed header
in AP level.

https://bugzilla.gnome.org/show_bug.cgi?id=796705
2018-07-04 12:10:10 +02:00
Nicolas Dufresne
72ea2a5bc3 h264dec: Remove false assumption about parity order
The decoder was trying to detect earlier that a field was lost base
on guessing the parity order. This breaks in streams were the parity
order changes.

This patch reverts the field order prediction code added by commit
8dd93e9c8.

https://bugzilla.gnome.org/show_bug.cgi?id=796169
2018-06-18 11:43:01 -04:00
Nicolas Dufresne
076af84654 h264dec: Properly set sentinel in ref frame list
This ensure that we always have sentinels set in the reference
pictures arrays. The code wasn't unsafe, this simply improve the
tracing, so instead of printing 32 lines of zeros, va tracer
prints proper empty lists.

https://bugzilla.gnome.org/show_bug.cgi?id=796169
2018-06-14 13:32:12 -04:00
Víctor Manuel Jáquez Leal
6ccd5d6fb2 libs: display: remove gst_vaapi_display_ref()
Replace it with gst_object_ref()

https://bugzilla.gnome.org/show_bug.cgi?id=796470
2018-06-14 16:41:00 +02:00
Víctor Manuel Jáquez Leal
fb1c4c52cc libs: display: remove gst_vaapi_display_unref()
Use gst_object_unref() instead.

https://bugzilla.gnome.org/show_bug.cgi?id=796470
2018-06-14 16:41:00 +02:00
Hyunjun Ko
a6881b9b5e libs: display: replace gst_vaapi_display_new() with gst_vaapi_display_config()
Gobjectification for GstVaapiDisplay was almost done by the commit 185da3d1.
But still something breaking GObject code convention remains, which is
calling gst_vaapi_display_new() in each decendants.

This patch replaces it with gst_vaapi_display_config(), defined in private
header.

https://bugzilla.gnome.org/show_bug.cgi?id=796470
2018-06-14 16:41:00 +02:00
Víctor Manuel Jáquez Leal
8de7dcfe3c libs: display: redefine gst_vaapi_display_create()
The function name was gst_vaapi_display_create_unlocked(), nonetheless
it wasn't called unlocked. In order to keep the semantics this patch
renames the gst_vaapi_display_create_unlocked() as
gst_vaapi_display_create(), removing the previous function
gst_vaapi_display_create().

https://bugzilla.gnome.org/show_bug.cgi?id=796470
2018-06-14 16:41:00 +02:00
Víctor Manuel Jáquez Leal
b0bebebc01 libs: display: resurrect parent private member
This is, practically, a revert of commit dcf135e2.

The parent logic is useful for the EGL display, which is a decorator
of the real windowing subsystem (X11 or Wayland). Thus it is avoided
calling vaInitialize() and vaTerminate() twice.

https://bugzilla.gnome.org/show_bug.cgi?id=795391
2018-06-12 12:43:27 +02:00
Víctor Manuel Jáquez Leal
ad974b4c82 libs: display: egl: initialize params structure
Statically initialise the internal params structure.

https://bugzilla.gnome.org/show_bug.cgi?id=795391
2018-06-12 12:43:27 +02:00
Hyunjun Ko
50470ae89f display: egl: create VaapiDisplayEGL with native EGL display
gst_vaapi_display_egl_new_with_native_display() has been broken since
it wasn't used.

Currently it's needed to call this API to create a display providing
the EGL display, so it could avoid duplicated calls to the native
display (eg. eglTerminate).

Signed-off-by: Victor Jaquez <vjaquez@igalia.com>

https://bugzilla.gnome.org/show_bug.cgi?id=795391
2018-06-12 12:35:04 +02:00
Tianhao Liu
bb8894aaf9 libs: decoder: release VA buffers after vaEndPicture
This change is due a problem decoding JPEGs with Intel's media-driver:
no image was generated.

This patch relases the VA buffers after vaEndPicture() is called,
and not before (after vaRenderPicture()).

https://bugzilla.gnome.org/show_bug.cgi?id=796505
2018-06-08 12:39:06 +02:00
Tim-Philipp Müller
e31248dc28 meson: fix build when xrender or xrandr are not available
HAVE_XRENDER are defined to 1 or 0, not defined or undefined.
2018-06-08 00:56:14 +01:00
Hyunjun Ko
aa77862b62 libs: display: remove unnecessary legacy code since gobjectification
https://bugzilla.gnome.org/show_bug.cgi?id=796470
2018-06-06 19:47:18 +02:00
Hyunjun Ko
3056f06e02 libs: display: remove unused code
https://bugzilla.gnome.org/show_bug.cgi?id=796470
2018-06-06 19:47:18 +02:00
Hyunjun Ko
676e558331 libs: encoder: h265: increase log2_max_pic_order_cnt range according to spec
The specification says,
"log2_max_pic_order_cnt_lsb_minus4 shall be in the range of 0 to 12, inclusive."

This patch changes the upper limit from 6 to 12.

https://bugzilla.gnome.org/show_bug.cgi?id=796179
2018-06-04 18:38:54 +02:00
Víctor Manuel Jáquez Leal
e93232bbf4 libs: decoder: h264: use g_clear_pointer() 2018-05-18 18:42:49 +02:00
Víctor Manuel Jáquez Leal
41ab71a4fa libs: decoder: mpeg4, vc1: remove unused header 2018-05-18 18:42:35 +02:00
Víctor Manuel Jáquez Leal
4233987278 libs: decoder: remove unused forward declaration 2018-05-18 18:42:21 +02:00
Víctor Manuel Jáquez Leal
77527d67ab libs: remove gstbitwriter
Since it is deployed in gstreamer-core, there is no need to use
our custom version.

https://bugzilla.gnome.org/show_bug.cgi?id=795848
2018-05-06 17:29:45 +02:00
Hyunjun Ko
4af46f00c2 libs: egl: utils: mark context as wrapped when it is
The returning egl context may be null, so we should check the
return value.

https://bugzilla.gnome.org/show_bug.cgi?id=795391
2018-04-25 18:00:17 +02:00
Víctor Manuel Jáquez Leal
9fde93f80c libs: egl: utils: fix usage of GstGL macros
Include gl.h for the required GstGL symbols.

https://bugzilla.gnome.org/show_bug.cgi?id=795391
2018-04-25 16:29:28 +02:00
Tim-Philipp Müller
3900b4b36f meson: fix miscellaneous meson warnings
WARNING: Passed invalid keyword argument "rqeuired".
gst-libs/gst/base/meson.build:11: WARNING: Passed invalid keyword argument "version".
gst-libs/gst/base/meson.build:11: WARNING: Passed invalid keyword argument "soversion".
gst-libs/gst/vaapi/meson.build:223: WARNING: Passed invalid keyword argument "version".
gst-libs/gst/vaapi/meson.build:223: WARNING: Passed invalid keyword argument "soversion".
2018-04-20 11:50:55 +01:00
Paul Kocialkowski
5ee46f6751 display: drm: Allow finding DRM paths out of the PCI subsystem
This removes hard-coded checks on the parent subsystem of potential DRM
devices. These checks were set to exlude devices that do not originate
from the PCI bus, which is only a valid approach on x86 devices.

Other devices may have a DRM device originating from the platform
subsystem, so the checks that were previously restricted to PCI are
extended to cover platform devices as well.

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

Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
2018-04-19 17:42:43 +02:00
Hyunjun Ko
1825d939e7 libs: display: wayland: add gst_vaapi_display_wayland_new_with_va_display()
Implements new API function so that users could create GstVaapiDisplay
with their own VADisplay within a native display as backend.

https://bugzilla.gnome.org/show_bug.cgi?id=705821
2018-04-18 18:01:06 +02:00
Michael Olbrich
1f71b5a57d wayland: don't poll if there are no pending frames
Otherwise the following poll may not return for an arbitrary amount of
time. This can happen if another wayland event queue has flushed and read
our events.

https://bugzilla.gnome.org/show_bug.cgi?id=795224
2018-04-18 13:57:53 +02:00
Hyunjun Ko
e19570a8b6 libs: encoder: h265: 16 bit rounding of picture width and height
pic_width_in_luma_samples/pic_height_in_luma_samples can be 16-bit rounded
instead of 32-bit.

In addition, codedbuf_size must be calculated according to this change.

https://bugzilla.gnome.org/show_bug.cgi?id=753229
2018-04-16 15:57:21 +02:00
Julien Isorce
bfa2fbd39b libs: decoder: h264: ensure num_ref_frames is greater than 0
Even if it is the h264parse fault or bad video file, vaapih264dec
should set a proper value for VAPictureParameterBufferH264.num_ref_frames
as the driver might use it.

Also see "info.ref_frames = dpb_size;" in
gstvaapidecoder_h264.c::ensure_context

https://bugzilla.gnome.org/show_bug.cgi?id=793836
2018-03-16 11:14:48 -06:00
Víctor Manuel Jáquez Leal
c49a17ed15 libs: encoder: reimplement ROI using meta
Check input buffers for ROI metas and pass them to VA. Also added a
new "default-roi-delta-qp" property in order to tell the encoder what
delta QP should be applied to ROI by default.

Enabled it for H264 and H265 encoders.

https://bugzilla.gnome.org/show_bug.cgi?id=768248
2018-02-27 17:51:02 -05:00
Víctor Manuel Jáquez Leal
d3110713b8 Revert "libs: encoder: add api gst_vaapi_encoder_add/del_roi"
This reverts commit 7a6f690340.

https://bugzilla.gnome.org/show_bug.cgi?id=768248
2018-02-27 17:51:02 -05:00
Víctor Manuel Jáquez Leal
863b7fa6e0 libs: surface: cast to uintptr_t pointer
According to Debian package auto-building, uintptr_t is not an
unsigned long in i386 arch, raising an "incompatible pointer type"
error.

This patch adds a casting for compiler's satisfaction in i386.
2018-02-27 10:02:14 -06:00
Matteo Valdina
02c7c1bc17 libs: encoder: add zero as valid value for periodic keyframe.
Enabled zero as valid value for keyframe-period property.

https://bugzilla.gnome.org/show_bug.cgi?id=793829
2018-02-26 10:04:29 -06:00
Víctor Manuel Jáquez Leal
d18d6a8bd0 libs: encoder: code-style fix 2018-02-22 08:24:12 -06:00
Matteo Valdina
83886ced66 libs: encoder: h264,h265: extend max periodic keyframe.
Increased max values of periodic key frame for h26x codecs.
This allow more fine tunning of encoder that in certian scenario
want higher periodic key frame.

For example: it doesn't want a key frame each 10 seconds but
each 120 seconds.

https://bugzilla.gnome.org/show_bug.cgi?id=786320
2018-02-19 22:34:53 +01:00
Víctor Manuel Jáquez Leal
d26dc92021 build: meson: add missing GstGL dependency 2018-01-17 13:00:45 +01:00
Víctor Manuel Jáquez Leal
7418d4e954 libs: utils: egl: add missing guards for GstGL 2018-01-17 12:41:54 +01:00
Víctor Manuel Jáquez Leal
7e05160aaa libs: egl: utils: use eglGetPlatformDisplay()
eglGetDisplay() is currently broken in Mesa for Wayland.  Also using
eglGetDisplay() is rather fragile, and it is recommended to use
eglGetPlatformDisplay() when possible.

In order to do that, this patch uses the helper in GstGL. If
gstreamer-vaapi is not compiled with GstGL support, eglGetDisplay()
will be used.

https://bugzilla.gnome.org/show_bug.cgi?id=790493
2018-01-12 20:19:59 +01:00
Víctor Manuel Jáquez Leal
20b95f0fec libs: window: wayland: remove unused header include
Remove wayland-client.h include since there is no exposed symbols from
it.
2017-11-27 13:04:24 +01:00
Víctor Manuel Jáquez Leal
bfc7f66708 libs: encoder: h264,h265: guard rate control's macroblock
macroblock parameter appear on VA-API 1.0.0. It should be guarded.
2017-11-27 12:18:56 +01:00
Sreerenj Balachandran
6a3f30aab1 libs: encoder: h264: Add Hierarchical-B encode
Frames are encoded as different layers. Frame in a particular
layer will use pictures in lower or same layer as references.
Which means decoder can drop the frames in upper layer but still
decode lower layer frames.

B-frames, except the one in top most layer, are reference frames.
All the base layer frames are I or P.

eg: with 3 temporal layers

    T3:             B1            B3              B5              B7

    T2:                   B2                              B6

    T1:   I0                                P4                        P8

    T1, T2, T3: Temporal Layers
    P1...Pn:   P-Frames:
    B1...Bn:   B-frames:
    T1: I0->P4 , P4->P8 etc..
    T2: I0--> B2 <-- P4
    T3: I0--> B1 <-- B2, B2 --> B3 <-- P4

Signed-off-by: Sreerenj Balachandran <sreerenj.balachandran@intel.com>

https://bugzilla.gnome.org/show_bug.cgi?id=788918
2017-11-08 13:15:03 +01:00
Sreerenj Balachandran
53c83691f3 libs: encoder: h264: Add Hierarchical-P encode
Frames are encoded as different layers. A frame in a particular
layer will use pictures in lower or same layer as references.
Which means decoder can drop the frames in upper layer but still
decode lower layer frames.

eg: with 3 temporal layers

T3:             P1            P3              P5              P7

T2:                   P2                              P6

T1:   P0                                P4                        P8

T1, T2, T3: Temporal Layers
P1...pn:   P-Frames:
P0->P1 , P0->P2, P2->P3, P0->P4......repeat

Signed-off-by: Sreerenj Balachandran <sreerenj.balachandran@intel.com>

https://bugzilla.gnome.org/show_bug.cgi?id=788918
2017-11-08 13:15:03 +01:00
Sreerenj Balachandran
904931d7f3 libs: encoder: h264: Fix frame_num generation
The frame_num generation was not correctly implemented.
According to h264 spec, frame_num should get incremented
for each frame if previous frame is a referece frame.

For eg: IPBPB sequece should have the frame numbers 0,1,2,2,3

Signed-off-by: Sreerenj Balachandran <sreerenj.balachandran@intel.com>

https://bugzilla.gnome.org/show_bug.cgi?id=788918
2017-11-08 13:15:03 +01:00
Sreerenj Balachandran
ff91d62415 libs: encoder: h264: Add new property "prediction-type"
Adds new property "prediction-type" to select different reference
picture selection modes like hierarchical-p, hierarchical-b etc.

Signed-off-by: Sreerenj Balachandran <sreerenj.balachandran@intel.com>

https://bugzilla.gnome.org/show_bug.cgi?id=788918
2017-11-08 13:14:54 +01:00
XuGuangxin
dc583452d8 libs: encoder: h264: Add machinery for implementing hierarchical-prediction
Adds some basic building blocks to ease the implementation
of hierarchical prediction modes.

-- add an utility method to find temporal level of each frame
-- define max_ref_frame count based on temporal level count
-- add temporal_level_div[] for finding temporal level each frame
to be encoded.
-- find ip_period based on temporal level count

Signed-off-by: Sreerenj Balachandran <sreerenj.balachandran@intel.com>

https://bugzilla.gnome.org/show_bug.cgi?id=788918
2017-11-08 12:33:50 +01:00
XuGuangxin
e49859fde0 libs: encoder: h264: Add property "temporal-levels"
Adds new property "temporal-levels" to select the number of
temporal levels to be included in the encoded stream.

Signed-off-by: Sreerenj Balachandran <sreerenj.balachandran@intel.com>

https://bugzilla.gnome.org/show_bug.cgi?id=788918
2017-11-08 12:33:50 +01:00
XuGuangxin
89717a447f libs: encoder: objects: Add a reference flag
We can have p-frame as non-ref and also b-frame as ref
which are not supported yet. Reference flag
is the first machinery needed for more advanced
reference picture selection modes.

Signed-off-by: Sreerenj Balachandran <sreerenj.balachandran@intel.com>

https://bugzilla.gnome.org/show_bug.cgi?id=788918
2017-11-08 12:33:50 +01:00
Daniel van Vugt
e1f9959eb5 libs: surface: egl: add comment
Add a warning comment when using old intel-vaapi-drivers (>1.8.4),
where the creation of surfaces from GEM fd may fail.

https://bugzilla.gnome.org/show_bug.cgi?id=773453
2017-11-06 18:00:14 +01:00
Víctor Manuel Jáquez Leal
429e800204 libs: display: egl: add gst_vaapi_display_egl_set_current_display()
Adds a new function that changes the internal EGL display to the
current one (eglGetCurrentDisplay()) and sets the current context
too (eglGetCurrentContext()).

This new function is called by gst_vaapi_texture_egl_create() updating
the GstVaapiDisplayEGL with the current EGL display.

https://bugzilla.gnome.org/show_bug.cgi?id=773453
2017-11-02 11:18:50 +01:00
Víctor Manuel Jáquez Leal
98a136ae2a libs: texture: egl: update EGL display and context
It is required to use the context of the calling thread when wrapping
a foreign texture. According the documentation of
GstVideoGLTextureUploadMeta:

 "The caller of gst_video_gl_texture_upload_meta_upload() must
  have OpenGL set up and call this from a thread where it is valid
  to upload something to an OpenGL texture."

This patch updates the EGL display and context in GstVaapiDisplay
instance to the one used by te renderer that uploads the texture.

Original-patch-by: Daniel van Vugt <daniel.van.vugt@canonical.com>

https://bugzilla.gnome.org/show_bug.cgi?id=773453
2017-11-01 11:27:36 +01:00
Víctor Manuel Jáquez Leal
ac31160dfc libs: display: egl: free leaked memory
The EGL VAAPI display forgot to release the egl display, context and
proxied VAAPI display.

https://bugzilla.gnome.org/show_bug.cgi?id=773453
2017-11-01 11:27:36 +01:00
Víctor Manuel Jáquez Leal
0840c08cf1 libs: texture: egl: code style
https://bugzilla.gnome.org/show_bug.cgi?id=773453
2017-11-01 11:27:36 +01:00
Víctor Manuel Jáquez Leal
ea503ed085 libs: surface: egl: error message if no extension
Instead of silently fail to export the image if there is not available
the EGL_MESA_drm_image, log an error message. Also a code refactoring
was done.

https://bugzilla.gnome.org/show_bug.cgi?id=773453
2017-11-01 11:27:36 +01:00
Hyunjun Ko
acfabb3561 libs: encoder: allow to set bitrate on runtime
In case of streaming, controlling bitrate dynamically for encoder might be
important to manage quality of the streaming.

This patch is to support such a scenario.

https://bugzilla.gnome.org/show_bug.cgi?id=786321
2017-10-20 13:22:51 +02:00
Víctor Manuel Jáquez Leal
c7d712a932 libs: utils: log warn if display fail
gstreamer-vaapi initializes the display by trial-and-error, thus
logging an error message if the display initialisation fails the user
may be weary of the error message in the screen, if using VA-API 1.0

This commit set the VA error log handler to GStreamer warning level
while calling vaInitialize() and set it to error after that.

https://bugzilla.gnome.org/show_bug.cgi?id=783169
2017-10-03 13:37:23 +02:00
Víctor Manuel Jáquez Leal
63a76c9dd0 libs: display: delay getting screen resolution
Instead of extracting the screen resolution at GstVaapiDisplay
creation, this patch delay it until the screen size is requested for
first time.

https://bugzilla.gnome.org/show_bug.cgi?id=782212
2017-10-03 13:14:55 +02:00
Víctor Manuel Jáquez Leal
66e4593c33 libs: display: egl: avoid two vaDisplay instantiates
GstVaapiDisplayEGL is a wrapper of another GstVaapiDisplay, either X11
or Wayland. Nonetheless it created another vaDisplay for it, instead
of using the wrapped one.

This patch enables the reuse of the wrapped vaDisplay avoiding
instantiating two.

https://bugzilla.gnome.org/show_bug.cgi?id=782212
2017-10-03 13:14:55 +02:00
Víctor Manuel Jáquez Leal
494ac4e3a8 libs: display: remove display_type from display info
Since it's no required to pass the display type in the display info,
the structure member is removed.

https://bugzilla.gnome.org/show_bug.cgi?id=782212
2017-10-03 13:14:55 +02:00
Víctor Manuel Jáquez Leal
4e9de44ba2 libs: display: remove display_type member
It is not used any more since GstVaapiDisplay was ported as a
GstObject-based. This information is part of the class information.

https://bugzilla.gnome.org/show_bug.cgi?id=782212
2017-10-03 13:14:55 +02:00
Víctor Manuel Jáquez Leal
dcf135e2a5 libs: display: remove parent member
Parent was a crumb left from display cache.

https://bugzilla.gnome.org/show_bug.cgi?id=782212
2017-10-03 13:14:55 +02:00
Víctor Manuel Jáquez Leal
b23ccc69b0 libs: display: initialize value if they are not yet
This is a difference between the GObject API and the GstVaapi one: the
GValue passed to get a property value, in GObject has to be
initialized with g_value_init(), but in GstVaapi is has not.

In order to overcome this mismatch, this patch call g_value_init()
internally only in the passed one is not already initialized.

https://bugzilla.gnome.org/show_bug.cgi?id=788058
2017-09-22 20:06:42 +02:00
Víctor Manuel Jáquez Leal
6b35e00a28 libs: display: optimize properties setters and getters
Shuffled some code to avoid to find the properties descriptor in the
array twice, adding the internal functions _set_property() and
_get_property().

https://bugzilla.gnome.org/show_bug.cgi?id=788058
2017-09-22 20:06:42 +02:00
Víctor Manuel Jáquez Leal
0eeef92911 libs: display: install properties in class
Install the properties in the class as a normal GObject. Implement
set_property() and get_property() vmethods.

https://bugzilla.gnome.org/show_bug.cgi?id=788058
2017-09-22 20:06:42 +02:00
Víctor Manuel Jáquez Leal
9dcaa0d09f libs: display: remove gst_vaapi_display_properties_init()
Remove gst_vaapi_display_properties_init() since it can be unrolled in
gst_vaapi_display_class_init()

https://bugzilla.gnome.org/show_bug.cgi?id=788058
2017-09-22 20:06:42 +02:00
Víctor Manuel Jáquez Leal
9116ffb7b7 libs: display: remove libgstvaapi_init_once()
It is not required since it can be unrolled in
gst_vaapi_display_class_init()

https://bugzilla.gnome.org/show_bug.cgi?id=788058
2017-09-22 20:06:42 +02:00
Hyunjun Ko
b107520587 libs: decoder: h264/h265: decode codec data only if opened
Fixes regression introduced by commit 2eb2b26a.

There is a use case when the decoder set the src caps and immediatly
tries to process the media codec_data, this happens before decoder is
even opened, thus priv->parser is not instantiated yet.

https://bugzilla.gnome.org/show_bug.cgi?id=787818
2017-09-19 19:20:42 +02:00
Víctor Manuel Jáquez Leal
e308b452d6 libs: encoder: change mbbrc from uint to enum
Instead of handling the macroblock bitrate control as a integer, this
patch changes it as a enum, which is more self documented in the
GStreamer elements.

https://bugzilla.gnome.org/show_bug.cgi?id=787855
2017-09-18 20:19:20 +02:00
Jan Schmidt
b7c7335238 Fix a typo in the prop string for compliance-mode 2017-09-18 13:55:49 +10:00
Víctor Manuel Jáquez Leal
29cf49d56a libs: encoder: don't unref properties
This patch fixes a regression introduced in commit 148f867c, since the
props variable is set to object's member variable
encoder->properties. And it is set in the instance initialization,
thus it will not be leaked.

https://bugzilla.gnome.org/show_bug.cgi?id=787733
2017-09-15 18:34:49 +02:00
Hyunjun Ko
148f867c12 vaapiencode/libs: encoder: fix leaks of properties
https://bugzilla.gnome.org/show_bug.cgi?id=786321
2017-09-15 11:07:55 +02:00
Víctor Manuel Jáquez Leal
2eb2b26ad8 libs: decoder: at update_caps() decode codec_data
When updating the caps in decoder, if the caps has codec_data (avC
format), it has to be parsed to update the state of the decoder.

https://bugzilla.gnome.org/show_bug.cgi?id=786173
2017-09-14 16:58:17 +02:00
Hyunjun Ko
9875c0d84e libs: context: fix wrong counter of the array of attributes
The counter value passed to vaCreateConfig is always +1.

This is a regression caused by commit e42ec3ad.

The present patch fixes wrong counting of the array of attributes.

https://bugzilla.gnome.org/show_bug.cgi?id=787613
2017-09-13 10:56:16 +02:00
Hyunjun Ko
5333155e27 libs: encoder: h265: support I/P/B QP setting seperatedly
Creates 2 properties, qp-ip and qp-ib for setting different QP for P/B
frames
and set slice_qp_delta for each frame according to the value provided.

https://bugzilla.gnome.org/show_bug.cgi?id=785923
2017-09-13 10:47:22 +02:00
Hyunjun Ko
64a38a16f1 libs: encoder: h264: support I/P/B QP setting seperatedly
Creates 2 properties, qp-ip and qp-ib for setting different QP for P/B
frames
and set slice_qp_delta for each frame according to the value provided.
In addition, remove the limitation of (<= 4) when setting
slice_qp_delta.

https://bugzilla.gnome.org/show_bug.cgi?id=785923
2017-09-13 10:47:22 +02:00
Hyunjun Ko
5796750604 libs: encoder: h264/h265: keep min_qp as is unless it's over init_qp
Creates new variable for QP for I frame and keep it at configuration and
use this for pic_init_qp and slice_qp_delta setting.

Since changing min qp doesn't make sense, keep min qp as is.

https://bugzilla.gnome.org/show_bug.cgi?id=785923
2017-09-13 10:47:22 +02:00
Hyunjun Ko
e7c099b957 libs: encoder: h265: Add mbbrc property
This property supports Macroblock level Bitrate Control as the
following (same as h264 encoder):
0: auto
1: on
2: off

https://bugzilla.gnome.org/show_bug.cgi?id=785917
2017-09-13 10:45:49 +02:00
Hyunjun Ko
6816d7c151 libs: encoder: h264: Add mbbrc property
This property supports Macroblock level Bitrate Control as the
following:
0: auto
1: on
2: off

https://bugzilla.gnome.org/show_bug.cgi?id=785917
2017-09-13 10:45:49 +02:00
Hyunjun Ko
aa6aa996d6 libs: encoder: h265: add multi reference support
This is doing the same as h264 encoder as the following:

Using num_ref_frames provided and the result of the Query
VAConfigAttribEncMaxRefFrames, it determines the size of reference list
and perform encoding with multi reference frames as the following:

1\ The num_ref_frames is being considered as the number of
reference picture list0
2\ Encoder adds 1 reference frame more to the reference picture list1
internally if b-frame encoding.
3\ If num_ref_frames is bigger than the number of refrence frames
supported in the driver, it will be lowered.

Also this patch includes:
- Set num_negative_pics and num_positive_pics according to the number of
refs.
- Set delta_poc according to the number of refs.
- Increase max_dec_pic_buffering according to the number of refs
- Change max_num_reorder_pics according to num of bframes

https://bugzilla.gnome.org/show_bug.cgi?id=783804
2017-09-13 10:36:34 +02:00
Hyunjun Ko
3dbf440373 libs: encoder: h265: add refs property
Users can provide the number of reference frame by this property,
which is exaclty same as h264.

The value of the property will be considered as the number of
reference picture list0 and will add 1 reference frame more to the
reference picture list1 internally if b-frame encoding.

If the value provided is bigger than the number of refrence frames
supported in the driver, it will be lowered.

The maximum value is aligned to the value of the driver supported now.

https://bugzilla.gnome.org/show_bug.cgi?id=783804
2017-09-13 10:36:34 +02:00
Hyunjun Ko
f14563759a libs: encoder: h264/5: determine num_ref_idx_active_override_flag according to reference list
Follows the specification as below:

7.4.7.1 in Rec. ITU-T H.265 v4 (12/2016)
num_ref_idx_active_override_flag equal to 1 specifies that the syntax
element num_ref_idx_l0_active_minus1 is present for P and B slices and
that the syntax element num_ref_idx_l1_active_minus1 is present for B
slices.
num_ref_idx_active_override_flag equal to 0 specifies that the syntax
elements num_ref_idx_l0_active_minus1 and num_ref_idx_l1_active_minus1
are not present.

https://bugzilla.gnome.org/show_bug.cgi?id=783804
2017-09-13 10:36:34 +02:00
Hyunjun Ko
f7886008e3 libs: encoder: h265: keep idr_period equal to keyframe period
Remove FIXME code, which makes previous assignation spurious.
This also means to make idr_period equal to keyframe period,
which is same as h264 encoder.

https://bugzilla.gnome.org/show_bug.cgi?id=783804
2017-09-13 10:36:34 +02:00
U. Artie Eoff
6e3bfbc014 libs: encoder: h264_fei: VA-API 1.0 compat
Use VA_ENC_PACKED_HEADER_H264_SEI compat macro for VA-API 1.0
compatibility.

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

Signed-off-by: U. Artie Eoff <ullysses.a.eoff@intel.com>
2017-09-05 10:58:57 -07:00
Sreerenj Balachandran
7e0d5b934b FEI: libs: Add FEI encoder
Adding FEI encoder to core lib.

The code is splitted into three session:

1: gstvaapiencoder_h264_fei.{h,c}
This is the replica of gstvaapiencoder_h264.{c,h} but with FEI.
All the modes ENC, PAK and ENC_PAK are running based
the code in these files.

2: gstvaapifeienc_h264.{h,c}
Abstract implementation intended for ENC (only VME) operation.

3: gstvaapifeipak_h264.{h,c}
Abstrct implementation intended for PAK (only the PAK module)

Right now ENC_PAK, ENC and PAK are running based on code
in gstvaapiencoder_h264_fei.{h,c}. The abstract implementations
in gstvaapifeienc_h264.{h,c} and gstvaapifeipak_h264.{h,c} are
needed if user request for ENC+PAK mode operation.

ENC+PAK: Here we need to invoke two sequence of
vaBeginPicture/vaRenderPicutre/vaEndPicture for each frame,
first for the ENC only and the second for PAK only.
Each mode associated with separate context ,but same pool of surfaces are
shared between the modes.
This is more useful once we have custom BRC algorithms.

Other Contributors:
                   Wang, Yi <yi.a.wang@intel.com>
                   Leilei <leilei.shang@intel.com>
                   Zhong, Xiaoxia <xiaoxia.zhong@intel.com>
                   xiaominc <xiaomin.chen@intel.com>
                   Li, Jing B <jing.b.li@intel.com>

https://bugzilla.gnome.org/show_bug.cgi?id=785712
https://bugzilla.gnome.org/show_bug.cgi?id=784667
2017-09-01 11:36:13 +02:00
Sreerenj Balachandran
de2e4cd9bc FEI: libs: Add fei codec objects to GstVaapiEncPicture
All the codec objects(vaapi buffers) supposed to be
submited in vaRenderPicutre are associated with a GstVaapiEncPicture
for each frame, follow the same design for FEI too.

https://bugzilla.gnome.org/show_bug.cgi?id=785712
https://bugzilla.gnome.org/show_bug.cgi?id=784667
2017-09-01 11:32:24 +02:00
Sreerenj Balachandran
132eacde79 FEI: libs: Add fei codec objects in codedbufferproxy
MbCode, MV and Distortion buffers (fei codec objects)
can be treated as output of different fei modes based user request.
For eg: MbCode and MV are the output of ENC only. MbCode, MV and Dist
can be dumped as output in ENC_PAK mode for analysis purpose.
So treating them as a part of CodedBufferProxy too.
Here we avoided Qp, MbControl and MvPredictor codec objects since
there is no practical use case of treating them as "output buffers".

Other contributors:
               Zhong, Xiaoxia <xiaoxia.zhong@intel.com>
               xiaominc <xiaomin.chen@intel.com>
               Leilei <leilei.shang@intel.com>
               Li, Jing B <jing.b.li@intel.com>

https://bugzilla.gnome.org/show_bug.cgi?id=785712
https://bugzilla.gnome.org/show_bug.cgi?id=784667
2017-09-01 11:32:24 +02:00
Sreerenj Balachandran
d5542fa8c0 FEI: libs: Add fei codec objects to surface proxy
Add fei codec objects to surface proxy since handling the
fei buffers(codec objects here) external to gstvaapisurfaceproxy
will make the code complicated. Especially considering the behavior
of encoder where the input frame order from upstream and output
frame order to the downstream are not sequential.

Other contributors:
              Zhong, Xiaoxia <xiaoxia.zhong@intel.com>
              xiaominc <xiaomin.chen@intel.com>
              Leilei <leilei.shang@intel.com>
              Li, Jing B <jing.b.li@intel.com>

https://bugzilla.gnome.org/show_bug.cgi?id=785712
https://bugzilla.gnome.org/show_bug.cgi?id=784667
2017-09-01 11:32:24 +02:00
Sreerenj Balachandran
d0d9f5e274 FEI: Add codec objects for fei usecase
There are 6 new va buffer types, each defined as a specific codec object.
Borrowed the code from gstvaapicodecobject , but made a clear separation
to avoid any possible mess-up. Because unlike the other gstvaaicodecobjects,
feicodecobjects can be shared between elements and also can be accessed
from different thread.

Unlike the other fei codecs object, VAEncMiscParameterTypeFEIFrameControl
object is not shared between elements.So we utilize the already
existing gst_vaapi_enc_misc_param_new(), but still keeping the code
in gstvaapfei_objects_priv.h in order to have a better
code readability.

Fixme:
-- Probably we need _locked_map() and _unlocked_map()
-- Context can be associated with PreEnc(not just Enoder)
once we have the proper support inplace, but for now we don't have
PreEnc support, so should be safe enough to use GstVaapiEncoder.

https://bugzilla.gnome.org/show_bug.cgi?id=785712
https://bugzilla.gnome.org/show_bug.cgi?id=784667
2017-09-01 11:32:24 +02:00
Sreerenj Balachandran
0b91ebeb2c FEI: libs: add H264 fei specific utility functions
Added enum/flag type definitions for a number of FEI
input and output parameters.

Original author of the patch: Wang, Yi <yi.a.wang@intel.com>

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

Signed-off-by: Wang, Yi <yi.a.wang@intel.com>
Signed-off-by: Sreerenj Balachandran <sreerenj.balachandran@intel.com>
2017-09-01 11:32:24 +02:00
Sreerenj Balachandran
94483de40f FEI: libs: Add virtual method for secondary context creation.
Add a new vitrual method ensure_secondary_context to the
base encoder which is only required for the FEI entrypoint, that too
only when user configures the ENC+PAK mode. ENC+PAK mode is not something
supported directly by libva or driver, but this can be enabled
from the middleware.

Original Author of this idea: Leilei Shang <leilei.shang@intel.com>

Signed-off-by: Leilei Shang <leilei.shang@intel.com>
Signed-off-by: xiaominc <xiaomin.chen@intel.com>
Signed-off-by: Sreerenj Balachandran <sreerenj.balachandran@intel.com>

https://bugzilla.gnome.org/show_bug.cgi?id=785712
https://bugzilla.gnome.org/show_bug.cgi?id=784667
2017-09-01 11:32:24 +02:00
Sreerenj Balachandran
ac1de3d39a FEI: libs: make sure the default context creation works as expected.
Current code always guess the entrypoint during init phase in case
if there is no entrypoint already configured in GstVaapiContextInfo.
Make sure FEI Entrypoint is not messing up with this logic.

https://bugzilla.gnome.org/show_bug.cgi?id=785712
https://bugzilla.gnome.org/show_bug.cgi?id=784667
2017-09-01 11:32:24 +02:00
Sreerenj Balachandran
7d77cdd9f7 FEI: libs: Add FEI functional mode configuration
FEI Entrypoint can work in either one of the 3 different modes:
VA_FEI_FUNCTION_ENC, VA_FEI_FUNCTION_PAK or VA_FEI_FUNCTION_ENC_PAK.

Add infrastructure in gstvaapicontext and gstvaapiencoder for this
functioal mode configuration.

https://bugzilla.gnome.org/show_bug.cgi?id=785712
https://bugzilla.gnome.org/show_bug.cgi?id=784667
2017-09-01 11:32:07 +02:00
Sreerenj Balachandran
6bbe79925c FEI: libs: Add FEI Entrypoint mapping
Define the new mapping GST_VAAPI_ENTRYPOINT_SLICE_ENCODE_FEI
for VAEntrypointFEI.

https://bugzilla.gnome.org/show_bug.cgi?id=785712
https://bugzilla.gnome.org/show_bug.cgi?id=784667
2017-09-01 11:27:28 +02:00
Orestis Floros
0955752898 libs: decoder: h264: decode SVC base layer only
Drops non-base NALs when the base-only property is set to TRUE.
This modifies the behavior for MVC streams with base-only too: All the
non-base units are dropped before they are decoded instead of dropping
the non-base frames.

The relevant part from the H264 spec is:
> Decoders that conform to one or more of the profiles specified in
Annex A rather than the profiles specified in Annexes G or H shall
ignore (remove from the bitstream and discard) the contents of all NAL
units with nal_unit_type equal to 14, 15, or 20.

To eliminate side effects from the offending units:
- PPS's with a broken seq_parameter_set_id (referring to dropped subset
SPS's) are ignored.
- The NAL parsing is skipped and their flags are set to
GST_VAAPI_DECODER_UNIT_FLAG_SKIP.
- Prefix units are not stored in prev_pi. Otherwise, parse_slice() would
use them even if they are flagged to be skipped. Subset SPS's and slice
extension units are not stored there either.

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

Signed-off-by: Sreerenj Balachandran <sreerenj.balachandran@intel.com>
2017-08-28 17:32:57 -07:00
Orestis Floros
a016aa181b libs: decoder: h264: check nalu validity in parser info finalize
https://bugzilla.gnome.org/show_bug.cgi?id=732266

Signed-off-by: Sreerenj Balachandran <sreerenj.balachandran@intel.com>
2017-08-28 17:31:22 -07:00
Víctor Manuel Jáquez Leal
3bfb29e4c2 libs: encoder: remove unused cast macro
Remove internal macro to cast structure that are already declared
in the header.
2017-08-28 19:20:42 +02:00
Víctor Manuel Jáquez Leal
9c2246740b Revert "libs: encoders: remove unused cast macros"
This reverts commit fd7d38f7d2.
2017-08-28 19:09:07 +02:00
Víctor Manuel Jáquez Leal
fd7d38f7d2 libs: encoders: remove unused cast macros
They are only used inside the code, where another macro is defined.
Thus these exported macros have no use.
2017-08-28 18:32:36 +02:00
Víctor Manuel Jáquez Leal
d9c88f4785 libs: decoder: h264: improve code-style
https://bugzilla.gnome.org/show_bug.cgi?id=786173
2017-08-25 16:51:38 +02:00
Víctor Manuel Jáquez Leal
b942f9e17f libs: encoder: h264: handle deprecated enum
In VA-API 1.0 the enum VAEncPackedHeaderH264_SEI is deprecated, and
instead VAEncPackedHeaderRawData should be used.

This patch creates a compatibility symbol,
VA_ENC_PACKED_HEADER_H264_SEI, to expose the used enum according the
VA-API version.

https://bugzilla.gnome.org/show_bug.cgi?id=784398
2017-08-25 16:44:27 +02:00
Víctor Manuel Jáquez Leal
585628d2a2 libs: guard deprecated symbols
In VA-API 1.0 the H.264 baseline profile is deprecated. This patch
guards the H.264 baseline usage. Consider this commit as a
continuation of commit e0e0a474

https://bugzilla.gnome.org/show_bug.cgi?id=784398
2017-08-25 16:07:34 +02:00
Víctor Manuel Jáquez Leal
e8148cea0d libs: macro to get a renamed value in VA-API 1.0
In VA-API 1.0 the union bits in VAEncMiscParameterBufferROI has
renamed one member from roi_value_is_qp_delat to
roi_value_is_qp_delta, which is the correct name.

In order to keep back compatibility a macro has added to access this
union member.

https://bugzilla.gnome.org/show_bug.cgi?id=784398
2017-08-25 15:57:39 +02:00
Víctor Manuel Jáquez Leal
ffffb99473 libs: encoder: h264: fix enum namespace 2017-08-18 18:16:18 +02:00
Víctor Manuel Jáquez Leal
75fd0d4ff0 libs: encoder: h264: remove spurious assignation
Coverity scan bug:

An assigned value that is never used may represent unnecessary
computation, an incorrect algorithm, or possibly the need for cleanup
or refactoring.

ip_period is assigned first to be rewritter inmediatly after. The
first assignation is spurious.
2017-08-17 11:03:35 +02:00
Víctor Manuel Jáquez Leal
a07ff9641c libs: remove unused header
Since libgstvaapi is not distributed, there is no need to check for
private header inclusion. Thus removing it.

https://bugzilla.gnome.org/show_bug.cgi?id=786119
2017-08-13 18:08:19 +02:00
Víctor Manuel Jáquez Leal
3b8b2ff36c libs: utils: move gstvaapisurface.h to private headers
Since the utils don't expose API defined in gstvaapisource.h, it is
moved to their private headers where they are used.

https://bugzilla.gnome.org/show_bug.cgi?id=786119
2017-08-13 18:08:19 +02:00
Víctor Manuel Jáquez Leal
3f9ad1ffd8 libs: utils: remove va.h include in header
And include gstvaapicompat.h in the C files, since the VA-API is not
exposed in the headers.

https://bugzilla.gnome.org/show_bug.cgi?id=786119
2017-08-13 18:08:19 +02:00
Víctor Manuel Jáquez Leal
aaca75fefb libs: encoder: remove va.h include
Since it is already managed by gstvaapicompat.h

https://bugzilla.gnome.org/show_bug.cgi?id=786119
2017-08-13 18:08:19 +02:00
Víctor Manuel Jáquez Leal
9891f1a9e2 build: consolidate the VA sub API includes
Include all VA sub APIs headers in a single point (gstvaapicompat.h),
since they are all already included in va.h after VA-API 0.38.

https://bugzilla.gnome.org/show_bug.cgi?id=786119
2017-08-13 18:08:19 +02:00
Víctor Manuel Jáquez Leal
241b95dad2 libs: decoder: h265: remove spurious code
Coverity scan:

Logically dead code: The indicated dead code may have performed some
action; that action will never occur.

By using pointer arithmetic is impossible to get NULL.
2017-08-09 19:06:59 +02:00
Víctor Manuel Jáquez Leal
e42ec3ad3c libs: context: use attribs index instead pointers
Coverity scan bug:

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

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

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

This patch refactors config_create() to use an array index rather than
pointer arithmetic. Also a run-time check for index size was added.
2017-08-08 18:52:37 +02:00
Víctor Manuel Jáquez Leal
775f912247 libs: windows: wayland: fail if cannot remove last frame
Converity scan bug:

If the function returns an error value, the error value may be
mistaken for a normal value.

If g_atomic_pointer_compare_and_exchange() fails because the frame is
not the last one, the function fails. Thus, logging an info message.
2017-08-08 17:29:54 +02:00
Víctor Manuel Jáquez Leal
fbffda4e2f libs: utils: glx: check return value
Coverity scan bug:

If the function returns an error value, the error value may be
mistaken for a normal value.

Function sscanf returns the number of assignations done. Validate this
return value with the number of expected variables to match.
2017-08-08 17:21:52 +02:00
Víctor Manuel Jáquez Leal
d99d5704a4 libs: vaapi: object: remove unrequired NULL check
Coverity scan bug:

Dereference after null check: Either the check against null is
unnecessary, or there may be a null pointer dereference.

Variable klass has been validated as non-NULL several time before in
gst_vaapi_object_new() function, so there is no need to check it
again.
2017-08-08 17:12:06 +02:00
Víctor Manuel Jáquez Leal
d65ce31f14 libs: encoder: h265: remove spurious assignation
Coverity scan bug:

An assigned value that is never used may represent unnecessary
computation, an incorrect algorithm, or possibly the need for cleanup
or refactoring.

ip_period is assigned first to be rewritter inmediatly after. The
first assignation is spurious.
2017-08-08 17:06:17 +02:00
Víctor Manuel Jáquez Leal
f197749343 libs: encoder: h264: fix copy & paste error
Coverity scan bug:

The copied code will not have its intended effect.

This is a bug from commit cdaf15b2, where the intention is to
initialize RefPicList1 while setting RefPicList0.
2017-08-08 16:57:12 +02:00
Víctor Manuel Jáquez Leal
bd7716a739 libs: encoder: h265: fix possible integer overflow
Coverity scan bug:

Unintentional integer overflow. The expression's value may not be what
the programmer intended, because the expression is evaluated using a
narrow (i.e. few bits) integer type.

Cast operator to guint64 before computation to avoid narrowing.

merge with 3c5a6add
2017-08-08 16:56:58 +02:00
Víctor Manuel Jáquez Leal
4e27245f28 libs: decoder: mpeg4: fail if return value is not OK
Coverity scan bug:

An assigned value that is never used may represent unnecessary
computation, an incorrect algorithm, or possibly the need for cleanup
or refactoring.

In the return value of decode_slice() or
gst_mpeg4_parse_video_packet_header() are not success, thus fail
decode_packet() function.
2017-08-08 16:15:46 +02:00
Víctor Manuel Jáquez Leal
067968ae74 libs: decoder: h265: check for null
Coverity scan bug:

Dereference after null check: Either the check against null is
unnecessary, or there may be a null pointer dereference.

While looking for hte lowest poc, according to rest of the code, the
picture in the dbp (decoded picture buffer) might be NULL, thus we
could check for a NULL picture before assigned as found.

Also, split a comma operator because it is considered as a bad
practice because it possible side effects.
2017-08-08 16:15:45 +02:00
Víctor Manuel Jáquez Leal
d879664a0a libs: decoder: h265: untaint loop control variable
Coverity scan bug:

Scalars (for example, integers) are not properly
bounds-checked (sanitized) before being used as array or pointer
indexes, loop boundaries, or function arguments are considered as
tainted.

In this case, num_nals were not checked before used as loop control.
2017-08-08 15:38:16 +02:00
Víctor Manuel Jáquez Leal
9eddf6c004 libs: decoder: h264: remove unrequired NULL check
Coverity scan bug:

Dereference after null check: Either the check against null is
unnecessary, or there may be a null pointer dereference.

In the original commit for fill_picture_gaps() (commit 5abd2b90) the
prev_picture could be NULL, that's why the code did a null check. But,
since commit 52adebe7, the previous reference frames are tracked, thus
there is no need to check null anymore.
2017-08-08 13:46:56 +02:00
orestisf
ac9ddc5e8d libs: decoder: h264: decode MVC base view only
If processed SPS has mvc profile and the configuration is set to
base-only, the frame is drop.

https://bugzilla.gnome.org/show_bug.cgi?id=732265
2017-08-03 17:07:14 +02:00
orestisf
1dd03ac2fd libs: decoder: h264: add setter for base-only mode
https://bugzilla.gnome.org/show_bug.cgi?id=732265
2017-08-03 17:07:09 +02:00
Víctor Manuel Jáquez Leal
a1fc1e9822 libs: encoder: h264: missing property enum documentation 2017-08-02 11:40:17 +02:00
Hyunjun Ko
cdaf15b24d libs: encoder: h264: add multi reference support
Using num_ref_frames provided and the result of the Query
VAConfigAttribEncMaxRefFrames, it determines the size of reference list
and perform encoding with multi reference frames as the following:

1\ The num_ref_frames is being considered as the number of
reference picture list0
2\ Encoder adds 1 reference frame more to the reference picture list1
internally if b-frame encoding.
3\ If num_ref_frames is bigger than the number of refrence frames
supported in the driver, it will be lowered.

https://bugzilla.gnome.org/show_bug.cgi?id=783803
2017-08-02 11:21:02 +02:00
Hyunjun Ko
cd6a9736bd libs: encoder: h264: add refs property
Users can provide the number of reference frame by this property.

The value of the property will be considered as the number of
reference picture list0 and will add 1 reference frame more to the
reference picture list1 internally if b-frame encoding.

If the value provided is bigger than the number of refrence frames
supported in the driver, it will be lowered.

https://bugzilla.gnome.org/show_bug.cgi?id=783803
2017-08-02 11:20:35 +02:00
Hyunjun Ko
ec76a9a7e3 libs: encoder: implements gst_vaapi_encoder_ensure_max_num_ref_frames
This function will query VAConfigAttribEncMaxRefFrames to get the
maximum number of reference frames supported in the driver.
This will be used for h264/h265 encoding.

https://bugzilla.gnome.org/show_bug.cgi?id=783803
2017-08-02 11:17:39 +02:00
Tomas Rataj
c181308904 libs: display: when appending formats change pointers to indexes
Thus, it fixes an invalid read when YV12 or I420 are not supported by
the driver.

https://bugzilla.gnome.org/show_bug.cgi?id=785085
2017-08-01 16:23:22 +02:00
Sreerenj Balachandran
aa3543929b libs: encoder: h264: Add uncompliant mode reducing coded buffer size
Added a new property "compliance-mode", which default is the normal
strict compliant mode.

The second mode, "restrict-buf-alloc", is to limit the coded buffer
allocation size to improve performance in some specific Intel
platforms (there is asignificant performance improvement in parallel
encodings). Under this new mode, we use the MinCR field in A.3.1 for
pre-calculating the coded-buffer size.

https://bugzilla.gnome.org/show_bug.cgi?id=784590
2017-08-01 14:37:44 +02:00
Sreerenj Balachandran
f775bbfe07 libs: utils_h264: Extend LevelLimit table with MinCR field
Add MinCR(Minimum Compression Ratio) field to GstVaapiH264LevelLimits
based on Annex A.3

https://bugzilla.gnome.org/show_bug.cgi?id=784590
2017-08-01 14:32:30 +02:00
Víctor Manuel Jáquez Leal
777bba473e libs: utils: libva 1.0 changed the logging
The logging mechanism in libva has changed it's functions
signatures. This patch updates that for libva versions >= 1.0

https://bugzilla.gnome.org/show_bug.cgi?id=784398
2017-07-31 18:17:06 +02:00
Víctor Manuel Jáquez Leal
e0e0a47476 libs: decoder: h264: libva 1.0 deprecated baseline
libva 1.0 deprecated H.264 baseline profile and FMO support
(commit b4f332b3).

https://bugzilla.gnome.org/show_bug.cgi?id=784398
2017-07-31 18:17:06 +02:00
Víctor Manuel Jáquez Leal
8a7354380c build: meson: remove gstvaapidisplaycache.c
This is a missing bit of commit ec3e10f6
2017-07-26 20:32:09 +02:00
Hyunjun Ko
d78e094fd4 libs: display: x11: add gst_vaapi_display_x11_new_with_va_display()
Implements new API function so that users could create GstVaapiDisplay
with their own VADisplay within a native display as backend.

https://bugzilla.gnome.org/show_bug.cgi?id=766704
2017-07-18 18:50:39 +02:00
Hyunjun Ko
356212214b libs: display: pass display info when foreign display
When creating a GstVaapiDisplay using a foreign VADisplay, and render
with that display, it also requires native display of the backend.

https://bugzilla.gnome.org/show_bug.cgi?id=766704
2017-07-18 18:43:06 +02:00
Víctor Manuel Jáquez Leal
ec3e10f666 libs: display: remove cache
Remove a bunch of code that handles the VADisplay cache, since the
context sharing should be doing this correctly.

https://bugzilla.gnome.org/show_bug.cgi?id=747946
2017-07-18 18:20:21 +02:00
Víctor Manuel Jáquez Leal
a9c13a0934 libs: encoder: vp9: array terminated in zeros
There is a crash when setting ref-pic-mode since the #GEnumValue
array is not terminated with a structured with all memvers being
zero.

https://bugzilla.gnome.org/show_bug.cgi?id=785032
2017-07-17 18:59:13 +02:00
Matt Staples
66d26da39f libs: decoder: h264: push frames as soon as possible
Push frames downstream as soon as possible instead of waiting until
they are ejected from the DPB.

This patch makes the decoder not comply with the H.264 specification,
but it is required for some video cameras.

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

Signed-off-by: Víctor Manuel Jáquez Leal <vjaquez@igalia.com>
2017-07-10 19:30:46 +02:00
Víctor Manuel Jáquez Leal
28d1d048a6 libs: decoder: h264: add getter/setter for low latency mode
https://bugzilla.gnome.org/show_bug.cgi?id=783588
2017-07-07 19:32:11 +02:00
Hyunjun Ko
6ebf7b10ae libs: encoder: h264: submit sps in case of IDR picture
If the picture is IDR, also submit a SPS header.

This means when frame number reaches to keyframe-period or an force
key unit event arrives, we insert SPS/PPS again.

https://bugzilla.gnome.org/show_bug.cgi?id=776712
2017-07-04 14:25:39 +02:00
Hyunjun Ko
465d5868d9 libs: encoder: h264: set the frame as IDR if forced key unit
GST_VIDEO_CODEC_FRAME_IS_FORCE_KEYFRAME() is a flag usually used to manage
the `frame-lost` event in the case of streaming, such as RTP.

In case of this event, it is needed to start new GOP rather than just
produce an I-frame.

https://bugzilla.gnome.org/show_bug.cgi?id=776712
2017-07-04 14:25:39 +02:00
Sreerenj Balachandran
02a6e9a273 libs: encoder: h264: insert AU delimiter
Insert an AUD as the first NAL of each encoded frame.

Some applications require Access Unit Delimiter for decoding the
stream.

The AU delimeter insertion is done only when the aud parameter is
TRUE (by default is disabled). The reason of this it is because this
header is only available from Intel Gen9 and the VA intel driver
should be 1.8 or superior. Otherwise, the output will be corrupted.

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

Signed-off-by: Victor Jaquez <vjaquez@igalia.com>
2017-07-04 14:22:52 +02:00
Hyunjun Ko
9b73b31c7a libs: encoder: h264: initialize all elements of view_ids
Currently when num_views is changed by multiview-mode on sink caps, it produces
wrong MVC encoded stream since the array view_ids is not set properly according
to changed num_views.

So this patch initializes all of the array sequentially to handle this case.
Side effect is not going to happen by this patch since this array is being
handled by num_views.

https://bugzilla.gnome.org/show_bug.cgi?id=784321
2017-07-04 13:27:56 +02:00
Hyunjun Ko
5b38e7fbe2 Revert "encoder: h264: Use high profile by default"
This reverts commit 4aec5bdd72.

https://bugzilla.gnome.org/show_bug.cgi?id=757941
2017-07-03 18:48:07 +02:00
Hyunjun Ko
ca84fd211a libs: encoder: h264: set profile via capsfilter
Until now, the encoder ignored the profile in src caps and chose one
according with the given parameters. But the encoder must honor the
profile specifed in src caps.

This patch do that, and if the encoder needs to choose the profile,
it will do it by following these rules:

1\ If given parameters are not compatible with given profile, the
   encoder will bail out with an error.
2\ The encoder will choose the higher profile indicated in the
   src caps.

https://bugzilla.gnome.org/show_bug.cgi?id=757941
2017-07-03 18:38:16 +02:00
Hyunjun Ko
9397cd7d4d libs: decoder: h264: initialize active_sps/pps in reset
Since commits in https://bugzilla.gnome.org/show_bug.cgi?id=781142 landed,
they introduced regression in seek.

Formerly, once seek is done, decoder drops P-frames until I-frame arrives.
But since the commits landed, it doesn't drop P-frame and does try to
decode it continuously because active_sps is still alive. See ensure_sps function.
But there are prev_frames and prev_ref_frames reset already, then it
causes assertion.

So it's necessary to reset active_sps/pps also in reset method.

https://bugzilla.gnome.org/show_bug.cgi?id=783726
2017-06-15 13:40:27 +02:00
Víctor Manuel Jáquez Leal
3ed2023c2c libs: encoder: fix compilation with old versions of libva
There are some symbols that are not used when compiling with old
version of libva and those generates a compilation error.

Original-patch-by: Matt Staples <staples255@gmail.com>
2017-06-15 13:24:56 +02:00
Sreerenj Balachandran
595f8b7d4b libs: encoder: Fix the quality level clamping
Change the hard-coded range of quality-level from {1-8} to {1-7},
since it is the range Intel Open source driver supports.
Also perform the range clamping only if the user provided
quality-level is greater than the max-range suppored by the driver,
because there could be non-intel drivers giving lower value than
the hard-coded max value 7.

https://bugzilla.gnome.org/show_bug.cgi?id=783567
2017-06-13 16:51:52 +02:00
Víctor Manuel Jáquez Leal
eee8a78173 libs: encoder: log out the name of the profile
Instead of printing a number, it is more readable to log out, in
case of error, the name of the failing profile.
2017-06-13 13:51:01 +02:00
Hyunjun Ko
3dce250236 libs: encoder: h264: changes raw number of profile to macro name of its
Changes raw number of profile to macro name of its to improve readability.

https://bugzilla.gnome.org/show_bug.cgi?id=757941
2017-06-13 13:39:19 +02:00
Víctor Manuel Jáquez Leal
94b41c8d38 libs: encoder: set framerate if bigger than 0/1
Just set the framerate parameter if the framerate numerator and
denominator are bigger than zero.

Otherwise, in Intel Gen6 driver, a warning is raised disabling the
bitrate control.

Original-patch-by: Hyunjun Ko <zzoon@igalia.com>

https://bugzilla.gnome.org/show_bug.cgi?id=783532
2017-06-08 13:21:42 +02:00
Víctor Manuel Jáquez Leal
f8afb1eea4 libs: encoder: bitrate target percentage calculation
If the rate control is set to Constant Bit Rate (CBR) the target
percentage is 100%, otherwise is 70%
2017-06-07 16:04:38 +02:00
Víctor Manuel Jáquez Leal
4b5ecca29c libs: encoder: h264,h265,mpeg2,vp8,vp9: refactor ratecontrol param
Centralize the common configuration for the Rate Control parameter,
thus can be overloaded per each specific encoder.
2017-06-07 16:04:38 +02:00
Víctor Manuel Jáquez Leal
035efded75 libs: encoder: h264,h265,mpeg2,vp8,vp9: refactor framerate param
Since the framerate VA parameter is calculated equally among all the
encoders, it is better to handle it in the base encoder class.
2017-06-07 12:43:55 +02:00
Sreerenj Balachandran
4bf8ef724b libs: encoder: vp9: Adds CBR and VBR Encoding support
https://bugzilla.gnome.org/show_bug.cgi?id=766832

Signed-off-by: Hyunjun Ko <zzoon@igalia.com>
Signed-off-by: Víctor Manuel Jáquez Leal <vjaquez@igalia.com>
2017-06-07 12:08:10 +02:00
Hyunjun Ko
5d345b08fd libs: encoder: vp8: Adds VBR Encoding support
https://bugzilla.gnome.org/show_bug.cgi?id=778732
2017-06-07 11:24:38 +02:00
Hyunjun Ko
f68d0452be libs: encoder: h265: Adds VBR Encoding support
Enables Variable BitRate mode, which does set FrameRate and RateControl
parameters.

https://bugzilla.gnome.org/show_bug.cgi?id=778732
2017-06-07 11:24:38 +02:00
Hyunjun Ko
cbd912b89b libs: encoder: Describes more detail about the bitrate property
https://bugzilla.gnome.org/show_bug.cgi?id=778732
2017-06-07 11:24:38 +02:00
Víctor Manuel Jáquez Leal
81886682cd libs: encoder: h265: add rate control parameter
https://bugzilla.gnome.org/show_bug.cgi?id=783449
2017-06-07 11:24:38 +02:00
Víctor Manuel Jáquez Leal
d733714ef8 libs: encoder: h264,h265,mpeg2: add framerate parameter
https://bugzilla.gnome.org/show_bug.cgi?id=783449
2017-06-07 11:24:38 +02:00
Víctor Manuel Jáquez Leal
846c276e26 libs: encoder: vp8,h264,h265,mpeg2: set misc param once
Instead of recalculating the miscellaneous buffer parameters for
every buffer, it is only done once, when the encoder is configured.
And for every buffer, the same structures are just copied.

https://bugzilla.gnome.org/show_bug.cgi?id=783449
2017-06-07 11:24:38 +02:00
Víctor Manuel Jáquez Leal
acf106e1a7 libs: encoder: vp8,h264,h265,mpeg2: refactor misc parameters
This is patch pretends to decouple the assignation of the values
in the parameter structures and the VA buffer's parameters setting.

It may lead to some issues since HRD, framerate or controlrate may
not be handled by the specific encoder, but they are set in
the VA buffer's parameters.

I leave as it because this patch is just a transitional patch.

https://bugzilla.gnome.org/show_bug.cgi?id=783449
2017-06-07 11:24:38 +02:00
Víctor Manuel Jáquez Leal
daff4e9fbd libs: encoder: vp8: fix frame rate calculation
According to the VA documentation:

     The framerate is specified as a number of frames per second,
     as a fraction.  The denominator of the fraction is given in
     the top half (the high two bytes) of the framerate field, and
     the numerator is given in the bottom half (the low two bytes).

     For example, if framerate is set to (100 << 16 | 750), this is
     750 / 100, hence 7.5fps.

     If the denominator is zero (the high two bytes are both zero)
     then it takes the value one instead, so the framerate is just
     the integer in the low 2 bytes.

This patch fixes the the framerate calculation in vp8 encoder
according to this.

https://bugzilla.gnome.org/show_bug.cgi?id=783449
2017-06-07 11:24:38 +02:00
Víctor Manuel Jáquez Leal
baac8dc8a3 libs: encoder: vp8: refactor FrameRate parameter
Move frame-rate parameter from ensure_misc_params() to
ensure_contro_rate_param() since it only has meaning when the
control rate is either VBR or CBR.

https://bugzilla.gnome.org/show_bug.cgi?id=783449
2017-06-07 11:24:38 +02:00
Víctor Manuel Jáquez Leal
fc5106bd31 libs: encoder: h264,h265,mpeg2,vp8: refactor HDR
Move the Hypothetical Reference Decoder (HRD) parameter, from
ensure_misc_params() to ensure_control_rate_params(), since it
only shall be defined when the control rate is either VBR or CBR.

https://bugzilla.gnome.org/show_bug.cgi?id=783449
2017-06-07 11:24:38 +02:00
Víctor Manuel Jáquez Leal
b538a86d4e libs: encoder: h264,vp8,mpeg2: refactor control rate
Instead of filling the control rate param in ensure_misc_params(),
this patch refactor it out, as a first step to merge the same code
for all the encoders.

https://bugzilla.gnome.org/show_bug.cgi?id=783449
2017-06-07 11:24:38 +02:00
Víctor Manuel Jáquez Leal
5c05a8b436 libs: encoder: h264, h265, mpeg2: remove assert
Remove spurious asserts for misc parameters. If they cannot be
allocated, FALSE is already returned.
2017-06-07 11:24:38 +02:00
Víctor Manuel Jáquez Leal
37b81a7b69 libs: encoder: use VA quality level structure
Instead of using a proxy to story the buffer quality level, the
encoder now uses the native VA structure, which is copied to the
dynamically allocated VAEncMiscParameterBuffer.

This approach is computationally less expensive.
2017-06-07 11:24:08 +02:00
Víctor Manuel Jáquez Leal
0e31137dec libs: standardize the FIXME comment
This is a trivial patch that makes homogeneous the FIXME tag in
comments.

For more info about these comment style:
http://wiki.c2.com/?FixmeComment
2017-06-01 16:05:50 +02:00
Hyunjun Ko
e66aaf166c libs: encoder: vp8: set quality level regardless of rate control mode
https://bugzilla.gnome.org/show_bug.cgi?id=782957
2017-05-23 11:55:03 +02:00
Víctor Manuel Jáquez Leal
ed3360bf3b libs: encoder: check for maximum number of slices
Right now, H264 and HEVC can set as a property the number of slices to
process. But each driver can set a maximum number of slices, depending
on the supported profile & entry point.

This patch verifies the current num_slices to process against the maximum
permitted by the driver and the media size.

https://bugzilla.gnome.org/show_bug.cgi?id=780955
2017-05-19 16:33:27 +02:00
Víctor Manuel Jáquez Leal
58f6e78017 libs: utils: mark functions as internals
The functions in this header are internal to the library.
2017-05-15 18:36:21 +02:00
Víctor Manuel Jáquez Leal
3c31e8292a libs: context: add missing documentation
Document the region-of-interest configuration variables.
2017-05-15 18:35:40 +02:00
Hyunjun Ko
f09f21def7 libs: window: x11: fix src rect info when using vpp
Since we started using VPP in VaapiWindowX11, we need to care about
the case that src rect and window's size are different.

So, once VPP has converted to other format, we should honor the
size of the VPP's surface as source rect. Otherwise, it is cropped
according the previous size of the source rect.

https://bugzilla.gnome.org/show_bug.cgi?id=782542
2017-05-12 16:23:38 +02:00
Hyunjun Ko
f3302a0a79 libs: encoder: h264: set ROI params during encoding
Set ROI params during encoding each frame, which are set via
gst_vaapi_encoder_add_roi ()

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

Signed-off-by: Víctor Manuel Jáquez Leal <vjaquez@igalia.com>
2017-05-12 11:12:56 +02:00
Hyunjun Ko
7a6f690340 libs: encoder: add api gst_vaapi_encoder_add/del_roi
Implements and exposes new api gst_vaapi_encoder_add/del_roi to set ROI regions.

https://bugzilla.gnome.org/show_bug.cgi?id=768248
2017-05-12 11:12:56 +02:00
Hyunjun Ko
b41d72b7c5 libs: encoder/context: query region of interest support
Queries if the driver supports "Region of Interest" (ROI) during the config
creation.

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

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

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

Signed-off-by: Víctor Manuel Jáquez Leal <vjaquez@igalia.com>
2017-05-12 11:12:56 +02:00
Víctor Manuel Jáquez Leal
3ec7996d75 libs: encoder: fix a comment 2017-05-12 11:12:56 +02:00
Víctor Manuel Jáquez Leal
4269adf791 libs: encoder: guard quality level configuration
The quality level appeared in VA-API 0.36. So let's guard its
usage.
2017-05-11 12:23:28 +02:00
Sreerenj Balachandran
4f343f82e3 encoders: add quality level tuning
This patch adds the handling of VAEncMiscParameterTypeQualityLevel,
in gstreamer-vaapi encoders:

  The encoding quality could be set through this structure, if the
  implementation supports multiple quality levels. The quality level set
  through this structure is persistent over the entire coded sequence, or
  until a new structure is being sent. The quality level range can be queried
  through the VAConfigAttribEncQualityRange attribute. A lower value means
  higher quality, and a value of 1 represents the highest quality. The quality
  level setting is used as a trade-off between quality and speed/power
  consumption, with higher quality corresponds to lower speed and higher power
  consumption.

The quality level is set by the element's parameter "quality-level" with a
hard-coded range of 1 to 8.

Later, when the encoder is configured in run time, just before start
processing, the quality level is scaled to the codec range. If
VAConfigAttribEncQualityRange is not available in the used VA backend, then
the quality level is set to zero, which means "disabled".

All the available codecs now process this parameter if it is available.

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

Signed-off-by: Víctor Manuel Jáquez Leal <vjaquez@igalia.com>
2017-05-11 11:51:56 +02:00
Hyunjun Ko
2d7c7630c9 libs: windows: wayland: fix leak if failure of sync
Sometimes gst_vaapi_window_wayland_sync returns FALSE when poll returns EBUSY
during destruction.
In this case, if GstVaapiWindow is using vpp, leak of vpp surface happens.
This surface is not attached to anything at this moment, so we should release
it manually.

https://bugzilla.gnome.org/show_bug.cgi?id=781695
2017-04-25 11:24:38 +02:00
Hyunjun Ko
824974e657 libs: window: wayland: mark frames as done
When the frame listener callbacks 'done', the number of pending
frames are decreased. Nonetheless, there might be occasions where
the buffer listener callbacks 'release', without calling previously
frame's 'done'. This leads to problem with
gst_vaapi_window_wayland_sync() operation.

This patch marks as done those frames which were callbacked, but if
the buffer callbacks 'release' and associated frame is not marked
as 'done' it is so, thus the number of pending frames keeps correct.

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

Signed-off-by: Víctor Manuel Jáquez Leal <vjaquez@igalia.com>
2017-04-24 13:16:03 +02:00
Víctor Manuel Jáquez Leal
3b314ba93e libs: window: wayland: don't sync at destroy()
Don't call gst_vaapi_window_wayland_sync() when destroying the
wayland window instance, since it might lead to a lock at
gst_poll_wait() when more than one instances of vaapisink are
rendering in the same pipeline, this is because they share the
same window.

Since now all the frames are freed we don't need to freed the
private last_frame, since its address is invalid now.

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

Signed-off-by: Hyunjun Ko <zzoon@igalia.com>
2017-04-24 13:14:05 +02:00
Hyunjun Ko
ca314a25cc libs: window: wayland: null buffer at destroy()
Fix leakage of the last wl buffer.

VAAPI wayland sink needs to send a null buffer while destruction,
it assures that all the wl buffers are released. Otherwise, the last
buffer's callback might be not called, which leads to leak of
GstVaapiDisplay.

This was inspired by gstwaylandsink.

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

Signed-off-by: Víctor Manuel Jáquez Leal <vjaquez@igalia.com>
2017-04-21 16:01:47 +02:00
Jagyum Koo
896a836f1d libs: window: wayland: rt event queue at destroy()
The proxy object of wl_buffer for the last frame remains in the
wl_map. Even though we call wl_buffer_destroy() in
frame_release_callback(), the proxy object remains without being
removed, since proxy object is deleted when wayland server sees the
delete request and sends 'delete_id' event.

We need to call roundtrip before destroying event_queue so that the
proxy object is removed. Otherwise, it would be mess up as receiving
'delete_id' event from previous play, when playing in the next
va/wayland window with the same wl_display connection.

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

Signed-off-by: Víctor Manuel Jáquez Leal <vjaquez@igalia.com>
2017-04-21 16:01:46 +02:00
Víctor Manuel Jáquez Leal
9c3a4edf05 libs: window: wayland: cancel read at poll message
Always call wl_display_cancel_read() when an errno is set, but
different to EAGAIN or EINTR.

https://bugzilla.gnome.org/show_bug.cgi?id=780442
2017-04-21 16:01:34 +02:00