Commit graph

1300 commits

Author SHA1 Message Date
Víctor Manuel Jáquez Leal
222dc8d7d8 vaapipostproc: deprecate format, width and size parameters
Since they should only be controlled by caps negotiation.
2020-03-20 16:07:43 +00:00
He Junyan
532a1e5509 libs,plugins: decoder: Add -intra profile support for hevc.
In hevc, we can consider the -intra profile a subset of the none
-intra profile. The -intra profiles just contain I frames and we
definitely can use the none -intra profiles's context to decode
them.

Signed-off-by: Víctor Manuel Jáquez Leal <vjaquez@igalia.com>
2020-03-20 14:57:49 +01:00
Víctor Manuel Jáquez Leal
d6bcbe47e9 plugin: don't error if cannot create display
This might generated errors on automatic tools such as CI. Let's
rather just raise a warning and let continue.
2020-03-17 12:49:12 +01:00
U. Artie Eoff
da008baac2 vaapivideobufferpool: force video meta if sizes are different
The strides and offsets could be the same, but the allocation
size might be different (e.g. alignment).  Thus, ensure we also
set the flag to copy from VA memory to system memory when alloc
size differs.

Fixes #243
2020-03-06 12:08:44 +00:00
Víctor Manuel Jáquez Leal
385892dd32 vaapidecode: don't set base sink caps twice
Base class's sink pad caps are already set when calling set_format().
There's no need to call it again in gst_vaapidecode_negotiate().
2020-03-05 14:18:32 +01:00
Víctor Manuel Jáquez Leal
6e65356017 vaapidecode: unlock stream if caps update fails
If caps update fail a dead lock occurs since the stream mutex is not
unlocked.
2020-03-05 13:26:38 +01:00
Víctor Manuel Jáquez Leal
164656ee1d Revert "vaapivideomemory: Store surface allocation flags."
This reverts commit dd428cc4a1 because
it rewrites the buffer size whilst surface allocation flags are
stored when allocator_params_init() is called since fab890ce.

Fix: #239
2020-02-28 11:37:06 +01:00
Víctor Manuel Jáquez Leal
fab890ceb5 vaapivideomemory: Try surface with allocation flags.
When a vaapi allocator is instantiated, it first try to generate a
surface with the specified configuration.

This patch adds, in this tried buffer, the requested allocation flags.
2020-02-23 13:12:15 +01:00
Víctor Manuel Jáquez Leal
dd428cc4a1 vaapivideomemory: Store surface allocation flags.
Store surface allocation flags passed to the vaapi allocator in
GObject's qdata, because it might be used by the vaapivideobufferpool
when recreating the allocator given any resolution change.
2020-02-23 13:12:15 +01:00
U. Artie Eoff
4573d3eefe vaapipostproc: do not compensate for crop/direction if no VPP
If we do not have functional VPP, then cropping and video
direction is non-functional and we should avoid calling
any of the gst_vaapi_filter* APIs.
2020-02-21 08:49:06 -08:00
U. Artie Eoff
39f2c932ee vaapipostproc: only set VPP colorimetry when VPP is available
If we don't have functional vpp then we should not call
gst_vaapi_filter_set_colorimetry.
2020-02-21 08:28:10 -08:00
He Junyan
15e169fbf1 videobufferpool: don't reset surface when created internally
The bug fixing, in commit 89f202ea, just considers the case when
surface's DMABuf is set through gst_buffer_pool_acquire_buffer(),
which is typically a decoder's behavior. But vaapipostproc doesn't
provide any surface when calling gst_buffer_pool_acquire_buffer(),
thus a surface is created when GstMemory is allocated.

If the surface proxy in buffer's meta is reset at
buffer_pool_reset_buffer(), that surface will be destroyed and it
won't be available anymore. But GstBuffers are cached in the buffer
pool and they are reused again, hence only those images are rendered
repeatedly.

Fixes: #232
2020-02-21 15:52:43 +00:00
Víctor Manuel Jáquez Leal
57e792136c libs: blend: filter: handle finalize() if display isn't assigned
I've just discovered iHD driver in Skylake doesn't have VideoProc
entry point, hence, in this platform, when vaapioverlay is tried to be
registered, critical warnings are raised because blend doesn't have a
display assigned.

As it is possible to have drivers without EntryPointVideoProc it is
required to handle it gracefully. This patch does that: only tries to
register vaapioverlay if the testing display has VPP and finalize()
vmethods, in filter and blend, bail out if display is NULL.
2020-02-21 15:11:31 +00:00
Víctor Manuel Jáquez Leal
566af572af vaapipostproc: demote log message to trace level 2020-02-16 12:22:16 +00:00
Víctor Manuel Jáquez Leal
33c80bccfe vaapidecode: don't remove chroma-site nor colorimetry
Since now they can be handled by vaapipostproc.
2020-02-07 15:54:27 +01:00
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
U. Artie Eoff
b384593d3d plugins: use plugin base macros to access pad specific data
Don't access base struct fields directly since the underlying
definition can change.  Instead, use the accessor macros.
2019-12-11 21:27:48 +00:00
He Junyan
f4fc37ccc5 libs: decoder: Modify decode src's template raw formats
We do not need to maintain a standalone list of decoder's output
template for raw formats and that is easy to make mistake(for
example, the AYVU is wrong in that list, should be VUYA).
Just use GST_VAAPI_FORMATS_ALL to replace the raw formats list for
src template.
2019-12-11 19:44:24 +00:00
He Junyan
9d8467dc60 libs: postproc: Modify src/sink template raw formats
We need to provide more precise template caps for postproc's src
and sink pads. The GST_VIDEO_FORMATS_ALL make all video formats
available which are really superfluous.
2019-12-11 16:39:23 +00:00
He Junyan
f16c93a187 libs: video-format: add GST_VAAPI_FORMATS_ALL
GST_VAAPI_FORMATS_ALL collects all declared formats in video-format
as a caps template string, and make them available in caps with
memory:VASurface feature.

Fixes: #199
2019-11-27 01:44:49 +01:00
Tim-Philipp Müller
8af5ef8a0b Remove autotools build 2019-10-14 01:01:27 +01:00
U. Artie Eoff
40bcefcb3b vaapipostproc: fix off-by-one coord translations
When translating navigation x,y coordinates for
video-direction, it is necessary to subtract 1
when using the video dimensions to compute the
new x,y coordinates.  That is, a 100x200 image
should map coordinates in x=[0-99],y=[0-199].

This issue was found with unit tests provided
in !182.
2019-10-11 16:37:31 +00:00
Yan Wang
4c87644914 vaapipostproc: Use level value for skin-tone-enhancement filter.
Currently the parameter of skin-tone-enhancement filter is forced
to zero. In fact it could be set different value by the user.
So create a new property named as "skin-tone-enhancement-level"
for accepting the used defined parameter value.
At the same time, skin-tone-enhancement is marked as deprecated.
When skin-tone-enhancement-level is set, skin-tone-enhancement
will be ignored.
2019-09-30 18:14:53 +00:00
U. Artie Eoff
73ac0c4e50 gst: encode: h264_fei: remove useless comparison
The expression "len >= 0" is always true since "len"
is an unsigned type.  And it is clear that the writers
intention was not to write "len > 0" since we handle
len == 0 in the ensuing "if (len < 3)" conditional
block.
2019-09-19 12:09:35 -07:00
Víctor Manuel Jáquez Leal
f0d6263318 libs: encoders: use GST_PARAM_USER_SHIFT to define internal params
This patch makes use of GST_PARAM_USER_SHIFT to define the internal
param in encoders to decide which parameters to expose. Thus
gstreamer-vaapi will not interfere with any change in GStreamer in the
future.

Also, the internal symbol was change to
GST_VAAPI_PARAM_ENCODER_EXPOSURE to keep the namespacing.
2019-09-11 14:32:22 +02:00
Philippe Normand
a90daabb84 pluginutil: Remove Mesa from drivers white list
The Mesa Gallium driver is poorly tested currently, leading to bad user
experience for AMD users. The driver can be added back to the white list at
runtime using the GST_VAAPI_ALL_DRIVERS environment variable.
2019-09-06 16:10:54 +00:00
U. Artie Eoff
2f0f5e1ef9 vaapipostproc: allow cropping via properties
Add crop-left, crop-right, crop-top and crop-bottom
properties to vaapipostproc.
2019-09-05 10:42:28 -07:00
U. Artie Eoff
55654f2915 vaapipostproc: rotate outbuf and crop meta if forwarding
When forwarding crop meta to downstream, the output
buffer and crop meta need to be rotated, too.

Test:
 for i in 90r 180 90l vert horiz ul-lr ur-ll
 do
  gst-launch-1.0 -vf videotestsrc num-buffers=500 \
   ! videocrop top=100 bottom=30 left=40 right=20 \
   ! vaapipostproc video-direction=$i \
   ! vaapisink & \
  gst-launch-1.0 -vf videotestsrc num-buffers=500 \
   ! videocrop top=100 bottom=30 left=40 right=20 \
   ! vaapipostproc video-direction=$i \
   ! identity drop-allocation=true \
   ! vaapisink
 done
2019-09-05 11:03:34 +00:00
U. Artie Eoff
c6ee20fab3 vaapipostproc: fix output buffer WxH for crop meta forwarding
Adding crop meta x,y to w,h only compensates for left,top
cropping.  But we also need to compensate for right,bottom
cropping.

The video meta contains the appropriate w,h (uncropped)
values, so use it instead.

Test:

 gst-launch-1.0 -vf videotestsrc num-buffers=500 \
  ! videocrop top=50 bottom=30 left=40 right=20 \
  ! vaapipostproc ! vaapisink & \
 gst-launch-1.0 -vf videotestsrc num-buffers=500 \
  ! videocrop top=50 bottom=30 left=40 right=20 \
  ! vaapipostproc ! identity drop-allocation=1 \
  ! vaapisink
2019-09-05 11:03:34 +00:00
U. Artie Eoff
9fd020a117 vaapipostproc: handle size and direction together in src events
Mapping a pointer event needs to consider both size and
video-direction operations together, not just one or the other.

This fixes an issue where x,y were not being mapped correctly
for 90r, 90l, ur-ll and ul-lr video-direction. In these directions,
the WxH are swapped and GST_VAAPI_POSTPROC_FLAG_SIZE is set.  Thus,
the first condition in the pointer event handling was entered and
x,y scale factor were incorrectly computed due to srcpad WxH
swap.

This also fixes all cases where both video-direction and scaling
are enabled at the same time.

Test that all pointer events map appropriately:

for i in `seq 0 7`
do
 GST_DEBUG=vaapipostproc:5 gst-launch-1.0 -vf videotestsrc \
  ! vaapipostproc video-direction=${i} width=300 \
  ! vaapisink
 GST_DEBUG=vaapipostproc:5 gst-launch-1.0 -vf videotestsrc \
  ! vaapipostproc video-direction=${i} width=300 height=200 \
  ! vaapisink
 GST_DEBUG=vaapipostproc:5 gst-launch-1.0 -vf videotestsrc \
  ! vaapipostproc video-direction=${i} height=200 \
  ! vaapisink
 GST_DEBUG=vaapipostproc:5 gst-launch-1.0 -vf videotestsrc \
  ! vaapipostproc video-direction=${i} \
  ! vaapisink
done
2019-09-04 16:03:24 -07:00
U. Artie Eoff
6700f642fc vaapipostproc: advertise crop meta is handled
Advertise to upstream that vaapipostproc can handle
crop meta.

When used in conjunction with videocrop plugin, the
videocrop plugin will only do in-place transform on the
crop meta when vaapipostproc advertises the ability to
handle it.  This allows vaapipostproc to apply the crop
meta on the output buffer using vaapi acceleration.
Without this advertisement, the videocrop plugin will
crop the output buffer directly via software methods,
which is not what we desire.

vaapipostproc will not apply the crop meta if downstream
advertises crop meta handling; vaapipostproc will just
forward the crop meta to downstream.  If crop meta is
not advertised by downstream, then vaapipostproc will
apply the crop meta.

Examples:

1. vaapipostproc will forward crop meta to vaapisink
 gst-launch-1.0 videotestsrc \
  ! videocrop left=10 \
  ! vaapipostproc \
  ! vaapisink

2. vaapipostproc will do the cropping
 gst-launch-1.0 videotestsrc \
  ! videocrop left=10 \
  ! vaapipostproc \
  ! identity drop-allocation=1 \
  ! vaapisink
2019-08-30 17:01:55 +00:00
He Junyan
258719e0ed plugin: encode: delete useless init_properties.
Also delete the get_properties function in encode class. We now
use g_object_class_list_properties to get all properties for
internal encoder class.
2019-08-30 21:21:04 +08:00
He Junyan
2ab5e0ef46 plugin: encode: delete set/get_property func in encode class
Use standard gobject's property functions to replace the old way.
2019-08-30 21:21:04 +08:00
He Junyan
46ce4e3054 plugin: encode: delete gst_vaapiencode_init_properties
No need to init the properties got by get_default_properties func
now. The properties are inited correctly in internal encoder class.
2019-08-30 21:21:04 +08:00
He Junyan
1256680486 gst: encode: enable new type of property mechanism. 2019-08-30 21:19:14 +08:00
He Junyan
05643dadb5 gst: encode: add property help functions for encoder properties.
The encoder is a true gstobject now and all the properties are using
gobject's properties mechanism. Add help functions to handle the properties
between encode and encoder class.
The basic idea is mapping the same property between encoder and encode. All
the encoder's properties will have the same name, the same type in encode.
The set/get property function just forward the property setting/getting to
the encoder using the same property name and value. Because the encoder is
created on needed, we need to cache the property setting in encode.
2019-08-30 21:06:47 +08:00
Víctor Manuel Jáquez Leal
d671197684 vaapipostproc: check for filter before appending caps
While ensuring the allowed sink pad caps, the filter attributes set
the frame size restriction, but it is not ensured, at that moment,
that the filter is already instantiaded.

In order to silence the glib logs, this patch add only calls
gst_vaapi_filter_append_caps() if the filter is instantiated.
2019-08-29 11:03:30 +00:00
Thibault Saunier
9fe6b621a2 Classify vaapidecodebin as a hardware decoder 2019-08-28 12:49:03 -04:00
He Junyan
70cefdd272 libs: postproc: fix a memory leak point.
filter_ops and filter_formats should already have valid value when
the function gst_vaapipostproc_ensure_filter_caps re-enter
2019-08-27 16:33:34 +00:00
Wangfei
6f8ea02b61 vaapidecode: support transform ROI meta
This will benefit the use case like:

src --->   encode    ---> decode ---> circle ROI ---> sink
     |                |
     --> analyse to -->
         get ROI
2019-08-26 09:36:54 +00:00
Mathieu Duponchelle
0592731715 docstrings: port ulinks to markdown links 2019-08-23 19:10:15 +02:00
Víctor Manuel Jáquez Leal
dae057588b libs: remove surface's parent context
In commit 18031dc6 surface's parent context is not assigned because of
circular references. Since then (2013), there's has no issue with
subpictures attached to a context, the current only users of this API.

This patch cleans up all of related code with the unused surface's
parent context.
2019-08-20 17:11:23 +02:00
Víctor Manuel Jáquez Leal
e8b52f59f5 vaapidecode: guard if no structure is available in caps 2019-08-19 17:26:55 +00:00
Víctor Manuel Jáquez Leal
f88d18bebe vaapipostproc: append frame size restrictions in caps 2019-08-19 17:26:55 +00:00
Víctor Manuel Jáquez Leal
6f61252f9d vaapiencode: set frame size restrictions in caps
Fixes: #12
2019-08-19 17:26:55 +00:00
Víctor Manuel Jáquez Leal
3ba3966fc3 vaapiencode: enhance how the profile is defined
This code doesn't define the profile used by the internal encoder, but
it used to "predict" which is going to be used and to get the caps
restrictions.

Before the profile was predicted by checking the donwstream caps, but
sometimes they are not defined, setting an unknown profile. In order
to enhances this situation, the encoder asks to internal encoder if it
has one. If so, it is used.

To ask the internal encoder's profile a new accessor function was
added: gst_vaapi_encoder_get_profile()
2019-08-19 17:26:55 +00:00
Víctor Manuel Jáquez Leal
f7c1ac036d libs: profilecaps: move caps config into a new file
Implement all the appending of frame size restrictions in caps, for
encoders and decoders, in a new source file.
2019-08-19 17:26:55 +00:00
Víctor Manuel Jáquez Leal
6cb3e741fd vaapipostproc: handle navigation downstream event
When navigation events contains coordiantes those have to be mapped
to the new size and/or orientation.
2019-08-19 16:48:50 +00:00
Víctor Manuel Jáquez Leal
bcb29e8399 vaapipostproc: handle image-orientation upstream event
Now that vaapipostproc can possible handle video-direction, it
should also handle the image-orientation event from upstream if
video-direction property is set to auto.
2019-08-19 16:48:50 +00:00
Víctor Manuel Jáquez Leal
b8a333e0c3 vaapipostproc: add missing locks when adding flags 2019-08-19 16:48:49 +00:00
Víctor Manuel Jáquez Leal
bd175f9956 vaapipostproc: update filter before fixate caps
It is requiered to know if postproc is capable to change the video
direction before fixating the source caps.

In order to do it, it'ss required to know if there's a functional VPP,
but that's checked at create() vmethod, which occurs after caps
fixating.

This patch checks for a functional VPP at fixate caps and, if so,
checks for the enabled filtes and later do the caps fixations.
2019-08-19 16:48:49 +00:00