Commit graph

406 commits

Author SHA1 Message Date
Philipp Zabel
91dd9c1929 v4l2object: fix typo in comment
https://bugzilla.gnome.org/show_bug.cgi?id=796940
2018-08-21 12:01:41 -04:00
Philipp Zabel
02d3f9748b v4l2object: improve colorspace handling for JPEG sources
gstjpegdec sets 1:4:0:0 colorimetry (full range BT.601 YCbCr encoding
with unknown primaries and unknown transfer function). This currently
gets translated to bt601 or bt709 depending on resolution.
Both cases result in a negotiation failure:

    ERROR: from element /GstPipeline:pipeline0/v4l2video0convert:v4l2video0convert0: Device '/dev/video0' does not support 1:4:0:0 colorimetry

Improve the guessing game by selecting JPEG colorimetry (JPEG colorspace
with sRGB transfer function) under these specific conditions, and loosen
the matching so that 1:4:0:0 input gets accepted if the device is
actually configured to 1:4:7:1 (V4L2_PIX_FMT_JPEG default).

https://bugzilla.gnome.org/show_bug.cgi?id=796940
2018-08-21 12:01:41 -04:00
Philipp Zabel
9595fd08e3 v4l2object: stop V4L2 from zeroing extended colorimetry for non-mplane
Setting the priv field to a magic value stops V4L2 core from zeroing
the extended colorimetry fields quantization, ycbcr_enc, and xfer_func
for non-mplane queues.

https://bugzilla.gnome.org/show_bug.cgi?id=796940
2018-08-21 12:01:41 -04:00
Zeeshan Ali
af27ecae3f v4l2: Remove a trailing whitespace
Otherwise, the latest gst-indent check doesn't pass.
2018-08-19 15:39:16 +02:00
Iñigo Huguet
3f360e8f15 v4l2src: fix first input used is always used next times
The input from an v4l2 device that was used the first time was
remembered for next times, and set again always the pipeline is
set to READY state. This was making that users wasn't able to
select a different input without having to create a new pipeline.

This patch makes that v4l2src element forget previous used input
when going to NULL state, so it will check again for the current
selected input when going again to READY state. Users can change
to NULL state, select a new input with a VIDIOC_S_INPUT ioctl
and change to PLAYING again.

https://bugzilla.gnome.org/show_bug.cgi?id=796908
2018-08-02 08:00:44 -04:00
Nicolas Dufresne
b12b8b0b22 v4l2src: Try to avoid TRY_FMT when camera is streaming
Some camera firmware crash is TRY_FMT is called during streaming. As a
side effect. This try and detect that the same format as currently
running is about to be tried, and skip renegotiation.

https://bugzilla.gnome.org/show_bug.cgi?id=796789
2018-07-11 19:05:00 -04:00
Nicolas Dufresne
b677ae3cb6 v4l2object: Really always set colorimetry
This fixes patch dd1c5aed65 which
pretended to always set colorimetry but the patch was incomplete.
This is again best effort considering the spec says that for CAPTURE
you may only read this value.
2018-06-27 16:57:29 -04:00
Philipp Zabel
32fa1e7a65 v4l2object: use S_SELECTION instead of S_CROP in gst_v4l2_object_set_crop
The S_CROP call doesn't work on mem2mem output queues. Use the
S_SELECTION call to set the crop rectangle and only fall back to
S_CROP for ancient kernels.
This will allow v4l2videoenc to set the coded size on the output
queue via S_FMT and then set the visible size via the crop rectangle,
as required by the V4L2 codec API.

https://bugzilla.gnome.org/show_bug.cgi?id=796672
2018-06-27 16:31:39 -04:00
Nicolas Dufresne
f72c7131ae v4l2object: Don't open the device in get property
This is both racy and inefficient. This function is still missing some
locking which will be address in later patch.

https://bugzilla.gnome.org/show_bug.cgi?id=796185
2018-05-28 12:58:45 -04:00
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
Nicolas Dufresne
e62bd2f7d8 v4l2object: Indent very long line 2016-07-11 19:17:49 -04:00
Reynaldo H. Verdejo Pinochet
4b16b16aaf v4l2: use opened device caps instead of physical device ones
The same physical device can export multiple devices. In
this case, the capabilities field now contains a union of
all caps available from all exported V4L2 devices alongside
a V4L2_CAP_DEVICE_CAPS flag that should be used to decide
what capabilities to consider. In our case, we need the
ones from the exported device we are using.

https://bugzilla.gnome.org/show_bug.cgi?id=768195
2016-07-07 17:46:06 -04:00
Nicolas Dufresne
e31c6aa427 v4l2object: Coding style fixes 2016-06-07 17:02:47 -04:00
Nicolas Dufresne
3b5cac3659 v4l2: Add an error return to _try/_set_format
This way one can easily ignore errors. Previously, error were always
posted ont he bus.

https://bugzilla.gnome.org/show_bug.cgi?id=766172
2016-06-07 17:02:43 -04:00
Philipp Zabel
616ccbb0db v4l2object: fill colorimetry in gst_v4l2_object_acquire_format
Instead of relying on the default colorimetry chosen by
gst_video_info_set_format(), set info.colorimetry from the
values returned by G_FMT. This allows decoders to propagate
their input colorimetry downstream.

https://bugzilla.gnome.org/show_bug.cgi?id=766383
2016-06-06 17:39:26 -04:00
Philipp Zabel
b5530a19a7 v4l2object: refactor gst_v4l2_object_get_colorspace to take a v4l2_format parameter
Move the extraction of colorimetry parameters from struct v4l2_format and the
setting of the identity matrix for RGB formats into the function to avoid code
duplication.

https://bugzilla.gnome.org/show_bug.cgi?id=766383
2016-06-06 17:39:26 -04:00
Philipp Zabel
74f020fd2f v4l2object: use G_SELECTION instead of G_CROP in gst_v4l2_object_acquire_format
The gst_v4l2_object_acquire_format() function is used by v4l2videodec to obtain
the currently set capture format. Since G_FMT returns the coded size, the
visible size needs to be obtained from the compose rectangle in order to
negotiate it with downstream elements. The G_CROP call hasn't worked on mem2mem
capture queues for a long time. Instead use the G_SELECTION call to obtain the
compose rectangle and only fall back to G_CROP for ancient kernels.

https://bugzilla.gnome.org/show_bug.cgi?id=766381
2016-06-06 17:33:27 -04:00
Kieran Bingham
b4e6a71566 v4l2object: Use non-deprecated V4L2 type for RGB15
Support for the updated V4L2_PIX_FMT_XRGB555 was added in commit
2538fee2fd however, when setting the format
for use in v4l2 ioctls, the old deprecated format is still used. Convert
this to the new accepted format type, as the preferred format.

https://bugzilla.gnome.org/show_bug.cgi?id=767300
2016-06-06 17:19:41 -04:00
Guillaume Desmottes
1840fa9363 v4l2object: fix caps leak
gst_v4l2_object_probe_caps() was taking an extra ref on the returned
caps for no reason.

https://bugzilla.gnome.org/show_bug.cgi?id=766610
2016-05-25 13:40:54 -04:00
Wim Taymans
c9c051d53d v4l2: avoid leaking GValues
unset the GValue if we don't use it any more to avoid leaks.
2016-04-12 11:56:08 +02:00
Aurélien Zanelli
c163250f0d v4l2object: probe all colorspace supported by device
A device can support more than one colorspace for a given image
dimension and pixel format. So we have to probe all the supported
colorspace and not only rely on the default one. Otherwise we could end
up with negotiation failure if the caps colorimetry field don't match
the v4l2 device default one even if the v4l2 could support such
colorimetry.

This patch enable probing if colorspace for both capture and output
device. It really makes sense for output device since the colorspace
shall be set by the application and a little less for capture device
which, at the moment, shall provide the colorspace; ie: the v4l2
specification seems to not take into account the fact that a capture
device could do colorspace conversion.

As a side effet, probing takes some times and so sligthly delay v4l2
initialization. Note that this patch only probe colorspace and not all
colorspace, matrix, transfer and range combination to avoid taking too
much time, especially with low-speed devices as full probing do 1782
ioctl.

https://bugzilla.gnome.org/show_bug.cgi?id=755937
2016-03-24 14:05:45 -04:00
Alban Bedel
d746e1ef51 v4l2object: fix capture with bayer formats other than bggr
gst_v4l2_object_get_caps_info() always return V4L2_PIX_FMT_SBGGR8
for all bayer formats. This is obviously broken if the device use
another ordering. Fix this by properly reading the format parameter.

https://bugzilla.gnome.org/show_bug.cgi?id=763318
2016-03-08 11:15:08 -05:00
Josep Torra
c65b66432e v4l2: fix colorimetry for NV12
Replicate V4L2_MAP_QUANTIZATION_DEFAULT macro behavior.
At #v4l it was described that documentation might be wrong and that
we should trust this macro instead.

https://bugzilla.gnome.org/show_bug.cgi?id=762529
2016-03-07 11:36:59 -05:00
Nicolas Dufresne
0569178ca7 v4l2: Re-add colorimetry field for RGB formats
This time, check if it's an RGB format and sets the transformation
matrix to identity. The rest of the colorimetry information is
meaningfull and shall be kept.

https://bugzilla.gnome.org/show_bug.cgi?id=759624
2016-01-22 14:17:24 -05:00
Wim Taymans
710ab7f083 v4l2: fix sRGB colorspace definition
V4l2 can also use the sRGB colorspace for YUV formats and thus needs a
default matrix.
2016-01-22 10:05:01 +01:00
Wim Taymans
681bab62e5 v4l2: Add adobe colorspace support
Use the new primaries and transfer function for Adobe RGB.
Explicitly list the colorimetry instead of using the default GStreamer
ones. The defaults for BT2020, for example, do not match.
Explicitly set the matrix of SRGB to RGB.
2016-01-21 10:49:44 +01:00
Nicolas Dufresne
496137854b v4l2object: Cleanup uneeded return statement 2016-01-19 15:17:50 -05:00
Nicolas Dufresne
fd32440609 v4l2object: Don't set colorimetry for non YUV formats
Setting colormetry in caps for RGB have no meaning, but worst it
confuses the converters downstream.

https://bugzilla.gnome.org/show_bug.cgi?id=759624
2016-01-19 15:17:50 -05:00
Nicolas Dufresne
2538fee2fd v4l2object: Update formats table
This change add all the new RGB based format. Those format removes the
ambiguity with the ALPHA channel. Some other missing multiplanar format
has been added with some additional cleanup.
2015-12-18 15:58:01 -05:00
Philipp Zabel
cf29e6c0b7 v4l2: add gst_v4l2_object_probe_caps
Add a variant of gst_v4l2_object_get_caps that bypasses the probed_caps cache.

https://bugzilla.gnome.org/show_bug.cgi?id=733827
2015-11-25 14:32:28 -05:00
Reynaldo H. Verdejo Pinochet
8ef6ecc244 v4l2/object: remove unnecessary NULL check before g_free() 2015-11-15 01:43:08 -08:00
Aurélien Zanelli
aaab7b6ab1 v4l2object: add support of NV16, NV61 and NV24 formats
Mapped respectively to V4L2_PIX_FMT_NV16/V4L2_PIX_FMT_NV16M,
V4L2_PIX_FMT_NV61,V4L2_PIX_FMT_NV61M and V4L2_PIX_FMT_NV24 v4l2 formats.

https://bugzilla.gnome.org/show_bug.cgi?id=758058
2015-11-13 10:29:01 -05:00
Dimitrios Katsaros
a55b9060f8 v4l2: Allow framerate to be large then 100pfs
This limit was arbitrary. We still fixate near 100pfs for compatibility.

https://bugzilla.gnome.org/show_bug.cgi?id=752825
2015-07-25 10:40:51 -04:00
Luis de Bethencourt
600942788d v4l2: document fallthrough cases
Pacify coverity and document fallthrough cases in switch statements.

CID #1308948, #1308947, #1308946
2015-06-29 16:05:48 +01:00
Nicolas Dufresne
0f81b2e99c v4l2: Also set colorimetry on output devices
This completes the code that set the colorimetry on output
device.
2015-06-08 19:14:41 -04:00
Nicolas Dufresne
87a4884acd v4l2: Add missing SMTP240M matrix
This is missing in the doc, but was in the header.
2015-06-08 19:14:41 -04:00
Nicolas Dufresne
b5d66d68ce v4l2object: Fully implement colorimetry support
This fixes wrong mapping for sRGB as in GStreamer sRGB correctly
apply to RGB formats, while in V4L2 it's an alias for sYCC. Also
add support for the new quantization (range), ycbcr_encoding (matrix)
and xfer_func (transfer) enumeration.
2015-06-08 17:56:48 -04:00
Nicolas Dufresne
0196fdb5ec v4l2: Don't warn when optional CID are not implement
gst_v4l2_get_attributre() shall only be used when the CID is expected
to be supported. Otherwise, we get unwanted warning posted to the bus.
2015-06-05 15:34:12 -04:00
Wim Taymans
8c116cfcd8 v4l2: don't add the same interlace mode twice
Some drivers modify the interlace mode to progressive, no matter what
input you give them, make sure that we don't add the same interlace mode
twice.
2015-04-22 18:05:24 +02:00
Tobias Modschiedler
8390288a6e v4l2: Ask the driver about its requirements for min_buffers before initiating buffer pool.
If propose_allocation() had not been called yet, it was possible that the driver was not asked at all.
In buffer pool: Consider minimum number of buffers requested by driver when setting config.

https://bugzilla.gnome.org/show_bug.cgi?id=746834
2015-04-02 17:29:19 -04:00
Thiago Santos
6cfa6c0da8 v4l2object: add gst_v4l2_object_try_format
Similar to set_format but it uses TRY_FMT instead of S_FMT

https://bugzilla.gnome.org/show_bug.cgi?id=682770
2015-03-13 18:47:55 +00:00
Aurélien Zanelli
88703ae585 v4l2: query crop configuration after each call of S_CROP
S_CROP ioctl is write-only and the device can adjust crop rectangle so
we query back the crop configuration after each S_CROP to know what has
been done.

https://bugzilla.gnome.org/show_bug.cgi?id=736133
2015-02-26 08:38:32 -05:00
Aurélien Zanelli
7a1613b9e1 v4l2object: set colorspace in caps for capture devices
This information is set by the driver for a capture device, and so could
be forwarded to pipeline by setting the colorimetry in caps.

https://bugzilla.gnome.org/show_bug.cgi?id=743186
2015-02-25 14:48:20 -05:00
Aurélien Zanelli
600027a1ee v4l2bufferpool: fix import_userptr() in single-planar API when n_planes > 1
In the V4L2 single-planar API, when format is semi-planar/planar,
drivers expect the planes to be contiguous in memory.
So this commit change the way we handle semi-planar/planar format
(n_planes > 1) when we use the single-planar API (group->n_mem == 1).

To check that planes are contiguous and have expected size, ie: no
padding. We test the fact that plane 'i' start address + plane 'i'
expected size equals to plane 'i + 1' start address. If not, we return
in error.

Math are done in bufferpool rather than in allocator because the
former is aware of video info.

https://bugzilla.gnome.org/show_bug.cgi?id=738013
2015-02-25 14:25:01 -05:00
Philippe De Muyter
61a5e5af95 v4l2object: recognize and distinguish all bayer arrangements
Up to now, v4l2src recognized only "bggr" amongst the bayer arrangements.
Recognize now also the "rggb", "gbrg" and "grbg" arrangements.

https://bugzilla.gnome.org/show_bug.cgi?id=742363
2015-02-25 14:14:59 -05:00
Nicolas Dufresne
6afd1c5d57 v4l2: Enable copy when no known allocation params
When there is no allocation parameters in the query, enable copy
threshold. When this threshold is reached, the buffer pool will start
copying when the pool reaches a critical level. If the driver supports
CREATE_BUFS, this will be used instead.
2015-02-19 23:16:00 -05:00
Peter Seiderer
c88e042458 v4l2object: reuse caps framerate if not overwritten by v4l2 device
Enables duration setting in v4l2src.

https://bugzilla.gnome.org/show_bug.cgi?id=740403
2015-01-22 18:52:44 -05:00
Nicolas Dufresne
3dae65ede8 v4l2object: Always set format
Right now we try to be clever by detecting if device format have
changed or not, and skip setting format in this case. This is valid
behaviour with V4L2, but it's also very error prone. The rational
for not setting these all the time is for speed, though I can't
measure any noticeable gain on any HW I own. Also, until recently,
we where doing get/set on the format for each format we where
probing, making it near to impossible that the format would match.
This also fixes bug where we where skipping frame-rate setting if
format didn't change.

https://bugzilla.gnome.org/show_bug.cgi?id=740636
2014-12-15 18:38:00 -05:00
Nicolas Dufresne
43d5a523f1 Revert "v4l2: move vb_queue probing from allocator to v4l2object"
This reverts commit ec6b8b84af.
2014-11-24 10:36:30 -05:00
Nicolas Dufresne
3591a91067 Revert "v4l2object: allow to automatic selection of dmabuf"
This reverts commit e6c2ad5571.
2014-11-24 10:33:29 -05:00
Benjamin Gaignard
e6c2ad5571 v4l2object: allow to automatic selection of dmabuf
If the v4l2 queue support dmabuf select this buffer pool mode
and update the query with allocator.
This patch only concern exporting dmabuf and not importing dmabuf
fd from downstream element.

https://bugzilla.gnome.org/show_bug.cgi?id=699382
2014-11-21 11:29:04 -05:00