Commit graph

38 commits

Author SHA1 Message Date
Seungha Yang
8794f4b713 d3d11: Documentation update
* Update class metadata
  * for wrapper bin elements to be distinguishable from internal element.
  * D3D11 -> Direct3D11 for consistency
* Add missing Since mark everywhere
* Update plugin cache

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2029>
2021-02-23 03:34:11 +09:00
Seungha Yang
5006d91208 d3d11decoder: Take account of min buffers of downstream buffer pool
Since our decoder DPB texture pool cannot be grown once it's
configured, we should pre-allocate sufficient number of textures
for zero-copy playback (but not too many).
The "min buffers" allocation query parameter can be a hint for
the number of required textures in addition to DPB size.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2017>
2021-02-15 17:24:06 +09:00
Seungha Yang
e8df47b022 d3d11h265dec: Add support for interlaced stream
Note that we have no D3D11 deinterlace element yet.

If downstream is not support format:Interlaced caps feature including all
D3D11 the other elements, aspect-ratio will be adjusted as an
alternative approach.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2008>
2021-02-09 16:19:41 +00:00
Seungha Yang
6bdf09d252 d3d11decoder: Fix deadlock when DPB texture pool is full
Unlike other stateless decoder implementations (e.g., VA),
our DPB pool cannot be grown since we are using
texture array (pre-allocated, fixed-size d3d11 texture pool).
So, if there's no more available texture to use,
there's no way other than copying it to downstream's
d3d11 buffer pool. Otherwise deadlock will happen.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2003>
2021-02-03 20:46:22 +00:00
Seungha Yang
0f7af4b143 d3d11: Move core methods to gst-libs
Move d3d11 device, memory, buffer pool and minimal method
to gst-libs so that other plugins can access d3d11 resource.
Since Direct3D is primary graphics API on Windows, we need
this infrastructure for various plugins can share GPU resource
without downloading GPU memory.
Note that this implementation is public only for -bad scope
for now.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/464>
2021-01-13 15:01:20 +00:00
Seungha Yang
59a1897c39 d3d11: Privatize d3d11memory implementation
Hide most of symbols of GstD3D11Memory object.
GstD3D11Memory is one of primary resource for imcoming d3d11 library
and it's expected to be a extensible feature.
Hiding implementation detail would be helpful for later use case.

Summary of this commit:
* Now all native Direct3D11 resources are private of GstD3D11Memory.
  To access native resources, getter methods need to be used
  or generic map (e.g., gst_memory_map) API should be called
  apart from some exceptional case such as d3d11decoder case.
* Various helper methods are added for GstBuffer related operations
  and in order to remove duplicated code.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1892>
2020-12-21 01:02:37 +09:00
Seungha Yang
f9a0efe3ed d3d11h264dec: Add support for interlaced stream
Add support for interlaced stream.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1534>
2020-11-13 15:25:43 +00:00
Seungha Yang
337cb883fa d3d11h{264,265}dec: Submit picture level parameters only once
Submit PICTURE_PARAMETERS and INVERSE_QUANTIZATION_MATRIX
buffers only once per picture. Multiple submission is redundant.
Also this modification would fix broken hevc decoding with
dependent slice.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1749>
2020-11-01 14:29:42 +00:00
Seungha Yang
0bb73ec800 d3d11decoder: Get rid of framerate field from pad template
Framerate is optional value and we don't have any framerate
related restriction for those elements. This commit is to fix
negotiation failure when upstream doesn't set framerate on caps.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1747>
2020-11-01 00:51:46 +09:00
Seungha Yang
9a796482dc d3d11decoder: Allow 10bits only profiles
HEVC_VLD_Main10 and VP9_VLD_10bit_Profile2 might not support
8bit format (i.e., NV12) depending on GPU vendor.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1742>
2020-10-31 00:37:48 +09:00
Nicolas Dufresne
f22fc190e7 h265decoder: Add support for l0/l1
Add support for reference list needed for VA-API and some V4L2 decoders.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1713>
2020-10-21 09:05:57 -04:00
Nicolas Dufresne
f330b5ae62 h265decoder: Sync with the H264 implementation
This ensures that we get the last reference to picture being outputed,
avoiding GstBuffer structure copies and simplifying the buffer management.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1713>
2020-10-21 09:05:57 -04:00
Seungha Yang
f615677051 d3d11decoder: Directly access ID3D11VideoDecoderOutputView for decoding
Decoder output view is stored in GstD3D11Memory object instead of
wrapper struct now. So qdata is no more required.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1712>
2020-10-20 17:56:57 +09:00
Seungha Yang
bb5ef4fd5b d3d11decoder: Cleanup code
* Don't need to set pts/dts/duration on output buffer of frame.
  it's handled by baseclass
* Remove meaningless debug output

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1567>
2020-09-15 15:54:53 +00:00
Seungha Yang
117f593cff d3d11h265dec: Fix possible invalid memory access
The number of element to copy should be num_tile_columns_minus1
and num_tile_rows_minus1.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1374>
2020-06-25 13:58:57 +00:00
Seungha Yang
bc99ea1e30 d3d11decoder: Disable zero-copy for blacklisted device
Should enable it for verified devices. For now, Xbox is blacklisted

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1339>
2020-06-16 10:49:02 +00:00
Seungha Yang
2fe473fa50 d3d11decoder: Fix wrong return type from output_picture vfunc
Return type should be GstFlowReturn, not gboolean

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1213>
2020-04-23 22:06:24 +00:00
Seungha Yang
5965b6ef85 d3d11decoder: Add helper methods for negotiation and decide_allocation
The implementation for all codecs is almost the same.
No need to duplicate code.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1079>
2020-04-22 23:20:44 +00:00
Seungha Yang
3208e3d371 Revert "d3d11decoder: Check decoder status report"
This reverts commit 418e6991c1.

Not all drivers seem to be friendly to this API.
Revert to avoid incomprehensible crash with Nvidia.
2020-03-28 12:12:03 +00:00
Seungha Yang
58a4c33a0e d3d11vp9dec: Add support for internal frame resizing
VP9 codec allows resizing reference frame by spec. Handling this case
is a bit tricky especially when the resizing happens on non-keyframe,
because pre-allocated decoder textures (i.e., dpb) have negotiated
resolution and to change resolution meanwhile decoding on non-keyframe,
each texture might need to be re-created, copied to new dpb somehow,
and re-negotiated with downstream.

Due to the complicated requirement of negotiation driven
resizing handling, this commit adds shader into d3d11decoder object
to resize only corresponding frames. Note that if the resolution change
is detected on keyframe, decoder will re-negotiate with downstream.
2020-03-09 23:44:12 +09:00
Seungha Yang
c10b5f06a5 d3d11decoder: Set GstVideoAlignment to downstream d3d11 buffer pool
To copy decoder output texture to another d3d11 texture, the downstream
texture needs to be aligned too.
2020-03-09 23:44:12 +09:00
Seungha Yang
5609d8751c h265decoder: Pass max_dpb_size to new_sequence vfunc
same as we are doing in h264decoder
2020-03-08 16:11:35 +09:00
Seungha Yang
7c153b6e93 d3d11h265dec: Fix scaling list parsing
Scaling list can be signalled via sps or pps. Decoder should check
both of them.
2020-03-07 12:57:38 +09:00
Seungha Yang
cfb6283613 d3d11h265dec: Properly signal the ucNumDeltaPocsOfRefRpsIdx
ucNumDeltaPocsOfRefRpsIdx should be the NumDeltaPocs[RefRpsIdx].
2020-03-07 12:20:03 +09:00
Seungha Yang
83b056cb77 h265decoder: Port to nal type classification macro
... and remove namespaceless macro methods from baseclass
2020-03-05 23:22:39 +09:00
Nicolas Dufresne
020ee62c59 d3d11: Use gst_video_decoder_get_frame()
Now that the system_frame_number is saved on the pictures we can use
gst_video_decoder_get_frame() helper instead of getting the full list
and looping over it.
2020-03-05 03:06:16 +00:00
Nicolas Dufresne
00d04784d3 Move CODEC base classes into it's own library
This introduce a library which contains a set of base classes which
handles the parsing and the state tracking for the purpose of decoding
different CODECs. Currently H264, H265 and VP9 are supported. These
bases classes are used to decode with low level decoding API like DXVA,
NVDEC, VDPAU, VAAPI and V4L2 State Less decoders. The new library is
named gstreamer-codecs-1.0 / libgstcodecs.
2020-03-05 03:06:16 +00:00
Seungha Yang
418e6991c1 d3d11decoder: Check decoder status report
... and if h/w decoder reports error, increase error count.
2020-02-28 13:21:00 +09:00
Seungha Yang
4643dc1c12 d3d11decoder: Ensure the written bitstream buffer size is 128 bytes aligned
DXVA spec is saying that the size of bitstream buffer provided by hardware decoder
should be 128 bytes aligned. And also the host software decoder should
align the size of written buffer to 128 bytes. That means if the slice
(or frame in case of VP9) size is not aligned with 128 bytes,
the rest of non 128 bytes aligned memory should be zero-padded.

In addition to aligning implementation, some variables are renamed
to be more intuitive by this commit.
2020-02-24 14:46:27 +00:00
Seungha Yang
fe72bf6053 d3d11decoder: Register elements per GPU device with capability check
This implementation is similar to what we've done for nvcodec plugin.
Since supported resolution, profiles, and formats are device dependent ones,
single template caps cannot represent them, so this modification
will help autoplugging and fallback.

Note that the legacy gpu list and list of resolution to query were
taken from chromium's code.
2020-02-18 11:58:45 +00:00
Seungha Yang
3e78afbe0a d3d11decoder: Move handle_frame implementation to baseclass
... and remove unused start, stop method from subclass.

Current implementation does not require subclass specific behavior
for the handle_frame() method.
2020-02-12 12:34:58 +00:00
Seungha Yang
371b181292 d3d11decoder: Use consistent resolution between output caps and video meta
h264/h265 decoded buffer might have crop area then we need to
adjust video meta based on the padding space
2020-02-05 00:52:48 +00:00
Seungha Yang
f852ce01e4 d3d11decoder: Add support for zero-copy playback
When downstream support d3d11 memory with forward playback case,
expose decoder output view memory objects without copying.
2020-02-05 00:52:48 +00:00
Seungha Yang
96f0f4b613 d3d11memory: Always use native DXGI format if device support it
Use consistent memory layout between dxva and other shader use case.
For example, use DXGI_FORMAT_NV12 texture format instead of
two textures with DXGI_FORMAT_R8_UNORM and DXGI_FORMAT_R8G8_UNORM.
2020-01-13 01:58:08 +00:00
Seungha Yang
9ee40679b5 Revert "d3d11: Add support for D3D11_USAGE_DYNAMIC"
This reverts commit ddd13fc7c0

Dynamic usage can reduce the number of copy per frame but make
things complicated and the benefit seems to not significant.
Also since we don't provide _map() method for the dynamic usage,
application cannot read buffers which make "last-sample" property
unusable in case of d3d11videosink.
2020-01-13 01:58:08 +00:00
Seungha Yang
e188893963 d3d11: Don't register decoders if unavailable
DXVA requires a hardware interface but may not be available,
such as in the case of VMs or when the GPU vendor does not provide a decoder interface.
2020-01-11 17:42:04 +09:00
Seungha Yang
43a8eb9e92 d3d11decoder: Fix build on non-desktop target
Although the target platform of D3D11 decoding API are both desktop and UWP app,
DXVA header is blocked by "WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)"
which is meaning that that's only for desktop app.
To workaround this inconsistent annoyingness, we need to define WINAPI_PARTITION_DESKTOP
regardless of target WinAPI partition.
2020-01-06 18:45:56 +09:00
Seungha Yang
a139c8c7e8 d3d11: Add h265 decoder element
Some DPB management implementation is taken from gstreamer-vaapi
2019-12-31 02:13:48 +00:00