Commit graph

3731 commits

Author SHA1 Message Date
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
5c51601cdf d3d11decoder: Use aligned resolution for staging texture
Not only any textures for decoder output view, any destination texture
which would be copied from decoder output texture need to be aligned too.
Otherwise driver sometimes crashed/hung (not sure why).
2020-03-09 23:44:12 +09:00
Seungha Yang
5074cecc82 d3d11colorconverter: Add support cropping
Vertex buffer will be updated if input texture resolution is different
from GstVideoInfo or when an user requests specific crop area.
2020-03-09 23:44:06 +09:00
Seungha Yang
c6c83ca493 d3d11bufferpool: Add padding space for semi-planar YUV formats
Resolution of NV12, P010, and P016 formats must be multiple of two.
Otherwise texture cannot be created. Instead of doing this alignment
per API consumer side, do this in buffer pool for simplicity.
2020-03-09 10:14:53 +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
b70a192220 d3d11h264dec: Make use of max_dpb_size passed by baseclass
Most likely this modification can save GPU memory.
2020-03-08 16:03: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
c6b8157dd6 codecs: Pass the max_dpb_size to new_segment virtual
On new_segment, the decoder is expected to negotiate. The decoder may want to
pre-allocate the needed buffers. Pass the max_dpb_size as this is needed to
determin how many buffers should be allocated.
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
be3de5a3db d3d11vp9dec: Add support for reverse playback
This commit moves parsing code for superframe and frame header into
handle_frame() method, and removes parse() implementation from vp9decoder
baseclass.

The combination of
- multiple frames are packed in a given input buffer (i.e., superframe)
- reverse playback
seems to be complicated and also it doesn't work as intended in some case
2020-03-03 12:15:33 +00:00
Matthew Read
3e2d86ea18 openslessink: Allow openslessink to handle 48kHz streams.
The most common audio sample rate in AV streams is 48kHz, and the most
common device output sample rate is 48kHz. This allows handing of 48kHz
input streams without resampling.

Remove comments about avoiding the use of 48kHz.
2020-03-03 08:59:01 +00:00
Heinrich Kruger
03cf2d42a5 decklink: Add support for 2K DCI video modes
Extend the video modes supported by the decklink plugin to include 2K
DCI video modes.
2020-03-03 08:05:56 +00:00
Heinrich Kruger
796fffa441 decklink: Update Decklink SDK to 10.11.4
This change is needed to support 2K DCI video modes.

Version 10.8 of the Decklink SDK supported DCI video modes for output
only. This updated version drops that restriction.

The current latest version of the Decklink SDK is 11.5, however
the gstreamer decklink plugin is not compatible with API changes
introduced in version 11 of the SDK. Therefore I have opted to upgrade
to the latest 10.x version instead.
2020-03-03 08:05:56 +00:00
Seungha Yang
9b7c20bfca d3d11videosink: Clarify the meaning of various width and height variables
* Remove redundant variables for width/height and par from GstD3D11Window.
  GstVideoInfo holds all the values.
* Don't need to pass par to gst_d3d11_window_prepare().
  It will be parsed from caps again
* Remove duplicated math

Fixing regression of the commit 9dada90108
2020-03-02 22:01:43 +09:00
Yeongjin Jeong
25e9ee10b0 d3d11vp9dec: Port to GstVP9SuperframeInfo
The vp9parser is now exposed new API for parsing superframe info.
2020-03-02 01:55:36 +09:00
Seungha Yang
9575d835ba d3d11decoder: Do not print warning message if retry count is in expected range
gst_d3d11_result() will print warning message when HRESULT != S_OK.
However, since the retry is trivial stuff, check hr == E_PENDING first
and do not warn it.
2020-02-28 13:21:04 +09: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
f2e322197e d3d11window: Set DXGI_PRESENT_ALLOW_TEARING only in fullscreen mode
The DXGI_PRESENT_ALLOW_TEARING flag might cause unexpected tearing
side effect. Setting it in fullscreen mode only seems to be
the correct usage as in the Microsoft's direct3d examples.
2020-02-26 13:18:16 +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
Haihao Xiang
acc14225c9 msdk: libva: Don't set the hint if MFX_VERSION is lower than 1025
MFX_MEMTYPE_VIDEO_MEMORY_ENCODER_TARGET is defined since MFX_VERSION
1025.
2020-02-24 01:26:58 +00:00
Seungha Yang
fbe7917a94 d3d11decoder: Add padding space on decoder output view when it's not aligned
Most H/W decoders have required alignment and dxva is also the case.
2020-02-20 17:32:42 +09: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
13586bc77a d3d11device: Fix typo
s/vender/vendor
2020-02-18 11:58:45 +00:00
Seungha Yang
8ead80eecd d3d11device: Adjust debug level for when _new() fails
gst_d3d11_device_new might be used to enumerate device.
2020-02-18 11:58:45 +00:00
Seungha Yang
36fb790243 d3d11videosink: Ensure upload staging texture to fallback render texture
gst_video_frame_copy will copy input frame to stating texture
of fallback frame. Then, we need to map fallback texture with GST_MAP_D3D11
flag to upload the staging texture to render texture. Otherwise
the render texture wouldn't be updated.
2020-02-16 21:29:08 +09:00
Seungha Yang
9bf4746e2f d3d11decoder: Fix copying decoder view to staging
Source texture (decoder view) might be larger than destination (staging) texture.
In that case, D3D11_BOX structure should be passed to CopySubresourceRegion method
in order to specify the exact target area.
2020-02-13 21:25:15 +09:00
Seungha Yang
f6cdb91f55 d3d11window: Fix for broken dirty rect drawing on Windows 7
DXGI_SWAP_EFFECT_DISCARD cannot be used with dirty rect drawing feature
of IDXGISwapChain1::Present().
Note that IDXGISwapChain1 interface is available on Platform Update for Windows 7
and DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL is also the case.
2020-02-12 22:38:53 +09:00
Seungha Yang
4383b387b7 d3d11window: Fix for dxva decoder output view rendering
Use resolution specified in caps for input_rect instead of
passed width and height value. The width and height might be modified
ones by d3d11videosink, then frame resolution might be different.
2020-02-12 12:34:58 +00:00
Seungha Yang
a39a5bf131 d3d11decoder: Refactor decoding process
* Move decoding process to handle_frame
* Remove GstVideoDecoder::parse implementation
* Clarify flush/drain/finish usage

In forward playback case, have_frame() call will be followed by
handle_frame() but reverse playback is not the case.
To ensure GstVideoCodecFrame, the decoding process should be placed inside
of handle_frame(), instead of parse().

Since we don't support alignment=nal, the parse() implementation is not worth.
In order to fix broken reverse playback, let's remove the parse()
implementation and revisit it when adding alignment=nal support.
2020-02-12 12:34:58 +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
6da90b59f4 d3d11videosink: Remove max size condition from pool
Actually our buffer pool size and the number of backbuffer are
independent. In case of reverse playback, upstream might request
a lot of buffers (up to GOP size).
2020-02-12 12:34:58 +00:00
Nirbheek Chauhan
266dc41596 nvcodec: Mark class data as may-be-leaked to quiet the leaks tracer
The class data with the caps in it will be leaked if the element is
registered but never instantiated. There is no way around this. Mark
the caps as such so that the leaks tracer does not warn about it.

This is the same as pad template caps getting leaked, which are also
marked as may-be-leaked. These objects are initialized exactly once,
and are 'global' data.
2020-02-12 00:00:51 +05:30
Haihao Xiang
50ae5061f9 msdkvp9enc: output raw vp9 stream instead of IVF stream
video/x-vp9 is required in the src pad, however the output includes a
IVF header, which makes the pipeline below doesn't work

  gst-launch-1.0 videotestsrc ! msdkvp9enc ! msdkvp9dec ! fakesink

Since mfx 1.26, the VP9 encoder supports bitstream without IVF header,
so in this patch, the mfx version is checked and msdkvp9enc is enabled
only if mfx 1.26+ is available
2020-02-10 06:46:28 +00:00
Jan Schmidt
6c1e5ab311 androidmedia: Support float i-frame-interval
Android 25 added support for i-frame-interval to be a floating
point value. Store the property as a float and use the newer
version when it's available.
2020-02-09 02:19:12 +11:00
Jan Schmidt
29e3d09014 androidmedia: Allow dynamic bitrate changes on Android >= 19
Android 19 added an API for dynamically changing the bitrate in a running
codec.

Also make it so that even when not update-able at runtime, parameters will at least
be stored so that they take effect the next the codec is restarted.
2020-02-09 02:19:12 +11:00
Jan Schmidt
1b8bf1be01 androidmedia: Handle force-keyunit requests
Use API from Android 19 to request a keyframe from the MediaCodec
when indicated by the base class.
2020-02-09 02:19:12 +11:00
Jan Schmidt
cfe318ea03 androidmedia: Permit Codec surface to be NULL
The AMC encoder wrapper doesn't support input surfaces yet,
and passes NULL when configuring the underlying codec.

This was broken in commit 7fcf3e
Fixes https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/issues/1102
2020-02-09 02:19:12 +11:00
Nirbheek Chauhan
3ca87d9988 nvcodec: Fix crash in decoder on 32-bit Windows
Same fix as 1a7ea45ffd, but I didn't
test the decoder so I missed that the function pointers here weren't
using the correct calling convention too.
2020-02-06 13:39:52 +00:00
Seungha Yang
478fb29974 d3d11window: Clear cached buffer per new caps
d3d11window holds one buffer to redraw client area per resize event.

When the input format is being changed, this buffer should be cleared
to avoid mismatch beween newly configured shader/videoprocessor and
the format of previously cached buffer.
2020-02-06 00:46:46 +09:00
Sebastian Dröge
5b8ff98f96 nvdec: Don't leak template caps when registering elements with old NVIDIA driver 2020-02-05 09:49:20 +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
2f32f30b62 d3d11memory: Add a method to specify 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
69f7f958a0 d3d11decoder: Create decoder output view whenever it's required
Whatever the reason, buffer in pool might be freed then we need to
configure decoder output views again.
2020-02-05 00:52:48 +00:00
Seungha Yang
567575e33d d3d11decoder: Need to zero initilized for g_once
A vairable to be used for g_once, it should be zero initialized
2020-02-05 00:52:48 +00:00
Seungha Yang
8ff667e463 d3d11allocator: Work as if buffer pool when running on texture array mode
Because the size of texture array cannot be updated dynamically,
allocator should block the allocation request. This cannot be
done at buffer pool side if this d3d11 memory is shared among
multiple buffer objects. Note that setting NO_SHARE flag to
d3d11 memory is very inefficient. It would cause most likey
copy of the d3d11 texture.
2020-02-05 00:52:48 +00:00