nxcodec: Modify the logic of judging the correctness of the incoming pixformat
Signed-off-by: yangsen5 <yangsen5@xiaomi.com>
This commit is contained in:
parent
dad9b5afa3
commit
524caec5a0
@ -114,13 +114,6 @@ int nxcodec_init(FAR nxcodec_t *codec)
|
||||
goto err0;
|
||||
}
|
||||
|
||||
if (codec->output.fdesc.pixelformat !=
|
||||
codec->output.format.fmt.pix.pixelformat)
|
||||
{
|
||||
ret = -EINVAL;
|
||||
goto err0;
|
||||
}
|
||||
|
||||
codec->output.format.type = codec->output.type;
|
||||
|
||||
ret = nxcodec_context_set_format(&codec->output);
|
||||
@ -138,13 +131,6 @@ int nxcodec_init(FAR nxcodec_t *codec)
|
||||
goto err0;
|
||||
}
|
||||
|
||||
if (codec->capture.fdesc.pixelformat !=
|
||||
codec->capture.format.fmt.pix.pixelformat)
|
||||
{
|
||||
ret = -EINVAL;
|
||||
goto err1;
|
||||
}
|
||||
|
||||
codec->capture.format.type = codec->capture.type;
|
||||
|
||||
ret = nxcodec_context_set_format(&codec->capture);
|
||||
|
@ -265,11 +265,29 @@ int nxcodec_context_dequeue_frame(FAR nxcodec_context_t *ctx)
|
||||
int nxcodec_context_get_format(FAR nxcodec_context_t *ctx)
|
||||
{
|
||||
FAR nxcodec_t *codec = nxcodec_context_to_nxcodec(ctx);
|
||||
struct v4l2_fmtdesc fdesc;
|
||||
int ret;
|
||||
|
||||
memset(&ctx->fdesc, 0, sizeof(ctx->fdesc));
|
||||
ctx->fdesc.type = ctx->type;
|
||||
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)
|
||||
|
@ -45,7 +45,6 @@ typedef struct nxcodec_context_s
|
||||
int fd;
|
||||
enum v4l2_buf_type type;
|
||||
struct v4l2_format format;
|
||||
struct v4l2_fmtdesc fdesc;
|
||||
FAR nxcodec_context_buf_t *buf;
|
||||
int nbuffers;
|
||||
} nxcodec_context_t;
|
||||
|
Loading…
Reference in New Issue
Block a user