Commit graph

76 commits

Author SHA1 Message Date
Nicolas Dufresne 2e76371666 v4l2: Fix use after free of fmtdesc part 2
Add missing code in merge commit e890e6e8d8
("v4l2: Fix use after free of fmtdesc"). The v4l2object code was
missing.

Related to https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4317

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4411>
2023-04-13 13:54:32 -04:00
Nicolas Dufresne e890e6e8d8 v4l2: Fix use after free of fmtdesc
The decoder needs to force another enumeration of the format. For
this it was clearing the v4l2object insternal list, leaving a fmtdesc
pointer pointing to freed memory. This patch clears the fmtdesc pointer
that has just been free. It also makes sure the probe function does not
use the cached formats list. The probe function will restore the current
fmtdesc pointer based on the currently configured pixelformat.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4317>
2023-04-13 15:32:14 +00:00
Nicolas Dufresne 3a17200638 v4l2: videodec: Prefer acquired caps over anything downstream
As we don't have anything smart in the fixation process, we may endup with
a format that has a lower bitdepth, even if downstream can handle higher
depth. it is notably the case when negotiating with deinterlace, which places
is non-passthrough caps before its passthrough one. This makes the generic
fixation prefer the formats natively supported by deinterlace element over
the HW 10bit format. As some HW can downscale 10bit to 8bit, this can break
10bit decoding.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4317>
2023-04-13 15:32:13 +00:00
Nicolas Dufresne 89854fd2f3 v4l2: videodec: Remove leading space in comment
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4317>
2023-04-13 15:32:13 +00:00
Alexande B 452c06782e osxvideosink: fix broken aspect ration and frame drawing region
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3336>
2023-04-05 09:48:34 +00:00
Shengqi Yu 8cf21fe744 v4l2object: Add support for YVU420M format
This is a multi-planar format with planes non contiguous in memory. It
is intended to be used only in drivers and applications that support the
multi-planar API.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4287>
2023-03-31 13:42:05 +00:00
Michael Tretter a11f811155 v4l2object: mark jpeg as parsed
Assuming that V4L2 CAPTURE devices always use one buffer per JPEG image, we can
always mark JPEGs provided by a V4L2 element as parsed.

The V4L2 elements require that JPEG images sent to V4L2 OUTPUT devices must
always be parsed.

This is necessary to link a V4L2 CAPTURE device with a V4L2 OUTPUT device
without explicitly marking the stream as parsed or adding a jpegparse into the
pipeline.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4229>
2023-03-21 14:58:15 +00:00
Sebastian Dröge ccad9a7338 plugins: Fix various trivial clang compiler warnings
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4210>
2023-03-18 16:16:55 +02:00
Tim-Philipp Müller 0fc568c6b1 gst-plugins-good: re-indent with GNU indent 2.2.12
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4182>
2023-03-17 03:18:54 +00:00
Khem Raj 817339c4de v4l2: Define ioctl_req_t for posix/linux case
this is an issue seen with musl based linux distros e.g. alpine [1]
musl is not going to change this since it breaks ABI/API interfaces
Newer compilers are stringent ( e.g. clang16 ) which can now detect
signature mismatches in function pointers too, existing code warned but
did not error with older clang

Fixes
gstv4l2object.c:544:23: error: incompatible function pointer types assigning to 'gint (*)(gint, ioctl_req_t, ...)' (aka 'int (*)(int, unsigned long, ...)') from 'int (int, int, ...)' [-Wincompatible-function-pointer-types]
    v4l2object->ioctl = ioctl;
                      ^ ~~~~~

[1] https://gitlab.alpinelinux.org/alpine/aports/-/issues/7580

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3950>
2023-02-14 20:36:28 +00:00
Pawel Stawicki 492d2b6498 v4l2h264dec: Fix Raspberry Pi4 will not play video in application
Ensure object v4l2object->pool will be released by
correctly releasing the temporary thread-safety lock

Fixes issue #1729

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3786>
2023-01-25 16:07:50 +00:00
Tim-Philipp Müller f6950b4537 v4l2: drop use of GSlice
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3695>
2023-01-24 15:25:07 +00:00
Nicolas Dufresne c4cd94f465 v4l2src: Fix crash in renegotiation
This regression was introduce by fix for making buffer pool thread safe. When
we renegotiate, the pool will be setup after we set the format. But the code
has been simplified to only get the pool once before, which caused a null
pointer deref.

Fixes 94ba019 ("v4l2: Fix SIGSEGV on 'change state' during 'format change'")
Related to !3481
Fixes #1626

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3513>
2022-12-02 19:25:52 +00:00
Pawel Stawicki 94ba019397 v4l2: Fix SIGSEGV on 'change state' during 'format change'
Ensure all access to v4l2object->pool imply taking a lock and a hard ref on the pool

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3481>
2022-12-01 12:47:54 +00:00
Elliot Chen 63ff99ca8e v4l2: bypass check some transfer types in colorimetry
v4l2 will report fail for some streams whose colorimetry value such as 2:4:8:3.
Can bypass check these transfer types in colorimetry to avoid error.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3440>
2022-11-23 13:06:29 +00:00
Nicolas Dufresne 5980fb76e7 video: Add arbitrary tile dimensions support
In current tile representation, only tiles with power of two
width and height in bytes are supported. This limitation
prevents adding more complex tiles formats.

In this patch, we deprecate tile_ws and tile_hs from GstVideoFormatInfo and
replace if with an array of GstVideoTileInfo. Each plane tiles are then
described with their pixels width/height, line stride and total size.
The helper gst_video_format_info_get_tile_sizes() that depends on the
deprecated API is also being removed. This can simply be removed as it wasn't
in any stable release yet.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3424>
2022-11-18 22:59:29 +00:00
F. Duncanh d77fe9495a v4l2videodec: Fixes three H.264/HEVC ITU conformance tests
Postpone the cleanup of any consecutive sequence of lost frames
which starts at frame 0, until frame 100 is dequeued from driver.

This allows fluster tests JVT/CVWP2_TOSHIBA_E, JVC/CVWP3_TOSHIBA_E
and HEVC/POC_A_Bossen_3 that sends out-of-order frames to successfully
complete  (e.g., test of Amphion vpu driver).

Fixes #1569

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3398>
2022-11-16 10:00:03 +00:00
Jakub Adam 2125dbbd0b ximagesrc: grab the server while capturing screen image
Makes sure screen resolution doesn't change in the middle of the
process.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1562>
2022-10-27 18:42:38 +00:00
Jakub Adam c93afcc99c ximagesrc: change video resolution when X11 screen gets resized
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1562>
2022-10-27 18:42:38 +00:00
Edward Hervey c37182b6b9 oss4: Fix debug category initialization
Fixes https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/1456

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3158>
2022-10-11 13:02:54 +00:00
Elliot Chen e76e98d109 v4l2videodec: add cap negotiation fail check in the capture configuration change
The capture configuration change may cause negotiation fail.
Need to check it to avoid enter the endless loop.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2960>
2022-09-17 21:21:22 +00:00
Thibault Saunier 6a4425e46a meson: Call pkgconfig.generate in the loop where we declare plugins dependencies
Removing some copy pasted code

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2970>
2022-09-01 21:17:35 +00:00
Jianhui Dai 625e74100d v4l2allocator: Fix invalid imported dmabuf fd
Fix a typo that set userptr to dmabuf fd. It leads to failure of
dmabuf-import io-mode.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2935>
2022-08-24 09:59:14 +00:00
Nicolas Dufresne d126f65485 v4l2bufferpool: Fix debug trace
The tracing of the buffer pointer was done on the secondary pointer, which
does not match with other traces of the same buffer. This made the trace
confusing and less useful.

Fixes #1379

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2893>
2022-08-16 14:33:24 +00:00
fduncanh 197b72f32a v4l2object.c: add support for Apple's full-range bt709 colorspace variant
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2793>
2022-07-26 15:14:41 +00:00
Elliot Chen e0564b04c6 v4l2: fix the critical log when unreference the buffer with no data
In the trick mode, driver may queue a valid buffer follow by an
empty buffer which has no valid data to indicate EOS.For the empty
buffer whose memory is multi-plane, need to resize it before
unreference it.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2731>
2022-07-25 16:44:05 +08:00
Nirbheek Chauhan 41bf3f6c1b osxaudio: Fix deprecation in macOS 12.0
kAudioObjectPropertyElementMaster has been renamed to
kAudioObjectPropertyElementMain

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2761>
2022-07-16 06:16:17 +00:00
fduncanh 735723c230 v4l2videodec: replace multiple decoder bug warnings with single one
Achieve this by dropping frames after a drain if the driver failed to so.
This works around RaspberryPi driver issue [1].

[1] https://github.com/raspberrypi/linux/issues/5059#issuecomment-

Fixes #1103

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2518>
2022-07-02 23:56:00 +00:00
fduncanh dfeb8198e4 v4l2videodec: replace multiple decoder bug warnings by a single warning
(warning due to incorrectly dropped frames at initial caps adjustment)

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2517>
2022-06-29 19:50:15 +00:00
Nicolas Dufresne 7c40fcb66e v4l2videodec: Fix activation of internal pool
If the driver does not support VIDIOC_CREATE_BUFS ioctl, the pool
configuration may get changed, which requires a validation. This would
fail to activate a pool in a case it shouldn't normally fail unless we
are out of memory.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2456>
2022-06-28 16:19:53 +00:00
Ignacio Casal Quinteiro 408f37c1d9 osxaudio: remove usage of goto
It is easier to follow the code without the goto now

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2251>
2022-06-08 06:28:17 +00:00
Ignacio Casal Quinteiro caa5972abd osxaudio: support hidden devices
macOS features hidden devices. These are devices that will
not be shown in the macOS UIs and that cannot be retrieved
without having the specific UID of the hidden device. There
are cases when you might want to have a hidden device, for example
when having a virtual speaker that forwards the data to a virtual
hidden input device from which you can then grab the audio.
The blackhole project supports these hidden devices and
this patch provides a way that if the device id is a hidden
device it will use it instead of check the hardware list of devices
to understand if the device is valid.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2251>
2022-06-08 06:28:17 +00:00
Ignacio Casal Quinteiro 243f8e8882 osx: fix indent
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2251>
2022-06-08 06:28:17 +00:00
Ignacio Casal Quinteiro 57fed3c911 osxaudio: iterate device only if needed
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2251>
2022-06-08 06:28:17 +00:00
Ignacio Casal Quinteiro a4a4d295a1 osxaudio: reduce scope of default device id variable
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2251>
2022-06-08 06:28:17 +00:00
Hou Qi 7f2fb3b783 v4l2: Reset transfer in gst_v4l2_object_acquire_format()
get_colorspace() checks input caps transfer when mapping V4L2_XFER_FUNC_709
back to V4L2_COLORSPACE_BT2020 and GST_VIDEO_TRANSFER_BT2020_12. After
receiving source change event, decoder will G_FMT and S_FMT again. So need
to reset transfer when acquiring format to avoid using the old transfer.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2475>
2022-05-26 17:09:28 +00:00
Nicolas Dufresne 6d6ebbbb36 v4l2videodec: Fix missing handling of resolution-change
The pool process function may poll and get the resolution-change event
whenever it is not possible to share our buffers. This typically happen
when downstream does not support GstVideoMeta.

Not handling this would cause the decoder thread to exit silently and the
pipeline to stall.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2457>
2022-05-24 18:02:12 +00:00
Nicolas Dufresne 4e441417b8 v4l2videodec: Downgrade to info resolution-change trace
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2457>
2022-05-24 18:02:12 +00:00
Hou Qi 85b53bb65d v4l2: set default resolution if caps has no such information
Output may attemp to set the width and height to zero values if
caps has no such information, which will cause capture get invalid
dimensions. Then decoder reports negotiation failure.

So need to set default resolution if caps has no such information.
Real values can be set again until source change event is signaled.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2400>
2022-05-20 12:23:40 +00:00
Nicolas Dufresne 522f19e013 v4l2videoenc: Setup crop rectangle if needed
Hantro H1 and Rockchip VEPU2 drivers will pad the width/height to a
multiple of 16. In order to obtain the right JPEG size, the image needs
to be cropped using the S_SELECTION API. This support is added as best
effort since older drivers may emulate this by looking at the capture
queue width/height.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2329>
2022-05-07 11:35:14 +00:00
Xavier Claessens b99ecc78ca Replace gst-i18n-*.h with gi18n-lib.h
GLib guarantees libintl is always present, using proxy-libintl as
last resort. There is no need to mock gettex API any more.

This fix static build on Windows because G_INTL_STATIC_COMPILATION must
be defined before including libintl.h, and glib does it for us as part
as including glib.h.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2028>
2022-04-19 18:01:06 +00:00
Hou Qi 8dcb8a28af v4l2videodec: copy colorimetry values to output_state caps
This is to avoid transcoding negotiation fail between v4l2h265dec
and v4l2h264enc caused by colorimetry mismatch.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2192>
2022-04-18 13:17:55 +00:00
Ming Qian dce02a870e v4l2: Add NV12_8L128 in gst_v4l2_object_get_caps_info
It should be included in
<https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1379>

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2158>
2022-04-13 07:20:58 +00:00
Ming Qian 6af66167d0 v4l2: Add a missed break
Fix a typo that miss a break in the switch statement

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2158>
2022-04-13 07:20:58 +00:00
Matthew Waters 5d76ddb466 osxcoreaudio: fix unused-but-set warning
../sys/osxaudio/gstosxcoreaudio.c:480:18: error: variable 'interleaved' set but not used [-Werror,-Wunused-but-set-variable]
  gboolean sign, interleaved;
                 ^

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2046>
2022-03-28 10:30:23 +00:00
Matthew Waters aa6c674dd8 osxvideosink: fix unused-but-set-variable warning
../sys/osxvideo/osxvideosink.m:859:11: error: variable 'data' set but not used [-Werror,-Wunused-but-set-variable]
  guint8 *data, *readp, *writep;
          ^

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2040>
2022-03-28 09:50:38 +11:00
Ming Qian 2861bd9456 v4l2: Add NV12_8L128 and NV12_10BE_8L128
These formats are used by i.MX 8QXP/8QM VPU.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1379>
2022-03-22 00:41:39 +00:00
Hou Qi b962126b06 v4l2videodec: set frame duration according to framerate
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1953>
2022-03-16 14:15:04 +00:00
Hou Qi 738dbf1cb7 v4l2videodec: safely retrun from video_dec_loop with stream unlock
This is to avoid decoder hang when doing trick play between
different resolutions.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1960>
2022-03-16 02:13:00 +00:00
Damian Hobson-Garcia 70086fda22 v4l2src: Add support for cropping at capture source input
Add properties to control input cropping in the V4L2 device.
The input cropping is applied before composing the result to the
capture buffer.  By default the capture size will be set to the same
size as the crop region, but it can be scaled to a different output
frame size if supported by the V4L2 device.
If scaling is not supported, the cropped image will
be composed as is into the top-left corner of the capture buffer.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1089>
2022-03-11 15:02:08 +00:00