From 01a86a21ca84c50751eec2192789496093c7d059 Mon Sep 17 00:00:00 2001 From: Yanjun Liao Date: Fri, 29 Mar 2024 17:41:26 +0800 Subject: [PATCH] fix[enc_utils]: Support read odd resolution image Change-Id: Ib6b9d9ebc9d552ee0fda0f3a14c77b2ae37881d8 Signed-off-by: Yanjun Liao --- utils/mpi_enc_utils.c | 2 +- utils/utils.c | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/utils/mpi_enc_utils.c b/utils/mpi_enc_utils.c index 9d525f35..acfa51b2 100644 --- a/utils/mpi_enc_utils.c +++ b/utils/mpi_enc_utils.c @@ -613,7 +613,7 @@ MPP_RET mpi_enc_test_cmd_update_by_args(MpiEncTestArgs* cmd, int argc, char **ar if (!cmd->hor_stride) cmd->hor_stride = mpi_enc_width_default_stride(cmd->width, cmd->format); if (!cmd->ver_stride) - cmd->ver_stride = cmd->height; + cmd->ver_stride = MPP_ALIGN(cmd->height, 2); if (cmd->type_src == MPP_VIDEO_CodingUnused) { if (cmd->width <= 0 || cmd->height <= 0 || diff --git a/utils/utils.c b/utils/utils.c index 6d4d6c45..d5f2ccfb 100644 --- a/utils/utils.c +++ b/utils/utils.c @@ -549,6 +549,8 @@ MPP_RET read_image(RK_U8 *buf, FILE *fp, RK_U32 width, RK_U32 height, } } + height = MPP_ALIGN(height, 2); + width = MPP_ALIGN(width, 2); for (row = 0; row < height / 2; row++) { read_size = fread(buf_u + row * hor_stride, 1, width, fp); if (read_size != width) { @@ -566,6 +568,8 @@ MPP_RET read_image(RK_U8 *buf, FILE *fp, RK_U32 width, RK_U32 height, } } + width = MPP_ALIGN(width, 2); + height = MPP_ALIGN(height, 2); for (row = 0; row < height / 2; row++) { read_size = fread(buf_u + row * hor_stride / 2, 1, width / 2, fp); if (read_size != width / 2) {