[x265] [PATCH] level: do not try to configure color space in x265_param_apply_profile()
Steve Borho
steve at borho.org
Mon Apr 27 20:09:26 CEST 2015
# HG changeset patch
# User Steve Borho <steve at borho.org>
# Date 1430158137 18000
# Mon Apr 27 13:08:57 2015 -0500
# Node ID 863f95cc51bda4151b0fa7c37e345cef4d18e020
# Parent 2266b0715a31937d3675947f947a106f86b55cfa
level: do not try to configure color space in x265_param_apply_profile()
Each profile has restrictions on which color spaces are allowed, and those must
be enforced, but applying a profile should not affect the input color space
defined by the user. We cannot change the input color space, doing so here was
both futile and incorrect. (fixes #128)
diff -r 2266b0715a31 -r 863f95cc51bd source/encoder/level.cpp
--- a/source/encoder/level.cpp Mon Apr 27 11:20:31 2015 -0500
+++ b/source/encoder/level.cpp Mon Apr 27 13:08:57 2015 -0500
@@ -344,31 +344,50 @@
extern "C"
int x265_param_apply_profile(x265_param *param, const char *profile)
{
- if (!profile)
+ if (!param || !profile)
return 0;
+
+#if HIGH_BIT_DEPTH
+ if (!strcmp(profile, "main") || !strcmp(profile, "mainstillpicture") || !strcmp(profile, "msp"))
+ {
+ x265_log(param, X265_LOG_ERROR, "%s profile not supported, compiled for Main10.\n", profile);
+ return -1;
+ }
+#else
+ if (!strcmp(profile, "main10") || !strcmp(profile, "main422-10") || !strcmp(profile, "main444-8") ||
+ !strcmp(profile, "main444-10"))
+ {
+ x265_log(param, X265_LOG_ERROR, "%s profile not supported, compiled for Main.\n", profile);
+ return -1;
+ }
+#endif
+
if (!strcmp(profile, "main"))
{
- /* SPSs shall have chroma_format_idc equal to 1 only */
- param->internalCsp = X265_CSP_I420;
-
-#if HIGH_BIT_DEPTH
- /* SPSs shall have bit_depth_luma_minus8 equal to 0 only */
- x265_log(param, X265_LOG_ERROR, "Main profile not supported, compiled for Main10.\n");
- return -1;
-#endif
+ if (!(param->internalCsp & X265_CSP_I420))
+ {
+ x265_log(param, X265_LOG_ERROR, "%s profile not compatible with %s input color space.\n",
+ profile, x265_source_csp_names[param->internalCsp]);
+ return -1;
+ }
}
else if (!strcmp(profile, "main10"))
{
- /* SPSs shall have chroma_format_idc equal to 1 only */
- param->internalCsp = X265_CSP_I420;
-
- /* SPSs shall have bit_depth_luma_minus8 in the range of 0 to 2, inclusive
- * this covers all builds of x265, currently */
+ if (!(param->internalCsp & X265_CSP_I420))
+ {
+ x265_log(param, X265_LOG_ERROR, "main10 profile not compatible with %s input color space.\n",
+ x265_source_csp_names[param->internalCsp]);
+ return -1;
+ }
}
else if (!strcmp(profile, "mainstillpicture") || !strcmp(profile, "msp"))
{
- /* SPSs shall have chroma_format_idc equal to 1 only */
- param->internalCsp = X265_CSP_I420;
+ if (!(param->internalCsp & X265_CSP_I420))
+ {
+ x265_log(param, X265_LOG_ERROR, "%s profile not compatible with %s input color space.\n",
+ profile, x265_source_csp_names[param->internalCsp]);
+ return -1;
+ }
/* SPSs shall have sps_max_dec_pic_buffering_minus1[ sps_max_sub_layers_minus1 ] equal to 0 only */
param->maxNumReferences = 1;
@@ -385,25 +404,20 @@
param->rc.cuTree = 0;
param->bEnableWeightedPred = 0;
param->bEnableWeightedBiPred = 0;
-
-#if HIGH_BIT_DEPTH
- /* SPSs shall have bit_depth_luma_minus8 equal to 0 only */
- x265_log(param, X265_LOG_ERROR, "Mainstillpicture profile not supported, compiled for Main10.\n");
- return -1;
-#endif
}
else if (!strcmp(profile, "main422-10"))
- param->internalCsp = X265_CSP_I422;
- else if (!strcmp(profile, "main444-8"))
{
- param->internalCsp = X265_CSP_I444;
-#if HIGH_BIT_DEPTH
- x265_log(param, X265_LOG_ERROR, "Main 4:4:4 8 profile not supported, compiled for Main10.\n");
- return -1;
-#endif
+ if (!(param->internalCsp & (X265_CSP_I420 | X265_CSP_I422)))
+ {
+ x265_log(param, X265_LOG_ERROR, "%s profile not compatible with %s input color space.\n",
+ profile, x265_source_csp_names[param->internalCsp]);
+ return -1;
+ }
}
- else if (!strcmp(profile, "main444-10"))
- param->internalCsp = X265_CSP_I444;
+ else if (!strcmp(profile, "main444-8") || !strcmp(profile, "main444-10"))
+ {
+ /* any color space allowed */
+ }
else
{
x265_log(param, X265_LOG_ERROR, "unknown profile <%s>\n", profile);
More information about the x265-devel
mailing list