Commit graph

3138 commits

Author SHA1 Message Date
Sreerenj Balachandran
5184f85d77 msdk: vpp: Allocation query fixes
prpose_allocation:
-- always instantiate a pool for for upstream
-- use async_depth + 1 as min buffer count

decide_allocation:
-- always create a new bufferpool for source pad.
Each of the msdk element has to create it's own mfxsurfacepool
which is an msdk contraint. For eg: Each Msdk component (vpp, dec and
enc)
will invoke the external Frame allocator for video-memory usage
So sharing the pool between gst-msdk elements might not be a good idea.

https://bugzilla.gnome.org/show_bug.cgi?id=793705
2018-04-25 12:33:00 -08:00
Xavier Claessens
83d0623293 Meson: Generate pc file for all plugins in bad
https://bugzilla.gnome.org/show_bug.cgi?id=794568
2018-04-25 11:08:09 +01:00
Jan Schmidt
e496f398ec nvenc: Remove GST_USE_UNSTABLE_API defines
GstGL is no longer unstable API since moving to -base
2018-04-25 02:44:14 +10:00
Jan Schmidt
02c2b0b275 nvenc: Use the HAVE_NVENC_GST_GL define instead of HAVE_GST_GL
Fix compiling against the GL interop by gating includes
on the right header
2018-04-25 02:44:14 +10:00
Seungha Yang
3f318ecb96 nvh265enc: Add Nvidia GPU based HEVC encoder
https://bugzilla.gnome.org/show_bug.cgi?id=795037
2018-04-25 01:59:30 +10:00
Seungha Yang
5f95094f39 nvencbase: Define sinkpad template in subclass
https://bugzilla.gnome.org/show_bug.cgi?id=795037
2018-04-25 01:59:30 +10:00
Seungha Yang
6242dae832 nvenc: Add debug catagory for nvh264enc
https://bugzilla.gnome.org/show_bug.cgi?id=795037
2018-04-25 01:59:30 +10:00
Edward Hervey
44390d9d1d decklinkvideosrc: Add support for extracting Closed Caption
If the "output-cc" property is set to TRUE and there is CC present
in the VBI Ancillary Data, they will be extracted and set on the
outgoing buffer as GstVideoCaptionMeta.

Only CDP packets are supported.

https://bugzilla.gnome.org/show_bug.cgi?id=773863
2018-04-23 16:16:06 +02:00
Tim-Philipp Müller
79c13988e4 Fix code indentation 2018-04-22 18:27:37 +01:00
Tim-Philipp Müller
595392d187 dx9screenscapsrc: consolidate UNLOCK 2018-04-22 18:25:34 +01:00
Tim-Philipp Müller
5e372f71b6 meson: fbdev: fix 'invalid keyword argument' meson warnings
Required is not a valid kwarg for cc.has_header()
2018-04-20 11:46:07 +01:00
Devarsh Thakkar
d0575a0bd1 kmssink: Add new entry for Xilinx DRM Driver
This adds entry for new DRM driver from xilinx
called "xlnx" which supports atomic modesetting.

We have kept entry for older DRM driver "xilinx_drm"
for backward compatility with a note describing
deprecation.

Signed-off-by: Devarsh Thakkar <devarsht@xilinx.com>

https://bugzilla.gnome.org/show_bug.cgi?id=795228
2018-04-18 21:15:04 +02:00
Nirbheek Chauhan
9118cc7a19 wasapisrc: Don't provide a clock based on WASAPI's clock
The clock seems to have a lot of drift (or we're using it incorrectly)
which causes buffers to be late on the sink and get dropped.

Disable till someone can investigate whether our usage of the API is
incorrect (it looked correct to me) or if something is wrong.
2018-04-18 15:05:29 +05:30
Snir Sheriber
73cd1aa9dc nvdec/nvenc: Support CUDA Toolkit 9
Since cuda-tools 9.0, nvcuvid.h is replaced by dynlink_nvcuvid.h.
This patch changes nvdec to use run-time dynamic linking if
cuda-tools version >= 9.
nvenc does not require any change since its necessary headers are
still available.

https://bugzilla.gnome.org/show_bug.cgi?id=791724
2018-04-17 23:33:04 +10:00
Sreerenj Balachandran
142ad9dbad msdk: jpegdec: Fix non-interleaved sample decode
Using the default value (InterleavedDec == MFX_SCANTYPE_UNKNOWN)
causing issues with non-interleaved sample decode. Ideally the usage
of MFXVideoDECODE_DecodeHeader should fix these type of issue, but
it seems to be not. But hardcoding the InterleaveDec to
MFX_SCANTYPE_NONINTERLEAVED
is fixing the problem and fortunately msdk seems to be taking care of
Interleaved samples
too .So let's hardcode it for now.

https://bugzilla.gnome.org/show_bug.cgi?id=793787
2018-04-16 14:37:21 -08:00
Nirbheek Chauhan
ff17a404b3 wasapi: Call CoIn/Uninitialize() around prepare()
Seems to be required for exclusive mode and also for all
initialization on Windows 7

https://bugzilla.gnome.org/show_bug.cgi?id=795274
2018-04-16 19:35:07 +05:30
Garima Gaur
8e6375c08b resindvd, uvch264src, dx9screencapsrc: fix clock ref leaks in error paths
https://bugzilla.gnome.org/show_bug.cgi?id=776376
2018-04-12 19:07:19 +01:00
Garima Gaur
70fbcf9c0f bluez: avdtpsrc: fix caps leak in error code paths
https://bugzilla.gnome.org/show_bug.cgi?id=776085
2018-04-12 18:19:32 +01:00
Nirbheek Chauhan
5409cd4920 wasapi: Handle return value of WaitForSingleObject
The wait could've failed for whatever reason, we should handle that.
2018-04-10 05:16:54 +05:30
Nirbheek Chauhan
0a518c9be1 wasapi: Call _Start if the client was _Reset
Otherwise we will wait forever in WaitForSingleObject because we forgot
to start the client again after _Stop is called in reset().

https://bugzilla.gnome.org/show_bug.cgi?id=795114
2018-04-10 05:16:54 +05:30
Nirbheek Chauhan
c427860a20 wasapi: Don't open the device in get_caps()
We can just return the template caps till the device is opened when
going from READY -> PAUSED. This fixes a CRITICAL when calling
ELEMENT_ERROR before the ringbuffer is allocated.

Also fixes a couple of leaks in error conditions.

https://bugzilla.gnome.org/show_bug.cgi?id=794611
2018-04-09 17:28:11 +05:30
Nirbheek Chauhan
b7653925db wasapi: Only use audioclient3 when low-latency
Causes glitches on very slow CPU machines or VMs, and our
out-of-the-box experience should be good.

https://bugzilla.gnome.org/show_bug.cgi?id=794497
2018-04-06 23:11:18 +05:30
Nirbheek Chauhan
41a4a8fe0d wasapi: Don't derive device period from latency time
This seems to cause glitches on devices with low CPU availability,
such as virtual machines. Maybe even actual machines under high load.

https://bugzilla.gnome.org/show_bug.cgi?id=794497
2018-04-06 23:11:11 +05:30
U. Artie Eoff
275d754156 msdk: fix plugin load on implementations with only HW support
We can't assume that MSDK always supports SW implementation
on all platforms.  Thus, msdk_is_available should check for
ANY implementation.

https://bugzilla.gnome.org/show_bug.cgi?id=794991
2018-04-04 17:31:14 -08:00
Nirbheek Chauhan
fc989ce544 wasapi: Squelch warning about %x and HRESULT
HRESULT is always a 32-bit value, as is guint.
2018-04-04 18:36:38 +05:30
Nirbheek Chauhan
affb0182c6 wasapisrc: Implement loopback recording
Now, when you set loopback=true on wasapisrc, the `device` property
should refer to a sink (render) device for loopback recording.

If the `device` property is not set, the default sink device is used.
2018-04-04 01:12:23 +05:30
Tim-Philipp Müller
f7352ecc5c msdk: fix meson syntax 2018-04-03 19:22:01 +01:00
Sreerenj Balachandran
e4b4f09496 msdk: vpp : Add frame rate control
https://bugzilla.gnome.org/show_bug.cgi?id=793705
2018-04-03 11:10:20 -08:00
Sreerenj Balachandran
c0ea4bdafb msdk: vpp : Add force-aspect-ratio property
https://bugzilla.gnome.org/show_bug.cgi?id=793705
2018-04-03 10:39:45 -08:00
Sreerenj Balachandran
fb8c536393 msdk: Add more scaling filter algorithms
https://bugzilla.gnome.org/show_bug.cgi?id=793705
2018-04-03 10:39:35 -08:00
Sreerenj Balachandran
51b6345dc4 msdk: vpp: Add support for horizontal and vertical mirroring
https://bugzilla.gnome.org/show_bug.cgi?id=793705
2018-04-03 10:39:24 -08:00
Sreerenj Balachandran
108c8fde7f msdk: vpp: Add detail/edge enhancement tuning
https://bugzilla.gnome.org/show_bug.cgi?id=793705
2018-04-03 10:39:13 -08:00
Sreerenj Balachandran
93c5dd2478 msdk: vpp: Add ProAmp(colorbalance) support
Added Hue, Saturation, Brightness and Contrast tuning support.

Fixme: Add GstColorBalanceInterface support

https://bugzilla.gnome.org/show_bug.cgi?id=793705
2018-04-03 10:39:02 -08:00
Sreerenj Balachandran
f5a3d3d799 msdk: vpp: Add deinterlacing support
https://bugzilla.gnome.org/show_bug.cgi?id=793705
2018-04-03 10:38:52 -08:00
Sreerenj Balachandran
36e81744d1 msdk: vpp:Add more filters
-- Add Denoise
-- Add Rotation

https://bugzilla.gnome.org/show_bug.cgi?id=793705
2018-04-03 10:38:41 -08:00
Sreerenj Balachandran
d3d89f02b3 msdk: Add VPP element
https://bugzilla.gnome.org/show_bug.cgi?id=793705
2018-04-03 10:38:19 -08:00
Hyunjun Ko
35b6411d4d msdk: dec: rename the function to what it means more exactly.
https://bugzilla.gnome.org/show_bug.cgi?id=793707
2018-04-02 15:55:55 -08:00
Hyunjun Ko
90491d889a msdk: allocator: libva: check if it's already using dmabuf when mapping
As long as we negotiate the "DMABuf" capsfeatures for now, map can't be
working. So we need to confirm not to do it if using DMABuf memory.

https://bugzilla.gnome.org/show_bug.cgi?id=793707
2018-04-02 15:49:32 -08:00
Daeseok Youn
faa892fb48 nvbaseenc: fix build warnings with HAVE_NVENC_GST_GL
fix following error:
gstnvbaseenc.c: In function ‘gst_nv_base_enc_set_context’:
gstnvbaseenc.c:451:17: error: unused variable ‘nvenc’ [-Werror=unused-variable]
   GstNvBaseEnc *nvenc = GST_NV_BASE_ENC (element);
                 ^

https://bugzilla.gnome.org/show_bug.cgi?id=794896
2018-04-02 19:42:15 +01:00
Nirbheek Chauhan
29c785ef28 decklink: Fix MinGW warnings due to MSVC-specific pragmas
https://bugzilla.gnome.org/show_bug.cgi?id=794652#c7
2018-03-31 11:16:38 +05:30
Hyunjun Ko
cdc591dbc0 msdkdec: use dmabuf if possible
https://bugzilla.gnome.org/show_bug.cgi?id=793707
2018-03-30 11:06:40 -08:00
Hyunjun Ko
ea92da6e54 msdk: dmabuf support
This patch includes:
1\ Implements MsdkDmaBufAllocator and allocation of msdk dmabuf memroy.
2\ Each msdk dmabuf memory include its own msdk surface kept by GQuark.
3\ Adds new option GST_BUFFER_POOL_OPTION_MSDK_USE_DMABUF

https://bugzilla.gnome.org/show_bug.cgi?id=793707
2018-03-30 11:06:05 -08:00
Hyunjun Ko
5df06545ef msdk: adds new function to get dmabuf information from surface.
https://bugzilla.gnome.org/show_bug.cgi?id=793707
2018-03-30 11:05:16 -08:00
Hyunjun Ko
bd8ffcb29d msdk: allocator: get dmabuf handle during allocation if required
https://bugzilla.gnome.org/show_bug.cgi?id=793707
2018-03-30 11:04:28 -08:00
Hyunjun Ko
c3438b5a0f msdk: generalize the parameter of msdk video memory functions
There needs to be generalized for the parameter from
GstVideoMsdkVideoMemory to GstMemory.

Thus we can call these functions if using DMABuf memory.

https://bugzilla.gnome.org/show_bug.cgi?id=793707
2018-03-30 11:03:00 -08:00
Hyunjun Ko
762eb97092 msdk: specify the way to find a proper cached response by request
The current way to find proper response by just comparing request's
value is wrong.  We need to compare the size of a frame and the
number of suggested frames.

Refer to the sample in https://github.com/Intel-Media-SDK/samples.

https://bugzilla.gnome.org/show_bug.cgi?id=793707
2018-03-30 11:02:26 -08:00
Paul Kocialkowski
a53019068d kmssink: Add support for the Allwinner DRM driver (sun4i-drm)
This adds the sun4i DRM driver to the list of DRM drivers in kmssink.
The driver allows displaying video in either the main plane or an
overlay plane.

https://bugzilla.gnome.org/attachment.cgi?bugid=794839
2018-03-30 09:16:39 -04:00
Sreerenj Balachandran
e40dc51fcd msdk: dec: remove framerate field from sink caps template
Removes unessential field framerate for decoder so that negotiation
works even if framerate is not provided from upstream.

https://bugzilla.gnome.org/show_bug.cgi?id=789752
2018-03-29 13:06:41 -08:00
Hyunjun Ko
1955ffed3f msdk: dec: set framerate to the driver only if provided
For example, if framerate 0/1 is provided from upstream, the driver
fails to configure and complain about it.

We can let it go and make the driver assuming framerate itself.

https://bugzilla.gnome.org/show_bug.cgi?id=789752
2018-03-29 12:41:48 -08:00
Hyunjun Ko
0eaf3bdcd9 msdk: h265dec: remove framerate field from sink caps template
Removes unessential field framerate for decoder so that negotiation
works even if framerate is not provided from upstream.

https://bugzilla.gnome.org/show_bug.cgi?id=789752
2018-03-29 12:40:34 -08:00
Sreerenj Balachandran
f1f148fe7c msdk: Don't set extended coding options for JPEG encode
MJPEG doesn't have support for extended coding options

https://bugzilla.gnome.org/show_bug.cgi?id=793873
2018-03-29 11:56:19 -08:00
Nirbheek Chauhan
90f6e6c097 decklink: Use g_thread_new instead of g_thread_create
It's deprecated, and causes a build failure in Cerbero because we pass
-DG_DISABLE_DEPRECATED.
2018-03-27 12:51:19 +05:30
Takeshi Sato
beab2ee4dc decklink: fix initialization fails in windows binary
There is no log of gst_decklink_com_thread () which initializes COM.
The initialization part is not valid with #ifdef MSC_VER.
Windows binaries are built with gcc.
As with other codes, it was avoidable by setting it to G_OS_WIN32
instead of MSC_VER.

https://bugzilla.gnome.org/show_bug.cgi?id=794652
2018-03-27 12:04:05 +05:30
Nirbheek Chauhan
a08d333e56 wasapi: Print the hresult hex value on error
This helps figure out precisely what error enum value was returned,
which can be necessary when the description is too generic
2018-03-27 12:02:21 +05:30
Sebastian Dröge
1b3b3677cc shmsink: Fix compilation with latest GLib
g_object_ref() forwards its arguments type.

gstshmsink.c: In function ‘gst_shm_sink_allocator_alloc_locked’:
/usr/include/glib-2.0/gobject/gobject.h:512:32: error: passing argument 3 of ‘gst_memory_init’ from incompatible pointer type [-Werror=incompatible-pointer-types]
 #define g_object_ref(Obj)      ((__typeof__(Obj)) (g_object_ref) (Obj))
                                ^
gstshmsink.c:292:45: note: in expansion of macro ‘g_object_ref’
     gst_memory_init (memory, params->flags, g_object_ref (self), NULL,
                                             ^~~~~~~~~~~~
2018-03-20 16:16:19 +02:00
Tim-Philipp Müller
1da3cd56a0 wasapi: try to satisfy both mingw and msvc
Fix-up for previous commit, hopefully.
2018-03-18 14:13:52 +00:00
Nicolas Dufresne
9387a936b5 kmssink: Add Amlogic upstreamer DRM driver support
Amlogic Upstream driver is named meson, not to be confuse with the build
system.
2018-03-18 09:50:51 -04:00
Tim-Philipp Müller
ca4cbaef24 wasapi: fix indentation 2018-03-17 23:52:31 +00:00
Tim-Philipp Müller
ec5c3cb714 wasapi: fix unresolved symbol linker error with vs2017 on win10
ERROR: unresolved external symbol PKEY_AudioEngine_DeviceFormat

Apparently the order of the header includes matters, and initguid.h
must be included first. Let's hope this doesn't break anything on
the other toolchains.

https://social.msdn.microsoft.com/Forums/windowsdesktop/en-US/ceff4e2d-8f63-4ab6-b09b-fdac65d62a80/pkeyaudioenginedeviceformat-link-error?forum=windowspro-audiodevelopment
2018-03-17 23:48:13 +00:00
Hyunjun Ko
52f669bf43 msdk: libva: remove unnecessary code and comments
https://bugzilla.gnome.org/show_bug.cgi?id=794276
2018-03-13 14:21:40 -08:00
Hyunjun Ko
6547b638c5 msdk: adds new debug category
https://bugzilla.gnome.org/show_bug.cgi?id=794276
2018-03-13 14:20:50 -08:00
Hyunjun Ko
443b3c98fa msdk: fix typo
https://bugzilla.gnome.org/show_bug.cgi?id=794276
2018-03-13 14:18:23 -08:00
Wang,Fei
0c69867d52 msdk: Fix the I420 video format support
Make sure I420 surface mapping works as expected by using
YV12 format and swap U/V plane's offset and pitches.

https://bugzilla.gnome.org/show_bug.cgi?id=793865
2018-03-13 13:54:17 -08:00
Nirbheek Chauhan
16b9e1e444 wasapi: Minor fixes for debug logging 2018-03-10 18:54:59 +05:30
Nirbheek Chauhan
1019537344 meson: Add deviceprovider changes to directsoundsrc
These were missed when they were added to Makefile.am
2018-03-10 18:54:59 +05:30
Nirbheek Chauhan
a2f5485893 wasapi: Guard IAudioClient2 structs and enums
These are already defined in the audioclient.h provided by the latest
MinGW headers, and the existing #ifndef were obviously wrong.

https://bugzilla.gnome.org/show_bug.cgi?id=794197
2018-03-10 18:54:59 +05:30
Tim-Philipp Müller
c2bcc2711a meson: fix build when msdk is not found 2018-03-09 23:59:16 +00:00
Sreerenj Balachandran
bdbc1d0bef msdk: Fix the misspelled file name in meson build 2018-03-09 10:33:22 -09:00
Emilio Pozuelo Monfort
898e01fe29 wasapi: ship audioclient3 header in tarballs
https://bugzilla.gnome.org/show_bug.cgi?id=794197
2018-03-09 11:42:13 +00:00
Hyunjun Ko
4918430858 msdk: enc: fix missing some frames to be encoded
There was not handling the end of encoding sequence in encoder.
This patch does drain any remaining internal streams while decoder
already does this.

Document says:
"To mark the end of the encoding sequence, call this function with a
NULL surface
pointer. Repeat the call to drain any remaining internally cached
bitstreams—one
frame at a time—until MFX_ERR_MORE_DATA is returned."

https://bugzilla.gnome.org/show_bug.cgi?id=793236
2018-03-08 11:39:25 -09:00
Hyunjun Ko
8a3630ffd7 msdk: dec: fix leaks when flushing
https://bugzilla.gnome.org/show_bug.cgi?id=793708
2018-03-08 11:38:52 -09:00
Hyunjun Ko
c9faf0d612 msdk: manage child sessions on parent GstMsdkContext
Sometimes parent context is released before its children get released.
In this case MFXClose of parent session fails.

To make sure that child sessions are closed before closing a parent
session,
Parent context needs to manage child sessions and close them first when
it's released.

https://bugzilla.gnome.org/show_bug.cgi?id=793412
2018-03-08 11:38:30 -09:00
Hyunjun Ko
37ef61586a msdk: dec: remove code to manage buffers with locked surface
https://bugzilla.gnome.org/show_bug.cgi?id=793413
2018-03-08 11:37:52 -09:00
Hyunjun Ko
b08b8ddae3 msdk: manage MSDK surfaces seperately
Currently a gst buffer has one mfxFrameSurface when it's allocated and
can't be changed.
This is based on that the life of gst buffer and mfxFrameSurface would
be same.
But it's not true. Sometimes even if a gst buffer of a frame is finished
on downstream,
mfxFramesurface coupled with the gst buffer is still locked, which means
it's still being used in the driver.

So this patch does this.
Every time a gst buffer is acquired from the pool, it confirms if the
surface coupled with the buffer is unlocked.
If not, replace it with new unlocked one.
In this way, user(decoder or encoder) doesn't need to manage gst buffers
including locked surface.

To do that, this patch includes the following:
1. GstMsdkContext
- Manages MSDK surfaces available, used, locked respectively as the
following:
  1\ surfaces_avail : surfaces which are free and unused anywhere
  2\ surfaces_used : surfaces coupled with a gst buffer and being used
now.
  3\ surfaces_locked : surfaces still locked even after the gst buffer
is released.

- Provide an api to get MSDK surface available.
- Provide an api to release MSDK surface.

2. GstMsdkVideoMemory
- Gets a surface available when it's allocated.
- Provide an api to get an available surface with new unlocked one.
- Provide an api to release surface in the msdk video memory.

3. GstMsdkBufferPool
- In acquire_buffer, every time a gst buffer is acquired, get new
available surface from the list.
- In release_buffer, it confirms if the buffer's surface is unlocked or
not.
  - If unlocked, it is put to the available list.
  - If still locked, it is put to the locked list.

This also fixes bug #793525.

https://bugzilla.gnome.org/show_bug.cgi?id=793413
https://bugzilla.gnome.org/show_bug.cgi?id=793525
2018-03-08 11:37:12 -09:00
Nirbheek Chauhan
c2956036b8 wasapi: Increase rank to prefer over directsoundsrc
Directsoundsrc/sink have multiple issues, most of which cannot be
fixed at all because the API is deprecated and is implemented as a
compatibility wrapper around WASAPI since Vista.

Users and developers should now use the wasapisrc/sink elements, and
future development efforts should go towards that.
2018-03-01 15:33:18 +05:30
Nirbheek Chauhan
05a37d3791 wasapi: Clarify usage of low-latency property, add myself as author
The low-latency property is *always* safe to enable, so applications
that do realtime communication should set it, and the elements will
automatically configure WASAPI to use the lowest possible device
period, and the audioringbuffer in audiobasesink will also be
configured accordingly.

Applications can also use exclusive mode during capture and playback
for the lowest possible latency if they know that the device will not
be used by any other application.

In this mode, the latency-time and buffer-time properties will be
completely ignored.
2018-02-26 16:23:11 +05:30
Nirbheek Chauhan
995059dc87 wasapi: Add a property for trying the AudioClient3 API
The AudioClient3 API is only available on Windows 10, and we will
automatically detect when it is available and use it.

However, using it for capturing audio with low latency and without
glitches seems to require setting the realtime priority of the entire
pipeline to "critical", which we cannot do from inside the element.

Hence, we can only enable that by default for wasapisink since
apps should be able to safely set the low-latency property to TRUE if
they need low-latency capture or playback.
2018-02-26 16:23:11 +05:30
Nirbheek Chauhan
f7d0ce2477 wasapi: Set realtime thread priority at runtime
Use LoadLibrary() to set the thread characteristics at runtime so it
works automagically regardless of where or how the plugin was built.
2018-02-26 16:23:11 +05:30
Nirbheek Chauhan
0cb11c15ed wasapi: Use IAudioClient3 interface when available
This allows us to request ultra-low-latency device periods even in
shared mode. However, this requires good drivers and Windows 10, so
we only enable this when we detect that we are running on Windows 10
at runtime.

You can forcibly disable this feature on Windows 10 by setting
GST_WASAPI_DISABLE_AUDIOCLIENT3=1 in the environment.
2018-02-26 16:23:11 +05:30
Nirbheek Chauhan
16af66ee95 wasapi: __uuidof is simply not available in C
Fix comment, and don't try to use it at all.
2018-02-26 16:23:11 +05:30
Nirbheek Chauhan
28874e15ff wasapi: Set a default category for util functions
Without this, they all go to the default category where they can be
missed
2018-02-26 16:23:11 +05:30
Nirbheek Chauhan
14b2d6b27a wasapi: Use a macro for HRESULT failure paths
Saves a lot of boilerplate across all files.
2018-02-26 16:23:11 +05:30
Hyunjun Ko
14f0186741 msdk: remove unused code
There's unused code remaining since MSDK bufferpool patches landed.

https://bugzilla.gnome.org/show_bug.cgi?id=793741
2018-02-23 14:30:56 -09:00
Sreerenj Balachandran
1c81bf4bdc msdkenc: remove unnecessary memset
https://bugzilla.gnome.org/show_bug.cgi?id=791479
2018-02-22 12:32:45 -09:00
Sreerenj Balachandran
3cc61f98b1 msdk: enc: Support force-key-unit events
https://bugzilla.gnome.org/show_bug.cgi?id=791479
2018-02-22 12:32:20 -09:00
Sreerenj Balachandran
a50ecfe46c msdk: enc: Fix typo 2018-02-20 17:22:35 -09:00
Sreerenj Balachandran
e924dec4e1 msdk: h264_enc: Enable B-pyramid prediction support
Since there is already an "adaptive-B" option, just
use boolean property for B-pyramid enabling.

Fixme: Not sure whether this can be supported in vp8 and vp9.
It could be possible through GPB (b without backward ref) but
can't verify currently. We can move this as common property
once verified with vp8 and vp9 without breaking any backward
compatibility.

https://bugzilla.gnome.org/show_bug.cgi?id=791637
2018-02-20 12:41:18 -09:00
Sreerenj Balachandran
07c05a75a5 msdk: Add more tuning options
Added tuning options for mb level bitrate control,
adaptive I-frame insertion, and adaptive B-frame insertion.

https://bugzilla.gnome.org/show_bug.cgi?id=791637
2018-02-20 12:41:08 -09:00
Sreerenj Balachandran
f25bcf7cb8 msdk: h264_enc: Add slice size tuning option
According to spec, it is a general property. But based on
testing it only works for h264 encoder.
Let's keep it as h264 specific for now.

https://bugzilla.gnome.org/show_bug.cgi?id=791637
2018-02-20 12:40:59 -09:00
Sreerenj Balachandran
ddd02be0de msdk: move enum definitions to separte file
Move enum value defintions which are (or in future) supported
by more than one codec into a common file.

https://bugzilla.gnome.org/show_bug.cgi?id=791637
2018-02-20 12:40:50 -09:00
Sreerenj Balachandran
b7dbcb26b8 msdk: encoder: h264: Enable trellis quantization tuning
Add a new property "trellis" to enable trellis quantization.
Keeping trellis as a flag value (which is boolean for gst x264 enc element)
since it is possible to enable/disable this seperately for
I,P and B frames through MediaSDK ext option headers.

The subclass implementations always need to inform base-encoder
if it requires the inclusion of Extend Header buffers (mfxExtCodingOption2
 and mfxExtCodingOption3).

https://bugzilla.gnome.org/show_bug.cgi?id=791637
2018-02-20 12:40:42 -09:00
Sreerenj Balachandran
d58c0bd509 msdk: h264_enc: Add LookaheadDownsampling support
This option controls down sampling in look ahead bitrate
control mode. According to spec it is only supported in AVC.

Fixme: Probably HEVC also have support for this in recent
MSDK versions. We could move the enumeration types to common
header usable for multiple codecs.

https://bugzilla.gnome.org/show_bug.cgi?id=791637
2018-02-20 12:39:53 -09:00
Sreerenj Balachandran
ae8d956c2c msdk: encode: Add more rate control options
MediaSDK has support for a number of rate control algorithms.
Adding all possible options to the property rate-control.

Fixme1: In case of failure, currently we don't have a proper method
to show which rate-control has been failed. It could be better
to add some extensive validation on EncQuery output in case of error.
Unfortunately, not all ratecontrol methods are supported by every codecs
and we don't have the dynamic detection of supported ratecontrol methods yet.

https://bugzilla.gnome.org/show_bug.cgi?id=791637
2018-02-20 12:39:28 -09:00
Sreerenj Balachandran
f076f1948e msdk: encode: Add property to set slice/partitioning
Adding a new property num-slices to set the number of
slices/partitions per frame. Adding it as a general
property for all codecs (except jpeg).

https://bugzilla.gnome.org/show_bug.cgi?id=791637
2018-02-20 12:39:13 -09:00
Sreerenj Balachandran
a165a1a1a9 msdk: encoder: h265: generalize the behavior of "i-frames" property
We have the property "i-frames" to set the IDR interval in a
gop. Unfortunately MSDK HEVC encoder behaves bit differently
for IdrInterval field, IdrInteval == 1 indicate every
I-frame should be an IDR (which is IdrInterval == 0 for other codecs),
IdrInteval == 2 means every other I-frame is an IDR
(which is IdrInterval == 1 for other codecs) etc.
So we generalize the behaviour of property "i-frames" by
incrementing the value by one in each case (only for HEVC).

https://bugzilla.gnome.org/show_bug.cgi?id=791637
2018-02-20 12:39:02 -09:00
Sreerenj Balachandran
fa0911c3f6 msdk: encoder: register only the required properties
The base encoder common properties are not valid for
mjpeg encoder where there is no motion compensation or rate control.
Delaying the property installation on the base gobject
untill the subclass class_init get invoked.

https://bugzilla.gnome.org/show_bug.cgi?id=791637
2018-02-20 12:38:28 -09:00
Víctor Manuel Jáquez Leal
0156d391ae msdk: add missing files for dist target
https://bugzilla.gnome.org/show_bug.cgi?id=793563
2018-02-19 22:16:07 +01:00
Edward Hervey
b3ca3e977c decklink: Fix array of devices usage
We need to allocate actual Device structures since we are going
to be setting callbacks with address to that structure

https://bugzilla.gnome.org/show_bug.cgi?id=777239
2018-02-14 16:00:34 +01:00
Sreerenj Balachandran
173b07ba11 msdk: vc1_dec: Add Advanced profile (WVC1) support
Only supporting asf header-format having BDUs with startcode.
It might be possible to support other formats too, but haven't tested.

https://bugzilla.gnome.org/show_bug.cgi?id=792589
2018-02-13 14:41:52 -09:00
Sreerenj Balachandran
55c0d7205d msdk: dec: Add non-packetized stream handling support
The gst-msdk decoders prefer packetized streams as input
and in this case we can avoid unnecessary input bitstream copy
to mfxBitstream. This works fine for codecs like h264 where
we only support byte-stream with au alignment. Other format
conversions should be done thorugh parsers. But this won't work
for codecs like vc1 where we don't have an autoplugged parser.
Even the parser is not capable to do format conversions.

Packetizing through base decoders parse() routine will bring a
lot of uncecessary of complexities and codecparser libraray dependency.
So we just use an interal gst_adaper to keep track of bitstream
which is not consumed by msdk durig AsynchronusDecoding.
This adapter will get used only if subclass implementations
set the "is_packetized" to FALSE for msdk base encoder.

https://bugzilla.gnome.org/show_bug.cgi?id=792589
2018-02-13 14:41:20 -09:00
Sreerenj Balachandran
760e6e54a7 msdk: Add VC1 decoder (simple and main profiles)
Adding Simple and Main profiles decode support.

Currently msdkvc1dec is not capable to handle the codec_data,
only instream headers are supported. Also msdk vc1 decoder
expecting instream with Sequence header as per SMPTE 421M Annex L.

Most of the decdoebin/playbin pipeline won't work with the above
constraints
because vc1parse is still not an autoplug element.

Only way to make mskdvc1dec work is by connecting a vc1parse
as an upstream element.

https://bugzilla.gnome.org/show_bug.cgi?id=792589
2018-02-13 14:40:54 -09:00
Sreerenj Balachandran
b622d21d6a msdk : Add RenderNode support
Use drm render node as the first choice of device node file.
Fall backs to use drm primary (/dev/dri/card[0-9])
if there is no render node available

Basic logic is inherited from gstreamer-vaapi, but using
gudev API rather than libudev directly.

Added gudev library as dependency for msdk.

https://bugzilla.gnome.org/show_bug.cgi?id=791599
2018-02-13 14:40:22 -09:00
Hyunjun Ko
76a82feae7 msdk: Avoid build failures on Windows until d3d allocator is implemented
https://bugzilla.gnome.org/show_bug.cgi?id=790752
2018-02-13 13:54:03 -09:00
Hyunjun Ko
72c6cd5545 msdkdec: use video memory if there's another MSDK context in a pipeline
1\ If downstream's pool is MSDK bufferpool,
2\ If there's shared GstMsdkContext in the pipeline,

a decoder decides to use video memory.

This policy should be improved to handle more cases.

https://bugzilla.gnome.org/show_bug.cgi?id=790752
2018-02-13 13:53:02 -09:00
Hyunjun Ko
375a50a876 msdk: add async depth from each msdk element to GstMsdkContext to be shared
In case that pipeline is like ".. ! decoder ! encoder ! ..." with using
video memory,
decoder needs to know the async depth of the following msdk element so
that it could
allocate the correct number of video memory.

Otherwise, decoder's memory is exhausted while processing.

https://bugzilla.gnome.org/show_bug.cgi?id=790752
2018-02-13 13:52:14 -09:00
Hyunjun Ko
f2b35abcab msdkdec/enc: query GstContext to share GstMsdkContext
How to share/create GstMsdkcontext is the following:

- Search GstMsdkContext if there's in the pipeline.
  - If found, check if it's decoder, encoder or vpp by job type.
    - If it's same job type, it creates another instance of
GstMsdkContext
     with joined-session.
    - Otherwise just use the shared GstMsdkContext.
  - If not found, just creates new instance of GstMsdkContext.

https://bugzilla.gnome.org/show_bug.cgi?id=790752
2018-02-13 13:51:18 -09:00
Hyunjun Ko
dc82ccb9a2 msdk: context: add job type to figure out if joining session is necessary
According to the driver's instruction, if there are two or more encoders
or decoders in a process, the session should be joined by
MFXJoinSession.

To achieve this successfully by GstContext, this patch adds job type
specified if it's encoder, decoder or vpp.

If a msdk element gets to know if joining session is needed by the
shared context,
it should create another instance of GstContext with joined session,
which
is not shared.

https://bugzilla.gnome.org/show_bug.cgi?id=790752
2018-02-13 13:50:48 -09:00
Hyunjun Ko
dddb84897f msdk: adds util functions to handle GstContext
To share GstMsdkContext with each msdk element,
it will be using GstContext.

Most common code is from gstreamer-vaapi.

https://bugzilla.gnome.org/show_bug.cgi?id=790752
2018-02-13 13:50:08 -09:00
Hyunjun Ko
a66d5620f3 msdkdec: use bufferpool
1\ In decide_allocation, it makes its own msdk bufferpool.
  - If downstream supports video meta, it just replace it with the msdk
bufferpool.
  - If not, it uses the msdk bufferpool as a side pool, which will be
decoded into.
    and will copy it to downstream's bufferpool.

2\ Decide if using video memory or system memory.
  - This is not completed in this patch.
  - It might be decided in update_src_caps.
  - But tested for both system memory and video memory cases.

https://bugzilla.gnome.org/show_bug.cgi?id=790752
2018-02-13 13:49:28 -09:00
Hyunjun Ko
580a52ec49 msdkenc: use bufferpool
1\ Proposes msdk bufferpool to upstream.
  - If upstream has accepted the proposed msdk bufferpool,
    encoder can get msdk surface from the buffer directly.
  - If not, encoder get msdk surface its own msdk bufferpool
    and copy from upstream's frame to the surface.

2\ Replace arrays of surfaces with msdk bufferpool.

3\ In case of using VPP, there should be another msdk bufferpool
   with NV12 info so that it could convert first and encode.

Calls gst_msdk_set_frame_allocator and uses video memory only on linux.
and uses system memory on Windows until d3d allocator is implemented.

https://bugzilla.gnome.org/show_bug.cgi?id=790752
2018-02-13 13:48:32 -09:00
Hyunjun Ko
2542b2d34d msdk: supports bufferpool
Implements 2 memory allocators:
1\ GstMsdkSystemAllocator: This will allocate system memory.
2\ GstMsdkVideoAllocator: This will allocate device memory depending
on the platform. (eg. VASurface)

Currently GstMsdkBufferPool uses video allocator currently by default
only on linux. On Windows, we should use system memory until d3d
allocator
is implemented.

https://bugzilla.gnome.org/show_bug.cgi?id=790752
2018-02-13 13:44:08 -09:00
Hyunjun Ko
4d860ec82b msdk: adds frame allocator using libva
Implements msdk frame allocator which is required from the driver.
Also makes these functions global so that GstMsdkAllocator could use
the allocated video memory later and couple with GstMsdkMemory.

GstMsdkContext keeps allocation information such as mfxFrameAllocRequest
and mfxFrameAllocResponse after allocation.

https://bugzilla.gnome.org/show_bug.cgi?id=790752
2018-02-13 12:43:42 -09:00
Hyunjun Ko
3ed9f7c5f1 msdkdec: fix typo
https://bugzilla.gnome.org/show_bug.cgi?id=790752
2018-02-13 12:43:00 -09:00
Hyunjun Ko
6ce9a66b80 msdk: implements GstMsdkContext.
Makes GstMsdkContext to be a descendant of GstObject so that
we could track the life-cycle of the session of the driver.

Also replaces MsdkContext with this one.
Keeps msdk_d3d.c alive for the future.

https://bugzilla.gnome.org/show_bug.cgi?id=790752
2018-02-13 12:41:28 -09:00
Hyunjun Ko
3f9d0fcaa9 msdk: libva: adds utility function between mfx and libva
https://bugzilla.gnome.org/show_bug.cgi?id=790752
2018-02-13 12:39:44 -09:00
Hyunjun Ko
b45147a6d4 msdk: adds new utility functions for conversion from gstreamer to libmfx
https://bugzilla.gnome.org/show_bug.cgi?id=790752
2018-02-13 12:37:47 -09:00
Hyunjun Ko
8f0450dad4 msdk: move and rename the function msdk_video_alignment
Move the msdk_video_alignment function from decoder
to msdk.c and rename so that others could call this function
without duplicated declaration.

https://bugzilla.gnome.org/show_bug.cgi?id=790752
2018-02-13 12:36:46 -09:00
Nirbheek Chauhan
8f61785485 wasapisrc: Re-align device period if necessary
Same changes as done for wasapisink in cbe2fc40a. Turns out this is
sometimes also needed for capture. Reported by Mathieu_Du.

Also improve logging in that case for easier debugging.
2018-02-09 02:09:04 +05:30
Nirbheek Chauhan
9078a3a41d meson: Fix wasapi build on Windows
Was missing device prober and avrt (on msvc)
2018-02-08 14:41:33 +05:30
Nirbheek Chauhan
69b90224fa wasapi: Unprepare when src/sink_prepare fails
unprepare() is not called automatically on failure.

https://bugzilla.gnome.org/show_bug.cgi?id=793289
2018-02-08 14:30:38 +05:30
Nirbheek Chauhan
cbe2fc40a4 wasapisink: Re-align device period if necessary
Sometimes the minimum period advertised by a card results in an
unaligned buffer size error during initialization in exclusive mode.
In that case, we can fetch the actual buffer size in frames and
calculate the period from that.

We can't do this pre-emptively because we can't call GetBufferSize
till Initialize has been called at least once.

https://bugzilla.gnome.org/show_bug.cgi?id=793289
2018-02-08 14:29:58 +05:30
Nirbheek Chauhan
7f1d60da5b wasapisink: pre-load the buffer with silence
This reduces the chances of startup glitches, and also reduces the
chances that we'll get garbled output due to driver bugs.

Recommended by the WASAPI documentation.

https://bugzilla.gnome.org/show_bug.cgi?id=793289
2018-02-08 14:29:58 +05:30
Nirbheek Chauhan
4dbca8df09 wasapi: Try to use latency-time and buffer-time
So far, we have been completely discarding the values of latency-time
and buffer-time and trying to always open the device in the lowest
latency mode possible. However, sometimes this is a bad idea:

1. When we want to save power/CPU and don't want low latency
2. When the lowest latency setting causes glitches
3. Other audio-driver bugs

Now we will try to follow the user-set values of latency-time and
buffer-time in shared mode, and only latency-time in exclusive mode (we
have no control over the hardware buffer size, and there is no use in
setting GstAudioRingBuffer size to something larger).

The elements will still try to open the devices in the lowest latency
mode possible if you set the "low-latency" property to "true".

https://bugzilla.gnome.org/show_bug.cgi?id=793289
2018-02-08 14:29:58 +05:30
Nirbheek Chauhan
624de04fdb wasapi: Cover more HRESULT error messages
This requires using allocated strings, but it's the best option. For
instance, a call could fail because CoInitialize() wasn't called, or
because some other thing in the stack failed.

https://bugzilla.gnome.org/show_bug.cgi?id=793289
2018-02-08 14:29:58 +05:30
Nirbheek Chauhan
62b6224e37 wasapi: Increase thread priority to reduce glitches
This is particularly important when running in exclusive mode because
any delays will immediately cause glitching.

The MinGW version in Cerbero is too old, so we can only enable this when
building with MSVC or when people build GStreamer for MSYS2 or other
MinGW-based distributions.

To force-enable this code when building with MinGW, build with
CFLAGS="-DGST_FORCE_WIN_AVRT -lavrt".

https://bugzilla.gnome.org/show_bug.cgi?id=793289
2018-02-08 12:04:20 +05:30
Nirbheek Chauhan
6ecbb7556a wasapi: Allow opening devices in exclusive mode
This provides much lower latency compared to opening in shared mode,
but it also means that the device cannot be opened by any other
application. The advantage is that the achievable latency is much
lower.

In shared mode, WASAPI's engine period is 10ms, and so that is the
lowest latency achievable.

In exclusive mode, the limit is the device period itself, which in my
testing with USB DACs, on-board PCI sound-cards, and HDMI cards is
between 2ms and 3.33ms.

We set our audioringbuffer limits to match the device, so the
achievable sink latency is 6-9ms. Further improvements can be made if
needed.

https://bugzilla.gnome.org/show_bug.cgi?id=793289
2018-02-08 12:04:20 +05:30
Nirbheek Chauhan
4b388814af wasapi: Rename struct element for device name
We will use ->device for storing a pointer to the IMMDevice structure
which is needed for fetching the caps supported by devices in
exclusive mode.

https://bugzilla.gnome.org/show_bug.cgi?id=793289
2018-02-08 12:04:20 +05:30
Nirbheek Chauhan
3f1e039007 wasapi: Fix indentation issues missed by the commit hook
These were missed because the relevant commits were made on Windows
where `indent` wasn't installed.
2018-02-08 11:46:01 +05:30
Nirbheek Chauhan
538ccb6093 wasapi: Correctly set ringbuffer segsize/segtotal
This will set the actual-latency-time and actual-buffer-time of the sink
and source.

We completely ignore the latency-time/buffer-time values set
on the element because WASAPI is happiest when it is reading/writing at
the default period. Improving this will likely require the use of the
IAudioClient3 interfaces which are not available in MinGW yet.

https://bugzilla.gnome.org/show_bug.cgi?id=792897
2018-01-31 14:58:21 +05:30
Nirbheek Chauhan
ec6a10ed06 wasapi: Implement a device provider for probing
Currently only does probing and does not handle messages from
endpoints/devices. In the future we want to do proper monitoring which
is well-supported in WASAPI.

https://bugzilla.gnome.org/show_bug.cgi?id=792897
2018-01-31 14:58:21 +05:30
Nirbheek Chauhan
d6d31064b4 wasapi: Implement support for >2 channels
We need to parse the WAVEFORMATEXTENSIBLE structure, figure out what
positions the channels have (if they are positional), and reorder them
as necessary.

https://bugzilla.gnome.org/show_bug.cgi?id=792897
2018-01-31 14:58:21 +05:30
Nicolas Dufresne
a7c207630c kmssink: Make render rectangle property controllable
https://bugzilla.gnome.org/show_bug.cgi?id=792798
2018-01-30 10:02:14 +00:00
Justin Kim
297f7e4f04 ahc: enable autofocus callback
It should be enabled to set autofocus properly, but
it seems to be commented out mistakenly from the first commit.

https://bugzilla.gnome.org/show_bug.cgi?id=790945
2018-01-26 10:13:00 +00:00
Sebastian Dröge
357a5746b0 directsoundsrc: Add missing \ in multi-line #define 2018-01-25 21:23:09 +02:00
Sebastian Dröge
b174a91a1a directsoundsrc: Add support for a DeviceProvider
https://bugzilla.gnome.org/show_bug.cgi?id=792782
2018-01-25 20:20:08 +02:00
Nirbheek Chauhan
c8c32a7200 wasapi: Fix some leaks, bugs, and compiler warnings
Also improve logging.
2018-01-25 17:57:23 +05:30
Tim-Philipp Müller
07c8417799 nvenc: add "gop-size" property
This also changes the default gop size from 30 to 75 frames.

https://bugzilla.gnome.org/show_bug.cgi?id=781410
2018-01-24 10:39:40 +00:00
Tim-Philipp Müller
bea0ea66be nvenc: mark properties that can be changed at runtime accordingly
https://bugzilla.gnome.org/show_bug.cgi?id=781410
2018-01-24 10:21:48 +00:00
Ole André Vadla Ravnås
59365e3d7b nvenc: Add support for dynamic bitrate/preset reconfiguration
Useful for dynamically updating bitrate in live scenarios.

https://bugzilla.gnome.org/show_bug.cgi?id=781410
2018-01-24 10:17:58 +00:00
Ole André Vadla Ravnås
bc92b10164 nvenc: Add support for I420
https://bugzilla.gnome.org/show_bug.cgi?id=781410
2018-01-24 09:30:49 +00:00
Tim-Philipp Müller
2a40ab6ad6 decklink: don't crash if there are no decklink devices
Fixes generic/states check.
2018-01-23 14:49:51 +00:00
Tim-Philipp Müller
9bb905620c decklink: don't limit number of devices to 16
There is no fixed limitation for the number of devices on the
decklink API side according to BlackMagic. Many PC motherboards
are able support 6 decklink cards each with up to 8 inputs so
a limit of 16 might well be too low.

https://bugzilla.gnome.org/show_bug.cgi?id=777239
2018-01-23 14:14:35 +00:00
Sebastian Dröge
b691700f5e directsoundsrc: Don't dynamically load one DirectSound symbol at runtime
Just link statically to it, like for all other DirectSound symbols.
2018-01-22 15:24:56 +02:00
Nirbheek Chauhan
1450851095 wasapi: Rewrite most of the code to make it work
Both the source and the sink elements were broken in a number of ways:

* prepare() was assuming that the format was always S16LE 2ch 44.1KHz.
  We now probe the preferred format with GetMixFormat().
* Device initialization was done with the wrong buffer size
  (buffer_time is in microseconds, not nanoseconds).
* sink_write() and src_read() were just plain wrong and would never
  write or read anything useful.
* Some functions in prepare() were always returning FALSE which meant
  trying to use the elements would *always* fail.
* get_caps() and delay() were not implemented at all.

TODO: support for >2 channels
TODO: pro-audio low-latency
TODO: SPDIF and other encoded passthroughs

Three new properties are now implemented: role, mute, and device.

* 'role' designates the stream role of the initialized device, see:
   https://msdn.microsoft.com/en-us/library/windows/desktop/dd370842(v=vs.85).aspx
* 'device' is a system-wide GUIDesque string for a specific device.
* 'mute' is a sink property and simply mutes it.

On my Windows 8.1 system, the lowest latency that works is:

  wasapisrc buffer-time=20000
  wasapisink buffer-time=10000

aka, 20ms and 10ms respectively. These values are close to the lowest
possible with the IAudioClient interface. Further improvements require
porting to IAudioClient2 or IAudioClient3.

https://docs.microsoft.com/en-us/windows-hardware/drivers/audio/low-latency-audio
2018-01-22 14:18:53 +05:30
Víctor Manuel Jáquez Leal
568c552ac0 msdk: change plugin's description
There are not only encoders nowadays, there are decoders too and a
postprocessor in the future.
2018-01-11 11:29:38 +01:00
Sreerenj Balachandran
b6c26919df msdk: init the debug category for mpeg2dec
https://bugzilla.gnome.org/show_bug.cgi?id=792260
2018-01-10 18:24:07 -09:00
Sreerenj Balachandran
7536d12095 msdk: Add mpeg2 decoder
https://bugzilla.gnome.org/show_bug.cgi?id=792260
2018-01-10 10:40:24 -09:00
Vivia Nikolaidou
b5ff71fc3c decklinkaudiosrc: Extrapolate stream/hw reference timestamps when video frame is missing
Sometimes we might get an audio packet without a corresponding video
frame. In these cases, the stream and hardware reference timestamps
would be missing, because they're called on the video frame. Instead of
potentially breaking stuff downstream that might depend on these, we now
extrapolate them.

https://bugzilla.gnome.org/show_bug.cgi?id=792042
2018-01-04 15:51:16 +02:00
Vivia Nikolaidou
a3a7d2e0ff decklink: Detect gaps on incoming stream times, issue warnings
When we receive a video or audio buffer, we calculate the next stream
time based on the current stream time + buffer duration. If the next
buffer's stream time is after that, we issue a warning.

This happens because the stream time incoming from Decklink should be
really constant and without gaps. If there is a gap, it means that
something went wrong, e.g. the internal buffer pool is empty (too many
buffers queued up downstream).

https://bugzilla.gnome.org/show_bug.cgi?id=781776
2018-01-04 15:43:17 +02:00
Vivia Nikolaidou
42a03a8124 Revert "WIP: Revert "Revert "decklink: Detect gaps on incoming stream times, issue warnings"""
This reverts commit 8dceeb5ccd.
2018-01-04 15:41:51 +02:00
Vivia Nikolaidou
8ee1534b80 Revert "decklinkaudiosrc: Extrapolate stream/hw reference timestamps when video frame is missing"
This reverts commit 6af863916a.
2018-01-04 15:41:44 +02:00
Vivia Nikolaidou
6af863916a decklinkaudiosrc: Extrapolate stream/hw reference timestamps when video frame is missing
Sometimes we might get an audio packet without a corresponding video
frame. In these cases, the stream and hardware reference timestamps
would be missing, because they're called on the video frame. Instead of
potentially breaking stuff downstream that might depend on these, we now
extrapolate them.

https://bugzilla.gnome.org/show_bug.cgi?id=792042
2018-01-04 13:54:37 +02:00
Vivia Nikolaidou
8dceeb5ccd WIP: Revert "Revert "decklink: Detect gaps on incoming stream times, issue warnings""
This reverts commit 07819afda4.
2018-01-04 13:54:37 +02:00
Olivier Crête
e19e02db93 shmsink: Block in preroll_wait on unlock
The correct behaviour of anything stuck in the ->render() function
between ->unlock() and ->unlock_stop() is to call
gst_base_sink_wait_preroll() and only return an error if this returns an
error, otherwise, it must continue where it left off!

https://bugzilla.gnome.org/show_bug.cgi?id=774950
2017-12-19 17:41:43 -05:00
Marcin Lewandowski
9a128603c9 smhsink: Check return values of functions working on memory
https://bugzilla.gnome.org/show_bug.cgi?id=768530
2017-12-19 17:32:19 -05:00
Tim-Philipp Müller
f4b9d8c299 applemedia: don't include private cocoa gl header 2017-12-19 21:35:31 +00:00
Tim-Philipp Müller
3010afa976 applemedia: fix build after gl move to -base 2017-12-19 17:57:22 +00:00
Tim-Philipp Müller
06e4403fdb gl: update plugins to use GstGL from -base 2017-12-19 12:02:31 +00:00
Sebastian Dröge
2b8f82f929 decklinkaudiosink: Start audio pre-rolling if the output is not started yet in render()
This seems to allow to schedule audio samples correctly at their right
times already.

https://bugzilla.gnome.org/show_bug.cgi?id=790114
2017-12-14 10:37:20 +02:00
Sebastian Dröge
011649790d decklinkvideosink: Only start if both sinks are set to PLAYING already
Not only if the video sink is set to PLAYING so far. Also give more
useful debug output about why we don't start, and don't start if already
started.

Also refactor the function to early-return instead of having a huge
if-else block over the whole function.

https://bugzilla.gnome.org/show_bug.cgi?id=790114
2017-12-14 10:37:20 +02:00
Sebastian Dröge
a38cf7d8a9 decklinkaudiosink: Include final flow return in debug output
https://bugzilla.gnome.org/show_bug.cgi?id=790114
2017-12-14 10:37:20 +02:00
Sebastian Dröge
3e70f00209 decklinkaudiosink: Check also against the clock if we run ahead of the clock too much
The buffer level as reported by the Decklink driver is completely
unreliable, and we could otherwise easily run ahead >1s if we're
unlucky.

https://bugzilla.gnome.org/show_bug.cgi?id=790114
2017-12-14 10:37:20 +02:00
Sebastian Dröge
118b2967e7 decklinkaudiosink: Implement resampling/buffer reversing for trick-modes
https://bugzilla.gnome.org/show_bug.cgi?id=790114
2017-12-14 10:37:20 +02:00
Sebastian Dröge
86888d9918 decklinkaudiosink: Re-implement around GstBaseSink instead of GstAudioBaseSink
The Decklink and GstAudioBaseSink APIs don't fit very well together,
which causes various problems due to inaccuracies in the clock
calculations and the actual ringbuffer and GStreamer's copy getting of
sync.

Problems are audio drop-outs and A/V sync getting wrong after
pausing/seeking.

https://bugzilla.gnome.org/show_bug.cgi?id=790114
2017-12-14 10:37:20 +02:00
Josep Torra
5676005235 vtenc: fix a warning when building in MacOS 10.12
vtenc.c:564:20: error: incompatible pointer types passing 'GstVTEnc *' (aka 'struct _GstVTEnc *')
to parameter of type 'GstVideoEncoder *' (aka 'struct _GstVideoEncoder *')
2017-12-12 08:40:33 +01:00
Nicolas Dufresne
44dabe21d9 kmssink: Fix CropMeta support
We copy the meta's from the original buffer to the wrapper or copied
buffer.

https://bugzilla.gnome.org/show_bug.cgi?id=790473
2017-12-06 13:34:19 -05:00
Nicolas Dufresne
d33aff0fa0 kmssink: Enforce pixel aspect ratio when we cannot scale
When we cannot scale, we need to enforce the pixel aspect ratio.
This was partly implemented in the previous patch. Doing this
simplify some of the code.

https://bugzilla.gnome.org/show_bug.cgi?id=784599
2017-12-06 13:34:19 -05:00
Sebastian Dröge
02e4d92cbf decklinkvideosink: Wait until scheduled playback is actually stopped before continuing
Otherwise we might "start" again, just to get finally stopped and then
getting errors all over the place.

https://bugzilla.gnome.org/show_bug.cgi?id=790114
2017-12-06 19:38:55 +02:00
Ursula Maplehurst
236398ee3f androidmedia: when flushing, better handle IllegalStateException received from getOutputBuffer
1. Similar to 880f3d8, don't consider not getting an output buffer as
   an error during flushing. I've seen the following sometimes when
   encoding:

   W GStreamer+amcvideoenc: java.lang.IllegalStateException
   W GStreamer+amcvideoenc:         at android.media.MediaCodec.getBuffer(Native Method)
   W GStreamer+amcvideoenc:         at android.media.MediaCodec.getOutputBuffer(MediaCodec.java:2886)

2. For amcvideodec/enc, call _find_nearest_frame (which grabs a fresh
   reference on a GstVideoCodecFrame) after we have an output buffer,
   so as to not leak the reference, in case getting an output buffer
   fails.

   Otherwise, if we get an error grabbing the output buffer, we leak
   the reference to the frame. This can cause issues with a
   v4l2bufferpool feeding the encoder not being able to clean itself
   up properly due to buffers still being marked as in-use.

https://bugzilla.gnome.org/show_bug.cgi?id=791258
2017-12-06 10:32:02 +02:00
Nicolas Dufresne
737067e793 kmssink: Add display-width/height properties
This is to be used with gst_video_overlay_set_render_rectangle()
so the application can calculate a rectangle that fits inside
the display. The property changes are notify in a way that you
can watch either notify::display-width or notify::display-height
and both will be up-to-data when this is called back. Before the
element is started, the size will be 0x0.

https://bugzilla.gnome.org/show_bug.cgi?id=784599
2017-12-01 12:01:59 -05:00
Haihua Hu
b24bb73101 kmssink: support videooverlay interface
Implement videooverlay interface in kmssink, divided into two cases:
when driver supports scale, then we do refresh in show_frame(); if
not, send a reconfigure event to upstream and re-negotiate, using the
new size.

https://bugzilla.gnome.org/show_bug.cgi?id=784599
2017-12-01 09:44:47 -05:00
Haihua Hu
ff9a4390cb kmssink: add can-scale property
https://bugzilla.gnome.org/show_bug.cgi?id=784599
2017-12-01 09:44:47 -05:00
Edward Hervey
c9acaae376 uvch264src: Check return values of all xu_query calls
And use warnings/returns like for other calls

CID #1373414
CID #1373417
2017-11-24 08:06:52 +01:00
Hyunjun Ko
3301dd34b5 msdkdec: keep draining even if a finish_task fails
Should continue draining so that it could try to
discard the rest of pending frames even if a finish_task fails.

https://bugzilla.gnome.org/show_bug.cgi?id=790312
2017-11-23 10:08:13 +02:00
Edward Hervey
6c2b9a4fae dvb: Fix previous commit
strlen on strings (and not sizeof) *sigh*
2017-11-23 08:14:06 +01:00
Edward Hervey
e12a86995e dvb: Fix sock_addr usage (for real)
It was great checking that the string was not too big ... but
it's better if we actually copy the proper amount of bytes :)

CID #206004
2017-11-23 08:12:03 +01:00
Edward Hervey
5706178d54 ipcpipeline: Don't leak structure
CID #1416131
2017-11-23 08:09:36 +01:00
Edward Hervey
39cd2bf8fe ipcpipeline: Simplify usage of g_cond_wait_until()
It will return FALSE if a timeout happened. So don't check if we
timed out afterwards, just use the return value.

CID #1416347
2017-11-23 08:05:48 +01:00
Edward Hervey
00cfa72085 ipcpipeline: Check the proper value
The code is meant to check the *peer* state change return value
(and not the sink's one).

CID #1416128
2017-11-23 08:02:58 +01:00
Hyunjun Ko
0933b8b45a msdkdec: fix buffer leaks during drain and a leak of videobufferpool
https://bugzilla.gnome.org/show_bug.cgi?id=790312
2017-11-22 17:30:07 +02:00
Hyunjun Ko
ddd9355767 msdkenc: handle the MORE_DATA case
If the driver requires more data, just unref the frame at the moment
then retreive/finish the frame after encoding is finished.

This also fixes a memory leak.

https://bugzilla.gnome.org/show_bug.cgi?id=790312
2017-11-22 17:30:07 +02:00
Sebastian Dröge
e2c8afa261 decklinkvideosink: Print "Starting" instead of "Stopping" when starting 2017-11-22 17:22:03 +02:00
Matthew Waters
4e422bec4f nvdec: implement flush/drain
Fixes outputted frame sequence when performing a seek

i.e. when seeking backwards, the first frame after the seek was a frame
from the future.  This would result in GstVideoDecoder essentially
marking all the timestamps as essentially bogus and the base class would
attempt to compensate.  A visible indication of this was 'decreasing timestamp'
warning after a seek.

https://bugzilla.gnome.org/show_bug.cgi?id=790478
2017-11-22 14:34:33 +11:00
Nicolas Dufresne
72eebe7f53 kmssink: Add Raspberry Pi (vc4) support 2017-11-21 12:04:58 -05:00
Sebastian Dröge
538aae2404 msdkh264enc: Implement frame-packing SEI insertion for side-by-side and top-bottom
Ideally this would be supported directly in the Intel MediaSDK but
that's not the case nowadays.

https://bugzilla.gnome.org/show_bug.cgi?id=774920
2017-11-20 14:39:03 +02:00
Hyunjun Ko
3c611da315 msdkenc: Fix handling of YUY2, UYVY, BGRA surfaces
https://bugzilla.gnome.org/show_bug.cgi?id=789847
2017-11-20 14:38:34 +02:00
Sebastian Dröge
d3eeb98f0c msdkenc: Add support for YV12, YUY2, UYVY and BGRA
By doing conversion with VPP to NV12 before the actual encoding.

https://bugzilla.gnome.org/show_bug.cgi?id=789847
2017-11-20 14:38:25 +02:00
Vivia Nikolaidou
71bfbce84d decklink: Remove unused "bflags" variable
We are ignoring all its flags anyway, so let's remove it altogether.
2017-11-09 12:08:35 +02:00
Vivia Nikolaidou
5ab660c4e2 decklink: Ignore some driver-set timecode flags
The "fields" flag is ignored because currently GStreamer doesn't support
having only top or only bottom fields inside a frame. The "drop frame"
flag is ignored because some occurrences have been spotted where it
wasn't set while it should have been. In practice, when we have 29.97 or
59.94 FPS, it's always drop-frame.

https://bugzilla.gnome.org/show_bug.cgi?id=790112
2017-11-09 11:55:13 +02:00
Vivia Nikolaidou
bae9427dc1 decklink: Don't crash when getting hw serial number doesn't return OK
If the return value isn't OK, it means we might be getting data that
points to an invalid memory address. That shouldn't make us crash.
2017-11-09 00:19:42 +02:00
Vivia Nikolaidou
07819afda4 Revert "decklink: Detect gaps on incoming stream times, issue warnings"
This reverts commit c1294e10f9.

Was not ready to be pushed yet.
2017-11-07 21:12:42 +02:00
Vivia Nikolaidou
c1294e10f9 decklink: Detect gaps on incoming stream times, issue warnings
When we receive a video or audio buffer, we calculate the next stream
time based on the current stream time + buffer duration. If the next
buffer's stream time is after that, we issue a warning.

This happens because the stream time incoming from Decklink should be
really constant and without gaps. If there is a gap, it means that
something went wrong, e.g. the internal buffer pool is empty (too many
buffers queued up downstream).

https://bugzilla.gnome.org/show_bug.cgi?id=781776
2017-11-07 16:45:52 +02:00
Hyunjun Ko
66d2bce8ff msdk: fix to build msdkvp8dec with mfx_dispatch
https://bugzilla.gnome.org/show_bug.cgi?id=789751
2017-11-04 11:14:50 +02:00
Edward Hervey
b9e8ffb4be dvb: Fix sockaddr_un usage
The sun_path field needs to be NULL-terminated

CID #206004
2017-11-04 07:51:14 +01:00
Hyunjun Ko
cd2dca6275 msdk: adds msdkvp8dec
https://bugzilla.gnome.org/show_bug.cgi?id=789751
2017-11-01 11:33:50 +02:00
Sebastian Dröge
62f04e801b msdk: Allow building against mfx_dispatcher
E.g. from https://github.com/lu-zero/mfx_dispatch
2017-10-30 18:20:23 +02:00
Matthew Waters
dc6c4ea5c2 vtdec: destroy and create the GL context on start()/stop()
Removes a reference count loop
2017-10-30 17:19:40 +11:00
Nicola Murino
6165e07b62 vtdec: flush decoder on stop
fix a memory leak if the decoder shut down before EOS

https://bugzilla.gnome.org/show_bug.cgi?id=787311
2017-10-30 17:16:49 +11:00
Nicola Murino
889e735675 vtenc: flush encoder on stop
https://bugzilla.gnome.org/show_bug.cgi?id=787311
2017-10-30 17:16:29 +11:00
Nicola Murino
c808b4dd11 vtenc: fix memory leak
finish encoding and clean buffers queue on flush. This avoid a memory leak
if the element shuts down before EOS

https://bugzilla.gnome.org/show_bug.cgi?id=787311
2017-10-20 01:49:22 +11:00