Commit graph

1178 commits

Author SHA1 Message Date
U. Artie Eoff
2b6fa19665 vaapipostproc: use sink resolution to calculate src colorimetry
The default output colorimetry is persuaded by the output
resolution, which is too naive when doing VPP cropping
and/or scaling.  For example, scaling 4K(sink)->1080P(src)
resolution (i.e. both YUV) results in bt2020(sink)->bt709(src)
colorimetry selection and some drivers don't support that
mode in vpp.

Thus, if output (i.e. downstream) does not specify a
colorimetry then we use the input resolution instead of the
output resolution to create the default colorimetry.  Also,
note that we still use the output format since it may be a
different color space than the input.  As in the example
above, this will result in bt2020(sink)->bt2020(src)
colorimetry selection and all drivers (afaik) should support
that in vpp.
2020-02-05 10:33:23 -08:00
U. Artie Eoff
c6d8ee737f vaapipostproc: set srcpad colorimetry unconditionally
We always need a srcpad colorimetry for VAAPI VPP
operations.

Also, check the return value of _set_colorimetry.
2020-02-05 10:16:16 -08:00
U. Artie Eoff
654e824555 vaapipostproc: do not override explicit srcpad colorimetry
If colorimetry has been set by a capsfilter (e.g.
vaapipostproc ! video/x-raw,colorimetry=bt709) then
don't try to override it.  Previously, the aforementioned
capsfilter will fail to negotiate if default colorimetry
is not the same as the capsfilter (e.g. 4K resolutions).
2020-02-05 10:16:16 -08:00
U. Artie Eoff
c01f2e30d6 vaapipostproc: set vpp filter colorimetry
Set the input and output colorimetry for vpp filter.
2020-02-05 10:16:16 -08:00
Víctor Manuel Jáquez Leal
7f61ad7938 vaapivideobufferpool: dmabuf implies allocator
Some code can be optimized since only if the dmabuf allocator is set,
the internal flag of dmabuf is TRUE, thus there's no need to evaluate
the allocator address.
2020-02-02 18:04:35 +01:00
Víctor Manuel Jáquez Leal
62f3329455 vaapivideobufferpool: reject configuration if allocator isn't vaapi
If the requested allocator in set_config() is not a VAAPI valid one,
reject the configuration, instead of lying and using a private one.

This patch superseeds !254 and !24
2020-02-02 17:22:43 +01:00
Víctor Manuel Jáquez Leal
5eca31b5e8 vaapivideobufferpool: add explanation for allocator reconfig 2020-02-02 17:22:43 +01:00
Víctor Manuel Jáquez Leal
377dd0cc6c vaapivideobufferpool: check for vaapi meta first
If the configured meta doesn't request vaapi meta then it is not a
vaapi buffer pool. Bail out as soon as possible.
2020-02-02 17:22:43 +01:00
Víctor Manuel Jáquez Leal
ed505f5ed4 vaapivideobufferpool: turn errors into warnings
set_config() vmethod should fail gracefully, thus upstream could
negotiate another pool if possible.

Instead of sending error messages to the bus, let demote the level
to warning.
2020-02-02 17:22:43 +01:00
Víctor Manuel Jáquez Leal
4778882728 vaapivideobufferpool: Reuse internal allocator is possible.
Instead of creating a new allocator when upstream requests a different
allocator, this patch tries to reuse the internal allocator if it was
already initializated.

If the stream changes, then either one will be unref and a new
allocator is created.
2020-01-27 20:31:12 +00:00
Víctor Manuel Jáquez Leal
9fa177951e vaapivideobufferpool: Log messages in proper category.
The log messages where logged in the GstBufferPool category because
the instance was not properly casted. This fix that situation.
2020-01-27 19:08:37 +01:00
Víctor Manuel Jáquez Leal
ee3d4c3206 libs: display: driver quirks mechanism
This mechanism comes from ffmpeg vaapi implementation, where they have
their own quirks.

A specific driver is identified by a substring present in the vendor
string. If that substring is found, a set of bitwise flags are store.
These flags can be accessed through the function
gst_vaapi_display_has_driver_quirks().

The purpose for this first quirks is to disable the put image try for
AMD Gallium driver (see [1]).

1. https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/merge_requests/72
2020-01-24 12:21:59 +00:00
Víctor Manuel Jáquez Leal
7a186975cc plugins: renable Mesa Gallium driver 2020-01-24 12:21:59 +00:00
Víctor Manuel Jáquez Leal
0815899121 vaapivideobufferpool: validate returned meta
Validate if the meta returned by gst_buffer_get_vaapi_video_meta() in
the acquired buffer is not null.

This situation should be very "pathological", but still it is better
be safe since that meta might be used later to create a new dma
buffer.
2020-01-24 11:55:22 +01:00
Philipp Zabel
89f202ea2e vaapivideobufferpool: always update/release the underlying surface proxy
gst_vaapi_video_buffer_pool_reset_buffer() is called when the sink
releases the last reference on an exported DMA buffer. This should
release the underlying surface proxy. To avoid releasing the wrong
surface due to a stale surface proxy reference in the buffer's
GstVaapiVideoMeta, always update the reference to the correct surface
in gst_vaapi_video_buffer_pool_acquire_buffer().
2020-01-24 09:10:44 +00:00
Víctor Manuel Jáquez Leal
e25ef7dfc2 vaapiencode: promote info to warning
Let's notify user about using constrained-baseline instead on
requested basline profile.
2020-01-21 14:12:29 +01:00
Nicolas Dufresne
866a9f069d vaapih264dec: Add a property to assume constrained-baseline
When baseline-as-constrained is set, the decoder will expose support
for baseline decoding and assume that the baseline content is
constrained-baseline. This can be handy to decode streams in hardware
that would otherwise not be possible to decode. A lot of baseline
content is in fact constrained.
2020-01-19 15:55:47 +00:00
Víctor Manuel Jáquez Leal
73159cdc5d vaapih264enc: accept baseline as constrained baseline compatible 2020-01-19 15:14:14 +00:00
Víctor Manuel Jáquez Leal
9f627ef234 vaapih264enc: update level in src caps
And, if downstream requests a specific level, the caps are not
negotiated, because there is no mechanism right now to specify a
custom level in the internal encoder.
2020-01-19 14:26:18 +00:00
Víctor Manuel Jáquez Leal
5e26efbcf2 vaapih264enc: force byte-stream if avc isn't supported
Removing the validation in gst_vaapiencode_h264_get_caps() since that
ought be handled in gst_vaapiencode_h264_set_config()
2020-01-19 14:57:04 +01:00
Philipp Zabel
d576963979 vaaph264enc: suppress avc if the driver does not support packed headers
Do not negotiate AVC output if the driver does not support it.
2020-01-19 14:57:04 +01:00
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
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
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
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
edca6efede vaapioverlay: use blend surface generator API
See #219
2020-01-14 19:01:41 +01: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
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
Víctor Manuel Jáquez Leal
11a8175fff plugins: add iHD driver in whitelist 2020-01-08 12:07:57 +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
894c1da6c7 plugins: base: add GstVideoAggregator subclass support 2020-01-06 19:56:10 +00:00
Stéphane Cerveau
3cde7db1d3 doc: fix pipeline typo in vaapipostproc 2020-01-06 17:41:53 +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
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
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
He Junyan
608ce681e5 libs: surface: port to GstMiniObject
GstVaapiMiniObject and GstVaapiObject are deprecated.

This is the first step to remove them by porting GstVaapiSurface as
a GstMiniBuffer descendant.

Signed-off-by: Víctor Manuel Jáquez Leal <vjaquez@igalia.com>
2019-12-20 05:01:08 +00:00
He Junyan
d56824c05c libs: image: port to GstMiniObject base class
GstVaapiMiniObject and GstVaapiObject are deprecrated. This is the
first step to remove them, by porting GstVaapiImage as a
GstMiniObject.

Signed-off-by: Víctor Manuel Jáquez Leal <vjaquez@igalia.com>
2019-12-20 05:01:07 +00:00
He Junyan
61de88e580 plugin: encode: change the dmabuf caps to all supported formats.
The encode's dmabuf caps definition is obsolete, it can support
more formats now. Re-define it to include all supported formats
in video format map.
2019-12-18 20:34:27 +08:00
He Junyan
2cad0e5629 plugin: encode: set sink's raw caps to GST_VAAPI_FORMATS_ALL.
Then encode plugin just supports raw formats declared in vaapi video
format map. This modification makes the template caps more precise.
2019-12-16 16:32:39 +08:00
U. Artie Eoff
b1bab9a317 plugins: base: add GstPad param to internal helper functions
The base plugin public API function implementations determine
which pad should be passed to the internal helper functions.
Currently, only the base plugin static sinkpad and static
srcpad are supported/used.  However, this change enables future
API functions to be added that can accept a pad (i.e. request pad)
from an element subclass (e.g. a GstVideoAggregator subclass).
2019-12-11 21:27:48 +00:00
U. Artie Eoff
ca2942176b plugins: base: manage pad-specific data in a single struct
Define a struct (GstVaapiPadPrivate) to encapsulate the
pad-specific data (i.e. buffer pool, allocator, info,
caps, etc.).

Add an interface to retrieve the data struct for a given
pad.

Finally, update the base plugin to use the data struct
throughout the implementation.

This will enable us to easily extend the base plugin in the
future to allow for N-to-1 pad subclasses (e.g. overlay/
composite).
2019-12-11 21:27:48 +00:00