Commit graph

1302 commits

Author SHA1 Message Date
Víctor Manuel Jáquez Leal
ecd1ca81a7 vaapidecode: always merge profile caps in sink caps
This commit fixes a regression of e962069d, where if the profile's
caps doesn't have a caps profile, it's ignored.

This patch add a conditional jump if the caps doesn't have a profile
field to merge it.

Fixes: #271
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/368>
2020-07-29 09:10:22 +02:00
Víctor Manuel Jáquez Leal
7c2f5f1dd8 vaapidecode: dma caps only use reported color format
This fix pipelines without vaapipostproc after vaapi decoder, such as

gst-launch-1.0 filesrc location=~/file.mp4 ! parsebin ! vaapih264dec ! glimagesink

On EGL platforms, so DMABuf is used.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/366>
2020-07-27 19:34:46 +02:00
Víctor Manuel Jáquez Leal
88f3b6b44d vaapidecode: use allowed srcpad caps for caps query
Instead of using just the template caps use the current allowed
srcpad caps, which is created considering the current decoder
context.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/366>
2020-07-27 19:32:00 +02:00
Víctor Manuel Jáquez Leal
634fefab5d vaapidecode: build allowed srcpad caps from va context
Instead of generating allowed srcpad caps with generic information,
now it takes the size an formats limits from the decoder's context.

This is possible since srcpad caps are generated after the internal
decoder is created.

The patch replaces gst_vaapi_decoder_get_surface_formats() with
gst_vaapi_decoder_get_suface_attributes().

From these attributes, formats are only used for VASurface memory
caps feature. For system memory caps feature, the old
gst_vaapi_plugin_get_allowed_srcpad_caps() is still used, since
i965 jpeg decoder cannot deliver mappable format for gstreamer.
And for the other caps features (dmabuf and texture upload) the
same static list are used.

This patch also adds DMABuf caps feature only if the context
supports that memory type. Nonetheless, we keep the pre-defined
formats since they are the subset of common derive formats formats
supported either by amd/gallium and both intel drivers, since,
when exporting the fd through vaAcquireBufferHandle()/
vaReleaseBufferHandle(), the formats of the derivable image cannot
be retriebable from the driver. Later we'll use the attribute
formats for the DMABuf feature too, when the code be ported to
vaExportSurfaceHandle().

Finally, the allowed srcpad caps are removed if the internal decoder
is destroyed, since context attribues will change.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/366>
2020-07-27 19:32:00 +02:00
Víctor Manuel Jáquez Leal
f04dd7f331 vaapidecode: reorder src caps template
Since negotiation depends on caps order, first is VA, then DMABuf,
later GLUploadTexture (deprecated) and finally raw.

Also, for decoders, the possible available color formats for DMABuf
is extended to all the possible VA color formats.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/366>
2020-07-27 19:01:54 +02:00
Marc Leeman
5b05e28a55 postproc: reconfigure after changing cropping values
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/365>
2020-07-24 17:09:19 +02:00
He Junyan
e911c1ff02 plugin: encode: Add static caps for template documentation.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/354>
2020-07-23 20:30:45 +02:00
He Junyan
f7e0303b9c plugin: encode: vp9: Use the dynamically built src template caps.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/354>
2020-07-23 20:30:45 +02:00
He Junyan
f3540c101c plugin: encode: vp8: Use the dynamically built src template caps.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/354>
2020-07-23 20:30:45 +02:00
He Junyan
adff28f8d2 plugin: encode: jpeg: Use the dynamically built src template caps.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/354>
2020-07-23 20:30:45 +02:00
He Junyan
f321c1b84d plugin: encode: mpeg2: Use the dynamically built src template caps.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/354>
2020-07-23 20:30:45 +02:00
He Junyan
95706691bd plugin: encode: h265: Use the dynamically built src template caps.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/354>
2020-07-23 20:30:45 +02:00
He Junyan
47fec28895 plugin: encode: h264: Use the dynamically built src template caps.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/354>
2020-07-23 20:30:45 +02:00
He Junyan
e260e9cd90 plugin: encode: Store the coded caps in type's init data.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/354>
2020-07-23 20:29:05 +02:00
He Junyan
53d5302cde plugin: util: add helper function build_template_coded_caps_by_codec()
Like build_template_raw_caps_by_codec(), this function can detect and
build the caps for specified codec based on the query of the profiles.
The result is coded caps such as video/x-h265, video/x-h264. The result
can be used as the template of encode's src or decode's sink.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/354>
2020-07-23 20:29:04 +02:00
He Junyan
617dba3869 plugins: utils: rename build_template_caps_by_codec.
Rename the function build_template_caps_by_codec() to the name of
build_template_raw_caps_by_codec(). It can be used to collect all
raw video formats for encode's sink and decode's src.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/354>
2020-07-23 20:27:00 +02:00
Víctor Manuel Jáquez Leal
e962069dbe vaapidecode: merge common profiles before setting size range
The synthetic profiles, such as H264 baseline, H265 intra, etc. are
added at the end of processing all available VA profiles. This
generated an non-optimal caps for negotiation, since the synthetic
profiles don't have frame size ranges.

This patch adds those possible synthetic profiles when the associated
profile is processed, with its frame size ranges.

Now allowed sink caps are simpler.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/363>
2020-07-23 19:29:19 +02:00
He Junyan
2da3314534 plugin: util: Add the missing DMA buffer input in template caps.
We pass the wrong parameter to gst_vaapi_build_caps_from_formats()
and lose the DMA feature in caps.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/362>
2020-07-21 22:07:49 +08:00
He Junyan
f82850c6d3 libs: decoder: H265: Add MAIN_12 profile supporting.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/359>
2020-07-20 16:26:32 +00:00
He Junyan
26afaab523 plugin: decode: correct ensure_allowed_sinkpad_caps's caps.
The decode allowed caps returned by ensure_allowed_sinkpad_caps()
contains all profiles of the whole VAAPI, like:
  image/jpeg, width=(int)[ 0, 1638 4 ], height=(int)[ 0, 16384 ];
  video/mpeg, mpegversion=(int)2, profile=(string){ simple, main },
  width=(int)[ 0, 2048 ], height=(int)[ 0, 2048 ]; video/x-h264,
  profile=(string){ main, high, constrained-baseline }, width=(int)[ 0,
  4096 ], height=(int)[ 0, 4096 ]; video/x-h264, profile=(string){
  constrained-high, progressive-high, baseline }; video/x-h265,
  profile=(string){ main, main-intra }, width=(int)[ 0, 8192 ],
  height=(int)[ 0, 8192 ]; video/x-vp8, width=(int)[ 0, 4096 ],
  height=(int)[ 0, 4096 ]; video/x-wmv, wmvversion=(int)3,
  format=(string)WVC1, profile=(string)advanced, width=(int)[ 0, 3840 ],
  height=(int)[ 0, 3840 ]; video/x-wmv, wmvversion=(int)3,
  profile=(string){ simple, main }, width=(int)[ 0, 3840 ],
  height=(int)[ 0, 3840 ]

Which is verbose and may have latent problems. It should only contains
the profiles belong to its codec type. For example, h265 should only
return:
  video/x-h265, profile=(string){ main, main-intra },
  width=(int)[ 0, 8192 ], height=(int)[ 0, 8192 ]

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/361>
2020-07-17 12:09:32 +08:00
Víctor Manuel Jáquez Leal
f1c44411f3 vaapidecodebin: don't force NV12 since P010_10LE is now possible
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/360>
2020-07-13 11:23:36 +02:00
Víctor Manuel Jáquez Leal
2a93455137 vaapidecode: Remove NO_SURFACE error handling
Since surfaces are not bounded to decoding context it makes no sense
to keep the surface semaphore. This patch removes the handling of
this error.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/353>
2020-07-09 18:13:48 +02:00
Víctor Manuel Jáquez Leal
a4c4314be6 Revert "vaapidecode: drop non-keyframe in reverse playback"
Since the number of surfaces are not bounded to decoder context,
this hack is no longer needed.

This reverts commit 19c0c8a973.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/353>
2020-07-09 16:06:23 +00:00
Víctor Manuel Jáquez Leal
d8f0e1b01f plugins: use VA allocator by default on raw caps
Instead of using dmabuf allocator in source pad, when raw video caps
are negotiated, it uses VA allocator as before, since it is stable
in more use cases, for example transcoding, and more backend drivers.

Dmabuf allocator is only used when dmabuf caps feature is negotiated.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/352>
2020-07-08 11:17:38 +00:00
Víctor Manuel Jáquez Leal
13d090b566 vaapisink: rank it as secondary
iHD doesn't provide a full implemention for rendering surfaces and
i965 has problems in wayland. And I suspect this path is followed
by other driver implementations.

This patch demotes the rank of vaapisink to secondary, so it will
not be autoplugged avoiding bad experience of users.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/336>
2020-07-08 10:48:40 +00:00
He Junyan
aa7370943d plugins: encode: h265: Add profile,level,tier to output caps.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/350>
2020-07-05 14:00:39 +00:00
Thibault Saunier
1c3facd215 docs: Mark parent classes as plugin API 2020-06-23 10:20:46 -04:00
He Junyan
72c4a161c0 plugins: pluginbase: Do not destroy display when _close()
When the element's state changes to NULL, it can still receive
queries, such as the image formats. The display is needed in such
queries but not well protected for MT safe.
For example, ensure_allowed_raw_caps() may still use the display
while it is disposed by gst_vaapi_plugin_base_close() because of
the state change.

We can keep the display until the element is destroyed. When the
state changes to NULL, and then changes to PAUSED again, the display
can be correctly set(if type changes), or leave untouched.

Fix: #260
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/343>
2020-06-11 18:32:58 +08:00
He Junyan
8486f82d98 libs: encoder: h265: Add support for MAIN 4:2:2 10 profile.
Using YUY2 as the input of the encoder can generate main 4:2:2 bit
streams and using Y210 as the input of the encoder can generate main
4:2:2 10 bit streams.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/334>
2020-06-05 08:42:35 +00:00
Thibault Saunier
8e400a5634 doc: Fix wrong link to GstVideoDirectionMethod 2020-06-03 18:50:10 -04:00
Thibault Saunier
31d85bfb65 Use gst_type_mark_as_plugin_api() for all non-element plugin types 2020-06-03 17:37:48 -04:00
Víctor Manuel Jáquez Leal
e68fece3e6 vaapidecoder: h264: remove baseline as constrained property
From now on always the baseline is going to be treated as constrained without
need of setting a property.

Since the property was added along the development cycle (1.17 / commit
866a9f06) and never released, we assume that it is safe to remove it.

Fixes: #252
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/328>
2020-05-21 13:10:57 +02:00
Víctor Manuel Jáquez Leal
6b2f83522f vaapivideobufferpool: fix meta overwrite
commit 7ac2a207 added a regression by erroneously assumed that
GstVaapiVideoMeta is actually a GstMeta, which is not.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/327>
2020-05-18 18:35:16 +02:00
Víctor Manuel Jáquez Leal
df06398917 vaapivideopool: Set pooled flag to added metas.
So this could hint filters how to use these metas.

Had to change the return value for texutre upload meta in order
to flag it.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/326>
2020-05-17 12:42:54 +02:00
He Junyan
3b118e2c45 plugin: use register_type to replace get_type for encode init.
xxx_register_type will detect the template sink caps and is needed
to be called at init time.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/315>
2020-05-16 19:58:15 +00:00
He Junyan
0b57e6e090 plugins: encode: Modify sink template of vp9 encode.
Use gst_vaapi_detect_codec_caps to get more precise template caps.
Also implement gst_vaapiencode_vp9_register_type, which should be
called at plugin register time.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/315>
2020-05-16 19:58:15 +00:00
He Junyan
6ffabe2139 plugins: encode: Modify sink template of vp8 encode.
Use gst_vaapi_detect_codec_caps to get more precise template caps.
Also implement gst_vaapiencode_vp8_register_type, which should be
called at plugin register time.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/315>
2020-05-16 19:58:15 +00:00
He Junyan
7459bee979 plugins: encode: Modify sink template of mpeg2 encode.
Use gst_vaapi_detect_codec_caps to get more precise template caps.
Also implement gst_vaapiencode_mpeg2_register_type, which should be
called at plugin register time.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/315>
2020-05-16 19:58:15 +00:00
He Junyan
5f5182f9ad plugins: encode: Modify sink template of h265 encode.
Use gst_vaapi_detect_codec_caps to get more precise template caps.
Also implement gst_vaapiencode_h265_register_type, which should be
called at plugin register time.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/315>
2020-05-16 19:58:15 +00:00
He Junyan
53a17f9c98 plugins: encode: Modify sink template of h264 encode.
Use gst_vaapi_detect_codec_caps to get more precise template caps.
Also implement gst_vaapiencode_h264_register_type, which should be
called at plugin register time.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/315>
2020-05-16 19:58:15 +00:00
He Junyan
d674d457ab plugins: encode: Modify sink template of jpeg encode.
Use gst_vaapi_detect_codec_caps to get more precise template caps.
Also implement gst_vaapiencode_jpeg_register_type, which should be
called at plugin register time.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/315>
2020-05-16 19:58:15 +00:00
He Junyan
3b3e987237 plugin: encode: add a helper macro to register encode type.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/315>
2020-05-16 19:58:15 +00:00
He Junyan
0e4c750918 plugins: util: Add a helper function to detect supported caps.
This helper function iterate all profiles and entrypoints belong
to the specified codec, query the VAConfigAttribRTFormat and list
all possible video formats.
This function is used by each codec to get the template sink caps
(for encode) or src caps(for decode) at register time, when just
all possible formats are listed and no need to be very accurate.
So there is no context created for the performance reason. Most
codecs just use YUV kinds of formats as the input/output, so we do
not include RGB kinds of formats. User can specified more formats
in extra_fmts(For example, jpeg may need BGRA) if needed.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/315>
2020-05-16 19:58:15 +00:00
He Junyan
3583a4b86c plugin: encode: extract the allowed caps maker as a helper function.
Extract all logic about making caps for encode's sink as a standalone
helper function. It can be reused.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/315>
2020-05-16 19:58:15 +00:00
He Junyan
f20bd8bfd1 libs: texture: Make texture a standard GstMiniObject.
We store GstVaapiTextureGLX and GstVaapiTextureEGL's private data in
the qdata of miniobject and avoid extending the base texture class.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/317>
2020-05-16 19:18:46 +02:00
Haihao Xiang
336c2b76d1 vaapipluginutil: Use GST_VAAPI_DISPLAY_TYPE_DRM for Mesa3D GBM
We may build this plugin with window system support but run it without
window system. Without this patch, the following pipeline will trigger a
segfault when running it without window system.

gst-launch-1.0 filesrc location=input.264 ! h264parse ! vaapih264dec ! fakesink

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/319>
2020-04-26 14:55:30 +08:00
He Junyan
e54671d4b3 libs,plugin: break surface-bufferproxy circular reference
The bufferproxy may reference the surface and the surface may also
reference the bufferproxy, producing a circular reference, which might
lead to serious resource leak problems.

Now make the relationship clearer, the bufferproxy's references is
transfered to surface, while bufferproxy just keeps the surface's
address without increasing its reference count.

The surface can be created through a bufferproxy like in
gst_vaapi_surface_new_with_dma_buf_handle(), and the surface might
get its bufferproxy via gst_vaapi_surface_get_dma_buf_handle(). In
both cases the surface holds a bufferproxy's reference.
2020-04-04 14:22:04 +02:00
He Junyan
ce3bf2c2ae plugin: bufferpool: use hashmap to cache dmabuf mem-surface
The old way of refer memory by bufferproxy is not a good one, since it
make the logic error prone.

Now it is established a map between surface-bufferproxy and its GstMemory,
caching the memory bound by a surface looked for the specified surface.
2020-04-04 14:21:57 +02:00
He Junyan
7701844813 plugin: bufferpool: Delete ACQUIRE_FLAG_NO_ALLOC flag.
Delete the GST_VAAPI_VIDEO_BUFFER_POOL_ACQUIRE_FLAG_NO_ALLOC flag.
In fact, no one is using that flag, and all vaapi buffers should
have GstVaapiVideoMeta.
2020-04-04 13:47:51 +02:00
U. Artie Eoff
4913d2b595 vaapipostproc: enable HDR10 tone mapping 2020-04-03 09:23:32 -07:00