Commit graph

347 commits

Author SHA1 Message Date
Whoopie
2d774554e9 v4l2object: Disable DMABuf for emulated formats
libv4l2 does not prevent exporting DMABuf even when emulated formats are
in use. As a side effect, userspace ends up with buffers of the original
formats which will cause issues.

https://bugzilla.gnome.org/show_bug.cgi?id=795097
2018-04-11 22:19:10 -04:00
Nicolas Dufresne
ebf8a6d0c0 v4l2object: Only use BT2020_12 for BT2020 v4l2 colorspace
BT2020_12 is not represented in V4L2, so drivers providing full colority
for BT2020 will set V4L2_XFER_FUNC_709 transfer function. To fix the
issue, we bump this to BT2020_12 if the resoltion is 4K, but we should
only do that if the colorspace is BT2020 to start with, otherwise it's
not possible to use normal BT709 for 4K 8bit formats.
2018-04-11 22:19:10 -04:00
Nicolas Dufresne
dd1c5aed65 v4l2object: Always set the colorimetry in S_FMT
So far we were only setting colorimetry for OUTPUT devices (v4l2sink or
m2m sink pad). This prevented selecting through caps negotiation the
colorimetry for CAPTURE devices (v4l2src or m2m src pad). This is rarely
selectable, but trying is harmless.
2018-04-11 22:19:10 -04:00
Seungha Yang
c4d13683f6 v4l2: Fix unknown type name ‘off_t’ error
Fix following build error

gstv4l2object.h:197:17: error: unknown type name ‘off_t’
       gint fd,  off_t offset);
                 ^

https://bugzilla.gnome.org/show_bug.cgi?id=794533
2018-03-27 13:46:58 -04:00
Nicolas Dufresne
7d4702e2fb v4l2: Fix support for 32bit mmap
https://bugzilla.gnome.org/show_bug.cgi?id=793103
2018-03-07 14:16:24 -05:00
Guillaume Desmottes
f7e280bf0d v4l2: fix division by 0 for complex video formats
So complex video formats have 0 as pstride. Don't try to divide the
stride in such cases.

https://bugzilla.gnome.org/show_bug.cgi?id=792596
2018-01-17 13:32:58 -05:00
Guillaume Desmottes
3bbfd15047 v4l2: display stride and width values if stride is too small
https://bugzilla.gnome.org/show_bug.cgi?id=792596
2018-01-17 13:32:58 -05:00
Nicolas Dufresne
97985a335c v4l2videodec: Add dynamic resolution change support
This implements a "big hammer" reallocation method. We effectively
drain and stop both side of the decoder and restart. This though is
the most generic method. This change should enable on most drivers
adaptive streaming.

https://bugzilla.gnome.org/show_bug.cgi?id=752962
2018-01-08 17:16:22 -05:00
Nicolas Dufresne
80815c292a v4l2object: Don't redefine mmap64
On Linux, there exist a case where mmap64 is already a define to mmap,
so avoid the redefine warning here.
2017-12-22 10:30:49 -05:00
Ting-Wei Lan
4026211154 v4l2object: Don't use mmap64 if off_t is 64-bit
The difference between mmap and mmap64 is the type of 'offset' argument.
mmap64 always uses a 64-bit interger as offset, while mmap uses off_t,
whose size can vary on different operating systems or architectures.

However, not all operating systems support mmap64. Fortunately, although
FreeBSD only has mmap, its off_t is always 64-bit regardless of
architectures, so we can simply use mmap when sizeof(off_t) == 8.

https://bugzilla.gnome.org/show_bug.cgi?id=791779
2017-12-22 10:30:49 -05:00
Nicolas Dufresne
24f01944ee Revert "v4l2object: Use mmap64 to match libv4l2 signature"
This reverts commit b61bba4848.
2017-12-22 10:30:13 -05:00
Ting-Wei Lan
784348235a v4l2object: Check for mmap64 before using it
mmap64 is not available on FreeBSD.

https://bugzilla.gnome.org/show_bug.cgi?id=791779
2017-12-21 21:58:29 -05:00
Nicolas Dufresne
e575e4eda8 v4l2object: Use a debug object for tracing
This way we can pass the pad name instead of the element for tracing
which helps identifying which v4l2object is used withing M2M element
like decoder, encoder and transform. For the reference, pads are name
<parent-name>:<pad-name>.
2017-12-13 14:42:25 -05:00
Florent Thiéry
a315810640 v4l2object: Fix dmabuf support detection
This resulted in improper selection of dmabuf on unsupported drivers.
The checked ioctl errno was not correct.

https://bugzilla.gnome.org/show_bug.cgi?id=790940
2017-11-29 10:13:44 -05:00
Tim-Philipp Müller
97285753fc v4l2: fix build without libv4l
https://bugzilla.gnome.org/show_bug.cgi?id=779466
2017-10-07 15:39:47 +01:00
Enrico Jorns
e9c00c083b v4l2object: auto-detect dmabuf export for V4L2_IO_AUTO on capture side
Issue an invalid VIDIOC_EXPBUF ioctl to the driver to check if the
driver supports dmabuf export. If the driver does not implement the
IOCTL, the error is ENOTTY. Any other error codes mean that the driver
implements VIDIOC_EXPBUF.

https://bugzilla.gnome.org/show_bug.cgi?id=779466
2017-10-05 21:20:19 -04:00
Nicolas Dufresne
c56eb21a82 v4l2object: Don't leak the par value 2017-09-13 11:52:09 -04:00
Ian Jamison
85ec6430d9 v4l2object: Handle BT2020 for colorspace and transfer
This was not fully handled in switches and
ub gst_v4l2_object_get_colorspace();

https://bugzilla.gnome.org/show_bug.cgi?id=787313
2017-09-06 11:33:53 -04:00
Ian Jamison
fc5d9c34a7 v4l2object: Fix colorimetry transfer lookup for 4K video
https://bugzilla.gnome.org/show_bug.cgi?id=787160
2017-09-06 11:33:53 -04:00
Nicolas Dufresne
0e9fe263ca v4l2: Enable VP9 format
This was missing, preventing the encoder and decoder to work
properly. This also adds support for camera that would produce
VP9 (if that exists).
2017-08-02 17:13:55 -04:00
Nicolas Dufresne
b61bba4848 v4l2object: Use mmap64 to match libv4l2 signature
https://bugzilla.gnome.org/show_bug.cgi?id=785628
2017-08-01 15:05:35 -04:00
Nicolas Dufresne
33f508d508 v4l2object: Removed unused members 2017-07-24 14:27:05 -04:00
Nicolas Dufresne
31d8a1d929 v4l2: Add run-time environment to enable libv4l2
The library has started preventing a lot of interesting use cases,
like CREATE_BUFS, DMABuf, usage of TRY_FMT. As the libv4l2 is totally
inactive and not maintained, we decided to disable it. As a convenience
we added a run-time environment that let you enable it for testing.

  GST_V4L2_USE_LIBV4L2=1

This of course only works if you have enabled libv4l2 at build time.
2017-07-24 14:19:02 -04:00
Nicolas Dufresne
4bcec1b190 v4l2object: Fix colorimetry validation
While not documented, gst_video_colorimetry_matches() only accepts well
known names. Looking at the code and unit test, this seems to be on
purpose, so fixing by parsing the string and compating the colorimetry
structures.
2017-07-21 23:34:59 -04:00
Nicolas Dufresne
cae0b9a2d2 v4l2object: Introduce quirk to skip slow probes
skip_try_fmt_probes quirk is set, V4L2 object will not probe for
interlace-mode and colorimetry to avoid relying on try_fmt. This quirk
will be used by v4l2src to avoid desastrous startup time with slow
USB webcams.

When this quirk is enabled, caller will have to iterate over the
negotiated caps as it may contains unsupported formats. If the peer
didn't choose a specific interlace-mode, or colorimetry, the value
chosen by the driver is set into the caps. For this reason, when this
mode is enabled, gst_v4l2_object_set_format() will require writable
caps.

https://bugzilla.gnome.org/show_bug.cgi?id=785156
2017-07-21 15:29:10 -04:00
Nicolas Dufresne
7d3b2628df v4l2object: always set the GstV4l2Error on error
Some of the error case were conditional to using try_fmt or not.
This is slightly unexpected, always set the error so the caller
can decide.

https://bugzilla.gnome.org/show_bug.cgi?id=785156
2017-07-21 15:29:10 -04:00
Nicolas Dufresne
059ccf9749 v4l2object: Minor style fix and useful trace
https://bugzilla.gnome.org/show_bug.cgi?id=785156
2017-07-21 15:29:10 -04:00
Nicolas Dufresne
c00d4cae3c v4l2object: Fix try/s_fmt errors
According to the spec,TRY_FMT cannot return EBUSY, though it can
return EINVAL if it was not possible to update the format to
something supported.

https://bugzilla.gnome.org/show_bug.cgi?id=785156
2017-07-21 15:29:10 -04:00
Nicolas Dufresne
558e9f4e57 v4l2object: Validate colorimetry in S/TRY_FMT
This is in preparation for removing slow TRY_FMT probes for
colorimetry. As we won't have tried that colorimetry we cannot
assume the driver will accept it.

https://bugzilla.gnome.org/show_bug.cgi?id=785156
2017-07-21 15:29:10 -04:00
Nicolas Dufresne
336c8a7dad v4l2object: Validate field in S/TRY_FMT
This is in preparation from removing the slow TRY_FMT probes for
interlacing. As we won't have tried that interlace-mode already
we need to validate that the driver isn't refusing it.

https://bugzilla.gnome.org/show_bug.cgi?id=785156
2017-07-21 15:29:10 -04:00
Nicolas Dufresne
6d0a9abdf0 v4l2: Fix 4K colorimetry
Since 1.6, the transfer function for BT2020 has been changed from BT709
to BT2020_12. It's the same function, but with more precision. As a side
effect, the V4L2 colorpsace didn't match GStreamer colorspace. When
GStreamer ended up making a guess, it would not match anything supported
by V4L2 anymore. This this by using BT2020_12 for BT2020 colorspace and
BT2020 transfer function in replacement of BT709 whenever a 4K
resolution is detected.
2017-07-18 12:03:17 -04:00
Nicolas Dufresne
08643993df v4l2object: Only check CROPCAP for par once
The pixel aspect ratio is documented to not change unless the TV
Standard is changed. So this mean that this will be uniform across all
possible format and resolutions.

https://bugzilla.gnome.org/show_bug.cgi?id=784674
2017-07-18 12:03:17 -04:00
Nicolas Dufresne
83cb5ef957 v4l2object: Remove unused defines 2017-07-17 20:48:28 -04:00
Nicolas Dufresne
bec03858fa v4l2: Merge v4l2_calls.h into gstv4l2object.h
First step of a larger cleanup, all function from v4l2_calls are in fact
methods on GstV4l2Object. This split makes the code really confusing.
This also remove no longer unused macros.
2017-07-17 20:48:28 -04:00
Nicolas Dufresne
3bbd43f7eb v4l2object: Trace unknown fourcc as text
This makes it easier to find out what is not supported.
2017-07-14 13:31:30 -04:00
Nicolas Dufresne
06424c438e v4l2: Don't probe for unneeded format
For v4l2videodec/enc, we generate elements per formats, and in
this case we can speed up the start up by only probing the format
we care about.
2017-07-14 13:31:30 -04:00
Guillaume Desmottes
47ca2ce499 v4l2: increase by one the number of allocated buffers
Increasing this number fix a buffer starvation problem I'm hitting
with a "v4l2src ! kmssink" pipeline.

kmssink requests 2 buffer as it keeps a reference on the last rendered
one. So we were allocating 3 buffers for the pipeline.
Once the first 2 buffers have been pushed we ended up with:
- one buffer queued in v4l2
- one being pushed
- one kept as last rendered

If this 3rd buffer is released after that v4l2 used the first one to
capture we end up with a buffer starvation problem as no buffer is currently
queued in v4l2 for capture.

Fixing this by adding one extra buffer to the pipeline so when one
buffer is being pushed downstream the other can already be queued to
capture the next frame.

We were already adding 3 buffers if downstream didn't reply to the
allocation query. I reduced this number to 2 to compensate the extra
buffer which is now always added.

https://bugzilla.gnome.org/show_bug.cgi?id=783049
2017-06-29 15:13:18 -04:00
Ayaka
342de49bf6 v4l2: increase pre-allocated encoded buffer size
As of today, the MFC encoder often need to exceed that 1 MB
size for encoded buffer we fixed earlier for decoding.

https://bugzilla.gnome.org/show_bug.cgi?id=728438
2017-05-24 14:00:22 -04:00
Philipp Zabel
ce5c0b8f92 v4l2object: set streamparm for outputs that support it
Without a specified framerate from the sink, the decoder frame interval
should be set using the framerate of the encoded video stream.
Therefore, the v4l2object should be able to change the framerate on the
output if the V4L2 device accepts it.

This is also necessary for mem2mem encoders so that their bitrate
calculation code may work correctly and they may report the correct
frame duration on the capture queue.

https://bugzilla.gnome.org/show_bug.cgi?id=779466
2017-04-05 09:26:05 -04:00
Carlos Rafael Giani
79d9cd44b6 v4l2object: Also add videometa if there is padding to the right and bottom
https://bugzilla.gnome.org/show_bug.cgi?id=780478
2017-03-24 13:57:10 -04:00
Olivier Crête
75d2a57783 v4l2: Remove unused definitions 2017-03-14 16:35:25 -04:00
Edgard Lima
8635258046 Update Edgard Lima's email
https://bugzilla.gnome.org/show_bug.cgi?id=779230
2017-02-27 00:34:19 +00:00
Nicolas Dufresne
0b83e4ceaf v4l2object: Update image size when extrapolating
Update the image size according the amount of data we are going to
read/write. This workaround bugs in driver where the sizeimage provided
by TRY/S_FMT represent the buffer length (maximum size) rather then the expected
bytesused (buffer size).

https://bugzilla.gnome.org/show_bug.cgi?id=775564
2017-02-22 03:53:30 -05:00
Reynaldo H. Verdejo Pinochet
b460f18f17 v4l2: fix typo in _acquire_format() error messages
Fixes:

https://bugzilla.gnome.org/show_bug.cgi?id=778815
2017-02-21 10:17:56 -08:00
Juan Pablo Ugarte
b6723ecd3c v4l2object: mark singleton caps as "may be leaked" objects.
Set MAY_BE_LEAKED flag on static pads returned by gst_v4l2_object_get_*_caps()
functions. Made functions thread safe by using g_once_init[enter|leave]
funtions.

https://bugzilla.gnome.org/show_bug.cgi?id=778453
2017-02-10 16:35:53 -05:00
Enrico Jorns
eb25b058f9 v4l2: Remove usage and definition of LOG_CAPS macro
Unlike former definitions of LOG_CAPS, the current implementation simply
expands to GST_DEBUG_OBJECT. The LOG_CAPS macro is rarely used and most
uses duplicate already existing GST_DEBUG_OBJECT lines. Therefore, the
caps are often printed twice which unnecessarily clutters the debug log.

Replace LOG_CAPS calls with GST_DEBUG_OBJECT, remove LOG_CAPS calls, and
delete the definition of LOG_CAPS.

https://bugzilla.gnome.org/show_bug.cgi?id=776899
2017-01-16 10:29:47 -05:00
Víctor Manuel Jáquez Leal
6ec3cc70b2 v4l2object: Don't check size in a non-list value
After commit 1ea9735a I see these error while using the webcam
integrated in my laptop:

GStreamer-CRITICAL **: gst_value_list_get_size: assertion 'GST_VALUE_HOLDS_LIST (value)' failed

The issue is gst_v4l2src_value_simplify() was doing its job of
generating a single value, rather than the original list. That why,
when getting the list size, a critical warning was raised.

This patch takes advantage of the compiler optimizations to verify
first if the list was simplified, thus use it directly, otherwise,
if it is a list, verify its size.

https://bugzilla.gnome.org/show_bug.cgi?id=776106
2016-12-14 19:22:36 +01:00
Arun Raghavan
1ea9735afb v4l2object: Don't set empty interlace-mode list
If for some reason we fail to probe formats (all try_fmt calls fail, for
example), this is not a critical error, but we end up with an empty list
of interlace modes. This causes all subsequent negotiation to fail.

This patch fixes interlace-mode setting to be skipped if we failed to
detect any.

https://bugzilla.gnome.org/show_bug.cgi?id=775702
2016-12-08 10:13:39 +05:30
Tobias Schneider
932adb1968 v4l2object: fix extra-controls leak
Gst struct v4l2object->extra_controls is created if user sets appropriate
option but it is not freed on destruction of v4l2object.

https://bugzilla.gnome.org/show_bug.cgi?id=773580
2016-10-31 12:06:27 -04:00
Nicolas Dufresne
f0678d73b1 v4l2object: Don't assert when used by the monitor
The monitor sets the object->element object as a GstObject. This
works for debug traces, but will assert for ELEMENT_ERROR. This
was the only case where that could happen. Add a check for that.
2016-07-11 19:17:49 -04:00