Commit graph

3648 commits

Author SHA1 Message Date
Víctor Manuel Jáquez Leal
b3570febf7 libs: utils: delete useless gst_vaapi_profile_caps_append_encoder. 2020-01-02 18:01:52 +01:00
He Junyan
a6cf75e8c6 libs: encoder: get surfaces resolution the same time with formats.
We can get all the information about the video format at one shot
when we create the test context for getting the supported formats.

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

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

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

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

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

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

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

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

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

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

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

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

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

as the correct result.
2019-12-20 10:02:03 +00:00
Víctor Manuel Jáquez Leal
4da8dc2550 libs: display: code clean up 2019-12-20 08:40:54 +01:00
He Junyan
b2cabe2f5b libs: display: refine the profile/entrypoint map.
The old way make the one config for each profile/entrypoint pair,
which is not very convenient for description the relationship
between them. One profile may contain more than one entrypoints
to within it, so a set like data structure should be more suitable.
2019-12-20 07:39:43 +00:00
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
Víctor Manuel Jáquez Leal
e398f2c245 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.
2019-12-20 05:01:07 +00:00
Víctor Manuel Jáquez Leal
84cc6f31a5 libs: surface: use macro accessors 2019-12-20 05:01:07 +00:00
Víctor Manuel Jáquez Leal
af4ff803ff libs: surface: fix internal documentation 2019-12-20 05:01:07 +00:00
He Junyan
6bf33ada4f 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>
2019-12-20 05:01:07 +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
a6289308ee 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>
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
Víctor Manuel Jáquez Leal
4bb41e6ca3 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
2019-12-17 18:31:36 +01:00
Víctor Manuel Jáquez Leal
f82cec2ce3 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
2019-12-17 18:31:36 +01:00
Víctor Manuel Jáquez Leal
d69a4b8c05 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
2019-12-17 18:31:36 +01:00
Víctor Manuel Jáquez Leal
47b0932911 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.
2019-12-17 18:31:29 +01:00
Víctor Manuel Jáquez Leal
6ecbb8d100 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
2019-12-17 17:57:09 +01:00
Víctor Manuel Jáquez Leal
b55b0538c9 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
2019-12-17 17:56:51 +01: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
Thibault Saunier
506b6c53c5 Do not mix declaration and code 2019-12-10 18:44:11 -03:00
Víctor Manuel Jáquez Leal
1168d6d548 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
2019-11-29 15:34:05 +00:00
Víctor Manuel Jáquez Leal
6fb5387d5b libs: video-format: remove dead code 2019-11-27 01:45:29 +01: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
He Junyan
a8be369840 libs: video-format: change GST_VIDEO_FORMAT_AYUV to VUYA.
We only support VUYA format in gst vaapi now, need to correct
the mapping.
2019-11-06 22:38:57 +08:00
U. Artie Eoff
1c3b02daf2 tests: check: vaapipostproc test_orientation_mouse_events
Test that vaapipostproc properly translates mouse events
when using video-direction (orientation).
2019-10-16 12:53:07 -07:00
U. Artie Eoff
8bcfacdb62 tests: check: vaapipostproc test_crop_mouse_events
Test that vaapipostproc properly translates mouse events
when cropping.
2019-10-16 12:53:07 -07:00
U. Artie Eoff
7ce24e6ff7 tests: check: initial unit test support
Add minimal unit test toolchain files and a simple
vaapipostproc unit test.
2019-10-16 12:49:17 -07:00
U. Artie Eoff
97aabe8784 tests: move examples and tests to subfolders
This makes way for adding unit (check) tests.
2019-10-16 12:48:24 -07: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
Víctor Manuel Jáquez Leal
58a512b7c5 libs: window: x11: Avoid usage of deprecated API 2019-10-11 17:59:25 +02:00
Víctor Manuel Jáquez Leal
f80dee40c8 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
2019-10-11 17:13:34 +02:00
U. Artie Eoff
600aba57cf libs: filter: fix default orientation regression
Fix regression introduced in f232f87f70
2019-10-09 12:12:23 -07:00
U. Artie Eoff
038b608cde libs: filter: use OP_DATA_DEFAULT_VALUE macro 2019-10-08 10:16:18 -07:00
U. Artie Eoff
f232f87f70 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.
2019-10-07 11:39:19 -07:00
U. Artie Eoff
6690031b2b libs: filter: query param spec for default scale method
Related: #159
2019-10-07 11:19:00 -07:00