# HG changeset patch # User Santhoshini Sekar<santhosh...@multicorewareinc.com> # Date 1434522753 -19800 # Wed Jun 17 12:02:33 2015 +0530 # Node ID fb4eecc53e5789094d5a12999c7c2d8e56060b1e # Parent be0ed447922cc81e809d296e75424bb71822aea7 aq: new auto variance mode with biasing to dark scenes
diff -r be0ed447922c -r fb4eecc53e57 doc/reST/cli.rst --- a/doc/reST/cli.rst Tue Jun 16 11:15:03 2015 +0530 +++ b/doc/reST/cli.rst Wed Jun 17 12:02:33 2015 +0530 @@ -1179,7 +1179,7 @@ ignored. Slower presets will generally achieve better compression efficiency (and generate smaller bitstreams). Default disabled. -.. option:: --aq-mode <0|1|2> +.. option:: --aq-mode <0|1|2|3> Adaptive Quantization operating mode. Raise or lower per-block quantization based on complexity analysis of the source image. The @@ -1190,6 +1190,7 @@ 0. disabled 1. AQ enabled **(default)** 2. AQ enabled with auto-variance + 3. AQ enabled with auto-variance and bias to dark scenes .. option:: --aq-strength <float> diff -r be0ed447922c -r fb4eecc53e57 source/CMakeLists.txt --- a/source/CMakeLists.txt Tue Jun 16 11:15:03 2015 +0530 +++ b/source/CMakeLists.txt Wed Jun 17 12:02:33 2015 +0530 @@ -30,7 +30,7 @@ mark_as_advanced(FPROFILE_USE FPROFILE_GENERATE NATIVE_BUILD) # X265_BUILD must be incremented each time the public API is changed -set(X265_BUILD 63) +set(X265_BUILD 64) configure_file("${PROJECT_SOURCE_DIR}/x265.def.in" "${PROJECT_BINARY_DIR}/x265.def") configure_file("${PROJECT_SOURCE_DIR}/x265_config.h.in" diff -r be0ed447922c -r fb4eecc53e57 source/common/param.cpp --- a/source/common/param.cpp Tue Jun 16 11:15:03 2015 +0530 +++ b/source/common/param.cpp Wed Jun 17 12:02:33 2015 +0530 @@ -1092,7 +1092,7 @@ "Lookahead depth must be less than 256"); CHECK(param->lookaheadSlices > 16 || param->lookaheadSlices < 0, "Lookahead slices must between 0 and 16"); - CHECK(param->rc.aqMode < X265_AQ_NONE || X265_AQ_AUTO_VARIANCE < param->rc.aqMode, + CHECK(param->rc.aqMode < X265_AQ_NONE || X265_AQ_AUTO_VARIANCE_BIASED < param->rc.aqMode, "Aq-Mode is out of range"); CHECK(param->rc.aqStrength < 0 || param->rc.aqStrength > 3, "Aq-Strength is out of range"); diff -r be0ed447922c -r fb4eecc53e57 source/encoder/slicetype.cpp --- a/source/encoder/slicetype.cpp Tue Jun 16 11:15:03 2015 +0530 +++ b/source/encoder/slicetype.cpp Wed Jun 17 12:02:33 2015 +0530 @@ -131,15 +131,16 @@ { blockXY = 0; double avg_adj_pow2 = 0, avg_adj = 0, qp_adj = 0; - if (param->rc.aqMode == X265_AQ_AUTO_VARIANCE) + double bias_strength = 0.f; + if (param->rc.aqMode == X265_AQ_AUTO_VARIANCE || param->rc.aqMode == X265_AQ_AUTO_VARIANCE_BIASED) { - double bit_depth_correction = pow(1 << (X265_DEPTH - 8), 0.5); + double bit_depth_correction = 1.f / (1 << (2*(X265_DEPTH-8))); for (blockY = 0; blockY < maxRow; blockY += 16) { for (blockX = 0; blockX < maxCol; blockX += 16) { uint32_t energy = acEnergyCu(curFrame, blockX, blockY, param->internalCsp); - qp_adj = pow(energy + 1, 0.1); + qp_adj = pow(energy * bit_depth_correction + 1, 0.1); curFrame->m_lowres.qpCuTreeOffset[blockXY] = qp_adj; avg_adj += qp_adj; avg_adj_pow2 += qp_adj * qp_adj; @@ -149,8 +150,9 @@ avg_adj /= blockCount; avg_adj_pow2 /= blockCount; - strength = param->rc.aqStrength * avg_adj / bit_depth_correction; - avg_adj = avg_adj - 0.5f * (avg_adj_pow2 - (11.f * bit_depth_correction)) / avg_adj; + strength = param->rc.aqStrength * avg_adj; + avg_adj = avg_adj - 0.5f * (avg_adj_pow2 - (11.f)) / avg_adj; + bias_strength = param->rc.aqStrength; } else strength = param->rc.aqStrength * 1.0397f; @@ -160,7 +162,12 @@ { for (blockX = 0; blockX < maxCol; blockX += 16) { - if (param->rc.aqMode == X265_AQ_AUTO_VARIANCE) + if(param->rc.aqMode == X265_AQ_AUTO_VARIANCE_BIASED) + { + qp_adj = curFrame->m_lowres.qpCuTreeOffset[blockXY]; + qp_adj = strength * (qp_adj - avg_adj) + bias_strength * (1.f - 11.f / (qp_adj * qp_adj)); + } + else if (param->rc.aqMode == X265_AQ_AUTO_VARIANCE) { qp_adj = curFrame->m_lowres.qpCuTreeOffset[blockXY]; qp_adj = strength * (qp_adj - avg_adj); diff -r be0ed447922c -r fb4eecc53e57 source/x265.h --- a/source/x265.h Tue Jun 16 11:15:03 2015 +0530 +++ b/source/x265.h Wed Jun 17 12:02:33 2015 +0530 @@ -278,6 +278,7 @@ #define X265_AQ_NONE 0 #define X265_AQ_VARIANCE 1 #define X265_AQ_AUTO_VARIANCE 2 +#define X265_AQ_AUTO_VARIANCE_BIASED 3 /* NOTE! For this release only X265_CSP_I420 and X265_CSP_I444 are supported */ diff -r be0ed447922c -r fb4eecc53e57 source/x265cli.h --- a/source/x265cli.h Tue Jun 16 11:15:03 2015 +0530 +++ b/source/x265cli.h Wed Jun 17 12:02:33 2015 +0530 @@ -360,7 +360,7 @@ H0(" --[no-]strict-cbr Enable stricter conditions and tolerance for bitrate deviations in CBR mode. Default %s\n", OPT(param->rc.bStrictCbr)); H0(" --analysis-mode <string|int> save - Dump analysis info into file, load - Load analysis buffers from the file. Default %d\n", param->analysisMode); H0(" --analysis-file <filename> Specify file name used for either dumping or reading analysis data.\n"); - H0(" --aq-mode <integer> Mode for Adaptive Quantization - 0:none 1:uniform AQ 2:auto variance. Default %d\n", param->rc.aqMode); + H0(" --aq-mode <integer> Mode for Adaptive Quantization - 0:none 1:uniform AQ 2:auto variance 3:auto variance with bias to dark scenes. Default %d\n", param->rc.aqMode); H0(" --aq-strength <float> Reduces blocking and blurring in flat and textured areas (0 to 3.0). Default %.2f\n", param->rc.aqStrength); H0(" --qg-size <int> Specifies the size of the quantization group (64, 32, 16). Default %d\n", param->rc.qgSize); H0(" --[no-]cutree Enable cutree for Adaptive Quantization. Default %s\n", OPT(param->rc.cuTree)); _______________________________________________ x265-devel mailing list x265-devel@videolan.org https://mailman.videolan.org/listinfo/x265-devel