v4l2 encoder: size in info object not updated if capture port sizeimage is changed in driver
Nicolas Dufresne
nicolas at ndufresne.ca
Wed Jun 11 12:43:53 UTC 2025
Hi Pratik,
Le mer. 11 juin 2025, 02 h 32, Pratik Pachange <ppachang at qti.qualcomm.com>
a écrit :
> Hi,
>
>
>
> In gstv4l2videoenc, gst_v4l2_video_enc_set_format(), S_FMT is called on
> CAPTURE port first and then later, on the OUTPUT port.
>
>
>
> Initially, on capture port, the width and height values set using S_FMT
> call are ignored by the driver and it returns default values. (
> https://docs.kernel.org/userspace-api/media/v4l/dev-encoder.html#initialization
> )
>
It's a very bad spec decision clearly, since it imply doing back and forth,
doing useless ioctl. I'll have to check if we can change that, it's
possible it miss-match with actual code.
Later, when S_FMT is called on output port, video driver internally
> reconfigures the capture port with the desired width and height and updates
> the sizeimage of the capture buffers
>
But this updated sizeimage value is not updated in the Gstvideoinfo of
> v4l2object of capture side and the bufferpool created during
> decide_allocation remains with the older value.
>
This is not specced apparently. I pretty much dislike a flow that requires
going backward.
Originally, it's application task to guess the compressed buffer size. I'm
pretty sure GStreamer simply assumed this size (2M or more, would have to
check) will be used.
In GStreamer itself, due to lack of spec, all I can do is increased/
improved the requested size image.
Nicolas
> This is causing assertions when the encoded output is of bigger size than
> the gst buffers of v4l2bufferpool.
>
> https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/4409
>
>
> 1. sizeimage that we get from video driver
>
>
>
>
> 2. The buffers allocated on capture queue are of bigger size.
>
>
>
>
> 3. Gst v4l2bufferpool is unaware of the change in size.
>
>
>
>
> 4. If the encoded output size is greater than the size of gstbuffer in
> v4l2bufferpool, there are assertion while trying to copy the buffers.
>
>
>
>
>
>
>
> How can we address this issue, because decide_allocation is completed
> before s_fmt is called on output queue.
>
>
>
>
> Thanks
> Pratik
>
>
>
>
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/gstreamer-devel/attachments/20250611/ffdd78bf/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.png
Type: image/png
Size: 78514 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/gstreamer-devel/attachments/20250611/ffdd78bf/attachment-0004.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image002.png
Type: image/png
Size: 95512 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/gstreamer-devel/attachments/20250611/ffdd78bf/attachment-0005.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image003.png
Type: image/png
Size: 31153 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/gstreamer-devel/attachments/20250611/ffdd78bf/attachment-0006.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image004.png
Type: image/png
Size: 7434 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/gstreamer-devel/attachments/20250611/ffdd78bf/attachment-0007.png>
More information about the gstreamer-devel
mailing list