Commit graph

99 commits

Author SHA1 Message Date
Nicolas Dufresne
661f0c161e v4l2codecdec: Fix error handling
If none of the format the HW produce is supported, the fiter will be NULL,
which would lead to assertion when trying to release it.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1268>
2020-05-19 17:51:11 +00:00
Nicolas Dufresne
26264163de v4l2decoder: Add legacy non-multiplanar support
The Cedrus driver uses the lagacy buffer type (non-mplane). This automatically
detect and use the right v4l2_buf_type. This also affect code using
v4l2_buffer and v4l2_format structures.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1268>
2020-05-19 17:51:11 +00:00
Nicolas Dufresne
14b0b68354 v4l2codecs: Update kernel headers
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1268>
2020-05-19 17:51:11 +00:00
Víctor Manuel Jáquez Leal
d2aae6bb96 codecs: h264decoder: ref pic lists as decode_slice parameters
Pass reference picture lists to decode_slice() vmethods

Change gstv4l2codech264dec and gstnvh264dec accordingly.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1238>
2020-05-19 16:57:09 +00:00
Ting-Wei Lan
d10e2381c7 v4l2codecs: Fix compilation error on FreeBSD
This commit does the following things to fix compilation on FreeBSD:

1. Add required typedefs to linux/types-compat.h.
2. Remove unnecessary include linux/ioctl.h and replace linux/types.h
   with linux/types-compat.h. Both files do not exist on FreeBSD.
3. Check the header including makedev macro. FreeBSD does not have
   sys/sysmacros.h, and including it unconditionally causes error.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1259>
2020-05-11 15:17:31 +00:00
Nicolas Dufresne
5ece17ecbd v4l2slvp8dec: Flip the meaning of segment_feature_mode
In section 9.3.4 a), segment_feature_mode have 0 for absolute and 1 for delta,
while in 19.2, it says the opposite. But the reference code, which usually
rules over the text state that 1 means absolute:

 if (hdr->update_data)
 {
     hdr->abs = bool_get_bit(bool);

And uses it with that meaning to decide weither to override the existing value
or just add the detla. This fixes multiple decoding issues.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1245>
2020-05-05 17:57:08 +00:00
Nicolas Dufresne
11c62eb015 v4l2slvp8dec: Copy header version
This field was not copied.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1245>
2020-05-05 17:57:08 +00:00
Nicolas Dufresne
8c56822936 v4l2slvp8dec: Add debugging for reference frames
This simply trace the frame number of the references used for decoding.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1245>
2020-05-05 17:57:08 +00:00
Nicolas Dufresne
a449815f95 v4l2slvp8dec: Ensure width/height is always set
Our parser strictly read the bitstream. As it's known from DXVA that always
having a valid width/height might be needed, use the cached width/height
instead of the value from the parser. This didn't impact Hantro driver.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1245>
2020-05-05 17:57:08 +00:00
Nicolas Dufresne
ffd74fb5ec v4l2slvp8dec: Fix debug category name
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1245>
2020-05-05 17:57:08 +00:00
Nicolas Dufresne
bf9f82c8c3 v4l2codecs: Factor out plugin registration
This introduce a common place for generic functions and factor out the plugin
registration code. This code is nearly identical between implementation.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1216>
2020-04-28 22:53:11 +00:00
Nicolas Dufresne
de2cccaa47 v4l2decoder: Relax width/height return value check
The driver adjust the width/height to coded size. This was not an issue for
H264, as the coded size is in the bitstream, but is an issue with VP8.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1216>
2020-04-28 22:53:11 +00:00
Nicolas Dufresne
72c0b3e5ae v4l2codecs: Add VP8 decoder
This is derived from the H264 decoder, some boiler plate will be factored out
in the following commits.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1216>
2020-04-28 22:53:11 +00:00
Seungha Yang
ac850fd25d v4l2slh264dec: Support avc and avc3 formats
h264decoder baseclass provides parsed sps/pps (from codec data) for
subclass. Also, since current implementation is putting start code prefix
manually, the format of stream should not be matter for subclass.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1214>
2020-04-23 23:38:03 +00:00
Víctor Manuel Jáquez Leal
e96435dfea v4l2codecs: allocator: use gst_clear_object
So tracer can do its job.
2020-04-20 12:23:32 +00:00
Víctor Manuel Jáquez Leal
691fdb85c0 v4l2codecs: fix v4l2codecdevice get type
Currently the GType of v4l2codecdevice is hardcoded to zero, but it
rather should be delivered by the GType system.
2020-04-10 21:05:19 +02:00
Nicolas Dufresne
8f0ceba251 v4l2codecs: Fix FD leak during device enumeration
This was revealed by Coverity.

CID 1461248
2020-04-08 20:25:44 +00:00
Nicolas Dufresne
f5da12bcf5 v4l2decoder: Fix file descriptor leak
A copy paste error was leading to file descriptor leak. This was detected by
Coverity.

CID 1461285
2020-04-07 17:10:08 -04:00
Nicolas Dufresne
4cb871eb53 v4l2codecs: Only build this plugin on Linux
This is not useful on any other OSs, it will also avoid potential build
failure as this code uses Linux specific calls.
2020-03-31 09:34:05 -04:00
Nicolas Dufresne
7254a18f0f v4l2codecs: Add plugin dependency
This ensure that the registry cache get updated when a meaningful change is
made in /dev for files named media*.
2020-03-31 09:34:05 -04:00
Nicolas Dufresne
e70993bf43 v4l2codecs: Wait for buffers to come back
This code add required mechanism to try and allocate (not implemented yet)
otherwise wait for more buffers. This also comes with mechanism to terminate
the wait on flush or PAUSED_TO_READY transitions.
2020-03-31 09:34:05 -04:00
Nicolas Dufresne
09a9ffcda6 v4l2codecs: Implement flushing sequence
This simply consit of cycling through STREAMOFF/STREAMON with stateless
decoders.
2020-03-31 09:34:05 -04:00
Nicolas Dufresne
f69283819a v4l2codecs: allocator: Add method to wait for more buffers
This add function to wait for buffers to get back into the pool along with a
set_flushing() method to allow unblocking this wait.
2020-03-31 09:34:05 -04:00
Nicolas Dufresne
bc0a8ff40d v4l2codecs: pool: Create new buffer when pool is empty
This simply create an empty GstBuffer when the pool is empty. This way it's up
to the allocator to grow or wait if we ran out of memory.
2020-03-31 09:34:05 -04:00
Nicolas Dufresne
ee26c9c9a1 v4l2slh264dec: Improve end_picture() robustness
Use a goto to ensure that for all cases we cleanup the current picture state.
And move the src buffer allocation higher, so we don't queue a bitstream
buffer if we don't have a picture buffer to decode into.
2020-03-31 09:34:05 -04:00
Nicolas Dufresne
390cbe1f00 v4l2slh264dec: Add output format negotiation
This allow negotiating the output format through caps. Some drivers can
pipeline the decoder buffer through an image processor. This only support
colorspace conversion for now.
2020-03-31 09:34:05 -04:00
Nicolas Dufresne
6494d7b056 v4l2format: Convert between V4L2 and GST video format
This will be needed in the output format negotiation.
2020-03-31 09:34:05 -04:00
Nicolas Dufresne
2a1836f183 v4l2codecs: Read driver provided stride
This implements driver stride support but only for single allocation buffers.
This code is imported from the original v4l2 plugin and adapted to the new
helper context.
2020-03-31 09:34:05 -04:00
Nicolas Dufresne
21652a8e52 v4l2h264dec: Copy frames when GstVideoMeta is not supported
In some case, when downstream does not support GstVideoMeta, we need to
normalize the stride and offset of the buffer so that downstream can render
properly with a GstVideoMeta. This code is not called when GstVideoMeta is
supported downstream.
2020-03-31 09:34:05 -04:00
Nicolas Dufresne
3c2d25eebf v4l2codec: Add initial GstVideoMeta support
In this patch we strictly set the GstVideoMeta width/height to the coded width
and height. Further patches will add stride support and frame copying when
downstream does not support GstVideoMeta.
2020-03-31 09:34:05 -04:00
Nicolas Dufresne
f6690420ce v4l2slh264dec: Prevent spurious renegotiation
Don't let downstream cause a renegotiation at random point in time. This would
lead to spurious renegotiation and the decoder state may not be recoverable.
2020-03-31 09:34:05 -04:00
Nicolas Dufresne
b47929a74d v4l2slh264dec: Hold on picture buffers
These buffers should not be reused for decoding until they are no longer
referenced.
2020-03-31 09:34:05 -04:00
Nicolas Dufresne
b107c20198 v4l2codecs: Fix bytesused value
Pass the actual amount of bytes we have copied into the bitstream buffer. Also
unmap the memory before queuing.
2020-03-31 09:34:05 -04:00
Nicolas Dufresne
0d740a184e v4l2codech264dec: Implement finish frame
This enables the request to be processed by the HW (STREAMON) and to be pushed
downstream for further processing.
2020-03-31 09:34:05 -04:00
Nicolas Dufresne
3cc6643050 v4l2codecdecoder: Add support for dequeuing buffers
This includings polling of the request and streamon/streamoff.
2020-03-31 09:34:05 -04:00
Nicolas Dufresne
4305771178 v4l2codech264dec: Implement queuing
We now pass the controls, associated to a request, queue the bitstream, qeueue
a picture buffer to decode into and finally queue the request. This now runs
until the buffer pool is exhausted. The next step will be to dequeue.
2020-03-31 09:34:05 -04:00
Nicolas Dufresne
a307499437 v4l2decoder: Add helpers to queue buffer and requests 2020-03-31 09:34:05 -04:00
Nicolas Dufresne
db787adfa1 v4l2codec: Add getter for buffer index in allocator and pool 2020-03-31 09:34:05 -04:00
Nicolas Dufresne
527f040bfc v4l2h264codecdec: Copy bitstream parameter and data
In this patch we fill the control structure with the bitstream paramter and
copy the bitstream data into V4L2 memory. Slice paramters are only the subset
of what Hantro needs, without any support for interlaced content.
2020-03-31 09:34:05 -04:00
Nicolas Dufresne
2bac52a6fb v4l2slh264dec: Use the newly introduced allocator / pool
We now allocate and free the memory needed for streaming.
2020-03-31 09:34:05 -04:00
Nicolas Dufresne
c120f8b041 v4l2codec: Add allocator and pool implementation
This is a pooling allocator and the buffer pool does nothing other then
reusing the GstBuffer structure. Note that the pool is an internal pool, so
the start/stop/set_config virtual functions are not implemented.
2020-03-31 09:34:05 -04:00
Nicolas Dufresne
d476e6d689 v4l2codec: decoder: Add allocation helper 2020-03-31 09:34:05 -04:00
Nicolas Dufresne
7ae57631d4 v4l2codecs: Implement H264 format negotiation 2020-03-31 09:34:05 -04:00
Nicolas Dufresne
020a019fd6 v4l2codecs: Add initial formats helpers 2020-03-31 09:34:05 -04:00
Nicolas Dufresne
a007e2dd9d v4l2codecs: Add skeleton of H264 decoder
This introduces the skeleton of the H264 decoder. The plugin will list the
devices and register a subclass of the GstV4L2CodecH264Dec base class. The
subclass will pick the required specific information from the GstV4L2Device
stored in the subclass structure.
2020-03-31 09:34:05 -04:00
Nicolas Dufresne
b7762fc332 v4l2codec: Add GstV4L2Deocder helper object
This is a GstObject which will be used to hold on media and video device file
descriptor and provide abstracted ioctl calls with these descriptor. At the
moment this helper contains just enough to enumerate the supported format.
This part will be used by the plugin to register the CODEC specific elements..
2020-03-31 09:34:05 -04:00
Nicolas Dufresne
dd2b0302b3 v4l2codecs: Copy all needed Linux kernel headers
Most of the features we need are very early or not expose yet in the uAPI.
Using an internal copy ensure that we everything we need is defined avoiding
to add load of checks and conditionnal code.
2020-03-31 09:34:05 -04:00
Nicolas Dufresne
6d9c98ae5a v4l2codecs: Add device enumeration
This introduces a GstV4L2CodecDevice structure and helper to retrieve a
list of CODEC device drivers. In order to find the device driver we
enumerate all media devices with UDEV. We then get the media controller
topology and locate a entity with function encoder or decoder and make
sure it is linked to two V4L2 IO entity pointing to the same device
node.
2020-03-31 09:34:05 -04:00
Nicolas Dufresne
6958fb6d59 v4l2codecs: Introdude a V4L2 CODECs Accelerator plugin
This plugin will support new CODECs uAPI in the Linux kernel. These
consist of an accelerator interface similar to DXVA, NVDEC, VDPAU and
VAAPI.
2020-03-31 09:34:05 -04:00