mirror of
https://github.com/LibreELEC/LibreELEC.tv.git
synced 2025-08-04 00:17:49 +00:00
Rockchip: ffmpeg: v4l2request: support validating framesizes supported by the driver
This commit is contained in:
parent
946d66c50c
commit
3198acc472
@ -0,0 +1,66 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Alex Bee <knaerzche@gmail.com>
|
||||||
|
Date: Sun, 19 Sep 2021 13:10:55 +0200
|
||||||
|
Subject: [PATCH] v4l2_request: validate supported framesizes
|
||||||
|
|
||||||
|
Signed-off-by: Alex Bee <knaerzche@gmail.com>
|
||||||
|
---
|
||||||
|
libavcodec/v4l2_request.c | 38 +++++++++++++++++++++++++++++++++++++-
|
||||||
|
1 file changed, 37 insertions(+), 1 deletion(-)
|
||||||
|
|
||||||
|
diff --git a/libavcodec/v4l2_request.c b/libavcodec/v4l2_request.c
|
||||||
|
index a8f0ee79ee..2fbe166341 100644
|
||||||
|
--- a/libavcodec/v4l2_request.c
|
||||||
|
+++ b/libavcodec/v4l2_request.c
|
||||||
|
@@ -376,6 +376,42 @@ int ff_v4l2_request_decode_frame(AVCodecContext *avctx, AVFrame *frame, struct v
|
||||||
|
return v4l2_request_queue_decode(avctx, frame, control, count, 1, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
+static int v4l2_request_try_framesize(AVCodecContext *avctx, uint32_t pixelformat)
|
||||||
|
+{
|
||||||
|
+ V4L2RequestContext *ctx = avctx->internal->hwaccel_priv_data;
|
||||||
|
+ struct v4l2_frmsizeenum frmsize = {
|
||||||
|
+ .index = 0,
|
||||||
|
+ .pixel_format = pixelformat,
|
||||||
|
+ };
|
||||||
|
+
|
||||||
|
+ if (ioctl(ctx->video_fd, VIDIOC_ENUM_FRAMESIZES, &frmsize) < 0)
|
||||||
|
+ return 0;
|
||||||
|
+
|
||||||
|
+ /*
|
||||||
|
+ * We only validate min/max framesize for V4L2_FRMSIZE_TYPE_STEPWISE here, since the alignment
|
||||||
|
+ * which is eventually needed will be done driver-side later in VIDIOC_S_FMT and there is no need
|
||||||
|
+ * validate step_width/step_height here
|
||||||
|
+ */
|
||||||
|
+
|
||||||
|
+ do {
|
||||||
|
+
|
||||||
|
+ if (frmsize.type == V4L2_FRMSIZE_TYPE_DISCRETE && frmsize.discrete.width == avctx->coded_width &&
|
||||||
|
+ frmsize.discrete.height == avctx->coded_height)
|
||||||
|
+ return 0;
|
||||||
|
+ else if ((frmsize.type == V4L2_FRMSIZE_TYPE_STEPWISE || frmsize.type == V4L2_FRMSIZE_TYPE_CONTINUOUS) &&
|
||||||
|
+ avctx->coded_width >= frmsize.stepwise.min_width && avctx->coded_height >= frmsize.stepwise.min_height &&
|
||||||
|
+ avctx->coded_width <= frmsize.stepwise.max_width && avctx->coded_height <= frmsize.stepwise.max_height)
|
||||||
|
+ return 0;
|
||||||
|
+
|
||||||
|
+ frmsize.index++;
|
||||||
|
+
|
||||||
|
+ } while (ioctl(ctx->video_fd, VIDIOC_ENUM_FRAMESIZES, &frmsize) >= 0);
|
||||||
|
+
|
||||||
|
+ av_log(avctx, AV_LOG_INFO, "%s: pixelformat %u not supported for width %u height %u\n", __func__, pixelformat, avctx->coded_width, avctx->coded_height);
|
||||||
|
+
|
||||||
|
+ return -1;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
static int v4l2_request_try_format(AVCodecContext *avctx, enum v4l2_buf_type type, uint32_t pixelformat)
|
||||||
|
{
|
||||||
|
V4L2RequestContext *ctx = avctx->internal->hwaccel_priv_data;
|
||||||
|
@@ -404,7 +440,7 @@ static int v4l2_request_try_format(AVCodecContext *avctx, enum v4l2_buf_type typ
|
||||||
|
|
||||||
|
while (ioctl(ctx->video_fd, VIDIOC_ENUM_FMT, &fmtdesc) >= 0) {
|
||||||
|
if (fmtdesc.pixelformat == pixelformat)
|
||||||
|
- return 0;
|
||||||
|
+ return v4l2_request_try_framesize(avctx, pixelformat);
|
||||||
|
|
||||||
|
fmtdesc.index++;
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user