[RESOLVED] HEVC/H.265 10/12-bit Support

Support forum for DGDecNV
User avatar
MeteorRain
Posts: 130
Joined: Fri Jul 25, 2014 4:04 pm
Location: New Jersey

[RESOLVED] HEVC/H.265 10/12-bit Support

Post by MeteorRain »

Simply because the other ticket is marked as resolved, I guess I should create a new one to bring it to your attention.

Well, the UHD bluray is just one reason to ask for 10 bit support. The other reason is that broadcasting 4k TV program has been using HEVC Main10 profile for a long time. Thus the support to decode them is fairly demanded. LAVFilter can already decode using h/w correctly, so I'm more interested in how far we are from the goal. Appreciate if you can share some news (if any), or better, share some new binaries ;).
User avatar
admin
Posts: 4551
Joined: Thu Sep 09, 2010 3:08 pm

Re: (Shameless feature request) HEVC/H.265 10-bit Support

Post by admin »

Thanks for pointing out this use case for MAIN10. I wasn't aware of it.

What I can tell you is that nVidia is actively working on it and when they have it completed for CUVID, I will immediately release a new binary.
User avatar
MeteorRain
Posts: 130
Joined: Fri Jul 25, 2014 4:04 pm
Location: New Jersey

Re: (Shameless feature request) HEVC/H.265 10-bit Support

Post by MeteorRain »

:bow: :bravo:
User avatar
admin
Posts: 4551
Joined: Thu Sep 09, 2010 3:08 pm

Re: (Shameless feature request) HEVC/H.265 10-bit Support

Post by admin »

@MeteorRain

How are you processing MAIN10? Does the filter deliver 10-bit in some form for use with Avisynth? What form is it? Or does the filter dither down and deliver 8 bits? Your answers will guide my development. Thank you.
DAE avatar
Aleron Ives
Posts: 126
Joined: Fri May 31, 2013 8:36 pm

Re: (Shameless feature request) HEVC/H.265 10-bit Support

Post by Aleron Ives »

I would certainly hope dithering to 8 bits isn't part of the processing chain, as that rather negates the point of using 10 bits. Not only does a higher bit depth decrease banding artifacts, but it can result in up to 30% better compression, assuming the video has lots of flat blocks (e.g. animation).
User avatar
admin
Posts: 4551
Joined: Thu Sep 09, 2010 3:08 pm

Re: (Shameless feature request) HEVC/H.265 10-bit Support

Post by admin »

Well sure, Aleron, but given that Avisynth is 8-bit, what is the accepted way for a source filter to deliver 10 bits so that it can be used downstream? For example, what does LAV filters deliver for 10-bit sources? Dithering to 8 bits would be only a useful additional option.

As I mentioned, now is the time for you guys to guide the development. I don't know anything at all about 10-bit chains. Tell me what is needed.
User avatar
MeteorRain
Posts: 130
Joined: Fri Jul 25, 2014 4:04 pm
Location: New Jersey

Re: (Shameless feature request) HEVC/H.265 10-bit Support

Post by MeteorRain »

From my point of view, I'd like to see an option specifying the output format.

If you ever observed the lsmash-works package, it actually comes with an option format="XXX" where you can specify "YUV420P8" for 8bit yv12, and "YUV420P10" for 10bit. Also 16bit and RGB options available.

For DGNV, I don't see a reason to support so many colorspaces by default, so I'd say output_depth = 8 / 10 is enough.

For 8 bit output, either dither down, or truncate, since people who use this option are simply looking for a quick dirty solution.

For 10 bit output, or even 16 if you want to support, produce a picture with 2x width, and use 2 consecutive pixels to present 1 high bit depth pixel.

There are plenty of filters to work with high bit depth, so technically any reasonable output can be converted into a common format so there should not be many worries on that.

Hope this helps.
User avatar
MeteorRain
Posts: 130
Joined: Fri Jul 25, 2014 4:04 pm
Location: New Jersey

Re: (Shameless feature request) HEVC/H.265 10-bit Support

Post by MeteorRain »

By the way I'm actually not aware that we can use DGNV in DXVA mode.
If the CUVID version hasn't been completed, is it possible to support decoding Main10 using DXVA?
AFAIK LAVFilter has supported that for a while and I'm getting ~0% CPU usage when decoding Main10 HEVC 4k on GTX950.

(And I'm actively introduce this to my friend so hopefully you'll get more donations to support the development :scratch: )
DAE avatar
jpsdr
Posts: 214
Joined: Tue Sep 21, 2010 4:16 am

Re: (Shameless feature request) HEVC/H.265 10-bit Support

Post by jpsdr »

Be sure to don't mix things, because there is 2 seperate things :
- Bit depth for the DCT (or similar) matrix use for calculation.
- Bit depth of the video.
You can encode 8 bits video with 10 bits precision matrix. That's what it's done in anime fansubs with x264 10 bits.
When you decode this, output is 8 bits.
There is the same thing for MPEG-2, where DCT matrix can be 8,9 or 10 bits, but video is 8bits. MPEG-2 DVD compliant can be 8,9 or 10 bits DCT matrix, and on MPEG-2 stream (DVD compliant also), it's even allowed to switch precision matrix "on the fly".
Personnaly i would see 2 steps :
- First take care of 8 bits video encoded with 10 bits matrix.
- Then see what to do with 10 bits video.
For avisynth, in the first place, indeed use dither or truncate in case of 10 bits video.
After, maybe search to see what format/trick filters uses to work with more than 8 bits (for those who are), but it's probably just using 16 bits.
This is not a standard thing for avisynth, so i personnaly think that the default output option should be 8 bits.
User avatar
admin
Posts: 4551
Joined: Thu Sep 09, 2010 3:08 pm

Re: (Shameless feature request) HEVC/H.265 10-bit Support

Post by admin »

Thanks, guys. 10-bit DCT etc. should already be supported. We're not talking about that. We're talking about delivering 10-bit video to Avisynth.

It's easy to wave your hands and say deliver 10-bit any way you want but that doesn't help me. I already know I can deliver it any way I want! The question is what specifically I should want, and that is determined by what people are actually doing with 10-bit chains and what downstream filters are already expecting. So I'd really appreciate hearing from anyone that actually implements a 10-bit chain using Avisynth.
User avatar
MeteorRain
Posts: 130
Joined: Fri Jul 25, 2014 4:04 pm
Location: New Jersey

Re: (Shameless feature request) HEVC/H.265 10-bit Support

Post by MeteorRain »

jpsdr wrote:Be sure to don't mix things, because there is 2 seperate things :
- Bit depth for the DCT (or similar) matrix use for calculation.
- Bit depth of the video.
You can encode 8 bits video with 10 bits precision matrix. That's what it's done in anime fansubs with x264 10 bits.
When you decode this, output is 8 bits.
That's not true.
Lots of anime fansubs make good use of debanding filters and pass 10 bit videos directly to 10 bit x264.
Even if they feed 8 bit videos, the internal input preprocessor will promote the bitdepth to 10 bit before even start encoding.
Thus there's no way to actually distinguish between them, and of course the decoded video will always be 10 bit, such as in P010 colorspace.
User avatar
MeteorRain
Posts: 130
Joined: Fri Jul 25, 2014 4:04 pm
Location: New Jersey

Re: (Shameless feature request) HEVC/H.265 10-bit Support

Post by MeteorRain »

admin wrote:It's easy to wave your hands and say deliver 10-bit any way you want but that doesn't help me. I already know I can deliver it any way I want! The question is what specifically I should want, and that is determined by what people are actually doing with 10-bit chains and what downstream filters are already expecting. So I'd really appreciate hearing from anyone that actually implements a 10-bit chain using Avisynth.
Sure. But it's ... uh, quite confusing.

The most common formats people use are, interleave 10 bit and stacked 16 bit.

Stacked 16 bit is to have a picture with 2x height, where MSB on the top half, and LSB on the bottom half.
Thus, if a 16 bit pixel is 0xMMLL, then it's the following pattern.

Code: Select all

MMMMMMMM
MMMMMMMM
MMMMMMMM
MMMMMMMM
LLLLLLLL
LLLLLLLL
LLLLLLLL
LLLLLLLL
This is suitable for intermediate editing filters in avisynth.

Interleave 10 bit is to have a picture with 2x width, where MSB and LSB are grouped together.
Thus if a 10 bit pixel is 0xmMLL, then the following pattern.

Code: Select all

MLMLMLMLMLMLMLML
MLMLMLMLMLMLMLML
MLMLMLMLMLMLMLML
MLMLMLMLMLMLMLML
ML -> 0b 00000012 345678XY

Interleave 10 bit is used by x264 to retrieve data from avisynth.


So the high bitdepth process chain is like, if the source is 10 bit

Code: Select all

LWLibavVideoSource(format="YUV420P16", stacked=true) # Stacked 16
Varies of filters # Stacked 16
f3kdb(...) #Interleave 10
# To x264
Or if the source is 8 bit

Code: Select all

AVISource(...) # 8
U16() # Stacked 16
Varies of filters # Stacked 16
f3kdb(...) #Interleave 10
# To x264
User avatar
MeteorRain
Posts: 130
Joined: Fri Jul 25, 2014 4:04 pm
Location: New Jersey

Re: (Shameless feature request) HEVC/H.265 10-bit Support

Post by MeteorRain »

If you wanna make everyone happy, then the following options are suggested,

Code: Select all

int output_depth = 8 (8..16)
  Specify output depth.
  For 9..16, 2 pixels will be used to represent 1 such pixel.

bool stacked = false
  Use the stacked format for a hack of AviSynth high bit-depth support if set to true.
  The stacked format splits MSB and LSB into vertically, and MSB comes on top of output image.
  Otherwise use the interleaved format.
(See also LWLibavVideoSource.)
User avatar
admin
Posts: 4551
Joined: Thu Sep 09, 2010 3:08 pm

Re: (Shameless feature request) HEVC/H.265 10-bit Support

Post by admin »

:bravo:
Thanks MeteorRain! That's exactly what I needed. I can forward this information to nVidia and they can deliver like that from CUVID, thus avoiding any need for my filter to have to massage things.
User avatar
MeteorRain
Posts: 130
Joined: Fri Jul 25, 2014 4:04 pm
Location: New Jersey

Re: (Shameless feature request) HEVC/H.265 10-bit Support

Post by MeteorRain »

Most demanding format are stacked 16 and just 8.

If you are asking nVidia guys to do the job, kindly ask them to do stacked 16. If someone need 8 bit, just cut and return the upper half.
User avatar
admin
Posts: 4551
Joined: Thu Sep 09, 2010 3:08 pm

Re: (Shameless feature request) HEVC/H.265 10-bit Support

Post by admin »

Sounds good, thanks again.
User avatar
MeteorRain
Posts: 130
Joined: Fri Jul 25, 2014 4:04 pm
Location: New Jersey

Re: (Shameless feature request) HEVC/H.265 10-bit Support

Post by MeteorRain »

User avatar
admin
Posts: 4551
Joined: Thu Sep 09, 2010 3:08 pm

Re: (Shameless feature request) HEVC/H.265 10-bit Support

Post by admin »

Is that 10-bit and how do you rip these UHD disks? Just AnyDVD HD as usual?
User avatar
MeteorRain
Posts: 130
Joined: Fri Jul 25, 2014 4:04 pm
Location: New Jersey

Re: (Shameless feature request) HEVC/H.265 10-bit Support

Post by MeteorRain »

admin wrote:Is that 10-bit and how do you rip these UHD disks? Just AnyDVD HD as usual?
It should be 10-bit but I haven't decided whether or not to place that order.
User avatar
admin
Posts: 4551
Joined: Thu Sep 09, 2010 3:08 pm

Re: (Shameless feature request) HEVC/H.265 10-bit Support

Post by admin »

Sorry for going OT here by asking about rippers guys. Let's keep it to 10-bit support. :)
DAE avatar
jpsdr
Posts: 214
Joined: Tue Sep 21, 2010 4:16 am

Re: (Shameless feature request) HEVC/H.265 10-bit Support

Post by jpsdr »

Well, it's not totaly 100% off topic in a way. Quick answer : As far as i know, UHD Blu-Ray have new protection and nothing is able to decrypt yet.
User avatar
MeteorRain
Posts: 130
Joined: Fri Jul 25, 2014 4:04 pm
Location: New Jersey

Re: (Shameless feature request) HEVC/H.265 10-bit Support

Post by MeteorRain »

3 months passed and now GTX 10o0 even supports 12-bit decoding. Still no updates from their dev team?
User avatar
admin
Posts: 4551
Joined: Thu Sep 09, 2010 3:08 pm

Re: (Shameless feature request) HEVC/H.265 10-bit Support

Post by admin »

Still waiting...

My guess is CUVID is not high on the priority list. We just have to wait and see.
User avatar
admin
Posts: 4551
Joined: Thu Sep 09, 2010 3:08 pm

Re: (Shameless feature request) HEVC/H.265 10-bit Support

Post by admin »

Intel just released a version of the MSDK that supports 10-bit HEVC decoding. As a result of the vacillation by nVidia regarding CUVID I am seriously considering updating DGDecIM to support HEVC, which would bring us 10-bit support. Going forward, I am not entranced by the idea of maintaining two lines of development, so if nVidia doesn't get off the pot with CUVID, we may have to say goodbye. Decisions, decisions. :scratch:
User avatar
MeteorRain
Posts: 130
Joined: Fri Jul 25, 2014 4:04 pm
Location: New Jersey

Re: (Shameless feature request) HEVC/H.265 10-bit Support

Post by MeteorRain »

Well I doubt if that'll support hevc-10 on 4th gen iGPU.
Post Reply