Commit graph

1189 commits

Author SHA1 Message Date
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
Víctor Manuel Jáquez Leal c06b587819 vaapipostproc: element warning if video direction is unsupported
If the video direction is unsupported by the driver, an element
warning is posted in the bus to notify the application.

gst_vaapi_enum_type_get_nick() was added in the library thus it can
be used elsewhere. It retrives the nick from an enum gtype.
2019-08-19 16:48:49 +00:00
Víctor Manuel Jáquez Leal e48b0a90f1 vaapivideomemory: demote error message to info
The main reason to demote the message's level is because it is not an
error, it's a possible output of the trial and there's a code path
that handles it.

Secondly, it's very annoying when using gallium driver for radeon.
2019-08-15 12:58:44 +02:00
Víctor Manuel Jáquez Leal 14ea838512 vaapidecodebin: set queue's max size buffers to 1
Otherwise the queue will swallow all the available decoder's surfaces
reaching a dead-lock.

This setting might impact the bin's peformance, but it's a trade-off.
2019-07-26 12:43:17 +02:00
Víctor Manuel Jáquez Leal 1fa172f032 vaapidecodebin: set properties default values 2019-07-26 12:40:01 +02:00
Víctor Manuel Jáquez Leal ec9a2a4b4e vaapidecode: don't error if can't push buffers downtream
When the code path goes to push buffers downstream when no surface
available in decoder context, and it fails the code bails out with a
fatal error.

That behavior is wrong, since it shouldn't be fatal. The use case is
when the video stream is disabled.

This patch just ignores the errors in this situation and demotes the
level of a log message.
2019-07-26 12:40:01 +02:00
U. Artie Eoff 4e4ca03bc1 vaapipostproc: update PAR when rotating
When rotating, swap pixel-aspect-ratio during
negotiation.

Fixes #181
2019-07-15 15:33:15 -07:00
U. Artie Eoff f1aa0cc5e0 vaapipostproc: add rotation support
Adds vpp rotation support to vaapipostproc.  Uses
property video-direction. Default is identity (no
rotation).

Closes #104
2019-07-09 12:26:46 -07:00
Wangfei e4bec306b6 vaapidecode: set initial decode format according surface chroma type
For surfaces with different chroma type, it is prefer to initialize
a format which chroma type should be same with surface chroma type
instead of using fixed NV12.
2019-06-26 10:36:56 +00:00
Wangfei 67ed67515b libs: decoder: jpeg: add support 400/411/422/444 chroma type
When create vaapi surface, it is better to use the chroma type get
from jpeg file instead of using fixed 420 format. And the correct
chroma type can be determined by horizontal_factor/vertical_factor
flags that get from jpegparse.
2019-06-26 10:36:56 +00:00
U. Artie Eoff a6dfb6e5be plugins: remove last negotiated video info if caps are same
If the allocation caps and negotiated caps are the same,
then ensure any previously negotiated video info is also
removed.  This can occur when multi-resolution video
decoding returns to it's original resolution.

Fixes #170
2019-06-10 21:28:13 -07:00
U. Artie Eoff 5f41422215 vaapivideomemory: allow negotiated info to be removed
Allow NULL negotiated_vinfo to be passed into
gst_allocator_set_vaapi_negotiated_video_info to allow
any previously set info to be removed.
2019-06-10 20:39:28 -07:00