[x265] [PATCH] cutree: Enable CUTree for ratecontrol when tune=ssim and bug fix for cutree
Gopu Govindaswamy
gopu at multicorewareinc.com
Wed Dec 18 07:06:11 CET 2013
# HG changeset patch
# User Gopu Govindaswamy <gopu at multicorewareinc.com>
# Date 1387346740 -19800
# Node ID f16bb88d53318be9c032bef226d50c57abde4f04
# Parent 6f1a39a9e886cf7c7a9ccf2948ca3e87d45abb12
cutree: Enable CUTree for ratecontrol when tune=ssim and bug fix for cutree
1. added cutree into cli option, default cutree is disabled
2. --tune=ssim then aq and cutree is enabled
3. Fixed bug in slicetype-frameCostRecalculate()
the qp offset for B and B-REF from lowres qpAqOffset, for non-B from lowres qpoffset
4. Fixed bug in Ratecontrol-getQScale - the clip duration should (frameduration * timescale)
when cutree is enabled
diff -r 6f1a39a9e886 -r f16bb88d5331 source/common/common.cpp
--- a/source/common/common.cpp Tue Dec 17 10:50:03 2013 +0530
+++ b/source/common/common.cpp Wed Dec 18 11:35:40 2013 +0530
@@ -399,7 +399,7 @@
else if (!strcmp(tune, "ssim"))
{
param->rc.aqMode = X265_AQ_VARIANCE;
- // not yet supported
+ param->rc.cuTree = 1;
}
else if (!strcmp(tune, "zero-latency"))
{
@@ -514,11 +514,13 @@
{
param->rc.aqMode = X265_AQ_NONE;
param->rc.bitrate = 0;
+ param->rc.cuTree = 0;
}
if (param->rc.aqStrength == 0)
{
x265_log(param, X265_LOG_WARNING, "Aq mode specified, but Aq strength is 0, ignored\n");
param->rc.aqMode = 0;
+ param->rc.cuTree = 0;
}
if (param->rc.aqMode == 0 && param->rc.cuTree)
{
@@ -641,6 +643,7 @@
}
TOOLOPT(param->bEnableWeightedBiPred, "weightbp");
TOOLOPT(param->rc.aqMode, "aq-mode");
+ TOOLOPT(param->rc.cuTree, "cutree");
if (param->rc.aqMode)
fprintf(stderr, "aq-strength=%.2f ", param->rc.aqStrength);
fprintf(stderr, "\n");
@@ -742,6 +745,9 @@
}
OPT("input-csp") p->internalCsp = parseName(value, x265_source_csp_names, berror);
OPT("me") p->searchMethod = parseName(value, x265_motion_est_names, berror);
+ OPT("cutree") p->rc.cuTree = bvalue;
+ OPT("no-cutree") p->rc.cuTree = bvalue;
+
else
return X265_PARAM_BAD_NAME;
#undef OPT
@@ -800,6 +806,7 @@
s += sprintf(s, " sao-lcu-bounds=%d", p->saoLcuBoundary);
s += sprintf(s, " sao-lcu-opt=%d", p->saoLcuBasedOptimization);
s += sprintf(s, " b-pyramid=%d", p->bBPyramid);
+ BOOL(p->rc.cuTree, "cutree");
#undef BOOL
return buf;
diff -r 6f1a39a9e886 -r f16bb88d5331 source/encoder/ratecontrol.cpp
--- a/source/encoder/ratecontrol.cpp Tue Dec 17 10:50:03 2013 +0530
+++ b/source/encoder/ratecontrol.cpp Wed Dec 18 11:35:40 2013 +0530
@@ -601,7 +601,10 @@
if (cfg->param.rc.cuTree)
{
- q = pow(BASE_FRAME_DURATION / CLIP_DURATION(2 * frameDuration), 1 - cfg->param.rc.qCompress);
+ double scale = curSlice->getSPS()->getVuiParameters()->getTimingInfo()->getTimeScale();
+ double units = curSlice->getSPS()->getVuiParameters()->getTimingInfo()->getNumUnitsInTick();
+ double timescale = units / scale;
+ q = pow(BASE_FRAME_DURATION / CLIP_DURATION(frameDuration * timescale), 1 - cfg->param.rc.qCompress);
}
else
q = pow(rce->blurredComplexity, 1 - cfg->param.rc.qCompress);
diff -r 6f1a39a9e886 -r f16bb88d5331 source/encoder/slicetype.cpp
--- a/source/encoder/slicetype.cpp Tue Dec 17 10:50:03 2013 +0530
+++ b/source/encoder/slicetype.cpp Wed Dec 18 11:35:40 2013 +0530
@@ -218,14 +218,12 @@
return -1;
}
+ estimateFrameCost(p0, p1, b, false);
if (cfg->param.rc.cuTree)
{
pic->m_lowres.satdCost = frameCostRecalculate(frames, p0, p1, b);
return pic->m_lowres.satdCost;
}
-
- estimateFrameCost(p0, p1, b, false);
-
if (cfg->param.rc.aqMode)
pic->m_lowres.satdCost = pic->m_lowres.costEstAq[b - p0][p1 - b];
else
@@ -1523,7 +1521,7 @@
{
int score = 0;
int *row_satd = Frames[b]->rowSatds[b-p0][p1-b];
- double *qp_offset = (Frames[0]->sliceType == X265_TYPE_B) ? Frames[b]->qpAqOffset : Frames[b]->qpOffset;
+ double *qp_offset = IS_X265_TYPE_B(Frames[0]->sliceType) ? Frames[b]->qpAqOffset : Frames[b]->qpOffset;
x265_emms();
for (int cuy = heightInCU - 1; cuy >= 0; cuy--)
{
diff -r 6f1a39a9e886 -r f16bb88d5331 source/x265.cpp
--- a/source/x265.cpp Tue Dec 17 10:50:03 2013 +0530
+++ b/source/x265.cpp Wed Dec 18 11:35:40 2013 +0530
@@ -147,6 +147,8 @@
{ "hash", required_argument, NULL, 0 },
{ "no-strong-intra-smoothing", no_argument, NULL, 0 },
{ "strong-intra-smoothing", no_argument, NULL, 0 },
+ { "no-cutree", no_argument, NULL, 0 },
+ { "cutree", no_argument, NULL, 0 },
{ 0, 0, 0, 0 }
};
@@ -339,6 +341,7 @@
H0(" --recon-depth Bit-depth of reconstructed raw image file. Defaults to input bit depth\n");
H0("\nSEI options:\n");
H0(" --hash Decoded Picture Hash SEI 0: disabled, 1: MD5, 2: CRC, 3: Checksum. Default %d\n", param->decodedPictureHashSEI);
+ H0(" --[no-]cutree Enable cutree for Adaptive Quantization. Default %d\n", param->rc.cuTree);
#undef OPT
#undef H0
exit(0);
More information about the x265-devel
mailing list