Commit graph

3485 commits

Author SHA1 Message Date
Víctor Manuel Jáquez Leal
38d7297bb6 vaapih264enc: intersect the new proposed caps
Instead of just leave to keep the proposed caps, with the best profile
in the allowed caps, is its intersected again.
2020-01-19 12:54:02 +00:00
Víctor Manuel Jáquez Leal
8b4d18da0a vaapih264enc: propose new profile caps and fixate it
When the available caps doesn't intersect with the allowed caps in the
pipeline, a new caps is proposed rather than just expecting to
iterate.

Later, the intersected caps (profile_caps) is fixated in order to
extract the configuration.
2020-01-19 12:54:02 +00:00
Víctor Manuel Jáquez Leal
a56ac3bffe vaapih264enc: common fail for gst_vaapiencode_h264_set_config()
Add a common fail code path for gst_vaapiencode_h264_set_config().
2020-01-19 12:54:02 +00:00
Víctor Manuel Jáquez Leal
eda173b3b0 libs: encoder: unref formats array if none
The formats array is always created, in order to keep the logic and
to avoid broken caps, if this formats array doesn't contain any
elements, it has to be unref and the function should return NULL.
2020-01-19 10:37:02 +00:00
Víctor Manuel Jáquez Leal
6eafebc804 vaapih264enc: fix log message
Before the log wasn't processed because wrong instance pointer.
2020-01-19 10:46:13 +01:00
He Junyan
25422b6766 plugin: encode: Add H265 main-444 profile.
Expose the main-444 profile to h265enc caps, when the upstream
chooses to use VUYA as input, we choose main 4:4:4 profile to encode
the frames.
2020-01-17 11:02:44 +00:00
He Junyan
633ec98349 libs: encoder: h265: Consider main-444 profile when encoding.
Add support of main-444 profile for parameter setting and packed header
generation.
2020-01-17 11:02:44 +00:00
Víctor Manuel Jáquez Leal
1db3ce56a0 vaapiencode: DMABuf only if PRIME is available
Add DMABuf capsfeature in encoders' allowed sinkcaps only if PRIME
memory type is available in the VA surface attributes of codec
context.
2020-01-17 11:31:57 +01:00
Haihao Xiang
c864e20d2c Add hooks/pre-commit.hook
meson.build in gstreamer-vaapi requires hooks/pre-commit.hook

Copied and pasted pre-commit.hook from other gstreamer modules to make
sure gstreamer-vaapi follows the same code style
2020-01-16 09:25:02 +08:00
He Junyan
6c7d445010 libs: encoder: h265: Set encoder paramters base on entrypoint.
When the tune is NONE, we now can choose entrypoint freely. So the
GST_VAAPI_ENCODER_TUNE macro may not return the correct current
entrypoint.
We also delay CTU size calculation after entrypoint has been decided.
2020-01-15 09:22:52 +00:00
Víctor Manuel Jáquez Leal
9da5196b5a Remove all FEI related
FEI encoders are not actively mantained neither tested, and it is
using infrastructure that is changing and FEI is stopping this
effort.

Also it is required to rethink how FEI can be used in GStreamer.
2020-01-15 07:30:15 +00:00
U. Artie Eoff
1364070eca vaapioverlay: ensure sinkpad has current buffer
Use the gst_video_aggregator_pad_has_current_buffer API
to check if the current sinkpad has a queued buffer before
attempting to obtain a input buffer from the base plugin.
If the sinkpad does not have a current buffer, then it is
either not producing them yet (e.g. current time < sinkpad
start time) or it has reached EOS.

Previously, we only handled EOS case.

Example:

 gst-launch-1.0 videotestsrc num-buffers=100 \
  ! vaapipostproc ! vaapioverlay name=overlay \
  ! vaapisink videotestsrc timestamp-offset=1000000000 \
  num-buffers=100 ! video/x-raw,width=160,height=120 \
  ! overlay.
2020-01-14 11:37:22 -08:00
Víctor Manuel Jáquez Leal
889fac3823 vaapioverlay: unroll the recursive call
Recursive functions are elegant but dangerous since they might
overflow the stack. It is better to turn them into a list tranversal
if possible, as this case.
2020-01-14 19:52:18 +01:00
Víctor Manuel Jáquez Leal
d0e14ec308 vaapioverlay: add minimal documentation 2020-01-14 19:52:18 +01:00
Víctor Manuel Jáquez Leal
81f3a7f02b libs: blend: simplify generator API
Instead of using a parent structure that has to be derived by API
consumers, this change propse a simplification by using the common
pattern of GTK of passing a function pointer and user data which will
be passed as its parameter. That user data contains the state and the
function will be called to update that state.
2020-01-14 19:52:18 +01:00
U. Artie Eoff
f97d858237 libs: blend: remove begin/render/end API
This API was risky and is superseded by the surface
generator (process) API.

Resolves #219
2020-01-14 19:01:46 +01:00
U. Artie Eoff
edca6efede vaapioverlay: use blend surface generator API
See #219
2020-01-14 19:01:41 +01:00
U. Artie Eoff
1363b53a9f libs: blend: add surface generator API
This new API allows the user to call a single method (process)
which handles the [display] lock/unlock logic internally for
them.

This API supersedes the risky begin, render, end API.
It eliminates the need for the user to call a lock method
(process_begin) before processing the input buffers
(process_render) and calling an unlock method (process_end)
afterwards.

See #219
2020-01-14 15:07:32 +00:00
He Junyan
36fd4d5d8a plugin: encode: List all possible profiles to detect input formats.
The current get_profile just return one possible profile for the encode,
which is not enough.  For example, if we want to support HEVC 4:4:4
profile, the input of encode should be VYUA rather than NV12 in HEVC
main profile. So the command line:

gst-launch-1.0 videotestsrc num-buffers=200 ! capsfilter \
caps=video/x-raw,format=VUYA,width=800,height=600 ! vaapih265enc \
tune=low-power init-qp=30 ! fakesink

can not work because vaapih265enc just report NV12 in sink caps, we need
to specify the profile obviously like:

gst-launch-1.0 videotestsrc num-buffers=200 ! capsfilter \
caps=video/x-raw,format=VUYA,width=800,height=600 ! vaapih265enc \
tune=low-power init-qp=30 ! capsfilter caps=video/x-h265, \
profile=main-444 ! fakesink

The encode should have the ability to choose the profile based on input
format automatically. If the input video format is VUYA, the main-444
profile should be auto choosed.

We modify to let get_allowed_profiles of each encode sub class to return
an array of all supported profiles based on downstream's allowed caps, or
return NULL if no valid profiles specified by downstream.
If no allowed profiles found, all profiles which belong to the current
encoder's codec will be the candidates.
The function gst_vaapi_encoder_get_surface_attributes collects the surface's
attributes for that profile list we just get.

So for this case, both NV12 and VUYA should be returned.

TODO: some codec like VP9, need to implement the get_profile() function.
2020-01-14 11:36:18 +00:00
He Junyan
67e7e15408 plugin: util: add helper function to detect profiles in caps. 2020-01-14 11:36:18 +00:00
He Junyan
0a2a25981c libs: encoder: add a helper function to get all supported profiles 2020-01-14 11:36:17 +00:00
Seungha Yang
3737692dd4 libs: decoder: Don't unref null object
** (gst-launch-1.0:9789): CRITICAL **: 15:29:09.330:
  gst_vaapi_context_unref: assertion 'context != NULL' failed
2020-01-13 09:03:47 +01:00
U. Artie Eoff
ad31d5bb81 plugins: overlay: use proper NULL check on double pointer
Check the address of the variable is not NULL,
not the address of the pointer.
2020-01-10 17:40:56 +00:00
He Junyan
40eceaf64a libs: codedbuf: delete a useless field.
The context field in GstVaapiCodedBuffer is not inited correctly
and is never used, just delete it.
2020-01-08 23:42:21 +08:00
Víctor Manuel Jáquez Leal
11a8175fff plugins: add iHD driver in whitelist 2020-01-08 12:07:57 +00:00
He Junyan
9bfc8240b4 libs: encoder: modify 265 SPS header's profile compatibility flag.
Make the SPS profile compatibility flags more precisely conform to
the HEVC Spec.
2020-01-08 17:48:22 +08:00
Víctor Manuel Jáquez Leal
742d7e17e6 test: vaapioverlay: bail test if not available
vaapioverlay is only registered if the VA driver support the blend
operation.

This patch only executes the test if vaapioverlay is available,
otherwise the test is bail out without raising an error.
2020-01-06 20:58:17 +01:00
Víctor Manuel Jáquez Leal
e4b4836170 tests: vaapioverlay: force drm backend 2020-01-06 20:58:17 +01:00
Víctor Manuel Jáquez Leal
db338f1316 libs: blend: update to new mini-object API 2020-01-06 19:56:10 +00:00
U. Artie Eoff
a3c2c93216 tests: check: add basic vaapioverlay test
Add test_overlay_position test to verify sink_1 input
is overlayed onto sink_0 input at the appropriate
position.
2020-01-06 19:56:10 +00:00
U. Artie Eoff
d28ffd73c3 plugins: add vaapioverlay plugin
A plugin similar to the base compositor element but
uses VA-API VPP blend functions to accelerate the
overlay/compositing.

Simple example:

 gst-launch-1.0 -vf videotestsrc ! vaapipostproc \
  ! tee name=testsrc ! queue \
  ! vaapioverlay sink_1::xpos=300 sink_1::alpha=0.75 \
  name=overlay ! vaapisink testsrc. ! queue ! overlay.
2020-01-06 19:56:10 +00:00
U. Artie Eoff
b76c0a0caf libs: add a vaapi blend class
Support for the VA-API VPP blend functions.
2020-01-06 19:56:10 +00:00
U. Artie Eoff
894c1da6c7 plugins: base: add GstVideoAggregator subclass support 2020-01-06 19:56:10 +00:00
He Junyan
1b7f737ecd libs: image: init all image fields correctly. 2020-01-06 17:55:09 +00:00
Stéphane Cerveau
3cde7db1d3 doc: fix pipeline typo in vaapipostproc 2020-01-06 17:41:53 +01:00
He Junyan
d687e2cb78 libs: encoder: modify 265 VPS header fields.
vps_base_layer_internal_flag and vps_base_layer_available_flag
have been clearly defined now.
2020-01-03 15:29:14 +00:00
He Junyan
196fef9392 libs: display: fix a resource leak in X11 pixmap format. 2020-01-03 06:49:07 +00:00
Víctor Manuel Jáquez Leal
b3570febf7 libs: utils: delete useless gst_vaapi_profile_caps_append_encoder. 2020-01-02 18:01:52 +01:00
He Junyan
a6cf75e8c6 libs: encoder: get surfaces resolution the same time with formats.
We can get all the information about the video format at one shot
when we create the test context for getting the supported formats.

The current way to get the width and height ranges are inefficient,
since it calls the function gst_vaapi_profile_caps_append_encoder()
and it creates another temporal context to detect the resolution
information.

Signed-off-by: Víctor Manuel Jáquez Leal <vjaquez@igalia.com>
2020-01-02 18:01:45 +01:00
Víctor Manuel Jáquez Leal
b4d73433c3 libs: encoder: vp9: fix code style 2019-12-29 17:58:36 +01:00
He Junyan
3398c64036 libs: encoder: set entrypoint based on tune automatically
Some profile, such as H265_MAIN_444 on new Intel platform, may only
support ENTRYPOINT_SLICE_ENCODE_LP entrypoint. This leads two
problems:

1. We need to specify the tune mode like `vaapih265enc tune=low-power`
   every time when we need to use this kind of profile. Or we can not
   create the encoder context successfully.

2. More seriously, we set the entrypoint to a fixed value in
   init_context_info() and so the create_test_context_config() can not
   create the test context for these profile and can not get the
   supported video formats, either.

We now change the entrypoint setting based on the tune option of the
encoder. If no tune property provided, we just choose the first
available entrypoint.
2019-12-29 17:58:36 +01:00
He Junyan
b50f06309a libs: encoder: set context info profile by encoder
Instead of init_context_info() setting the passed profile, it is
assumed that it has to be set by each encoder.

Signed-off-by: Víctor Manuel Jáquez Leal <vjaquez@igalia.com>
2019-12-29 17:58:36 +01:00
He Junyan
4f43d28beb libs: context: add invalid entrypoint symbol
The symbol GST_VAAPI_ENTRYPOINT_INVALID is just a representation of
zero, which was already used as an invalid value tacitly. This patch
only makes it explicit.

Signed-off-by: Víctor Manuel Jáquez Leal <vjaquez@igalia.com>
2019-12-29 17:58:36 +01:00
He Junyan
c05ce44815 libs: pixmap: Fix a pixmap creation crash.
We use GST_VAAPI_OBJECT_NATIVE_DISPLAY with wrong parameter for x11
pixmap creation, which causes crash if we run the internal test case
of:

test-decode --pixmap
2019-12-29 02:00:51 +08:00
He Junyan
3355cd4691 plugin: encode: set allowed_sinkpad_caps to empty.
We now set encode->allowed_sinkpad_caps to NULL if we fail to get
surfaces formats. This causes two problem:
1. gst_video_encoder_proxy_getcaps use NULL as its caps parameter,
which changes its behavior. It will use encode's sinkpad template
rather than empty caps to do the clip job. So even if we fail to set
allowed_sinkpad_caps, gst_video_encoder_proxy_getcaps can still return
valid caps.
2. We should just set the allowed_sinkpad_caps once. The NULL point
make the ensure_allowed_sinkpad_caps function works again and again.
2019-12-23 01:28:56 +08:00
He Junyan
5ad67ea666 libs: encoder: Add NULL pointer check for context when finalize.
Context may be NULL if pipeline fail in early stage, and the
ensure_context will not be called. Need to add a pointer protection
for it.
2019-12-22 15:22:57 +08:00
U. Artie Eoff
18d1c75d1a plugins: base: do not reset can_dmabuf
Don't reset the can_dmabuf field.  This restores the
close/reset logic that existed prior to commit
ca2942176b in regards to
dmabuf support.

Plugins only call gst_vaapi_plugin_base_set_srcpad_can_dmabuf
once during startup, but may need to reset the other private
fields multiple times during negotiation.  Thus, can_dmabuf
should be exempt from the resets.

Fixes #208
2019-12-20 06:38:42 -08:00
He Junyan
7ce44bc372 plugin: encode: Refine encode's sink caps.
The old manner to get the encode's sink caps is not correct.
Such as 264 encode, it gets:

video/x-raw(memory:VASurface),
format=(string){ ENCODED, NV12, I420, YV12, YUY2, UYVY, Y210,
P010_10LE, AYUV, Y410, Y444 }, width=(int)[ 32, 4096 ],
height=(int)[ 32, 4096 ], framerate=(fraction)[ 0/1, 2147483647/1 ];
video/x-raw(memory:DMABuf), format=(string){ I420, YV12, RGBA },
width=(int)[ 32, 4096 ], height=(int)[ 32, 4096 ],
framerate=(fraction)[ 0/1, 2147483647/1 ];
video/x-raw, format=(string){ NV12 }, width=(int)[ 32, 4096 ],
height=(int)[ 32, 4096 ], framerate=(fraction)[ 0/1, 2147483647/1 ]

where the formats for memory:VASurface and memory:DMABuf are superfluous.
All the "I420, YV12, YUY2, UYVY, Y210, RGBA" can not be really used as
input format for encoder.

We should get:
video/x-raw, format=(string){ NV12 }, width=(int)[ 32, 4096 ],
height=(int)[ 32, 4096 ], framerate=(fraction)[ 0/1, 2147483647/1 ];
video/x-raw(memory:VASurface), format=(string){ NV12 },
width=(int)[ 32, 4096 ], height=(int)[ 32, 4096 ],
framerate=(fraction)[ 0/1, 2147483647/1 ]; video/x-raw(memory:DMABuf),
format=(string){ NV12 }, width=(int)[ 32, 4096 ],
height=(int)[ 32, 4096 ], framerate=(fraction)[ 0/1, 2147483647/1 ]

as the correct result.
2019-12-20 10:02:03 +00:00
Víctor Manuel Jáquez Leal
4da8dc2550 libs: display: code clean up 2019-12-20 08:40:54 +01:00
He Junyan
b2cabe2f5b libs: display: refine the profile/entrypoint map.
The old way make the one config for each profile/entrypoint pair,
which is not very convenient for description the relationship
between them. One profile may contain more than one entrypoints
to within it, so a set like data structure should be more suitable.
2019-12-20 07:39:43 +00:00