platform/upstream/gstreamer.git
4 years agoplugin: encode: set allowed_sinkpad_caps to empty.
He Junyan [Sun, 22 Dec 2019 06:35:18 +0000 (14:35 +0800)]
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.

4 years agolibs: encoder: Add NULL pointer check for context when finalize.
He Junyan [Sun, 22 Dec 2019 07:22:57 +0000 (15:22 +0800)]
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.

4 years agoplugins: base: do not reset can_dmabuf
U. Artie Eoff [Fri, 20 Dec 2019 14:38:42 +0000 (06:38 -0800)]
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
ca2942176b5632e07eebac23336954f9aaf1cb26 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

4 years agoplugin: encode: Refine encode's sink caps.
He Junyan [Thu, 5 Dec 2019 16:21:12 +0000 (00:21 +0800)]
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.

4 years agolibs: display: code clean up
Víctor Manuel Jáquez Leal [Fri, 20 Dec 2019 07:37:11 +0000 (08:37 +0100)]
libs: display: code clean up

4 years agolibs: display: refine the profile/entrypoint map.
He Junyan [Thu, 12 Dec 2019 13:34:21 +0000 (21:34 +0800)]
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.

4 years agolibs: surface: port to GstMiniObject
He Junyan [Thu, 19 Dec 2019 13:19:10 +0000 (14:19 +0100)]
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>
4 years agolibs: surface: rename create function names to init
Víctor Manuel Jáquez Leal [Thu, 19 Dec 2019 17:26:10 +0000 (18:26 +0100)]
libs: surface: rename create function names to init

There are several internal functions with 'create' name, but they
don't create any new structure, but rather it initializes that
structure. Renaming those function to reflect better their purpose.

4 years agolibs: surface: use macro accessors
Víctor Manuel Jáquez Leal [Thu, 19 Dec 2019 13:17:34 +0000 (14:17 +0100)]
libs: surface: use macro accessors

4 years agolibs: surface: fix internal documentation
Víctor Manuel Jáquez Leal [Thu, 19 Dec 2019 12:46:09 +0000 (13:46 +0100)]
libs: surface: fix internal documentation

4 years agolibs: codedbuffer: port to GstMiniObject
He Junyan [Wed, 18 Dec 2019 17:00:49 +0000 (18:00 +0100)]
libs: codedbuffer: port to GstMiniObject

GstVaapiMiniObject and GstVaapiObject are deprecated.

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

Signed-off-by: Víctor Manuel Jáquez Leal <vjaquez@igalia.com>
4 years agolibs: image: port to GstMiniObject base class
He Junyan [Wed, 18 Dec 2019 11:57:01 +0000 (12:57 +0100)]
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>
4 years agolibs: context: port to a plain C structure
He Junyan [Mon, 23 Sep 2019 17:01:22 +0000 (01:01 +0800)]
libs: context: port to a plain C structure

The GstVaapiMiniObject is obsolete and we need to replace it. This
patch turns GstVaapiContext into a plain C structure with its own
reference counting mechanism.

Also this patch removes unused overlays attributes.

Signed-off-by: Víctor Manuel Jáquez Leal <vjaquez@igalia.com>
4 years agoplugin: encode: change the dmabuf caps to all supported formats.
He Junyan [Tue, 17 Dec 2019 16:40:58 +0000 (00:40 +0800)]
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.

4 years agolibs: encoder: h264fei: remove unnecessary check
Víctor Manuel Jáquez Leal [Tue, 17 Dec 2019 16:09:37 +0000 (17:09 +0100)]
libs: encoder: h264fei: remove unnecessary check

Issue detected by Coverity

`info_to_pack.h264_slice_header` is always allocated by
gst_vaapi_feipak_h264_encode(), thus checking it to free it afterwards
in doesn't make much sense.  But it requires to be free on the error
path.

There may be a null pointer dereference, or else the comparison
against null is unnecessary.

In gst_vaapi_encoder_h264_fei_encode: All paths that lead to this null
pointer comparison already dereference the pointer earlier

4 years agolibs: encoder: h264fei: remove unnecessary assert
Víctor Manuel Jáquez Leal [Tue, 17 Dec 2019 16:05:22 +0000 (17:05 +0100)]
libs: encoder: h264fei: remove unnecessary assert

Issue detected by Coverity

An unsigned value can never be negative, so this test will always
evaluate the same way.

In add_slice_headers: An unsigned value can never be less than 0

4 years agolibs: encoder: h264fei: remove unnecessary check
Víctor Manuel Jáquez Leal [Tue, 17 Dec 2019 15:57:41 +0000 (16:57 +0100)]
libs: encoder: h264fei: remove unnecessary check

Issue detected by Coverity

There may be a null pointer dereference, or else the comparison
against null is unnecessary.

In gst_vaapi_encoder_h264_fei_encode: All paths that lead to this null
pointer comparison already dereference the pointer earlier

4 years agolibs: encoder: h264fei: don't free memory on stack
Víctor Manuel Jáquez Leal [Tue, 17 Dec 2019 15:49:47 +0000 (16:49 +0100)]
libs: encoder: h264fei: don't free memory on stack

Issue detected by Coverity

`info_to_pak` variable in gst_vaapi_encoder_h264_fei_encode() is
declared in the stack, but it is free in
gst_vaapi_feienc_h264_encode() as if declared on the heap.

This patch initializes the structure and removes the free.

A non-heap pointer is placed on the free list, likely causing a crash
later.

In gst_vaapi_encoder_h264_fei_encode: Free of an address-of
expression, which can never be heap allocated.

4 years agolibs: encoder: h264fei: fix surface leak
Víctor Manuel Jáquez Leal [Tue, 17 Dec 2019 12:22:12 +0000 (13:22 +0100)]
libs: encoder: h264fei: fix surface leak

Issue detected by Coverity

If the FEI mode is not handled the created resources should be
released and return and error code.

The system resource will not be reclaimed and reused, reducing the
future availability of the resource.

In gst_vaapi_encoder_h264_fei_encode: Leak of memory or pointers to
system resources

4 years agotests: check return calling of gst_navigation_event_parse.*
Víctor Manuel Jáquez Leal [Tue, 17 Dec 2019 12:09:58 +0000 (13:09 +0100)]
tests: check return calling of gst_navigation_event_parse.*

This issue was detected by Coverity.

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

In cb_mouse_event: Value returned from a function is not checked for
errors before being used

4 years agoplugin: encode: set sink's raw caps to GST_VAAPI_FORMATS_ALL.
He Junyan [Mon, 16 Dec 2019 08:25:02 +0000 (16:25 +0800)]
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.

4 years agoplugins: base: add GstPad param to internal helper functions
U. Artie Eoff [Thu, 14 Nov 2019 19:13:51 +0000 (11:13 -0800)]
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).

4 years agoplugins: base: manage pad-specific data in a single struct
U. Artie Eoff [Tue, 12 Nov 2019 20:21:52 +0000 (12:21 -0800)]
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).

4 years agoplugins: use plugin base macros to access pad specific data
U. Artie Eoff [Tue, 29 Oct 2019 22:13:44 +0000 (15:13 -0700)]
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.

4 years agolibs: decoder: Modify decode src's template raw formats
He Junyan [Mon, 2 Dec 2019 16:52:45 +0000 (00:52 +0800)]
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.

4 years agolibs: postproc: Modify src/sink template raw formats
He Junyan [Wed, 11 Dec 2019 06:11:13 +0000 (14:11 +0800)]
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.

4 years agoDo not mix declaration and code
Thibault Saunier [Tue, 10 Dec 2019 21:40:42 +0000 (18:40 -0300)]
Do not mix declaration and code

4 years agolibs: decoder: h265: skip all pictures prior the first I-frame
Víctor Manuel Jáquez Leal [Sun, 3 Nov 2019 16:59:01 +0000 (17:59 +0100)]
libs: decoder: h265: skip all pictures prior the first I-frame

Don't try to decode until the first I-frame is received within the
currently active sequence. i965 H265 decoder don't show any artifact
but it crashes.

Fixes: #98

4 years agolibs: video-format: remove dead code
Víctor Manuel Jáquez Leal [Wed, 27 Nov 2019 00:44:05 +0000 (01:44 +0100)]
libs: video-format: remove dead code

4 years agolibs: video-format: add GST_VAAPI_FORMATS_ALL
He Junyan [Wed, 30 Oct 2019 16:59:34 +0000 (00:59 +0800)]
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

4 years agolibs: video-format: change GST_VIDEO_FORMAT_AYUV to VUYA.
He Junyan [Wed, 6 Nov 2019 14:37:12 +0000 (22:37 +0800)]
libs: video-format: change GST_VIDEO_FORMAT_AYUV to VUYA.

We only support VUYA format in gst vaapi now, need to correct
the mapping.

4 years agotests: check: vaapipostproc test_orientation_mouse_events
U. Artie Eoff [Wed, 9 Oct 2019 22:13:09 +0000 (15:13 -0700)]
tests: check: vaapipostproc test_orientation_mouse_events

Test that vaapipostproc properly translates mouse events
when using video-direction (orientation).

4 years agotests: check: vaapipostproc test_crop_mouse_events
U. Artie Eoff [Wed, 9 Oct 2019 17:11:54 +0000 (10:11 -0700)]
tests: check: vaapipostproc test_crop_mouse_events

Test that vaapipostproc properly translates mouse events
when cropping.

4 years agotests: check: initial unit test support
U. Artie Eoff [Tue, 8 Oct 2019 19:20:26 +0000 (12:20 -0700)]
tests: check: initial unit test support

Add minimal unit test toolchain files and a simple
vaapipostproc unit test.

4 years agotests: move examples and tests to subfolders
U. Artie Eoff [Tue, 8 Oct 2019 19:19:06 +0000 (12:19 -0700)]
tests: move examples and tests to subfolders

This makes way for adding unit (check) tests.

4 years agoRemove autotools build
Tim-Philipp Müller [Mon, 14 Oct 2019 00:01:27 +0000 (01:01 +0100)]
Remove autotools build

4 years agovaapipostproc: fix off-by-one coord translations
U. Artie Eoff [Thu, 10 Oct 2019 22:26:36 +0000 (15:26 -0700)]
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.

4 years agolibs: window: x11: Avoid usage of deprecated API
Víctor Manuel Jáquez Leal [Fri, 11 Oct 2019 15:34:06 +0000 (17:34 +0200)]
libs: window: x11: Avoid usage of deprecated API

4 years agobuild: halt meson configuration if no renderer API
Víctor Manuel Jáquez Leal [Fri, 11 Oct 2019 15:13:34 +0000 (17:13 +0200)]
build: halt meson configuration if no renderer API

We should halt meson configuration if there is no render API
installed (either DRM, Wayland or X11).

That behavior was already in autotools but missed in meson. This patch
brings it back.

Fixes: #196

4 years agolibs: filter: fix default orientation regression
U. Artie Eoff [Wed, 9 Oct 2019 19:12:18 +0000 (12:12 -0700)]
libs: filter: fix default orientation regression

Fix regression introduced in f232f87f7082

4 years agolibs: filter: use OP_DATA_DEFAULT_VALUE macro
U. Artie Eoff [Mon, 7 Oct 2019 18:53:23 +0000 (11:53 -0700)]
libs: filter: use OP_DATA_DEFAULT_VALUE macro

4 years agolibs: filter: use macro for returning op default value
U. Artie Eoff [Mon, 7 Oct 2019 18:39:19 +0000 (11:39 -0700)]
libs: filter: use macro for returning op default value

The code is essentially the same for getting all op default
values.  Thus, use a macro to help minimize code duplication
and [hopefully] encourage using the same mechanism for all
default getters.

4 years agolibs: filter: query param spec for default scale method
U. Artie Eoff [Mon, 7 Oct 2019 16:56:37 +0000 (09:56 -0700)]
libs: filter: query param spec for default scale method

Related: #159

4 years agolibs: filter: query param spec for default skin-tone values
U. Artie Eoff [Mon, 7 Oct 2019 16:44:06 +0000 (09:44 -0700)]
libs: filter: query param spec for default skin-tone values

Related: #159

4 years agolibs: filter: query param spec for default video-direction
U. Artie Eoff [Wed, 2 Oct 2019 19:54:52 +0000 (12:54 -0700)]
libs: filter: query param spec for default video-direction

Related: #159

4 years agoadd .gitignore
U. Artie Eoff [Mon, 7 Oct 2019 17:23:09 +0000 (10:23 -0700)]
add .gitignore

4 years agovaapipostproc: Use level value for skin-tone-enhancement filter.
Yan Wang [Thu, 5 Sep 2019 08:40:52 +0000 (16:40 +0800)]
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.

4 years agolibs: decoder: h264, h266: fix g_return_val_if_fail() missuse
Víctor Manuel Jáquez Leal [Sat, 21 Sep 2019 11:39:42 +0000 (13:39 +0200)]
libs: decoder: h264, h266: fix g_return_val_if_fail() missuse

g_return_val_fail() documentations says:

  If expr evaluates to FALSE, the current function should be
  considered to have undefined behaviour (a programmer error).
  The only correct solution to such an error is to change the
  module that is calling the current function, so that it avoids
  this incorrect call.

So it was missused in a couple parts of the H264 and H265 internal
decoders. This patch changes that to plain conditionals.

Also, it was included a couple code-style fixes.

4 years agolibs: encoder: remove gst_vaapi_encoder_{ref,unref}()
Víctor Manuel Jáquez Leal [Mon, 23 Sep 2019 17:52:20 +0000 (19:52 +0200)]
libs: encoder: remove gst_vaapi_encoder_{ref,unref}()

Since GstVaapiEncoder is a descendant of of GstObject, there is no
need to keep a custom ref()/unref() methods. This patch deletes them.

4 years agolibs: encoder: correct encoder's ref/unref function.
He Junyan [Mon, 23 Sep 2019 17:03:02 +0000 (01:03 +0800)]
libs: encoder: correct encoder's ref/unref function.

GstVaapiEncoder now is a standard gstobject and need to use
gst_object_ref/unref functions.

4 years agogst: encode: h264_fei: remove useless comparison
U. Artie Eoff [Thu, 19 Sep 2019 19:09:20 +0000 (12:09 -0700)]
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.

4 years agolibs: encoder: h264_fei: fix potential overflow before widen
U. Artie Eoff [Thu, 19 Sep 2019 18:17:24 +0000 (11:17 -0700)]
libs: encoder: h264_fei: fix potential overflow before widen

Found by static analysis. encoder->mb_width * encoder->mb_height
is evaluated using 32-bit arithmetic before widen.  Thus, cast
at least one of these to guint64 to avoid overflow.

4 years agolibs: encoder: h264_fei: remove dead error condition
U. Artie Eoff [Thu, 19 Sep 2019 17:56:13 +0000 (10:56 -0700)]
libs: encoder: h264_fei: remove dead error condition

Found by static analysis.  The feipak is always null
when we reach the error target.

4 years agolibs: utils: add missing break in switch
U. Artie Eoff [Thu, 19 Sep 2019 17:49:11 +0000 (10:49 -0700)]
libs: utils: add missing break in switch

4 years agolibs: video-format: Make all YUV format available
He Junyan [Wed, 11 Sep 2019 03:56:35 +0000 (11:56 +0800)]
libs: video-format: Make all YUV format available

The YUV formats have no ambiguity for drivers, so we can add them all.
Some old driver(i965) does not implement full get/put image functions
but can use derive image funtions for the YUV format. It does not
report that kind of formats correctly in image query, but will derive
that YUV format image from surface. The dynamic mapping of YUV format
will block that manner.
Adding more YUV format mapping has no side effect. So considering the
legacy driver conformance, we add all YUV formats mapping statically
and dynamic mapping RBG formats

Fix: #189
Fix: #190

4 years agoegl: Fix racyness in display thread creation
Matthew Waters [Wed, 18 Sep 2019 05:30:03 +0000 (15:30 +1000)]
egl: Fix racyness in display thread creation

Multiple different scenarios could break the display thread creation and
end up blocking waiting for thread o be created.  Fix them all by
correctly waiting for a new boolean to become valid.

4 years agoegl: don't advertise a wrapped EGLContext as actually wrapped
Matthew Waters [Wed, 18 Sep 2019 05:29:03 +0000 (15:29 +1000)]
egl: don't advertise a wrapped EGLContext as actually wrapped

It's not actually wrapped as we create a new EGLContext from the passed
in EGLContext.  As a result, the created EGLContext was never destroyed.

4 years agolibs: h264decoder: do not return error for unhandled NAL unit.
He Junyan [Mon, 16 Sep 2019 15:28:31 +0000 (23:28 +0800)]
libs: h264decoder: do not return error for unhandled NAL unit.

Some streams have error data introducing unknown NAL type. There are
also kinds of NAL types we do not want to handle. The old manner will
set a decoder error when encounter this, which cause a latent crash bug.
The decoder may successfully decode the picture and insert it into DPB.
But there are error NAL units after the AU which cause the post unit error
and make that frame dropped. The later output of the picture still want
to ref that frame and crash.
No need to set decoder error when can not recognize or handle the NAL
unit, just skip it and continue.

Fix: #191

4 years agolibs: encoders: use GST_PARAM_USER_SHIFT to define internal params
Víctor Manuel Jáquez Leal [Wed, 11 Sep 2019 12:32:22 +0000 (14:32 +0200)]
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.

4 years agolibs: Add BGR10A2_LE support for color space conversion.
He Junyan [Mon, 9 Sep 2019 10:06:51 +0000 (18:06 +0800)]
libs: Add BGR10A2_LE support for color space conversion.

Fix: #179

4 years agolibs: surface: add pointer check for surface_new_from_formats.
He Junyan [Fri, 23 Aug 2019 06:41:06 +0000 (14:41 +0800)]
libs: surface: add pointer check for surface_new_from_formats.

The command line:
  gst-launch-1.0 filesrc location=some_name.mjpeg ! jpegparse !
  vaapijpegdec !  videoconvert ! video/x-raw,format=I420 ! vaapisink
will crash on i965 driver because of no pointer check.

We now generate the video format map between GST format and VA format
dynamically based on the image format returned by vaQueryImageFormats.
i965 driver does to report image format of 444P and Y800 forcc, while
the jpeg decoder context VASurfaceAttribPixelFormat use them. We can
not recognize these format and pass a NULL pointer to
gst_vaapi_surface_new_from_formats.
We need to add a pointer check here and let the fallback logic handle
this case correctly.
Other drivers work well.

4 years agolibs: utils: guard the VAEntrypointFEI symbol
Víctor Manuel Jáquez Leal [Sat, 7 Sep 2019 11:23:01 +0000 (13:23 +0200)]
libs: utils: guard the VAEntrypointFEI symbol

VAEntrypointFEI appeared in libva 2.0.0 (API version 1.0.0)

4 years agolibs: video-format: Refine the video format mapping.
He Junyan [Thu, 5 Sep 2019 06:48:22 +0000 (14:48 +0800)]
libs: video-format: Refine the video format mapping.

Improve the mapping between va format and gst format. The new map
will be generated dynamically, based on the query result of image
format in VA driver. Also consider the ambiguity of RGB color
format in LSB mode.

4 years agopluginutil: Remove Mesa from drivers white list
Philippe Normand [Mon, 15 Apr 2019 15:51:26 +0000 (16:51 +0100)]
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.

4 years agovaapipostproc: allow cropping via properties
U. Artie Eoff [Mon, 8 Jul 2019 21:18:00 +0000 (14:18 -0700)]
vaapipostproc: allow cropping via properties

Add crop-left, crop-right, crop-top and crop-bottom
properties to vaapipostproc.

4 years agovaapipostproc: rotate outbuf and crop meta if forwarding
U. Artie Eoff [Sat, 31 Aug 2019 00:31:45 +0000 (17:31 -0700)]
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

4 years agovaapipostproc: fix output buffer WxH for crop meta forwarding
U. Artie Eoff [Fri, 30 Aug 2019 21:14:30 +0000 (14:14 -0700)]
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

4 years agovaapipostproc: handle size and direction together in src events
U. Artie Eoff [Wed, 4 Sep 2019 17:52:51 +0000 (10:52 -0700)]
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

4 years agovaapipostproc: advertise crop meta is handled
U. Artie Eoff [Tue, 20 Aug 2019 21:22:57 +0000 (14:22 -0700)]
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

4 years agolibs: encoder: clean two virtual func in encoder class
He Junyan [Thu, 29 Aug 2019 10:44:36 +0000 (18:44 +0800)]
libs: encoder: clean two virtual func in encoder class

set_property and get_default_properties functions are no longer
needed for encoder class.

4 years agolibs: encoder: delete old set_property and property enum feienc264
He Junyan [Thu, 29 Aug 2019 10:43:30 +0000 (18:43 +0800)]
libs: encoder: delete old set_property and property enum feienc264

4 years agolibs: encoder: delete old set_property and property enum in h264 fei
He Junyan [Thu, 29 Aug 2019 10:39:27 +0000 (18:39 +0800)]
libs: encoder: delete old set_property and property enum in h264 fei

4 years agolibs: encoder: delete old set_property and property enum in vp9
He Junyan [Thu, 29 Aug 2019 10:37:58 +0000 (18:37 +0800)]
libs: encoder: delete old set_property and property enum in vp9

4 years agolibs: encoder: delete old set_property and property enum in vp8
He Junyan [Thu, 29 Aug 2019 10:36:51 +0000 (18:36 +0800)]
libs: encoder: delete old set_property and property enum in vp8

4 years agolibs: encoder: delete old set_property and property enum in mpeg2
He Junyan [Thu, 29 Aug 2019 10:35:59 +0000 (18:35 +0800)]
libs: encoder: delete old set_property and property enum in mpeg2

4 years agolibs: encoder: delete old set_property and property enum in jpeg
He Junyan [Thu, 29 Aug 2019 10:34:57 +0000 (18:34 +0800)]
libs: encoder: delete old set_property and property enum in jpeg

4 years agolibs: encoder: delete old set_property and property enum in h265
He Junyan [Thu, 29 Aug 2019 10:31:56 +0000 (18:31 +0800)]
libs: encoder: delete old set_property and property enum in h265

4 years agolibs: encoder: delete old set_property and property enum in h264
He Junyan [Thu, 29 Aug 2019 10:30:07 +0000 (18:30 +0800)]
libs: encoder: delete old set_property and property enum in h264

4 years agolibs: encoder: delete EncoderPropInfo related functions
He Junyan [Thu, 29 Aug 2019 10:17:42 +0000 (18:17 +0800)]
libs: encoder: delete EncoderPropInfo related functions

4 years agolibs: encoder: delete encoder_set_property
He Junyan [Thu, 29 Aug 2019 08:13:19 +0000 (16:13 +0800)]
libs: encoder: delete encoder_set_property

We no longer need this obsolete set_property function now after
switch to standard gobject's property manner.
Also delete the old encoder's property enum in the header file.

4 years agolibs: encoder: delete properties_get_default for base class
He Junyan [Thu, 29 Aug 2019 07:59:43 +0000 (15:59 +0800)]
libs: encoder: delete properties_get_default for base class

4 years agoplugin: encode: delete useless init_properties.
He Junyan [Thu, 29 Aug 2019 07:52:04 +0000 (15:52 +0800)]
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.

4 years agoplugin: encode: delete set/get_property func in encode class
He Junyan [Thu, 29 Aug 2019 07:43:45 +0000 (15:43 +0800)]
plugin: encode: delete set/get_property func in encode class

Use standard gobject's property functions to replace the old way.

4 years agoplugin: encode: delete gst_vaapiencode_init_properties
He Junyan [Thu, 29 Aug 2019 07:31:16 +0000 (15:31 +0800)]
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.

4 years agolibs: encoder: delete 3 useless init macro
He Junyan [Thu, 29 Aug 2019 07:19:10 +0000 (15:19 +0800)]
libs: encoder: delete 3 useless init macro

4 years agolibs: encoder: delete get_default_properties of feienc
He Junyan [Thu, 29 Aug 2019 07:16:26 +0000 (15:16 +0800)]
libs: encoder: delete get_default_properties of feienc

4 years agolibs: encoder: delete get_default_properties of H264 Fei
He Junyan [Thu, 29 Aug 2019 07:14:14 +0000 (15:14 +0800)]
libs: encoder: delete get_default_properties of H264 Fei

4 years agolibs: encoder: delete get_default_properties of VP9
He Junyan [Thu, 29 Aug 2019 07:07:17 +0000 (15:07 +0800)]
libs: encoder: delete get_default_properties of VP9

4 years agolibs: encoder: delete get_default_properties of VP8
He Junyan [Thu, 29 Aug 2019 07:06:25 +0000 (15:06 +0800)]
libs: encoder: delete get_default_properties of VP8

4 years agolibs: encoder: delete get_default_properties of MPEG2
He Junyan [Thu, 29 Aug 2019 07:03:52 +0000 (15:03 +0800)]
libs: encoder: delete get_default_properties of MPEG2

4 years agolibs: encoder: delete get_default_properties of JPEG
He Junyan [Thu, 29 Aug 2019 07:03:19 +0000 (15:03 +0800)]
libs: encoder: delete get_default_properties of JPEG

4 years ago libs: encoder: delete get_default_properties of H265
He Junyan [Fri, 30 Aug 2019 11:15:38 +0000 (19:15 +0800)]
 libs: encoder: delete get_default_properties of H265

4 years agolibs: encoder: delete get_default_properties of H264
He Junyan [Thu, 29 Aug 2019 06:59:12 +0000 (14:59 +0800)]
libs: encoder: delete get_default_properties of H264

4 years agolibs: encoder: delete the useless constructed func for encoder.
He Junyan [Thu, 29 Aug 2019 06:53:59 +0000 (14:53 +0800)]
libs: encoder: delete the useless constructed func for encoder.

4 years agolibs: encoder: implement get_view_ids for h264 encoder.
He Junyan [Mon, 26 Aug 2019 15:16:33 +0000 (23:16 +0800)]
libs: encoder: implement get_view_ids for h264 encoder.

4 years agogst: encode: enable new type of property mechanism.
He Junyan [Tue, 20 Aug 2019 15:56:33 +0000 (23:56 +0800)]
gst: encode: enable new type of property mechanism.

4 years agogst: encode: add property help functions for encoder properties.
He Junyan [Tue, 20 Aug 2019 14:16:35 +0000 (22:16 +0800)]
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.

4 years agolibs: encoder: add flags to all encoder properties.
He Junyan [Fri, 30 Aug 2019 10:39:32 +0000 (18:39 +0800)]
libs: encoder: add flags to all encoder properties.

G_PARAM_CONSTRUCT make all properties init correctly, we do not
need to init the properties manually.
G_PARAM_FLAG_VAAPI_ENCODER_EXPOSURE is a vaapi encoder specific
flag, means need to expose the property to according encode class.

4 years agolibs: encoder: Add properties for h264 encoder fei.
He Junyan [Tue, 20 Aug 2019 09:00:39 +0000 (17:00 +0800)]
libs: encoder: Add properties for h264 encoder fei.

Install properties for h264 encoder fei class. Also set the new get/set
property functions for gobject class. Still use the old properties
way now and this new feature will be enabled later.

4 years agolibs: encoder: Add properties for h264 fei encoder.
He Junyan [Tue, 20 Aug 2019 07:58:30 +0000 (15:58 +0800)]
libs: encoder: Add properties for h264 fei encoder.

Install properties for h264 fei encoder class. Also set the new get/set
property functions for gobject class. Still use the old properties
way now and this new feature will be enabled later.