[FFmpeg-devel] [PATCH] avdevice/v4l2: Switch to wrapped AVFrames and implement strides
Anton Khirnov
anton at khirnov.net
Mon Oct 2 13:23:51 EEST 2023
Quoting Asahi Lina via ffmpeg-devel (2023-09-29 09:52:23)
> V4L2 provides a line stride to the client for hardware that has
> alignment requirements. rawvideo cannot represent this, so switch to
> wrapped_avframe for raw video formats and calculate the plane strides
> manually.
>
> This is slightly messy because the existing helper APIs expect
> dimensions and an alignment value, while v4l2 provides the stride of
> plane 0 and the subsequent plane strides are implied, so we need to
> open-code the logic to calculate the plane strides.
>
> This makes vertical video work properly on Apple Macs with "1080p"
> cameras, which are actually square and can support resolutions like
> 1080x1920, which require stride padding to a multiple of 64 bytes.
>
> In principle, this could be extended to support the V4L2 multiplanar
> API, though there seem to be practically no capture (not M2M) drivers
> that support this, so it's not terribly useful right now.
>
> Signed-off-by: Asahi Lina <lina at asahilina.net>
> ---
> libavdevice/v4l2-common.c | 68 +++++++++++------------
> libavdevice/v4l2.c | 138 +++++++++++++++++++++++++++++++++++++++-------
> 2 files changed, 151 insertions(+), 55 deletions(-)
Wrapped AVFrames is an abominable hack that should be going away, not
spread to new places. The correct approach is move v4l2 rawvideo to a
lavfi source filter, then none of these hacks are needed.
--
Anton Khirnov
More information about the ffmpeg-devel
mailing list