nxcodec: Modify the logic of judging the correctness of the incoming pixformat

Signed-off-by: yangsen5 <yangsen5@xiaomi.com>
This commit is contained in:
yangsen5 2024-09-02 21:12:37 +08:00 committed by Xiang Xiao
parent dad9b5afa3
commit 524caec5a0
3 changed files with 21 additions and 18 deletions

View File

@ -114,13 +114,6 @@ int nxcodec_init(FAR nxcodec_t *codec)
goto err0; goto err0;
} }
if (codec->output.fdesc.pixelformat !=
codec->output.format.fmt.pix.pixelformat)
{
ret = -EINVAL;
goto err0;
}
codec->output.format.type = codec->output.type; codec->output.format.type = codec->output.type;
ret = nxcodec_context_set_format(&codec->output); ret = nxcodec_context_set_format(&codec->output);
@ -138,13 +131,6 @@ int nxcodec_init(FAR nxcodec_t *codec)
goto err0; goto err0;
} }
if (codec->capture.fdesc.pixelformat !=
codec->capture.format.fmt.pix.pixelformat)
{
ret = -EINVAL;
goto err1;
}
codec->capture.format.type = codec->capture.type; codec->capture.format.type = codec->capture.type;
ret = nxcodec_context_set_format(&codec->capture); ret = nxcodec_context_set_format(&codec->capture);

View File

@ -265,11 +265,29 @@ int nxcodec_context_dequeue_frame(FAR nxcodec_context_t *ctx)
int nxcodec_context_get_format(FAR nxcodec_context_t *ctx) int nxcodec_context_get_format(FAR nxcodec_context_t *ctx)
{ {
FAR nxcodec_t *codec = nxcodec_context_to_nxcodec(ctx); FAR nxcodec_t *codec = nxcodec_context_to_nxcodec(ctx);
struct v4l2_fmtdesc fdesc;
int ret;
memset(&ctx->fdesc, 0, sizeof(ctx->fdesc)); fdesc.type = ctx->type;
ctx->fdesc.type = ctx->type;
return ioctl(codec->fd, VIDIOC_ENUM_FMT, &ctx->fdesc) < 0 ? -errno : 0; while (true)
{
ret = ioctl(codec->fd, VIDIOC_ENUM_FMT, &fdesc);
if (ret < 0)
{
return -errno;
}
if (fdesc.pixelformat == ctx->format.fmt.pix.pixelformat)
{
break;
}
fdesc.index++;
}
ctx->format.type = ctx->type;
return ioctl(codec->fd, VIDIOC_TRY_FMT, &ctx->format) < 0 ? -errno : 0;
} }
int nxcodec_context_set_format(FAR nxcodec_context_t *ctx) int nxcodec_context_set_format(FAR nxcodec_context_t *ctx)

View File

@ -45,7 +45,6 @@ typedef struct nxcodec_context_s
int fd; int fd;
enum v4l2_buf_type type; enum v4l2_buf_type type;
struct v4l2_format format; struct v4l2_format format;
struct v4l2_fmtdesc fdesc;
FAR nxcodec_context_buf_t *buf; FAR nxcodec_context_buf_t *buf;
int nbuffers; int nbuffers;
} nxcodec_context_t; } nxcodec_context_t;