Log in

View Full Version : Only MainConcept H.264 codec support HDR?


PCU
25th August 2021, 16:34
https://www.theinsidetips.com/tip-1409-does-h-264-support-hdr/

When in doubt, encode H.264 media using the High profile.

I’ve said for years that H.264 is a limited codec – it doesn’t support frame sizes beyond 4K nor bit depths greater than 8-bit. But, recently I started wondering whether those statements are still true. So, I went to Wikipedia (linked below) to learn more.

H.264’s official name is AVC (for Advanced Video Codec). It is the most popular format for recording, compression and distribution in the world. (HEVC is #2.)

The H.264 standard can be viewed as a “family of standards” composed of a number of different profiles, although its “High profile” is by far the mostly commonly used format.

H.264 is the most commonly used format for Blu-ray Discs, where it is one of the three mandatory video compression formats.

According to Wikipedia, H.264 supports:

Frame sizes up to 8K, depending upon profile.
YUV 422 and 4:4:4 color sampling, depending upon profile
Stereoscopic 3D video
Depth maps
HLG HDR, provided the High-10 profile is used.
Color sampling and bit-depth support are determined by the profile used when encoding a file.

The High Profile, which is the most commonly used format, supports up to 4K images with 8-bit depth.
The High-10 profile supports 10-bit depth media, but not all software offers this option.
Only the High 4:4:4 Predictive Profile supports color sampling beyond 4:2:2 and bit-depths greater than 10-bit.
So, the answer to the question: “Does H.264 support HDR?” the answer is:

No, if you are using any of the H.264 profiles in Apple Compressor or Handbrake.
Yes, but only if you use the High10 profile in Adobe Media Encoder. (MaincConcept)

rwill
25th August 2021, 18:09
https://www.theinsidetips.com/tip-1409-does-h-264-support-hdr/

[snip]

So, the answer to the question: “Does H.264 support HDR?” the answer is:

No, if you are using any of the H.264 profiles in Apple Compressor or Handbrake.
Yes, but only if you use the High10 profile in Adobe Media Encoder. (MaincConcept)

Signaling HDR in H.264 is unrelated to the AVC profile. So 8-bit Main or High works just fine. I think there is even some Dolby Vision profile for 8-bit AVC single layer.

FranceBB
25th August 2021, 18:10
H.264 as a codec does support HDR, namely as BT2020/BT2100 colormatrix and also with the HLG transfer characteristic.
H.264 also supports bit depth up to 12bit planar.

Unfortunately this is not true for x264 as H.264 encoder, which is limited to 10bit planar.

But, to answer to your question:

- Can x264 encode in 8bit and 10bit?

Yes

- Can x264 encode in 4:2:0, 4:2:2 and 4:4:4 both 8bit and 10bit?

Yes

- Can x264 encode and flag the stream as BT601, BT709, BT2020 SDR?

Yes

- Can x264 encode and flag the transfer characteristic as HLG HDR?

Yes

x264.exe "\\mibctvan000\Ingest\MEDIA\temp\AVS Script.avs" --preset medium --profile high422 --level 5.2 --keyint 1 --no-cabac --slices 8 --avcintra 300 --avcintra-flavor sony --deblock -4:-4 --overscan show --colormatrix bt2020nc --range tv --log-level info --thread-input --transfer arib-std-b67 --colorprim bt2020 --videoformat component --nal-hrd cbr --output-csp i422 --output-depth 10 --output "\\mibctvan000\Ingest\MEDIA\temp\raw_video.h264"

This creates a 4:2:2 planar 10bit BT2020 HLG stream for instance.

- Can x264 encode in 12bit?

No, but other encoders can, however it's so uncommon that basically no one needs it...

PCU
25th August 2021, 19:16
H.264 as a codec does support HDR, namely as BT2020/BT2100 colormatrix and also with the HLG transfer characteristic.
H.264 also supports bit depth up to 12bit planar.

Unfortunately this is not true for x264 as H.264 encoder, which is limited to 10bit planar.

But, to answer to your question:

- Can x264 encode in 8bit and 10bit?

Yes

- Can x264 encode in 4:2:0, 4:2:2 and 4:4:4 both 8bit and 10bit?

Yes

- Can x264 encode and flag the stream as BT601, BT709, BT2020 SDR?

Yes

- Can x264 encode and flag the transfer characteristic as HLG HDR?

Yes



This creates a 4:2:2 planar 10bit BT2020 HLG stream for instance.

- Can x264 encode in 12bit?

No, but other encoders can, however it's so uncommon that basically no one needs it...

Thanks for info. what about max resolution of x264?

nevcairiel
25th August 2021, 21:43
As far as I know, x264 should also support higher resolutions, but it might run into memory limitations.
It should also be noted that the H.264 codec is really not ideal for such high resolutions (even at 4K this can be observed), and newer codecs will yield a much better compression and/or quality.

benwaggoner
26th August 2021, 02:58
What's your goal in making HDR H.264? Every HDR-capable device I know of supports HDR HEVC, but many of those DON'T support HDR H.264.

Balling
26th August 2021, 09:28
LG C9 does support H.264 8 bit PQ tagged files, it triggers HDR, see this sample. https://disk.yandex.ru/i/ZKd0INUrpHtoDg

And yep, x264 does even support HDR metadata since of the last spec. https://code.videolan.org/videolan/x264/-/merge_requests/5

PCU
26th August 2021, 11:48
What's your goal in making HDR H.264? Every HDR-capable device I know of supports HDR HEVC, but many of those DON'T support HDR H.264.

My only problem is Google, instead of using H.265, it uses VP9!

lvqcl
26th August 2021, 12:11
So, what's the point of your question? Why is it suddenly related to Google?

PCU
26th August 2021, 18:58
HDR 8K videos of Google is: VP9! (Even 4K)

Balling
26th August 2021, 19:22
HDR 8K videos of Google is: VP9! (Even 4K)

It is not just VP9, it is HDR in AV1 for 8K (no VP9 for 8K anymore) and VP9 is actually VP9.2 profile. HDR more or less needs 10 bit at least and so AVC is not usuable, since there are no HW decoders of Hi10P of AVC.

nevcairiel
26th August 2021, 20:02
HDR 8K videos of Google is: VP9! (Even 4K)

The real question is what does that have to do with H.264? It wouldn't fare any better then VP9.

FranceBB
27th August 2021, 10:31
What's your goal in making HDR H.264? Every HDR-capable device I know of supports HDR HEVC, but many of those DON'T support HDR H.264.

True. Consumer-wise, H.264 with HDR metadata is definitely not standard and it's kinda rare to find 10bit H.264 decoders in the wild, let alone HDR compatible ones that support Hi10P in H.264.

It is not just VP9, it is HDR in AV1 for 8K (no VP9 for 8K anymore) and VP9 is actually VP9.2 profile.


Yep. Still the bitrate in YouTube for those contents is so low that the quality is dreadful if watched on a large enough monitor. Right now 8K on YouTube is good enough (i.e barely acceptable) only if watched downscaled in a 4K monitor (which takes advantage of the added bitrate), otherwise you see the approximation errors and they're really not pleasant to watch, sadly... :(



HDR more or less needs 10 bit at least and so AVC is not usuable, since there are no HW decoders of Hi10P of AVC.

Well, for a consumer point of view, yes, I totally agree, however 4K and HDR support come in handy in x264 for professional workflows. Most playout ports back in 2013 didn't support H.265 files, therefore they shifted to H.264 instead (it's the case of XAVC Intra Class 300 and 480).
Companies who adopted UHD early on have therefore been "punished" and are now stuck using H.264 for UHD HDR contents to encode mezzanine files. Of course the end user will never see this file nor H.264 as the mezzanine file will be re-encoded live by hardware encoders in H.265 10bit planar at consumer-tier bitrates (which is generally around 25 Mbit/s for UHD Streams in TVs).

Anyway, an XAVC Intra Class 300 file at 50p 4:2:2 planar in HDR HLG has 500 Mbit/s, so there's plenty of bitrate to compensate the fact that H.264 wasn't meant to be used on UHD contents.

An example of playout ports that support H.264 HDR is "Versio" which is currently widespread across several broadcasters.


As always, this is just my 2˘.

PCU
27th August 2021, 11:34
Quality of encoded videos with AV1 is even worse than VP9! (YouTube)
What AV1 encoder is Google using that is so cluttered?

MasterNobody
28th August 2021, 14:02
Quality of encoded videos with AV1 is even worse than VP9! (YouTube)
What AV1 encoder is Google using that is so cluttered?

Maybe they are using their own hardware encoder VCU (Video Coding Unit (VCU) Hot Chips 2021 (https://www.anandtech.com/show/16912/hot-chips-2021-live-blog-graphics-intel-amd-google-xilinx))?

benwaggoner
2nd September 2021, 18:57
Yep. Still the bitrate in YouTube for those contents is so low that the quality is dreadful if watched on a large enough monitor. Right now 8K on YouTube is good enough (i.e barely acceptable) only if watched downscaled in a 4K monitor (which takes advantage of the added bitrate), otherwise you see the approximation errors and they're really not pleasant to watch, sadly... :(
YouTube is pretty bitstarved at every resolution. The majority of the quality gains from going up in resolution are actually from higher bitrate. 4K at their 8K bitrates with the same compute (so 4x MIPS/pixel) would absolutely look better than their native 8K.


Well, for a consumer point of view, yes, I totally agree, however 4K and HDR support come in handy in x264 for professional workflows. Most playout ports back in 2013 didn't support H.265 files, therefore they shifted to H.264 instead (it's the case of XAVC Intra Class 300 and 480).
Companies who adopted UHD early on have therefore been "punished" and are now stuck using H.264 for UHD HDR contents to encode mezzanine files. Of course the end user will never see this file nor H.264 as the mezzanine file will be re-encoded live by hardware encoders in H.265 10bit planar at consumer-tier bitrates (which is generally around 25 Mbit/s for UHD Streams in TVs).
Ah. But in that case 10-bit is available end-to-end, and high bitrates are used. There probably isn't much visible difference at the customer end.

Anyway, an XAVC Intra Class 300 file at 50p 4:2:2 planar in HDR HLG has 500 Mbit/s, so there's plenty of bitrate to compensate the fact that H.264 wasn't meant to be used on UHD contents.

Yeah, Hi422P at a high bitrate is a whole different matter!

Balling
4th September 2021, 17:34
Well, you can have 14 bit chroma and luma and even separate_colour_plane_flag encoding (not supported by decoder of ffmpeg, "h264").

6.6.25.7 Test bitstream PPH444P-7
Specification: All slices are coded as I or P slices. Each picture contains more than one slice. entropy_coding_mode_flag
is equal to 1, specifying the CABAC parsing process. chroma_format_idc is equal to 3, specifying the 4:4:4 chroma
format. Both bit_depth_luma_minus8 and bit_depth_chroma_minus8 are equal to 6, specifying 14 bit luma and chroma
sample bit depths. separate_colour_plane_flag is equal to 1. Each picture is a coded frame. The NAL units are
encapsulated in the byte stream format specified in Annex B of ITU-T H.264 | ISO/IEC 14496-10.
Functional stage: Decoding of I and P slices for 4:4:4 14 bit frames with separate_colour_plane_flag equal to 1, using
CABAC.

https://handle.itu.int/11.1002/2000/9486 (inside Bitstreams for Professional Profiles)

FranceBB
5th September 2021, 03:38
YouTube is pretty bitstarved at every resolution.

Yep.
This is a FULL HD stream from few days ago of a concert and it's definitely starved. The amount of noticeable banding is staggering...

Img1 (https://i.imgur.com/mwKfsVL.png) - Img2 (https://i.imgur.com/VTRWLVH.png) - Img3 (https://i.imgur.com/qQZkjfk.png) - Img4 (https://i.imgur.com/HJns1NI.png)