v4l2src: Give preference to contiguous memory format over non contiguous one while setting format to /dev/video
Submitted by Devarsh Thakkar
Link to original bug (#790265)
Description
Created attachment 363457
Patch we made to chage preference order for choosing contiguous video format over non-contiguous one
Hello,
According to my understanding gstreamer element v4l2src is programmed to prefer non-contiguous video format over contiguous one, i.e if you specify GST_VIDEO_FORMAT_NV12 in pipeline, then v4l2src will program the /dev/video node with V4L2_PIX_FMT_NV12M and not V4L2_PIX_FMT_NV12 if both are available from capture device point of view.
(I think this preference is set in https://cgit.freedesktop.org/gstreamer/gst-plugins- good/tree/sys/v4l2/gstv4l2object.c line 1822)
Now this was breaking the functionality of our use-case as one of the peer element had some issues with V4L2_PIX_FMT_NV12M so we had to change the preference order with attached patch and then we were able to use V4L2_PIX_FMT_NV12.
In my opinion think the better solutino here would be to give flexibility to user to choose whichever format he/she wants to use (like contiguous or non-contiguous), so can you please guide me on what is the best way to do this ?
In my view I see below possible things:
- Add a Boolean property prefer_contiguous_format in v4l2src plugin.
- Add separate GST_VIDEO_FORMAT macro for multiplanar formats.
- Add some property in caps through which user can select preference for contiguous video format if available.
Based upon your suggestion I would try to provide an updated patch.
Thanks,
Devarsh
Patch 363457, "Patch we made to chage preference order for choosing contiguous video format over non-contiguous one":
0001-v4l2-Give-preference-to-contiguous-format-if-support.patch
Version: 1.8.3