fix[utils]: adjust format range constraint

Change-Id: I12d57955d6ad84e063784e46893b1deec90785b6
Signed-off-by: xueman.ruan <xueman.ruan@rock-chips.com>
This commit is contained in:
xueman.ruan
2023-09-28 18:02:33 +08:00
committed by Herman Chen
parent 2c6f93d147
commit 22100022d7
4 changed files with 6 additions and 3 deletions

View File

@@ -164,6 +164,7 @@ typedef enum {
} MppFrameChromaLocation;
#define MPP_FRAME_FMT_MASK (0x000fffff)
#define MPP_FRAME_FMT_PROP_MASK (0x0ff00000)
#define MPP_FRAME_FMT_COLOR_MASK (0x000f0000)
#define MPP_FRAME_FMT_YUV (0x00000000)

View File

@@ -524,10 +524,11 @@ RK_S32 mpi_dec_opt_f(void *ctx, const char *next)
cmd->format = format;
return 1;
}
mpp_err("invalid input format 0x%x\n", format);
}
}
mpp_err("invalid output format\n");
cmd->format = MPP_FMT_YUV420SP;
return 0;
}

View File

@@ -208,10 +208,11 @@ RK_S32 mpi_enc_opt_f(void *ctx, const char *next)
cmd->format = format;
return 1;
}
mpp_err("invalid input format 0x%x\n", format);
}
}
mpp_err("invalid input format\n");
cmd->format = MPP_FMT_YUV420SP;
return 0;
}

View File

@@ -1561,7 +1561,7 @@ MPP_RET str_to_frm_fmt(const char *nptr, long *number)
else if (errno == 0 && nptr && *endptr != 0)
mpp_err("format: 0x%lx invalid (additional characters remain)", tmp);
else if (errno == 0 && nptr && !*endptr) {
if (tmp < UINT_MAX && tmp >= 0) {
if ((tmp < (MPP_FMT_BUTT | MPP_FRAME_FMT_PROP_MASK)) && tmp >= 0) {
*number = tmp;
ret = MPP_OK;
} else {