Commit graph

4218 commits

Author SHA1 Message Date
He Junyan
f5c7ada98e va: Destroy picture unreleased buffers when finalize.
The current way of GstVaDecodePicture's finalize will leak some
resource such as parameter buffers and slice data.
The current way deliberately leaves these resource releasing logic
to va decoder related function and trigger a warning if we free the
GstVaDecodePicture without releasing these resources.
But in practice, sometimes, you do not have the chance to release
these resource before picture is freed. For example, H264/Mpeg2
support multi slice NALs/Packets for one frame. It is possible that
we already succeed to parse and generate the first several slices
data by _decode_slice(), but then we get a wrong slice NAL/packet
and fail to parse it. We decide to discard the whole frame in the
decoder's base class, it just free the current picture and does not
trigger sub class's function again. In this kind of cases, we do
not have the chance to cleanup the resource, and the resource will
be leaked.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1841>
2020-11-30 13:03:11 +00:00
Seungha Yang
3e35a6f03f d3d11h264dec: Reconfigure decoder object on DPB size change
Even if resolution and/or bitdepth is not updated, required
DPB size can be changed per SPS update and it could be even
larger than previously configured size of DPB. If so, we need
to reconfigure DPB d3d11 texture pool again.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1839>
2020-11-26 08:52:49 +00:00
Víctor Manuel Jáquez Leal
8e6ad8267f va: allocator: add a memory pool object helper
Since both allocators use a memory pool, with its mutex and cond, this patch
refactors it into a single internal object, implementing a generic GstMemory
pool.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1815>
2020-11-24 13:00:00 +01:00
Víctor Manuel Jáquez Leal
8c128ead6d va: pool, allocator: honor GST_BUFFER_POOL_ACQUIRE_FLAG_DONTWAIT
In order to honor GST_BUFFER_POOL_ACQUIRE_FLAG_DONTWAIT in VA pool, allocators'
wait_for_memory() has to be decoupled from their prepare_buffer() so it could be
called in pools' acquire_buffer() if the flag is not set.

wait_for_memory() functions are blocking so the received memories are assigned
to the fist requested buffer, if multithreaded calls. For this a new mutex were
added.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1815>
2020-11-24 12:44:24 +01:00
Víctor Manuel Jáquez Leal
8fc50891b1 va: allocator: broadcast when flushing
This patch handles when the bufferpool request a new buffer while
flushing.

Also fixes the usage of g_cond_wait(), which demands to be used
inside a loop to avoid spurious wakeups.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1815>
2020-11-24 12:44:24 +01:00
Víctor Manuel Jáquez Leal
72ab56c376 va: allocator: free allocator when a mem is held
An application, using for example appsink, can hold buffers from any
va allocator after setting the pipeline to NULL. We need to destroy
the allocator when that memory is unrefed.

This patch juggles a bit with the allocator reference count in
memories in order to achieve this:

1. When memory is created no alloc ref is modified
2. When memory is released, alloc ref is decreased
3. When memory is reassiged to a buffer, alloc ref is increased
4. When memory is flushed, alloc ref is increased becase it is going
   to be decreased in gst_memory_unref()

Also this patch moves the deallocation of member variables to
finalize() rather than dispose()

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1815>
2020-11-24 12:44:24 +01:00
Víctor Manuel Jáquez Leal
ba4442a29d va: allocator: dmabuf: initialize cond
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1815>
2020-11-24 12:44:24 +01:00
Julian Bouzas
64f96facca nvcodec: Assume 25fps if framerate is invalid when calculating latency
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1826>
2020-11-23 18:27:43 +00:00
Seungha Yang
d1e7290109 d3d11: Add support for packed 4:2:2 and 4:4:4 10bits formats
Add support for Y210 and Y410 formats which are commonly used format
for en/decoders on Windows. Note that those formats cannot be used for
render target (output) of shader.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1821>
2020-11-20 02:28:54 +09:00
Olivier Crête
f83039531e d3d11h264dec: Accept constrained-high and progressive-high profiles
They're just subsets of the high profile.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1634>
2020-11-18 15:47:34 -05:00
Olivier Crête
e17e88e033 msdkh264dec: Accept constrained-high and progressive-high profiles
They're just subsets of the high profile.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1634>
2020-11-18 15:46:52 -05:00
Olivier Crête
e53da20938 nvdec: Accept progressive-high and contrained-high profiles
They're subsets of the high profiles with no interlacing and
no B-frames for constrained

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1634>
2020-11-18 15:46:52 -05:00
Seungha Yang
483768cfa7 va: h264dec: Add support for interlaced stream
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1812>
2020-11-17 20:20:32 +09:00
Víctor Manuel Jáquez Leal
eadda27dde va: h264dec: implement gst_va_h264_dec_new_field_picture()
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1812>
2020-11-17 19:57:35 +09:00
Seungha Yang
215835b201 va: h264dec: Fix picture_height_in_mbs_minus1
Fix for interlaced stream (when sps->frame_mbs_only_flag is equal to one)

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1812>
2020-11-17 19:57:35 +09:00
Víctor Manuel Jáquez Leal
a9ae00a2c1 va: h264dec: admit baseline if stream obeys A.2
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1812>
2020-11-17 19:57:35 +09:00
Seungha Yang
88ebe8031a codecs: h264decoder: Add more option arguments for reference picture getter
In case that "pic_order_cnt_type" is equal to zero, ref picture
list for B slice should not include non-existing picture
as per spec 8.2.4.2.3. And, the second field is not needed
for the process of frame picture reference list construction
since it needs to be frame unit, not field picture in that case.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1812>
2020-11-17 19:44:04 +09:00
He Junyan
1794a44577 va: pool: Check the force_videometa for all memory types.
force_videometa should mean that the buffer must use video meta to
map correctly. When the stride or the offset of the alloc_info is
different from the src caps, the downstream must use video meta.
So this flag should not link with the RAW caps only. All kinds of
caps(memory:VAMemory, memory:DMABuf) should have this flag.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1711>
2020-11-17 01:22:02 +08:00
He Junyan
7a8ac90010 va: basedec: Improve the decide_allocation().
In decide_allocation(), we now just use the other_pool for frames
copy when the src caps is raw. This can make the logic a little
clear. There is no need for us to check the alignment and video
meta again.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1711>
2020-11-17 01:21:54 +08:00
He Junyan
672a30d0de va: basedec: fallback to system memory if downstream caps is any.
When the downstream element reports an ANY caps, and it also fails to
support VideoMeta, we should fallback to the system memory.
Note: the basetransform kind elements never return valid allocation
query before set_caps(). So, if a basetransform return an ANY sink
caps, we always fallback to system memory for it.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1711>
2020-11-17 01:21:45 +08:00
Seungha Yang
d3d2af6c84 vah264dec: Fix for long term reference picture signalling
Allocate a GArray which is used to fill
VAPictureParameterBufferH264.ReferenceFrames (called per frame),
instead of alloc/free per frame.
Also this commit is to fix the condition where long-term reference
picture is needed for VAPictureParameterBufferH264.ReferenceFrames
entry.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1813>
2020-11-16 15:06:33 +00:00
Seungha Yang
a516c79ac9 d3d11window: Prefer full color range for display target colorspace
We don't need to preserve input color range for transformed target
color space. Also some GPUs doesn't seem to be happy with 16-235
color range for RGB color space.
Also, since our default display target color space is
DXGI_COLOR_SPACE_RGB_FULL_G22_NONE_P709, choosing full color range
would make more sense.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1814>
2020-11-16 20:48:35 +09:00
Víctor Manuel Jáquez Leal
c118ae11ab va: allocator: dmabuf: log unknown surface format
It is possible that surface format is not assigned, keeping its default
GStreamer value: unknown, but gst_video_format_to_string() doesn't print
unknown format, so this patch does it manually.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1811>
2020-11-15 09:52:51 +01:00
Víctor Manuel Jáquez Leal
a1e8cb76e7 va: allocator: dmabuf: destroy VASurface if no pooled buffer
When gst_va_dmabuf_allocator_setup_buffer_full() receives info (not NULL) it is
supposed that this buffer is not part of the allocator pool, so it has to be
de-allocated as soon it is freed.

This patch sets the destroy notify of the assigned GstVaBufferSurface if info is
not NULL.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1811>
2020-11-15 09:52:01 +01:00
Seungha Yang
9011a58491 vah264dec: Allow missing reference picture
baseclass might provide reference picture list with null picture.
Ensure picture before filling picture information.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1809>
2020-11-14 16:17:18 +00: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
7a53d7a4aa codecs: h264decoder: Store reference picture type using enum value
Managing reference picture type by using two variables
(ref and long_term) seems to be redundant and that can be
represented by using a single enum value.

This is to sync this implementation with gstreamer-vaapi so that
make comparison between this and gstreamer-vaapi easier and also
in order to minimize the change required for subclass to be able
to support interlaced.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1534>
2020-11-13 15:25:42 +00:00
Seungha Yang
977c3276d4 nvcodec: Fix various typo
Not sure where the DECOCER came from

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1803>
2020-11-12 13:10:13 +00:00
Víctor Manuel Jáquez Leal
5876f232ee va: comments to explain code
There are a couple part where code seems, at least to me, a bit oscure or
confusing. So let's better add an explanation.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1802>
2020-11-12 13:33:26 +01:00
Sanchayan Maity
406cd3bdef gsta2dpsink: Fix GstPad leak
The sinkpad returned by a call to gst_element_get_static_pad needs to be
unrefed.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1621>
2020-11-11 22:19:33 +05:30
Arun Raghavan
8aa6db2c8d bluez: a2dpsink: Add support for LDAC to a2dpsink
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1621>
2020-11-11 22:19:33 +05:30
Arun Raghavan
ef3085c743 bluez: avdtpsink: Add support for LDAC to avdtpsink
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1621>
2020-11-11 22:19:33 +05:30
Seungha Yang
5578e76e60 nvcodec: Add VP9 stateless decoder element
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1738>
2020-11-10 14:39:40 +00:00
Seungha Yang
71564f471d nvcodec: nvdecoder: Move to refcount based GstNvDecoderFrame
This refcount based way would be helpful for sharing nvdec frame among
multiple codec pictures and later zero-copy use case.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1738>
2020-11-10 14:39:40 +00:00
Seungha Yang
2a04fe5403 nvcodec: nvdecoder: Get rid of G_GNUC_INTERNAL
default is visibility=hidden. Don't need to use G_GNUC_INTERNAL
for new code therefore.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1738>
2020-11-10 14:39:40 +00:00
Seungha Yang
36ed24ac05 nvcodec: Add VP8 stateless decoder element
Like other nvcodec stateless decoders, the rank of this new nvvp8sldec
element will be secondary for now.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1738>
2020-11-10 14:39:40 +00:00
Seungha Yang
7c047da4b0 nvcodec: nvsldec: Fix typo in debug message
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1738>
2020-11-10 14:39:40 +00:00
Julian Bouzas
168b5f6536 nvcodec: leave g_once_init when all quarks are initialized
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1782>
2020-11-09 15:03:04 +00:00
Seungha Yang
0551d68bbb d3d11h264dec: Fix for MbaffFrameFlag and FrameNumList
As per spec 7.4.3 Slice header semantics, the flag value is derived as
MbaffFrameFlag = (mb_adaptive_frame_field_flag && !field_pic_flag)
and DXVA uses the value.
Regarding FrameNumList, in case of long-term ref, FrameNumList[i]
value should be long_term_frame_idx not long_term_pic_num.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1780>
2020-11-09 03:07:06 +09:00
Jason Pereira
cba368785b decklink: correct framerate 2KDCI 23.98
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1771>
2020-11-05 14:28:28 +00:00
Nicolas Dufresne
2950c76c8f va: Add HEVC decoding support
This add HEVC decoding support into the new VA plugin. This implementation has
been tested using the ITU comformance test (through fluster). It fails all
MAIN10 tests, as this is not implemented yet along with the following:

CONFWIN_A_Sony_1 (looks fine, but md5sum is incorrect)
PICSIZE_A_Bossen_1 (height too high)
PICSIZE_B_Bossen_1 (same)
VPSSPSPPS_A_MainConcept_1 (parser issue)

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1714>
2020-11-04 17:53:23 +00:00
Seungha Yang
2f5257fd69 Revert "d3d11decoder: Use D3D11/DXGI standard colorimetry"
This reverts commit a52fc6deed.

The change breaks H264/HEVC conformance bitstream tests

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1753>
2020-11-02 17:58:23 +00:00
Seungha Yang
a52fc6deed d3d11decoder: Use D3D11/DXGI standard colorimetry
D3D11/DXGI supports smaller set of colorimetry than all possible
combination. This restriction would make more streams convertible
by using ID3D11VideoProcessor

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1743>
2020-11-02 18:48:58 +09:00
Seungha Yang
a3a7e21f87 d3d11window: Use ID3D11VideoProcessor only if device supports corresponding conversion
... and drop support for ID3D11VideoProcessor if device doesn't
support ID3D11VideoContext1 interface and therefore we cannot
query conversion supportability.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1743>
2020-11-02 18:48:54 +09: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
Sebastian Dröge
f71493a57c decklink: Remove \n from debug output
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1721>
2020-10-30 16:23:31 +02:00
Sebastian Dröge
60b7bd23a8 decklink: Correctly indent everything
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1721>
2020-10-30 16:23:31 +02:00
Sebastian Dröge
56b2130300 decklink: Add a default profile id
This causes no changes to the profile but keeps the existing settings.
The profile can also be changed from e.g. the card's configuration
application and in that case probably should be left alone.

The default is the new value as it keeps the profile setting as it is,
which is consistent with the previous behaviour in 1.18.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1721>
2020-10-30 16:23:31 +02:00