This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

[BUG] x265 psyrd default value
#1
  • Hybrid version 2018.04.08.1
  • The psyrdoq value of a x265 encoder file is always 0.00 when the value was set as 1.00.
Reply
#2
The x265 command line you used:
x265 --input - --output-depth 10 --y4m --profile main10 --me umh --merange 24 --limit-modes --max-merge 3 --bframes 2 --ref 2 --rc-lookahead 24 --crf 30.00 --qpfile GENERATED_QP_FILE --rd 4 --rdoq-level 2 --range limited --colormatrix bt709 --output "H:\TMP\USERTMP\test.265"
(by applying the medium preset and adjusting a few settings)
Psy-RDO quantizer is grayed out an does nothing, which is correct since 'rdoq-level' is 0.
Quote:Psy-RDO Quantization:
PsyRDO quantization will adjust the distortion cost used in rate-distortion optimized quantization (RDO quant) favoring the preservation of energy in the reconstructed image. This generally improves perceived visual quality at the cost of lower quality metric scores.

At low strength levels, psy-rdoq will influence the quantization level decisions, favoring higher AC energy in the reconstructed image. As psy-rdoq strength is increased, more non-zero coefficient levels are added and fewer coefficients are zeroed by RDOQ’s rate distortion analysis. High levels of psy-rdoq can double the bitrate which can have a drastic effect on rate control, forcing higher overall QP, and can cause ringing artifacts. psy-rdoq is less accurate than psy-rd, it is biasing towards energy in general while psy-rd biases towards the energy of the source image. But very large psy-rdoq values can sometimes be beneficial, preserving film grain for instance.

Note:
It's get's enabled for --rdoq-level 1 and above.

(command line match: --psy-rdoq X, X from 0-50.0; default: --psy-rdoq 1.0Wink
Which is correct since you applied preset 'medium', which sets psy-rdoq to 0. see: http://x265.readthedocs.io/en/default/presets.html
Quote:--rdoq-level <0|1|2>, --no-rdoq-level

Specify the amount of rate-distortion analysis to use within quantization:

At level 0 rate-distortion cost is not considered in quant

At level 1 rate-distortion cost is used to find optimal rounding values for each level (and allows psy-rdoq to be effective). It trades-off the signaling cost of the coefficient vs its post-inverse quant distortion from the pre-quant coefficient. When --psy-rdoq is enabled, this formula is biased in favor of more energy in the residual (larger coefficient absolute levels)

At level 2 rate-distortion cost is used to make decimate decisions on each 4x4 coding group, including the cost of signaling the group within the group bitmap. If the total distortion of not signaling the entire coding group is less than the rate cost, the block is decimated. Next, it applies rate-distortion cost analysis to the last non-zero coefficient, which can result in many (or all) of the coding groups being decimated. Psy-rdoq is less effective at preserving energy when RDOQ is at level 2, since it only has influence over the level distortion costs.
see: http://x265.readthedocs.io/en/default/cl...rdoq-level

=> With '--rdoq-level 0', '--psy-rdoq 1' doesn't do anything. So it looks to me that Hybrid works correctly and you are making a mistake.
If you think I made a mistake in my assessment please let me know. In case there is a bug in Hybrid I'm happy to look into it. But atm. I see no reason problem.

Cu Selur
----
Dev versions are in the 'experimental'-folder of my GoogleDrive, which is linked on the download page.
Reply
#3
1. Enable 'x265->Misc->Random Stuff->Minimize command line'
2. Apply a preset whose default psyrdoq value is 1
3. Manually sets tu-inter-depth=1 / tu-intra-depth=1 by Hybrid GUI interface option
4. Encode a file, whose psyrdoq value will be 0 (incorrect)
5. Disable 'x265->Misc->Random Stuff->Minimize command line'
6. Encode again and save to a different file, now whose psyrdoq value will be 1 now (correct)

A little bit different from x264 scenerio, but they all looks like issues of 'minimize command line'.
Reply
#4
Will look into it over the weekend and report back.

Cu Selur
----
Dev versions are in the 'experimental'-folder of my GoogleDrive, which is linked on the download page.
Reply
#5
Quote:Apply a preset whose default psyrdoq value is 1
Can you tell me one?
Because looking at: http://x265.readthedocs.io/en/default/pr...ml#presets
There isn't a preset which sets '--psy-rdoq'.
So applying any preset will set '--psy-rdoq' will set 'psy-rdoq' to the default value which is 0.0:
--[no-]psy-rdoq <0..50.0>     Strength of psycho-visual optimization in RDO quantization, 0 to disable. Default 0.0

-> Still can't reproduce the issue.
But, I stumbled over some code which might cause your issue,..

Cu Selur
----
Dev versions are in the 'experimental'-folder of my GoogleDrive, which is linked on the download page.
Reply
#6
(12.04.2018, 20:33)Selur Wrote:
Quote:Apply a preset whose default psyrdoq value is 1
Can you tell me one?
Because looking at: http://x265.readthedocs.io/en/default/pr...ml#presets
There isn't a preset which sets '--psy-rdoq'.
So applying any preset will set  '--psy-rdoq' will set 'psy-rdoq' to the default value which is 0.0:
  --[no-]psy-rdoq <0..50.0>     Strength of psycho-visual optimization in RDO quantization, 0 to disable. Default 0.0

-> Still can't reproduce the issue.
But, I stumbled over some code which might cause your issue,..

Cu Selur

Tested the dev version file, x264 rc-lookahead and x265 psy-rdoq was all fixed.

I did read the Preset Option page before I submit this issue, and I thought maybe they just didn't list all the detail parameters in that page? Blush since http://x265.readthedocs.io/en/default/cl...n-psy-rdoq here mentioned psy-rdoq should be 1.0 for presets slow, slower, veryslow. (And maybe placebo also)  

And I tested further in the dev release you sent, by just enabling/disabling 'x265->Misc->Random Stuff->Minimize command line' after applying each preset, some other parameters could still be switched on/off.

(Following order is Enable / Disable 'minimize command line')

ultrafast:
high-tier=1/high-tier=0 (I think this should always be 0 by default, since the default setting in Hybrid GUI is main tier)
deblock=0:0/no-deblock (don't know which is correct, is that deblock should be disabled in preset ultrafast?)
no-opt-qp-pps/opt-qp-pps (I think this should always be disabled by default?)
no-opt-ref-list-length-pps/opt-ref-list-length-pps (I think this should always be disabled by default?)

superfast, veryfast, faster, fast, medium, slow, slower:
high-tier=1/high-tier=0
no-opt-qp-pps/opt-qp-pps
no-opt-ref-list-length-pps/opt-ref-list-length-pps

veryslow:
high-tier=1/high-tier=0
rskip/no-rskip (should be no-rskip for preset veryslow)
no-opt-qp-pps/opt-qp-pps
no-opt-ref-list-length-pps/opt-ref-list-length-pps

placebo:
high-tier=1/high-tier=0
tskip/no-tskip (I guess this should always be no-tskip by default?)
limit-refs=0/limit-refs=3 (should be 0 for placebo)
no-opt-qp-pps/opt-qp-pps
no-opt-ref-list-length-pps/opt-ref-list-length-pps

For you reference. Maybe you can fix them at the same time?
Reply
#7
Quote:I did read the Preset Option page before I submit this issue, and I thought maybe they just didn't list all the detail parameters in that page? Blush since
Looking at the source code:
if (preset)
    {
        char *end;
        int i = strtol(preset, &end, 10);
        if (*end == 0 && i >= 0 && i < (int)(sizeof(x265_preset_names) / sizeof(*x265_preset_names) - 1))
            preset = x265_preset_names[i];

        if (!strcmp(preset, "ultrafast"))
        {
            param->lookaheadDepth = 5;
            param->scenecutThreshold = 0; // disable lookahead
            param->maxCUSize = 32;
            param->minCUSize = 16;
            param->bframes = 3;
            param->bFrameAdaptive = 0;
            param->subpelRefine = 0;
            param->searchMethod = X265_DIA_SEARCH;
            param->bEnableEarlySkip = 1;
            param->bEnableSAO = 0;
            param->bEnableSignHiding = 0;
            param->bEnableWeightedPred = 0;
            param->rdLevel = 2;
            param->maxNumReferences = 1;
            param->limitReferences = 0;
            param->rc.aqStrength = 0.0;
            param->rc.aqMode = X265_AQ_NONE;
            param->rc.qgSize = 32;
            param->bEnableFastIntra = 1;
        }
        else if (!strcmp(preset, "superfast"))
        {
            param->lookaheadDepth = 10;
            param->maxCUSize = 32;
            param->bframes = 3;
            param->bFrameAdaptive = 0;
            param->subpelRefine = 1;
            param->bEnableEarlySkip = 1;
            param->bEnableWeightedPred = 0;
            param->rdLevel = 2;
            param->maxNumReferences = 1;
            param->limitReferences = 0;
            param->rc.aqStrength = 0.0;
            param->rc.aqMode = X265_AQ_NONE;
            param->rc.qgSize = 32;
            param->bEnableSAO = 0;
            param->bEnableFastIntra = 1;
        }
        else if (!strcmp(preset, "veryfast"))
        {
            param->lookaheadDepth = 15;
            param->bFrameAdaptive = 0;
            param->subpelRefine = 1;
            param->bEnableEarlySkip = 1;
            param->rdLevel = 2;
            param->maxNumReferences = 2;
            param->rc.qgSize = 32;
            param->bEnableFastIntra = 1;
        }
        else if (!strcmp(preset, "faster"))
        {
            param->lookaheadDepth = 15;
            param->bFrameAdaptive = 0;
            param->bEnableEarlySkip = 1;
            param->rdLevel = 2;
            param->maxNumReferences = 2;
            param->bEnableFastIntra = 1;
        }
        else if (!strcmp(preset, "fast"))
        {
            param->lookaheadDepth = 15;
            param->bFrameAdaptive = 0;
            param->rdLevel = 2;
            param->maxNumReferences = 3;
            param->bEnableFastIntra = 1;
        }
        else if (!strcmp(preset, "medium"))
        {
            /* defaults */
        }
        else if (!strcmp(preset, "slow"))
        {
            param->bEnableRectInter = 1;
            param->lookaheadDepth = 25;
            param->rdLevel = 4;
            param->rdoqLevel = 2;
            param->psyRdoq = 1.0;
            param->subpelRefine = 3;
            param->maxNumMergeCand = 3;
            param->searchMethod = X265_STAR_SEARCH;
            param->maxNumReferences = 4;
            param->limitModes = 1;
            param->lookaheadSlices = 4; // limit parallelism as already enough work exists
        }
        else if (!strcmp(preset, "slower"))
        {
            param->bEnableWeightedBiPred = 1;
            param->bEnableAMP = 1;
            param->bEnableRectInter = 1;
            param->lookaheadDepth = 30;
            param->bframes = 8;
            param->tuQTMaxInterDepth = 2;
            param->tuQTMaxIntraDepth = 2;
            param->rdLevel = 6;
            param->rdoqLevel = 2;
            param->psyRdoq = 1.0;
            param->subpelRefine = 3;
            param->maxNumMergeCand = 3;
            param->searchMethod = X265_STAR_SEARCH;
            param->maxNumReferences = 4;
            param->limitReferences = 2;
            param->limitModes = 1;
            param->bIntraInBFrames = 1;
            param->lookaheadSlices = 4; // limit parallelism as already enough work exists
            param->limitTU = 4;
        }
        else if (!strcmp(preset, "veryslow"))
        {
            param->bEnableWeightedBiPred = 1;
            param->bEnableAMP = 1;
            param->bEnableRectInter = 1;
            param->lookaheadDepth = 40;
            param->bframes = 8;
            param->tuQTMaxInterDepth = 3;
            param->tuQTMaxIntraDepth = 3;
            param->rdLevel = 6;
            param->rdoqLevel = 2;
            param->psyRdoq = 1.0;
            param->subpelRefine = 4;
            param->maxNumMergeCand = 4;
            param->searchMethod = X265_STAR_SEARCH;
            param->maxNumReferences = 5;
            param->limitReferences = 1;
            param->limitModes = 1;
            param->bIntraInBFrames = 1;
            param->lookaheadSlices = 0; // disabled for best quality
            param->limitTU = 4;
        }
        else if (!strcmp(preset, "placebo"))
        {
            param->bEnableWeightedBiPred = 1;
            param->bEnableAMP = 1;
            param->bEnableRectInter = 1;
            param->lookaheadDepth = 60;
            param->searchRange = 92;
            param->bframes = 8;
            param->tuQTMaxInterDepth = 4;
            param->tuQTMaxIntraDepth = 4;
            param->rdLevel = 6;
            param->rdoqLevel = 2;
            param->psyRdoq = 1.0;
            param->subpelRefine = 5;
            param->maxNumMergeCand = 5;
            param->searchMethod = X265_STAR_SEARCH;
            param->bEnableTransformSkip = 1;
            param->bEnableRecursionSkip = 0;
            param->maxNumReferences = 5;
            param->limitReferences = 0;
            param->bIntraInBFrames = 1;
            param->lookaheadSlices = 0; // disabled for best quality
            // TODO: optimized esa
        }
see: https://bitbucket.org/multicoreware/x265...ew-default
you are right.
-> Created a new issue inside the x265 bugtracker for this: https://bitbucket.org/multicoreware/x265...esets-page,
will adjust Hybrid to the source code.

Will go through the source code and adjust Hybrid.
Won't change things like tier&co which are covered by the presets and don't have a default value and are only given a default value by Hybrid.

Cu Selur
----
Dev versions are in the 'experimental'-folder of my GoogleDrive, which is linked on the download page.
Reply
#8
(14.04.2018, 09:11)Selur Wrote:
Quote:I did read the Preset Option page before I submit this issue, and I thought maybe they just didn't list all the detail parameters in that page? Blush since
Looking at the source code:
if (preset)
   {
       char *end;
       int i = strtol(preset, &end, 10);
       if (*end == 0 && i >= 0 && i < (int)(sizeof(x265_preset_names) / sizeof(*x265_preset_names) - 1))
           preset = x265_preset_names[i];

       if (!strcmp(preset, "ultrafast"))
       {
           param->lookaheadDepth = 5;
           param->scenecutThreshold = 0; // disable lookahead
           param->maxCUSize = 32;
           param->minCUSize = 16;
           param->bframes = 3;
           param->bFrameAdaptive = 0;
           param->subpelRefine = 0;
           param->searchMethod = X265_DIA_SEARCH;
           param->bEnableEarlySkip = 1;
           param->bEnableSAO = 0;
           param->bEnableSignHiding = 0;
           param->bEnableWeightedPred = 0;
           param->rdLevel = 2;
           param->maxNumReferences = 1;
           param->limitReferences = 0;
           param->rc.aqStrength = 0.0;
           param->rc.aqMode = X265_AQ_NONE;
           param->rc.qgSize = 32;
           param->bEnableFastIntra = 1;
       }
       else if (!strcmp(preset, "superfast"))
       {
           param->lookaheadDepth = 10;
           param->maxCUSize = 32;
           param->bframes = 3;
           param->bFrameAdaptive = 0;
           param->subpelRefine = 1;
           param->bEnableEarlySkip = 1;
           param->bEnableWeightedPred = 0;
           param->rdLevel = 2;
           param->maxNumReferences = 1;
           param->limitReferences = 0;
           param->rc.aqStrength = 0.0;
           param->rc.aqMode = X265_AQ_NONE;
           param->rc.qgSize = 32;
           param->bEnableSAO = 0;
           param->bEnableFastIntra = 1;
       }
       else if (!strcmp(preset, "veryfast"))
       {
           param->lookaheadDepth = 15;
           param->bFrameAdaptive = 0;
           param->subpelRefine = 1;
           param->bEnableEarlySkip = 1;
           param->rdLevel = 2;
           param->maxNumReferences = 2;
           param->rc.qgSize = 32;
           param->bEnableFastIntra = 1;
       }
       else if (!strcmp(preset, "faster"))
       {
           param->lookaheadDepth = 15;
           param->bFrameAdaptive = 0;
           param->bEnableEarlySkip = 1;
           param->rdLevel = 2;
           param->maxNumReferences = 2;
           param->bEnableFastIntra = 1;
       }
       else if (!strcmp(preset, "fast"))
       {
           param->lookaheadDepth = 15;
           param->bFrameAdaptive = 0;
           param->rdLevel = 2;
           param->maxNumReferences = 3;
           param->bEnableFastIntra = 1;
       }
       else if (!strcmp(preset, "medium"))
       {
           /* defaults */
       }
       else if (!strcmp(preset, "slow"))
       {
           param->bEnableRectInter = 1;
           param->lookaheadDepth = 25;
           param->rdLevel = 4;
           param->rdoqLevel = 2;
           param->psyRdoq = 1.0;
           param->subpelRefine = 3;
           param->maxNumMergeCand = 3;
           param->searchMethod = X265_STAR_SEARCH;
           param->maxNumReferences = 4;
           param->limitModes = 1;
           param->lookaheadSlices = 4; // limit parallelism as already enough work exists
       }
       else if (!strcmp(preset, "slower"))
       {
           param->bEnableWeightedBiPred = 1;
           param->bEnableAMP = 1;
           param->bEnableRectInter = 1;
           param->lookaheadDepth = 30;
           param->bframes = 8;
           param->tuQTMaxInterDepth = 2;
           param->tuQTMaxIntraDepth = 2;
           param->rdLevel = 6;
           param->rdoqLevel = 2;
           param->psyRdoq = 1.0;
           param->subpelRefine = 3;
           param->maxNumMergeCand = 3;
           param->searchMethod = X265_STAR_SEARCH;
           param->maxNumReferences = 4;
           param->limitReferences = 2;
           param->limitModes = 1;
           param->bIntraInBFrames = 1;
           param->lookaheadSlices = 4; // limit parallelism as already enough work exists
           param->limitTU = 4;
       }
       else if (!strcmp(preset, "veryslow"))
       {
           param->bEnableWeightedBiPred = 1;
           param->bEnableAMP = 1;
           param->bEnableRectInter = 1;
           param->lookaheadDepth = 40;
           param->bframes = 8;
           param->tuQTMaxInterDepth = 3;
           param->tuQTMaxIntraDepth = 3;
           param->rdLevel = 6;
           param->rdoqLevel = 2;
           param->psyRdoq = 1.0;
           param->subpelRefine = 4;
           param->maxNumMergeCand = 4;
           param->searchMethod = X265_STAR_SEARCH;
           param->maxNumReferences = 5;
           param->limitReferences = 1;
           param->limitModes = 1;
           param->bIntraInBFrames = 1;
           param->lookaheadSlices = 0; // disabled for best quality
           param->limitTU = 4;
       }
       else if (!strcmp(preset, "placebo"))
       {
           param->bEnableWeightedBiPred = 1;
           param->bEnableAMP = 1;
           param->bEnableRectInter = 1;
           param->lookaheadDepth = 60;
           param->searchRange = 92;
           param->bframes = 8;
           param->tuQTMaxInterDepth = 4;
           param->tuQTMaxIntraDepth = 4;
           param->rdLevel = 6;
           param->rdoqLevel = 2;
           param->psyRdoq = 1.0;
           param->subpelRefine = 5;
           param->maxNumMergeCand = 5;
           param->searchMethod = X265_STAR_SEARCH;
           param->bEnableTransformSkip = 1;
           param->bEnableRecursionSkip = 0;
           param->maxNumReferences = 5;
           param->limitReferences = 0;
           param->bIntraInBFrames = 1;
           param->lookaheadSlices = 0; // disabled for best quality
           // TODO: optimized esa
       }
see: https://bitbucket.org/multicoreware/x265...ew-default
you are right.
-> Created a new issue inside the x265 bugtracker for this: https://bitbucket.org/multicoreware/x265...esets-page,
will adjust Hybrid to the source code.

Will go through the source code and adjust Hybrid.
Won't change things like tier&co which are covered by the presets and don't have a default value and are only given a default value by Hybrid.

Cu Selur

Tested the new dev version, here are the issue still need to check/fix:

1. For all presets

high-tier=1  when enabling 'minimize command line' in all preset.
opt-qp-pps / opt-ref-list-length-pps are both true when disabling 'minimize command line'.

Same issues as the previous dev version.

2. min-cu-size = 16 if apply superfast preset and disable 'minimize command line', which should be 8 according to preset page.

It's a new one.

3. limit-refs = 3 if apply veryslow preset and disable 'minimize command line', which should be 1 according to preset page.

It's a new one.

4. limit-refs = 3 if apply placebo preset and disable 'minimize command line', which should be 0 according to preset page.

It's the same issue as previous dev version.
Reply
#9
looking into it,..
----
Dev versions are in the 'experimental'-folder of my GoogleDrive, which is linked on the download page.
Reply
#10
(14.04.2018, 00:42)andrewschen Wrote:
(12.04.2018, 20:33)Selur Wrote:
Quote:Apply a preset whose default psyrdoq value is 1
Can you tell me one?
Because looking at: http://x265.readthedocs.io/en/default/pr...ml#presets
There isn't a preset which sets '--psy-rdoq'.
So applying any preset will set  '--psy-rdoq' will set 'psy-rdoq' to the default value which is 0.0:
  --[no-]psy-rdoq <0..50.0>     Strength of psycho-visual optimization in RDO quantization, 0 to disable. Default 0.0

-> Still can't reproduce the issue.
But, I stumbled over some code which might cause your issue,..

Cu Selur

Tested the dev version file, x264 rc-lookahead and x265 psy-rdoq was all fixed.

I did read the Preset Option page before I submit this issue, and I thought maybe they just didn't list all the detail parameters in that page? Blush since http://x265.readthedocs.io/en/default/cl...n-psy-rdoq here mentioned psy-rdoq should be 1.0 for presets slow, slower, veryslow. (And maybe placebo also)  

And I tested further in the dev release you sent, by just enabling/disabling 'x265->Misc->Random Stuff->Minimize command line' after applying each preset, some other parameters could still be switched on/off.

(Following order is Enable / Disable 'minimize command line')

ultrafast:
high-tier=1/high-tier=0 (I think this should always be 0 by default, since the default setting in Hybrid GUI is main tier)
deblock=0:0/no-deblock (don't know which is correct, is that deblock should be disabled in preset ultrafast?)
no-opt-qp-pps/opt-qp-pps (I think this should always be disabled by default?)
no-opt-ref-list-length-pps/opt-ref-list-length-pps (I think this should always be disabled by default?)

superfast, veryfast, faster, fast, medium, slow, slower:
high-tier=1/high-tier=0
no-opt-qp-pps/opt-qp-pps
no-opt-ref-list-length-pps/opt-ref-list-length-pps

veryslow:
high-tier=1/high-tier=0
rskip/no-rskip (should be no-rskip for preset veryslow)
no-opt-qp-pps/opt-qp-pps
no-opt-ref-list-length-pps/opt-ref-list-length-pps

placebo:
high-tier=1/high-tier=0
tskip/no-tskip (I guess this should always be no-tskip by default?)
limit-refs=0/limit-refs=3 (should be 0 for placebo)
no-opt-qp-pps/opt-qp-pps
no-opt-ref-list-length-pps/opt-ref-list-length-pps

For you reference. Maybe you can fix them at the same time?

This is getting a wee bit off topic here, but for future reference Andrew, while encoding most HD content with x265 you're better off to simply increase Psy-RD to 2.0-3.5 and leave Psy-RDOQ at 0. Psy-RDOQ has a HUGE impact on file size with CRF RC (Rate Control), and will deteriorate your perceived video quality with 2 Pass RC, compared to Psy-RD. There are of course exceptions to this, however.

Also, unless you have a 40+ core server and time to kill, I would HIGHLY recommend against using raw presets (without changes).. In addition to most of the slower presets using Psy-RDOQ, they also have extremely high Motion Estimation searches selected. For most HD content, motion estimation reduces your encoding speed by MASSIVE amounts, with VERY little improvement in perceived visual quality. So, if time is an issue for your encodes, and you don't have a supercomputer, then choose the lowest ME and SubME possible (--me dia --subme 0).
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)