Commit graph

27092 commits

Author SHA1 Message Date
Staz M
180ab8377f decklink: Fixed decklinkvideosink auto format detection
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1994>
2021-01-29 16:49:07 +00:00
Seungha Yang
fba807bead nvh264sldec: Add support for output-delay to improve throughput performance
NVDEC API support delaying getting decoded output, and recommended
delay by API document is 4 frames. In case that throughput is
more critical factor than latency, we can prefer delayed output
as recommended by NVIDIA.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1925>
2021-01-29 16:22:28 +00:00
Seungha Yang
86e312c1b1 codecs: h264decoder: Add support for output delay
Some decoding APIs support delayed output or a command for decoding
a frame doesn't need to be sequential to corresponding command for
getting decoded frame. For instance, subclass might be able to
request decoding for multiple frames and then get for one (oldest)
decoded frame or so.
If aforementioned case is supported by specific decoding API,
delayed output might show better throughput performance.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1925>
2021-01-29 16:22:28 +00:00
Arun Raghavan
a417a761fd ldac: Use pkg-config instead of raw lib/header search
The ldacBT library includes pkg-config files for the standard and ABR
libraries, so let's just use that instead of doing a header/library
search.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1990>
2021-01-27 17:16:57 -05:00
Seungha Yang
66eed8a61d d3d11videosink: Don't limit max buffers of buffer pool
In some case, especially reverse playback, we would need more than
two buffers.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1989>
2021-01-27 20:08:51 +00:00
Seungha Yang
0b0bf1b0bf d3d11: Suppress some warning debug messages
* Don't warn for live object, since ID3D11Debug itself seems to be
  holding refcount of ID3D11Device at the moment we called
  ID3D11Debug::ReportLiveDeviceObjects(). It would report live object
  always
* Device might not be able to support some formats (e.g., P010)
  especially in case of WARP device. We don't need to warn about that.
* gst_d3d11_device_new() can be used for device enumeration. Don't warn
  even if we cannot create D3D11 device with given adapter index therefore.
* Don't warn for HLSL compiler warning. It's just noise and
  should not be critical thing at all

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1986>
2021-01-27 04:46:42 +09:00
Seungha Yang
657370a91c examples: Add d3d11videosink examples for shared-texture use cases
Add two examples to demonstrate "draw-on-shared-texture" use cases.

d3d11videosink will draw application's own texture without copy
by using:
- Enable "draw-on-shared-texture" property
- make use of "begin-draw" and "draw" signals

And then, application will render the shared application's texture
to swapchain's backbuffer by using
1) Direct3D11 APIs
2) Or, Direct3D9Ex + interop APIs

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1873>
2021-01-26 18:14:37 +00:00
Seungha Yang
60e223f4fd d3d11videosink: Add support for drawing on application's own texture
Add a way to support drawing on application's texture instead of
usual window handle.
To make use of this new feature, application should follow below step.
1) Enable this feature by using "draw-on-shared-texture" property
2) Watch "begin-draw" signal
3) On "begin-draw" signal handler, application can request drawing
   by using "draw" signal action. Note that "draw" signal action
   should be happen before "begin-draw" signal handler is returned

NOTE 1) For texture sharing, creating a texture with
D3D11_RESOURCE_MISC_SHARED_KEYEDMUTEX flag is strongly recommend
if possible because we cannot ensure sync a texture
which was created with D3D11_RESOURCE_MISC_SHARED
and it would cause glitch with ID3D11VideoProcessor use case.

NOTE 2) Direct9Ex doesn't support texture sharing which was
created with D3D11_RESOURCE_MISC_SHARED_KEYEDMUTEX. In other words,
D3D11_RESOURCE_MISC_SHARED is the only option for Direct3D11/Direct9Ex interop.

NOTE 3) Because of missing synchronization around ID3D11VideoProcessor,
If shared texture was created with D3D11_RESOURCE_MISC_SHARED,
d3d11videosink might use fallback texture to convert DXVA texture
to normal Direct3D texture. Then converted texture will be
copied to user-provided shared texture.

* Why not use generic appsink approach?
In order for application to be able to store video data
which was produced by GStreamer in application's own texture,
there would be two possible approaches,
one is copying our texture into application's own texture,
and the other is drawing on application's own texture directly.
The former (appsink way) cannot be a zero-copy by nature.
In order to support zero-copy processing, we need to draw on
application's own texture directly.

For example, assume that application wants RGBA texture.
Then we can imagine following case.

"d3d11h264dec ! d3d11convert ! video/x-raw(memory:D3D11Memory),format=RGBA ! appsink"
                             ^
                             |_ allocate new Direct3D texture for RGBA format

In above case, d3d11convert will allocate new texture(s) for RGBA format
and then application will copy again the our RGBA texutre into
application's own texture. One texture allocation plus per frame GPU copy will hanppen
in that case therefore.
Moreover, in order for application to be able to access
our texture, we need to allocate texture with additional flags for
application's Direct3D11 device to be able to read texture data.
That would be another implementation burden on our side

But with this MR, we can configure pipeline in this way
"d3d11h264dec ! d3d11videosink".

In that way, we can save at least one texture allocation and
per frame texutre copy since d3d11videosink will convert incoming texture
into application's texture format directly without copy.

* What if we expose texture without conversion and application does
  conversion by itself?
As mentioned above, for application to be able to access our texture
from application's Direct3D11 device, we need to allocate texture
in a special form. But in some case, that might not be possible.
Also, if a texture belongs to decoder DPB, exposing such texture
to application is unsafe and usual Direct3D11 shader cannot handle
such texture. To convert format, ID3D11VideoProcessor API needs to
be used but that would be a implementation burden for application.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1873>
2021-01-26 18:14:37 +00:00
Haihua Hu
66788366a0 dashsink: add h265 codec support
Return hvc1 for video/x-h265 mime type in mpd helper function

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1966>
2021-01-26 17:47:53 +00:00
He Junyan
db134d27a0 av1parse: set the default alignment for input and output.
1. Set the default output alignment to frame, rather than current
   alignment of obu. This make it the same behaviour as h264/h265
   parse, which default align to AU.
2. Set the default input alignment to byte. It can handle the "not
   enough data" error while the OBU alignment can not. Also make it
   conform to the comments.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1979>
2021-01-26 12:22:31 +00:00
He Junyan
be7a9e29df test: Add more test cases for the av1parse obu aligned output.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1979>
2021-01-26 12:22:31 +00:00
He Junyan
5abf4ad4dd av1parse: Reset the annex_b when meet TU inside a buffer.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1979>
2021-01-26 12:22:31 +00:00
He Junyan
d83f253258 av1parse: Output each OBU when output is aligned to obu.
The current behaviour for obu aligned output is not very precise.
Several OBUs will be output together within one gst buffer. We
should output each gst buffer just containing one OBU. This is
the same way as the h264/h265 parse do when NAL aligned.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1979>
2021-01-26 12:22:31 +00:00
He Junyan
ee1f6017ac av1parse: Always copy the OBU to cache.
The current optimization when input align and out out align are
the same is not very correct. We simply copy the data from input
buffer to output buffer, but we failed to consider the dropping of
OBUs. When we need to drop some OBUs(such as filter out the OBUs
of some temporal ID), we can not do simple copy. So we need to
always copy the input OBUs into a cache.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1979>
2021-01-26 12:22:31 +00:00
He Junyan
a9c8aa4788 av1parse: Improve the logic when to drop the OBU.
When drop some OBU, we need to go on. The current manner will make
the data access out range of the buffer mapping.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1979>
2021-01-26 12:22:31 +00:00
Marijn Suijten
e8bb0fa062 ext/ldac: Move duplicate sampling rates into #define
Because there was a typo in one of the duplicates already (see previous
commit) it is much safer to specify these once and only once.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1985>
2021-01-26 11:12:28 +01:00
Marijn Suijten
3747fdb1a6 ext/ldac: Fix typo in 88200(0) stereo encoder sampling rate
Fixes: a57681455 ("ext: Add LDAC encoder")
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1985>
2021-01-26 11:02:21 +01:00
Seungha Yang
6f6a82d0f5 d3d11: Add support for MPEG-2 video decoding
Add DXVA/Direct3D11 API based MPEG-2 decoder element

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1969>
2021-01-25 18:05:53 +00:00
Matthew Waters
3ed0ee95f2 wpesrc: fix possible small deadlock on shutdown
Problem is that unreffing the EGLImage/SHM Buffer while holding the
images_mutex lock may deadlock when a new buffer is advertised and
an attempt is made to lock the images_mutex there.

The advertisement of the new image/buffer is performed in the
WPEContextThread and the blocking dispatch when unreffing wants to run
something on the WPEContextThread however images_mutex has already been
locked by the destructor.

Delay unreffing images/buffers outside of images_mutex and instead just
clear the relevant fields within the lock.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1843>
2021-01-25 09:15:28 +00:00
Haihua Hu
1753d2931c dashsink: fix double unref of sinkpad caps
no need to unref caps in gst_mpd_helper_get_XXX_codec_from_mime
it will be unref in caller gst_dash_sink_get_stream_metadata()

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1981>
2021-01-25 10:28:45 +08:00
He Junyan
e8ec8f7dd7 codecparsers: av1: Fix a typo in frame_restoration_type setting.
Fixes: #1500
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1974>
2021-01-23 10:53:44 +00:00
He Junyan
7196abf7a3 av1parse: Fix some issues in the src caps.
1. Add the mono_chrome to identify 4:0:0 chroma-format.
2. Correct the mapping between subsampling_x/y and chroma-format.
   There is no 4:4:0 format definition in AV1. And 4:4:4 should
   let both subsampling_x/y be equal to 0.
3. Send the chroma-format when the color space is not RGB.

Fixes: #1502
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1974>
2021-01-23 10:53:44 +00:00
He Junyan
1029c84dbf vp9parse: Fix the subsampling_x/y to chroma format mapping.
The chroma format 4:4:4 needs both subsampling_x and subsampling_y
equal to 0.

Fixes: #1502
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1974>
2021-01-23 10:53:44 +00:00
Matthew Waters
82a9e4630c vulkan: remove duplicated check
Checking the same value twice is pointless

Fixes https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/issues/1504

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1977>
2021-01-22 12:38:09 +00:00
Matthew Waters
1a53dfbd64 ldac: also look for the ldac/ldacBT.h header.
Otherwise there will be a scenario where the library can be found but
not the header and a compilation build error will result

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1975>
2021-01-22 09:32:51 +00:00
Víctor Manuel Jáquez Leal
8a8688c639 va: filter: fix assignation to proper variable
Fix the result of a wrong copy&paste

Fixes: #1501
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1976>
2021-01-22 09:38:27 +01:00
Seungha Yang
1f7681c385 mfvideoenc: Add support for P010 d3d11 texture
Add P010 Direct3D11 texture format support

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1970>
2021-01-21 18:53:27 +09:00
Seungha Yang
7b9debedc8 d3d11: Don't use hardcoded maximum resolution value
Maximum supported texture dimension is pre-defined based on
feature level and it couldn't be INT_MAX in any case.
See also https://docs.microsoft.com/en-us/windows/win32/direct3d11/overviews-direct3d-11-devices-downlevel-intro

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1964>
2021-01-20 19:31:27 +09:00
He Junyan
44b7e9268c doc: Add the av1 parse element.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1614>
2021-01-19 18:38:03 +00:00
He Junyan
b93315fa6c codecparsers: Exclude the size of obu_size when identify OBU.
obu->obu_size does not contain the bytes of obu_size itself, we need
to exclude it when doing the saint check.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1614>
2021-01-19 18:38:03 +00:00
He Junyan
3e82c1f88e test: Add test cases for av1parse element.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1614>
2021-01-19 18:38:03 +00:00
He Junyan
fe19bc0a2e videoparsers: av1: Add the AV1 parse.
This AV1 parse implements the conversion between alignment of obu,
tu and frame, and the conversion between stream-format of obu-stream
and annexb.

TODO:
1. May need a property of operating_point to filter the OBUs
2. May add a property to disable deep parse.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1614>
2021-01-19 18:38:03 +00:00
He Junyan
057fedd178 codecs: mpeg2decoder: Fix a typo in header file's comment.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1963>
2021-01-20 00:57:34 +08:00
Seungha Yang
fd76521c24 d3d11videosink: Fix ugly thread name for Win32 window impl.
Don't need to put Win32 twice

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1962>
2021-01-19 11:23:56 +00:00
Seungha Yang
96923c4fa2 d3d11videosink: Fix MSVC build warnings around UWP code
gstd3d11window_corewindow.cpp(408): warning C4189:
  'storage': local variable is initialized but not referenced
gstd3d11window_corewindow.cpp(490): warning C4189:
  'self': local variable is initialized but not referenced
gstd3d11window_swapchainpanel.cpp(481): warning C4189:
  'self': local variable is initialized but not referenced

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1962>
2021-01-19 11:23:56 +00:00
Seungha Yang
d16b5b7f7f d3d11: Allow building UWP features with Desktop features if possible
WINAPI_PARTITION_DESKTOP and WINAPI_PARTITION_APP can coexist.
Although UWP only binaries should be used for production stage,
this change will be useful for development stage

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1962>
2021-01-19 11:23:56 +00:00
Seungha Yang
46c577222d d3d11decoder: Do more retry for ID3D11VideoContext::DecoderBeginFrame failure
Some GPUs (especially NVIDIA) are complaining that GPU is still busy
even we did 50 times of retry with 1ms sleep per failure.
Because DXVA/D3D11 doesn't provide API for "GPU-IS-READY-TO-DECODE"
like signal, there seems to be still no better solution other than sleep.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1913>
2021-01-18 12:04:53 +00:00
Seungha Yang
3f43fef3ce d3d11videosink: Fix build error on UWP
gstd3d11videosink.c(662): error C2065: 'sink': undeclared identifier

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1961>
2021-01-18 19:48:12 +09:00
He Junyan
0158849145 va: Fix some gst_object_unref error because the pointer is NULL.
!1957 introduces some error of gst_object_unref for NULL pointer.
Fixes all of them.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1959>
2021-01-17 14:00:50 +08:00
He Junyan
82c0f90197 va: Make the caps pointer operation atomic in vadecoder.
The vadecoder's srcpad_caps and sinkpad_caps pointers are outside of the
mutex protection. Just make all operation for them atomic.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1957>
2021-01-15 20:40:21 +08:00
He Junyan
6b1e1924fd va: Fix a latent race condition in vabasedec.
The vabasedec's display and decoder are created/destroyed between
the gst_va_base_dec_open/close pair. All the data and event handling
functions are between this pair and so the accessing to these pointers
are safe. But the query function can be called anytime. So we need to:
1. Make these pointers operation in open/close and query atomic.
2. Hold an extra ref during query function to avoid it destroyed.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1957>
2021-01-15 20:40:10 +08:00
Sebastian Dröge
4d07974b10 decklinkaudiosrc: Allow disabling audio sample alignment code by setting the alignment-threshold to 0
And handle setting it to GST_CLOCK_TIME_NONE as always aligning without
ever detecting a discont.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1956>
2021-01-14 14:37:32 +02:00
Seungha Yang
84db4b68fe mfvideoenc: Add support for Direct3D11 texture
Initial support for d3d11 texture so that encoder can copy
upstream d3d11 texture into encoder's own texture pool without
downloading memory.

This implementation requires MFTEnum2() API for creating
MFT (Media Foundation Transform) object for specific GPU but
the API is Windows 10 desktop only. So UWP is not target
of this change.
See also https://docs.microsoft.com/en-us/windows/win32/api/mfapi/nf-mfapi-mftenum2

Note that, for MF plugin to be able to support old OS versions
without breakage, this commit will load MFTEnum2() symbol
by using g_module_open()

Summary of required system environment:
- Needs Windows 10 (probably at least RS 1 update)
- GPU should support ExtendedNV12SharedTextureSupported feature
- Desktop application only (UWP is not supported yet)

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1903>
2021-01-13 20:15:04 +00:00
Mathieu Duponchelle
86c009e7aa webrtc: expose transport property on sender and receiver
As advised by !1366#note_629558 , the nice transport should be
accessed through:

> transceiver->sender/receiver->transport/rtcp_transport->icetransport

All the objects on the path can be accessed through properties
except sender/receiver->transport. This patch addresses that.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1952>
2021-01-13 19:22:42 +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
98eebf3322 va: allocator: Fix deadlock caused by double lock
Trivial bug fix for deadlock

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1949>
2021-01-12 21:28:04 +09:00
Matthew Waters
94fea694bc wpesrc: replace object lock usage with a new lock
Using the object lock is problematic for anything that can dispatch to
another thread which is what createWPEView() does inside
gst_wpe_src_start().  Using the object lock there can cause a deadlock.

One example of such a deadlock is when createWPEView is called, but
another (or the same) wpesrc is on the WPEContextThread and e.g. posts a
bus message.  This message propagations takes and releases the object
lock of numerous elements in quick succession for determining various
information about the elements in the bin.  If the object lock is
already held, then the message propagation will block and stall bin
processing (state changes, other messages) and wpe servicing any events.

Fixes https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/issues/1490

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1934>
2021-01-12 08:35:10 +00:00
Seungha Yang
ae7c20a6ed codecs: h264picture: Count only complete complementary field pair for dpb fullness decision
Our DPB implementation was designed as such that allowing
temporary DPB overflow in the middle of field picture decoding
and incomplete field pair should not trigger DPB bumping.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1947>
2021-01-10 23:27:27 +09:00
Seungha Yang
e14bbd7f5c codecs: h264decoder: Add support for field-pair input frame
In case that upstream pushed buffer as a frame unit, not picture
unit for interlaced stream, baseclass should be able to detect
AU boundary (i.e., complementary field pair).

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1947>
2021-01-10 23:11:01 +09:00
Seungha Yang
6366435e19 codecs: h264decoder: Remove unused private variables
... and reset() method to clear internal status at one place

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1947>
2021-01-10 22:02:54 +09:00