[x265] [PATCH] param: add more validation checks
sagar at multicorewareinc.com
sagar at multicorewareinc.com
Wed Feb 26 12:01:09 CET 2014
# HG changeset patch
# User Sagar Kotecha <sagar at multicorewareinc.com>
# Date 1393404182 -19800
# Wed Feb 26 14:13:02 2014 +0530
# Node ID f36f3bea0472d5f31a40001ac4f22b6b8868b9e2
# Parent b47fc23c75dfecd72d2c47b4e528d793228654be
param: add more validation checks
diff -r b47fc23c75df -r f36f3bea0472 source/common/param.cpp
--- a/source/common/param.cpp Wed Feb 26 03:26:00 2014 +0530
+++ b/source/common/param.cpp Wed Feb 26 14:13:02 2014 +0530
@@ -361,7 +361,7 @@
return 0;
}
-static int x265_atoi(const char *str, bool& bError)
+int x265_atoi(const char *str, bool& bError)
{
char *end;
int v = strtol(str, &end, 0);
@@ -870,6 +870,29 @@
"Default Display Window Top Offset must be 0 or greater");
CHECK(param->defDispWinBottomOffset < 0,
"Default Display Window Bottom Offset must be 0 or greater");
+ CHECK(param->rc.rfConstant < 0 || param->rc.rfConstant > 51,
+ "Valid quality based VBR range 0 - 51");
+ CHECK(param->bFrameAdaptive < 0 || param->bFrameAdaptive > 2,
+ "Valid adaptive b scheduling values 0 - none, 1 - fast, 2 - full");
+ CHECK(param->logLevel < -1 || param->logLevel > 3,
+ "Valid Logging level 0:ERROR 1:WARNING 2:INFO 3:DEBUG -1:NONE");
+ CHECK(param->scenecutThreshold < 0,
+ "scenecutThreshold must be greter than 0");
+ CHECK(param->rdPenalty < 0 || param->rdPenalty > 2,
+ "Valid penalty for 32x32 intra TU in non-I slices. 0:disabled 1:RD-penalty 2:maximum");
+ CHECK(param->keyframeMax < -1,
+ "Invalid max IDR period in frames. value should be greter than -1");
+ CHECK(param->decodedPictureHashSEI < 0 || param->decodedPictureHashSEI > 3,
+ "Invalid hash option. Decoded Picture Hash SEI 0: disabled, 1: MD5, 2: CRC, 3: Checksum");
+ CHECK(param->rc.vbvBufferSize < 0,
+ "Size of the vbv buffer can not be less than zero");
+ CHECK(param->rc.vbvMaxBitrate < 0,
+ "Maximum local bit rate can not be less than zero");
+ CHECK(param->rc.vbvBufferInit < 0 || param->rc.vbvBufferInit > 1,
+ "Valid VBV buffer occpancy range 0 - 1");
+ CHECK(param->rc.bitrate < 0,
+ "Target bitrate can not be less than zero");
+ CHECK(param->bFrameBias < 0, "Bias towards B frame decisions must be 0 or greter");
return check_failed;
}
diff -r b47fc23c75df -r f36f3bea0472 source/x265.cpp
--- a/source/x265.cpp Wed Feb 26 03:26:00 2014 +0530
+++ b/source/x265.cpp Wed Feb 26 14:13:02 2014 +0530
@@ -397,9 +397,11 @@
exit(0);
}
+int x265_atoi(const char *str, bool& bError);
bool CLIOptions::parse(int argc, char **argv, x265_param* param)
{
int berror = 0;
+ bool bError = false;
int help = 0;
int cpuid = 0;
int inputBitDepth = 8;
@@ -476,7 +478,7 @@
}
#define OPT(longname) \
else if (!strcmp(long_options[long_options_index].name, longname))
-
+#define atoi(str) x265_atoi(str, bError)
if (0) ;
OPT("cpuid") cpuid = atoi(optarg);
OPT("frames") this->framesToBeEncoded = (uint32_t)atoi(optarg);
@@ -496,12 +498,13 @@
else
berror |= x265_param_parse(param, long_options[long_options_index].name, optarg);
- if (berror)
+ if (berror || bError)
{
const char *name = long_options_index > 0 ? long_options[long_options_index].name : argv[optind - 2];
x265_log(NULL, X265_LOG_ERROR, "invalid argument: %s = %s\n", name, optarg);
return true;
}
+#undef atoi
#undef OPT
}
}
More information about the x265-devel
mailing list