x265 Configuration - empty / blank "Tuning" not available

Started by andrewk8, January 17, 2016, 10:20:16 PM

Previous topic - Next topic

andrewk8

Using Avidemux 2.6.911 Windows x64 nightly 160109.
I'm trying to use HEVC x265.
When configuring the codec, I have "Use advanced configuration" un-checked.
Under Tuning, an empty / blank tune is not available.
Per the x265 official documentation, an empty / blank tuning is default.
The four tunings available in Avidemux would all have a negative impact on file size (larger).  The empty / blank tuning and "grain" tunings are missing from Avidemux.
http://x265.readthedocs.org/en/default/presets.html

Pushman

And there is version 1.4 in Avidemux. Actual version of x265 is 1.8.

andrewk8

Still broken in 2.6.12 Windows x64.

"none" tuning is not available. Please don't force "Basic" users to apply a tuning to the presets.

Also "grain" is not available either.

Reference official x265 documentation
http://x265.readthedocs.org/en/default/presets.html#tuning

mean

There is not a lot of work done on x265 at the moment

Macroblockhead

I am also looking for the "none" tuning option. Doesn't matter how much work is done on x265 right now, that is not the issue here and does not explain why the DEFAULT option was removed. That's being very dismissive of a legit issue.

I love Avidemux but would hate to see laziness or illogical configuration options hinder its usefulness. I can not stand to use Handbrake or any other encoding software, so Avidemux is really my only option.

Please include the "none" and "grain" tuning options in the next release!

eumagga0x2a

I added just for fun "none" at https://github.com/mean00/avidemux2/blob/master/avidemux_plugins/ADM_videoEncoder/x265/qt4/Q_x265.cpp#L85


diff --git a/avidemux_plugins/ADM_videoEncoder/x265/qt4/Q_x265.cpp b/avidemux_plugins/ADM_videoEncoder/x265/qt4/Q_x265.cpp
index fe94dd8..727febf 100644
--- a/avidemux_plugins/ADM_videoEncoder/x265/qt4/Q_x265.cpp
+++ b/avidemux_plugins/ADM_videoEncoder/x265/qt4/Q_x265.cpp
@@ -82,7 +82,7 @@ static const aspectRatio predefinedARs[]={
static const char* listOfPresets[] = { "ultrafast", "superfast", "veryfast", "faster", "fast", "medium", "slow", "slower", "veryslow", "placebo" };
#define NB_PRESET sizeof(listOfPresets)/sizeof(char*)

-static const char* listOfTunings[] = { "psnr", "ssim", "zerolatency", "fastdecode" };
+static const char* listOfTunings[] = { "none", "psnr", "ssim", "zerolatency", "fastdecode" };
#define NB_TUNE sizeof(listOfTunings)/sizeof(char*)

static const char* listOfProfiles[] = { "main", "main10", "mainstillpicture" };


and recompiled Avidemux on my computer to see what happens. I encoded a 1280x720 video of 10 min duration with "none", with "psnr" and finally with "fastdecode" tuning, but resulting h265 videos turned out to be very close in size. "psnr" produced the smallest files, "fastdecode" the largest (+5%), "none" was in between (+4% up from "psnr"). There was no perceivable quality difference whatsoever.

I used the "superfast" preset only. My PC is not fast enough to play h265 in real time at this resolution, let alone to encode at a decent speed  ;D

eumagga0x2a

I'm very sorry, writing "just for fun" above was insufficient as a warning. This patch is not a valid solution and should not end up in the repository, please backout https://github.com/mean00/avidemux2/commit/6bb59711f290291c532bd60f37513e3b04d763e3. I never tried to understand why libx265 did not reject "none" like the command line utility x265 did, but it is not a valid tuning value. The right way to fix this would be not to add anything as tuning  https://github.com/mean00/avidemux2/blob/master/avidemux_plugins/ADM_videoEncoder/x265/ADM_x265Setup.cpp#L50 at all if "none" is selected.

My apologies again for causing this misunderstanding.


eumagga0x2a

It is getting funny. I compared the output of dumpx265Setup() while encoding a 16:9 SD mpeg2 video with all currently available valid x265 tunings including a locally added "grain" tuning as well as with invalid ones like "nonsense", then I tested with https://github.com/mean00/avidemux2/blob/master/avidemux_plugins/ADM_videoEncoder/x265/ADM_x265Setup.cpp#L50 commented out: the encoder treats invalid tuning strings the same as an empty one. In this sense, the patch worked.

Here is a list of diffs in comparison with the null tune (the preset was "veryfast"):

general.tuning=psnr

@@ -95,7 +95,7 @@
qpStep :4
rfConstant :20,000000
aqMode :1
-aqStrength :1,000000
+aqStrength :0,000000
vbvMaxBitrate :0
vbvBufferSize :0
vbvBufferInit :0,900000


This doesn't conform with http://x265.readthedocs.io/en/default/presets.html#tuning as aqMode and cuTree are not set to zero, but at least aqStrength is zero.

general.tuning=ssim

@@ -94,7 +94,7 @@
pbFactor :1,300000
qpStep :4
rfConstant :20,000000
-aqMode :1
+aqMode :2
aqStrength :1,000000
vbvMaxBitrate :0
vbvBufferSize :0


Looks plausible.

general.tuning=zerolatency

@@ -38,11 +38,11 @@
keyframeMax :250
maxNumReferences :2
bFrameAdaptive :0
-bframes :4
+bframes :0
bBPyramid :1
-lookaheadDepth :15
+lookaheadDepth :0
bFrameBias :0
-scenecutThreshold :40
+scenecutThreshold :0
*************************************
***      Intra Coding Tools       ***
*************************************
@@ -99,7 +99,7 @@
vbvMaxBitrate :0
vbvBufferSize :0
vbvBufferInit :0,900000
-cuTree :1
+cuTree :0
rfConstantMax :0,000000
rfConstantMin :0,000000
bStatWrite :0


Conforms with the docs, produces very large files (almost twice as big as with "none"/invalid/null tuning).

general.tuning=fastdecode

@@ -55,7 +55,7 @@
subpelRefine :1
searchRange :57
maxNumMergeCand :2
-bEnableWeightedPred :1
+bEnableWeightedPred :0
bEnableWeightedBiPred :0
*************************************
***        Analysis Tools         ***
@@ -72,8 +72,8 @@
bEnableSignHiding :1
bEnableTransformSkip :0
bEnableTSkipFast :0
-bEnableLoopFilter :1
-bEnableSAO :1
+bEnableLoopFilter :0
+bEnableSAO :0
bSaoNonDeblocked :0
cbQpOffset :0
crQpOffset :0


Follows the docs, produces moderately larger files.

general.tuning=grain

@@ -89,13 +89,13 @@
qp :32
bitrate :0
bStrictCbr :0
-qCompress :0,600000
-ipFactor :1,400000
-pbFactor :1,300000
+qCompress :0,800000
+ipFactor :1,100000
+pbFactor :1,100000
qpStep :4
rfConstant :20,000000
aqMode :1
-aqStrength :1,000000
+aqStrength :0,300000
vbvMaxBitrate :0
vbvBufferSize :0
vbvBufferInit :0,900000


Like with psnr, aqMode is not set to zero, but aqStrength is reduced. Produces the largest files with my source video.

The full output for the null tune is

*************************************
***      Encoder Environment      ***
*************************************
cpuid :1049151
bEnableWavefront :1
numaPools :(null)
frameNumThreads :0
logLevel :2
bLogCuStats :0
bEnablePsnr :0
bEnableSsim :0
decodedPictureHashSEI :0
*************************************
** Internal Picture Specification  **
*************************************
internalBitDepth :8
internalCsp :1
fpsNum :25
fpsDenom :1
sourceWidth :720
sourceHeight :576
levelIdc :0
interlaceMode :0
bRepeatHeaders :0
bEnableAccessUnitDelimiters :0
bEmitHRDSEI :0
*************************************
*** Coding Unit (CU) Definitions  ***
*************************************
maxCUSize :64
tuQTMaxInterDepth :1
tuQTMaxIntraDepth :1
*************************************
***  GOP Structure and Lookahead  ***
*************************************
bOpenGOP :1
keyframeMin :0
keyframeMax :250
maxNumReferences :2
bFrameAdaptive :0
bframes :4
bBPyramid :1
lookaheadDepth :15
bFrameBias :0
scenecutThreshold :40
*************************************
***      Intra Coding Tools       ***
*************************************
bEnableConstrainedIntra :0
bEnableStrongIntraSmoothing :1
*************************************
***      Inter Coding Tools       ***
*************************************
searchMethod :1
subpelRefine :1
searchRange :57
maxNumMergeCand :2
bEnableWeightedPred :1
bEnableWeightedBiPred :0
*************************************
***        Analysis Tools         ***
*************************************
bEnableAMP :0
bEnableRectInter :0
bEnableEarlySkip :1
rdPenalty :0
rdLevel :2
psyRd :0
*************************************
***         Coding Tools          ***
*************************************
bEnableSignHiding :1
bEnableTransformSkip :0
bEnableTSkipFast :0
bEnableLoopFilter :1
bEnableSAO :1
bSaoNonDeblocked :0
cbQpOffset :0
crQpOffset :0
bIntraInBFrames :0
noiseReductionIntra :0
noiseReductionInter :0
bLossless :0
bCULossless :0
*************************************
***         Rate Control          ***
*************************************
rateControlMode :2
qp :32
bitrate :0
bStrictCbr :0
qCompress :0,600000
ipFactor :1,400000
pbFactor :1,300000
qpStep :4
rfConstant :20,000000
aqMode :1
aqStrength :1,000000
vbvMaxBitrate :0
vbvBufferSize :0
vbvBufferInit :0,900000
cuTree :1
rfConstantMax :0,000000
rfConstantMin :0,000000
bStatWrite :0
bStatRead :0
qblur :0,500000
complexityBlur :20,000000
*************************************
***  Video Usability Information  ***
*************************************
aspectRatioIdc :0
sarWidth :64
sarHeight :45
bEnableOverscanInfoPresentFlag :0
bEnableOverscanAppropriateFlag :0
bEnableVideoSignalTypePresentFlag :0
videoFormat :5
bEnableVideoFullRangeFlag :0
bEnableColorDescriptionPresentFlag :0
colorPrimaries :2
transferCharacteristics :2
matrixCoeffs :2
bEnableChromaLocInfoPresentFlag :0
chromaSampleLocTypeTopField :0
chromaSampleLocTypeBottomField :0
bEnableDefaultDisplayWindowFlag :0
defDispWinLeftOffset :0
defDispWinRightOffset :0
defDispWinTopOffset :0
defDispWinBottomOffset :0


It seems, it leaves the values at there defaults as listed in http://x265.readthedocs.io/en/default/presets.html#presets for the "veryfast" preset. This said, I have no idea why invalid values are silently discarded producing exactly the desired effect.

The attached patch adds "grain" as tuning with invalid but working string "none" as default. Please do whatever you want with it. I've caused too much ruckus already ;)