fix[enc_utils]: Support read odd resolution image

Change-Id: Ib6b9d9ebc9d552ee0fda0f3a14c77b2ae37881d8
Signed-off-by: Yanjun Liao <yanjun.liao@rock-chips.com>
This commit is contained in:
Yanjun Liao
2024-03-29 17:41:26 +08:00
committed by Herman Chen
parent 4cc3fb25f7
commit 01a86a21ca
2 changed files with 5 additions and 1 deletions

View File

@@ -613,7 +613,7 @@ MPP_RET mpi_enc_test_cmd_update_by_args(MpiEncTestArgs* cmd, int argc, char **ar
if (!cmd->hor_stride) if (!cmd->hor_stride)
cmd->hor_stride = mpi_enc_width_default_stride(cmd->width, cmd->format); cmd->hor_stride = mpi_enc_width_default_stride(cmd->width, cmd->format);
if (!cmd->ver_stride) 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->type_src == MPP_VIDEO_CodingUnused) {
if (cmd->width <= 0 || cmd->height <= 0 || if (cmd->width <= 0 || cmd->height <= 0 ||

View File

@@ -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++) { for (row = 0; row < height / 2; row++) {
read_size = fread(buf_u + row * hor_stride, 1, width, fp); read_size = fread(buf_u + row * hor_stride, 1, width, fp);
if (read_size != width) { 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++) { for (row = 0; row < height / 2; row++) {
read_size = fread(buf_u + row * hor_stride / 2, 1, width / 2, fp); read_size = fread(buf_u + row * hor_stride / 2, 1, width / 2, fp);
if (read_size != width / 2) { if (read_size != width / 2) {