Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Video Encoding > High Efficiency Video Coding (HEVC)

Reply
 
Thread Tools Search this Thread Display Modes
Old 8th September 2018, 10:36   #6341  |  Link
Ma
Registered User
 
Join Date: Feb 2015
Posts: 326
The bug is in commit 2.8+48 https://bitbucket.org/multicoreware/...66b1fbeb421b2c

Now it is only one function to allocate analysis_data in multilib x265 8bit+10bit+12bit -- it is from 8bit part and sse_t type is uint32_t in this function. For 10bit and 12bit sse_t type is uint64_t, so this function allocate only half required memory for distortionData if you use multilib x265 for encoding 10bit or 12bit.

Patch proposition:
Code:
diff -r 88ee12651e30 source/encoder/api.cpp
--- a/source/encoder/api.cpp	Thu Aug 16 18:27:01 2018 +0530
+++ b/source/encoder/api.cpp	Sat Sep 08 06:45:23 2018 +0200
@@ -411,13 +411,18 @@
     bool isVbv = param->rc.vbvMaxBitrate > 0 && param->rc.vbvBufferSize > 0;
     int numDir = 2; //irrespective of P or B slices set direction as 2
     uint32_t numPlanes = param->internalCsp == X265_CSP_I400 ? 1 : 3;
+#if X265_DEPTH < 10
+    int numCUs_sse_t = param->internalBitDepth > 8 ? analysis->numCUsInFrame * 2 : analysis->numCUsInFrame;
+#else
+    int numCUs_sse_t = param->internalBitDepth > 8 ? analysis->numCUsInFrame : (analysis->numCUsInFrame + 1) / 2;
+#endif
 
     //Allocate memory for distortionData pointer
     CHECKED_MALLOC_ZERO(distortionData, x265_analysis_distortion_data, 1);
-    CHECKED_MALLOC_ZERO(distortionData->distortion, sse_t, analysis->numPartitions * analysis->numCUsInFrame);
+    CHECKED_MALLOC_ZERO(distortionData->distortion, sse_t, analysis->numPartitions * numCUs_sse_t);
     if (param->rc.bStatRead)
     {
-        CHECKED_MALLOC_ZERO(distortionData->ctuDistortion, sse_t, analysis->numCUsInFrame);
+        CHECKED_MALLOC_ZERO(distortionData->ctuDistortion, sse_t, numCUs_sse_t);
         CHECKED_MALLOC_ZERO(distortionData->scaledDistortion, double, analysis->numCUsInFrame);
         CHECKED_MALLOC_ZERO(distortionData->offset, double, analysis->numCUsInFrame);
         CHECKED_MALLOC_ZERO(distortionData->threshold, double, analysis->numCUsInFrame);
Test x265 Windows binary (multilib exe + patch) www.msystem.waw.pl/x265/x265-2.8+66-patched.7z
Ma is offline   Reply With Quote
Old 8th September 2018, 13:56   #6342  |  Link
K.i.N.G
Registered User
 
Join Date: Aug 2009
Posts: 90
I'm encoding an 4:2:2 1920x1080p 10bit video with HDR and i'm getting this error/warning:

x265 [error]: Recommended Settings for HDR: colour primaries should be BT.2020,
transfer characteristics should be SMPTE ST.2084,
matrix coeffs should be BT.2020,
the input video should be 10 bit 4:2:0
Disabling offset tuning for HDR videos

But the encoding just continues... is it safe to ignore this or should i convert the video to 4:2:0 (i'd rather not but if i really have to...)?
K.i.N.G is offline   Reply With Quote
Old 8th September 2018, 14:39   #6343  |  Link
SeeMoreDigital
Life's clearer in 4K UHD
 
SeeMoreDigital's Avatar
 
Join Date: Jun 2003
Location: Notts, UK
Posts: 12,219
Quote:
Originally Posted by K.i.N.G View Post
I'm encoding an 4:2:2 1920x1080p 10bit video with HDR and i'm getting this error/warning....

But the encoding just continues... is it safe to ignore this or should i convert the video to 4:2:0 (i'd rather not but if i really have to...)?
4:2:0 is still the chroma sub-sampling standard for all commercially released video. No domestic hardware players supports 4:2:2.
__________________
| I've been testing hardware media playback devices and software A/V encoders and decoders since 2001 | My Network Layout & A/V Gear |
SeeMoreDigital is offline   Reply With Quote
Old 8th September 2018, 14:51   #6344  |  Link
K.i.N.G
Registered User
 
Join Date: Aug 2009
Posts: 90
Quote:
Originally Posted by SeeMoreDigital View Post
4:2:0 is still the chroma sub-sampling standard for all commercially released video. No domestic hardware players supports 4:2:2.
I'm pretty sure my nvidia shield tv plays it just fine. And I'd be surprised if even the internal player of my tv couldn't handle 4:2:2 to be honest, but I cant test it right now (not at home for the whole weekend).

My concern is that I'm not sure what "disabling offset tuning for HDR videos" exactly means... Will the resulting encode still be HDR?
K.i.N.G is offline   Reply With Quote
Old 8th September 2018, 16:42   #6345  |  Link
SeeMoreDigital
Life's clearer in 4K UHD
 
SeeMoreDigital's Avatar
 
Join Date: Jun 2003
Location: Notts, UK
Posts: 12,219
Quote:
Originally Posted by K.i.N.G View Post
...And I'd be surprised if even the internal player of my tv couldn't handle 4:2:2 to be honest...
None of my smart TV's can. And my OPPO can't recognise such video streams placed within any supporting container!
__________________
| I've been testing hardware media playback devices and software A/V encoders and decoders since 2001 | My Network Layout & A/V Gear |
SeeMoreDigital is offline   Reply With Quote
Old 8th September 2018, 17:31   #6346  |  Link
RieGo
Registered User
 
Join Date: Nov 2009
Posts: 59
i agree. you won't be happy with a 4:2:2 video file. i encoded one file in 422 by accident. none of my devices could play it. plex also couldn't read it iirc. only pc could handle the file.
IMHO best thing to do would be convert your file to 4:2:0 before encoding. (or maybe it's just a problem with your source filter) you won't see a big difference and x265 won't have any problems with hdr metadata
RieGo is offline   Reply With Quote
Old 10th September 2018, 09:15   #6347  |  Link
mini-moose
Registered User
 
Join Date: Oct 2007
Posts: 385
Odd question maybe...
Do switches like --max-cll or --master-display have any effect on the actual video encode or are they more like flags for your HDR device?
mini-moose is offline   Reply With Quote
Old 10th September 2018, 11:17   #6348  |  Link
sneaker_ger
Registered User
 
Join Date: Dec 2002
Posts: 5,565
flags
sneaker_ger is offline   Reply With Quote
Old 10th September 2018, 22:17   #6349  |  Link
katzenjoghurt
Registered User
 
Join Date: Feb 2007
Posts: 128
Hi guys,

I'm currently trying to convert Star Wars Episode III to x265... and hell... it's a beast.
This movie gives me super ugly artifacts in dark scenes.

Original: https://i.imgur.com/PA9cWuR.png
Encoding: https://i.imgur.com/HpVbyf4.png (with meagre 2,300kb/s in that scene, 4,500kb/s on avg for the whole movie)

My settings were: --crf 23 --tune grain --profile main12 --output-depth 12 --rskip --qcomp 0.8 --no-open-gop --no-deblock --no-strong-intra-smoothing

I already tried aq-mode 3 but to retain an okayish quality I had to set the aq-strength to 1.5 and ended up with 12 mbit/s for this scene.
I then tried aq-strength 3 and ended up with with perfect quality... and wopping 43 mbit /s.

Why are dark scenes so much more costly than brighter scenes?
This does not feel right...
What can I do?
katzenjoghurt is offline   Reply With Quote
Old 10th September 2018, 22:30   #6350  |  Link
sneaker_ger
Registered User
 
Join Date: Dec 2002
Posts: 5,565
Quote:
Originally Posted by katzenjoghurt View Post
I already tried aq-mode 3 but to retain an okayish quality I had to set the aq-strength to 1.5 and ended up with 12 mbit/s for this scene.
Why did you not lower crf?
sneaker_ger is offline   Reply With Quote
Old 11th September 2018, 04:08   #6351  |  Link
Selur
Registered User
 
Selur's Avatar
 
Join Date: Oct 2001
Location: Germany
Posts: 7,259
Also:
Boosting the brightness and looking at the source sometimes shows lots of compression artifacts, so some smoothing/denoising of the dark areas might help to understand where the bit rate goes.
Dark areas often contain lots of noise and artifacts which the encoder interprets as details that should be preserved.
__________________
Hybrid here in the forum, homepage
Selur is offline   Reply With Quote
Old 11th September 2018, 05:16   #6352  |  Link
benwaggoner
Moderator
 
Join Date: Jan 2006
Location: Portland, OR
Posts: 4,750
Quote:
Originally Posted by sneaker_ger View Post
Why did you not lower crf?
Yeah, I recommend doing 2-pass VBR encoding when trying to figure out quality/bitrate tradeoffs, and then figuring out the optimal CRF from there.
__________________
Ben Waggoner
Principal Video Specialist, Amazon Prime Video

My Compression Book
benwaggoner is offline   Reply With Quote
Old 11th September 2018, 11:29   #6353  |  Link
Forteen88
Herr
 
Join Date: Apr 2009
Location: North Europe
Posts: 556
@katzenjoghurt. Maybe you should set x265: --zones
and increase/decrease bitrate where you want.
Forteen88 is offline   Reply With Quote
Old 11th September 2018, 11:41   #6354  |  Link
LigH
German doom9/Gleitz SuMo
 
LigH's Avatar
 
Join Date: Oct 2001
Location: Germany, rural Altmark
Posts: 6,753
Intentionally, aq-mode 3 is supposed to help with dark scenes, even without zones; but it needs a matching aq-strength too, and sufficient bitrate, and possibly other circumstances — and still can't work wonders...
__________________

New German Gleitz board
MediaFire: x264 | x265 | VPx | AOM | Xvid

Last edited by LigH; 11th September 2018 at 11:49.
LigH is offline   Reply With Quote
Old 11th September 2018, 14:42   #6355  |  Link
Forteen88
Herr
 
Join Date: Apr 2009
Location: North Europe
Posts: 556
Quote:
Originally Posted by katzenjoghurt View Post
My settings were: --crf 23 --tune grain --profile main12 --output-depth 12 --rskip --qcomp 0.8 --no-open-gop --no-deblock --no-strong-intra-smoothing
Are you aware of that GPU-decoding (certain newer GPUs) doesn't support 12-bits x265-video, but maximum 10-bits x265-video?
Forteen88 is offline   Reply With Quote
Old 11th September 2018, 15:10   #6356  |  Link
LigH
German doom9/Gleitz SuMo
 
LigH's Avatar
 
Join Date: Oct 2001
Location: Germany, rural Altmark
Posts: 6,753
And if you have source material with only 8 bit precision per color component, an internal precision of 12 bit per quantization coefficient would be a waste anyway.
__________________

New German Gleitz board
MediaFire: x264 | x265 | VPx | AOM | Xvid
LigH is offline   Reply With Quote
Old 11th September 2018, 18:45   #6357  |  Link
brumsky
Registered User
 
Join Date: Jun 2016
Posts: 116
Quote:
Originally Posted by katzenjoghurt View Post
Hi guys,

I'm currently trying to convert Star Wars Episode III to x265... and hell... it's a beast.
This movie gives me super ugly artifacts in dark scenes.

Original: https://i.imgur.com/PA9cWuR.png
Encoding: https://i.imgur.com/HpVbyf4.png (with meagre 2,300kb/s in that scene, 4,500kb/s on avg for the whole movie)

My settings were: --crf 23 --tune grain --profile main12 --output-depth 12 --rskip --qcomp 0.8 --no-open-gop --no-deblock --no-strong-intra-smoothing

I already tried aq-mode 3 but to retain an okayish quality I had to set the aq-strength to 1.5 and ended up with 12 mbit/s for this scene.
I then tried aq-strength 3 and ended up with with perfect quality... and wopping 43 mbit /s.

Why are dark scenes so much more costly than brighter scenes?
This does not feel right...
What can I do?
To me it looks like your PSY values are set very high. That could be an effect of tune grain though. Have you tried it without tune grain? Maybe take tune grain out and try playing with the PSY values. I've found aq-mode 3 to work well but it needs a bit high bit rate to help it. When I use aq-mode 3 I try to set the strength setting between .85-1, then up the bit rate as needed to reach my target quality.
brumsky is offline   Reply With Quote
Old 11th September 2018, 21:15   #6358  |  Link
katzenjoghurt
Registered User
 
Join Date: Feb 2007
Posts: 128
Hey brumsky et al.!

Yes... psy_rd was set to 4.
I kept grain mode but reduced psy_rd to 1 and set crf to 21 now and the artifacts are gone (while the file size got a bit smaller) ... the result is a bit smeared though.
Also it kills most of the grain.
https://i.imgur.com/eqQJXy7.png

Lowering Crf or Psy further won't do any good though... quite the contrary. At least on that example scene.

Last edited by katzenjoghurt; 11th September 2018 at 21:33.
katzenjoghurt is offline   Reply With Quote
Old 11th September 2018, 21:25   #6359  |  Link
katzenjoghurt
Registered User
 
Join Date: Feb 2007
Posts: 128
Quote:
Originally Posted by sneaker_ger View Post
Why did you not lower crf?
I didn't know that this is good practice.
Tried it out but didn't find any sweet spot yet though. :-/

Quote:
Originally Posted by Forteen88 View Post
Are you aware of that GPU-decoding (certain newer GPUs) doesn't support 12-bits x265-video, but maximum 10-bits x265-video?
Just something I tried out... 12-bit seemed to have helped in this thread. But no. Didn't work out for me.

Last edited by katzenjoghurt; 12th September 2018 at 08:57.
katzenjoghurt is offline   Reply With Quote
Old 12th September 2018, 19:54   #6360  |  Link
excellentswordfight
Lost my old account :(
 
Join Date: Jul 2017
Posts: 322
Quote:
Originally Posted by katzenjoghurt View Post
I didn't know that this is good practice.
Tried it out but didn't find any sweet spot yet though. :-/



Just something I tried out... 12-bit seemed to have helped in this thread. But no. Didn't work out for me.
Tune grain usually gives pretty bad results, I found it to be usefull in very few instances.

I would start over with main10, keep --no-strong-intra-smoothing and --no-sao, try a slower preset and a lower CRF value. If that doesnt give you good results start playing with AQ and qcomp
excellentswordfight is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 17:33.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.