Commit graph

33 commits

Author SHA1 Message Date
Nicolas Dufresne
bb9fbf0626 v4l2codecs: h264dec: Use the new picture lookup
This will avoid having to create a reference chain from CodecFrame
to GstH264Picture to GstV4l2Request.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1449>
2020-07-21 17:18:42 +09:00
Seungha Yang
e921a07715 codecs: h264decoder: Pass GstVideoCodecFrame to output_picture()
All subclasses are retrieving list to get target output frame, which
can be done by baseclass. And pass the ownership of the GstH264Picture
to subclass so that subclass can clear implementation dependent resources
before finishing the frame.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1449>
2020-07-21 17:18:42 +09:00
Seungha Yang
7a024a740f codecs: h264decoder: Don't attach extra ref of GstH264Picture to GstVideoCodecFrame
The lifecycle of GstH264Picture is being managed by our DPB
implementation. If it's still required, subclass can do that
by itself in the new_picture() method.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1449>
2020-07-21 17:18:42 +09:00
Nicolas Dufresne
7b3c101ced v4l2codecs: Enable 32x32 tiled NV12 support
This is used by Cedrus driver to support Allwinner VPU, also known as the
sunxi platforms.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1437>
2020-07-15 13:24:13 +00:00
Nicolas Dufresne
a2eb1b57ff v4l2slh264dec: Wait on previous pending request in slice mode
In slice mode, we'll do one request per slice. In order to recycle
bitstream buffer, and not run-out, wait for the last pending
request to complete and mark it done.

We only wait after having queued the current slice in order to reduce
that potential driver starvation and maintain performance (using dual
buffering).

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1395>
2020-07-02 12:21:51 -04:00
Nicolas Dufresne
b20c6fe6c4 v4l2slh264dec: Renew bitstream buffer after submitting slice
Submitting a slice actually clears the bitstream buffer. Ensure we
have a newly allocated bitstream buffer for the next slice.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1395>
2020-07-02 12:21:51 -04:00
Nicolas Dufresne
bc1a0323a9 v4l2slh264dec: Factor out bitstream allocation
No functional changes.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1395>
2020-07-02 12:21:51 -04:00
Nicolas Dufresne
779f331bd4 v4l2slh264dec: Add a helper to ensure output buffer
In preparation of multi-slice decoding, we will decode multiple
slices into the same buffer. This will ensure we have a buffer to
decode to, queued into the driver.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1395>
2020-07-02 12:21:51 -04:00
Nicolas Dufresne
d65f7de650 v4l2slh264dec: Factor out request wait
This will be reused to wait for previous slices to be complete
when dealing with following slices (in slice decoding mode).

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1395>
2020-07-02 12:21:51 -04:00
Nicolas Dufresne
176a860169 v4l2slh264dec: Remove double return in submit_bitstream()
This is code cleanup, no functional changes.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1395>
2020-07-02 12:21:51 -04:00
Nicolas Dufresne
1f48e60bde v4l2slh264dec: Fix typo in debug trace
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1395>
2020-07-02 12:21:51 -04:00
Nicolas Dufresne
483539f45c v4l2slh264dec: Fix reading mode and start code type
These two controls are not pointer based, so we don't need to pass any size or
pointer and need to copy the values afterward. This fixes H264 decoding
regression with Hantro and RKVDEC drivers.

Fixes 037730a787

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1330>
2020-06-09 10:52:44 -04:00
Nicolas Dufresne
d16367f046 v4l2codecs: h264: Add missing break
There was a missing break for the 4:4:4 case which would break the sizeimage
calculation. We don't currently have hardware that supports 4:4:4, so this
code wasn't tested. This was detected by Coverity.

CID 1463592 1463591

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1283>
2020-05-21 20:12:07 +00:00
Nicolas Dufresne
2160239548 v4l2slh264dec: Request large enough bitstream buffer
The Cedrus driver would otherwise choose 1KB buffer, which is too small.
This follows what some drivers do, which is simply to use the size a
packed raw image would have. Specifications do not really guaranty any minimum
compression ratio.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1268>
2020-05-19 17:51:11 +00:00
Nicolas Dufresne
037730a787 v4l2slh264dec: Add slice based decoder support
This adds support for slice based decoder like the Allwinner/Cedrus driver. In
order to keep things efficient, we hold the sink buffer until we reach the end
of the picture. Note that as we don't know which one is last, we lazy queue the
slices. This effectively introduces one slice latency.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1268>
2020-05-19 17:51:11 +00:00
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
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
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
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
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
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
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
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
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
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
7ae57631d4 v4l2codecs: Implement H264 format negotiation 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