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 > MPEG-4 AVC / H.264

Reply
 
Thread Tools Search this Thread Display Modes
Old 17th July 2012, 15:31   #1  |  Link
mzso
Registered User
 
Join Date: Oct 2009
Posts: 838
x264: No subsampling vs. subsampling

Hi!
After an argument I was wondering if chroma subsampling has any advantage outside speed.
I'm not aware of the internals of x264 but I thought maybe it could reduce the chroma information in the video in a more advanced manner, using complicated algorithms, instead of just cutting the resolution in half. (as far as I know x264 has a lot of psychovisual optimizations) It does reduce chroma information anyway (at least in lossy mode). Also the renderers wouldn't have to bother with upsampling.

If encoded to the same size which would look better? (lets assume that the subsampled has a good renderer)

Would encoding without subsampling have any encode time expense?

If a video can be encoded to a just as good (or better) quality without subsampling, why do they use 4:2:0 on Blu-rays?

If it can't be encoded to at least as good quality as with subsampling, what is the reason for it?
mzso is offline   Reply With Quote
Old 17th July 2012, 16:16   #2  |  Link
SassBot
Guest
 
Posts: n/a
Chroma subsampling is still used on Blu-Rays to save space. It's the same reason chroma subsampling has been used on every home video format. The average person won't see the difference, anyway, unless they have a player with a chroma upsampling bug.

Last edited by SassBot; 17th July 2012 at 16:19.
  Reply With Quote
Old 17th July 2012, 17:40   #3  |  Link
turab
Registered User
 
Join Date: Apr 2012
Posts: 40
Like SassBot said, the idea is that chroma subsampling has no significant affect on quality as perceived by humans. This holds true in most cases anyway. This article explains when it's not the case: http://www.glennchan.info/articles/t...ma/chroma1.htm. If you notice artefacts after subsampling, it is then that you should consider a higher-resolution chroma format. If you compressed the video without subsampling and was aiming for the same size (compared to if you were subsampling), the video would look less sharp and you'd possibly get macroblock artefacts and so on. At least with subsampling there are no macroblock artefacts and the affect on sharpness is much less if present at all.

Quote:
Originally Posted by mzso View Post
Would encoding without subsampling have any encode time expense?
Note that x264 doesn't necessarily do any subsampling. If you were converting to a different chroma format, then yes, it would affect time.
turab is offline   Reply With Quote
Old 17th July 2012, 18:14   #4  |  Link
mzso
Registered User
 
Join Date: Oct 2009
Posts: 838
Quote:
Originally Posted by SassBot View Post
Chroma subsampling is still used on Blu-Rays to save space. It's the same reason chroma subsampling has been used on every home video format. The average person won't see the difference, anyway, unless they have a player with a chroma upsampling bug.
The point of my question was that wheter x264 can achieve a similar or better result without subsampling


Quote:
Originally Posted by turab View Post
If you compressed the video without subsampling and was aiming for the same size (compared to if you were subsampling), the video would look less sharp and you'd possibly get macroblock artefacts and so on. At least with subsampling there are no macroblock artefacts and the affect on sharpness is much less if present at all.
Not quite convinced. Why do you think that x264 would be so bad at reducing chroma information? Have you tried it? Do you know of any videos that can be compared?

Last edited by mzso; 17th July 2012 at 18:20.
mzso is offline   Reply With Quote
Old 17th July 2012, 19:04   #5  |  Link
SassBot
Guest
 
Posts: n/a
Quote:
Originally Posted by mzso View Post
The point of my question was that wheter x264 can achieve a similar or better result without subsampling
Since subsampling reduces the amount of bits needed to compress the video, no. If you could get similar quality at the same bitrates without subsampled chroma there would be no reason to use subsample the chroma to begin with.

Last edited by SassBot; 17th July 2012 at 19:07.
  Reply With Quote
Old 17th July 2012, 19:22   #6  |  Link
Dark Shikari
x264 developer
 
Dark Shikari's Avatar
 
Join Date: Sep 2005
Posts: 8,689
Subsampling was originally used to reduce analog video bandwidth. It provides no real benefit for compressed video beyond speed. It's largely around for legacy and analog reasons.

Note that in real-world video formats, 4:2:0 may be better or worse than 4:4:4 depending on bitrate because of how the codecs are designed and the psychovisual effects of trading off resolution for quality.

If the source is 4:2:0, there is little point in compressing as 4:4:4, naturally.
Dark Shikari is offline   Reply With Quote
Old 17th July 2012, 19:23   #7  |  Link
vivan
/人 ◕ ‿‿ ◕ 人\
 
Join Date: May 2011
Location: Russia
Posts: 649
Quote:
Originally Posted by mzso View Post
Why do you think that x264 would be so bad at reducing chroma information?
Why do you think that x264 is reducing chroma infomation? It can output both 4:4:4 and 4:2:0. And why do you think it bad at doing it?

Quote:
Originally Posted by mzso View Post
Do you know of any videos that can be compared?
You can easily do it by yourself:
1) find any video withou subsampling (e.g. proper screen capture) or downscale any video by 50%.
2) encode it using x264. http://mewiki.project357.com/wiki/X2...ngs#output-csp
3) compare it (using not broken player & renderer).

Last edited by vivan; 17th July 2012 at 19:26.
vivan is offline   Reply With Quote
Old 17th July 2012, 19:39   #8  |  Link
Asmodian
Registered User
 
Join Date: Feb 2002
Location: San Jose, California
Posts: 3,630
I did a few limited tests with 4:2:2 source material (SVHS captures so very soft and very bad chroma already) using the lowest crf I thought gave a transparent 4:2:0 H.264.

Using 4:2:2 with the same settings gave a noticeably larger file that wasn't noticeably higher quality. Trying to match the size (I never really got the same size) resulted in a lower quality file. I never messed with chroma-qp-offset.

This is after deinterlacing, I could notice the difference (at least I thought I could) converting to 4:2:0 before deinterlacing.

Edit: I don't think any of this is relevant to modern digital source videos, sorry. Ah good ol' analogue formats.

Last edited by Asmodian; 17th July 2012 at 19:45.
Asmodian is online now   Reply With Quote
Old 17th July 2012, 20:13   #9  |  Link
benwaggoner
Moderator
 
Join Date: Jan 2006
Location: Portland, OR
Posts: 2,928
Quote:
Originally Posted by Asmodian View Post
This is after deinterlacing, I could notice the difference (at least I thought I could) converting to 4:2:0 before deinterlacing.
The nice thing about 4:2:2 for interlaced sources is that each line has its own chroma sample. With interlaced 4:2:0 an interlaced macroblock would have, for example, lines 0 and 2 share one chroma sample and lines 1 and 3 a different chroma sample. Stretching a sample out across that bigger spatial area makes them less accurate in general, and makes it harder for deinterlacing algorithms to determine the the best Cb and Cr values for the progressive output.

This was a big deal with Main Profile MPEG-2 sources (and a big reason High Profile 4:2:2 MPEG-2 gets used for mezzanine files in the industry). I've done some experimentation with H.264 interlaced 4:2:0 using MBAFF, which seems to be a lot less problematic. This would make sense, as progressive macroblocks don't get the interlaced chroma, and interlaced blocks by definition will have less chroma correlation between physically adjoining lines versus temporally adjoining lines.

Still, I'm not quite ready to say MBAFF 4:2:0 is good enough for mezzanine use.

Quote:
Edit: I don't think any of this is relevant to modern digital source videos, sorry. Ah good ol' analogue formats.
Subsampling is used in most digital source video. Consumer or prosumer gear generally uses 4:2:0. 4:2:2 is standard in most professional video workflows. 4:4:4 is used for high-end film production and such, but I almost never see a 4:4:4 source file in practice.
__________________
Ben Waggoner
Principal Video Specialist, Amazon Prime Video

My Compression Book
benwaggoner is offline   Reply With Quote
Old 17th July 2012, 20:44   #10  |  Link
Didée
Registered User
 
Join Date: Apr 2002
Location: Germany
Posts: 5,394
Quote:
I've done some experimentation with H.264 interlaced 4:2:0 using MBAFF, which seems to be a lot less problematic. This would make sense, as progressive macroblocks don't get the interlaced chroma,
Ben, I'm fully with you concerning the drawbacks regarding chroma in interlaced 4:2:0. However, I don't see how MBAFF in H.264 could help to improve something? In case of (interlaced) 4:2:0 sampling, the (interlaced) chroma sampling is already in the source, before any encoder even gets its hands on the data. I understand MBAFF helps improving coding efficiency, but it doesn't change anything about the sampling of the source data.

(At some point time back, I cracked my head about how MBAFF might handle the point of different chroma sample positions for [progressive] vs. [interlaced]. Days and headaches later, I realized that it just doesn't, because there's no need. Chroma sample positions play a role when 4:2:0 is created from a higher (chroma) resolution parent. But when the encoder gets into play, all is already fixed and done.)
__________________
- We´re at the beginning of the end of mankind´s childhood -

My little flickr gallery. (Yes indeed, I do have hobbies other than digital video!)
Didée is offline   Reply With Quote
Old 17th July 2012, 22:21   #11  |  Link
mzso
Registered User
 
Join Date: Oct 2009
Posts: 838
Quote:
Originally Posted by Dark Shikari View Post
Subsampling was originally used to reduce analog video bandwidth. It provides no real benefit for compressed video beyond speed. It's largely around for legacy and analog reasons.

Note that in real-world video formats, 4:2:0 may be better or worse than 4:4:4 depending on bitrate because of how the codecs are designed and the psychovisual effects of trading off resolution for quality.

If the source is 4:2:0, there is little point in compressing as 4:4:4, naturally.
Thanks for the affirmation. So I it all depends on if the codec is good enough, since I assume the format doesn't have any requirements.

Quote:
Originally Posted by vivan View Post
Why do you think that x264 is reducing chroma infomation? It can output both 4:4:4 and 4:2:0. And why do you think it bad at doing it?

You can easily do it by yourself:
1) find any video withou subsampling (e.g. proper screen capture) or downscale any video by 50%.
2) encode it using x264. http://mewiki.project357.com/wiki/X2...ngs#output-csp
3) compare it (using not broken player & renderer).
Since lossy compression is about removing information that's not (much) noticable it naturally reduces the chroma information (too).
I didn't say it was bad at it, that was "turab". I implied/assumed the opposite.
mzso is offline   Reply With Quote
Old 17th July 2012, 22:35   #12  |  Link
turab
Registered User
 
Join Date: Apr 2012
Posts: 40
Quote:
Originally Posted by mzso View Post
Thanks for the affirmation. So I it all depends on if the codec is good enough, since I assume the format doesn't have any requirements.


Since lossy compression is about removing information that's not (much) noticable it naturally reduces the chroma information (too).
I didn't say it was bad at it, that was "turab". I implied/assumed the opposite.
I didn't mean to imply that x264 was a bad encoder... rather that chroma subsampling is a better solution to reduce data than lossy compression. Dark Shikari is saying it depends on the bitrate, and I suppose he meant that at high bitrates, it's actually better to avoid subsampling. That sounds about right.
turab is offline   Reply With Quote
Old 18th July 2012, 00:40   #13  |  Link
Asmodian
Registered User
 
Join Date: Feb 2002
Location: San Jose, California
Posts: 3,630
Quote:
Originally Posted by benwaggoner View Post
Subsampling is used in most digital source video. Consumer or prosumer gear generally uses 4:2:0. 4:2:2 is standard in most professional video workflows. 4:4:4 is used for high-end film production and such, but I almost never see a 4:4:4 source file in practice.
I actually just meant that the results of my tests using SVHS sources probably do not mean much in this context. I understand the real "resolution" of the chroma on the tape is quite low; certainly there are almost no details in the chroma to be lost during sub sampling. If one used a "new" 4:2:2 or 4:4:4 source I imagine the results of a test like I had done could be different.
Asmodian is online now   Reply With Quote
Old 4th August 2012, 21:28   #14  |  Link
mzso
Registered User
 
Join Date: Oct 2009
Posts: 838
Come to think of it (after watching some 1080i50 videos) is probably the same thing with 50i -> deinterlacing(to 50p) and 50p (with a good encoder) at the same bitrate.
mzso is offline   Reply With Quote
Old 5th August 2012, 03:50   #15  |  Link
gyth
Registered User
 
Join Date: Sep 2011
Posts: 86
Quote:
Originally Posted by mzso View Post
Do you know of any videos that can be compared?
Video game footage pulled from an emulator is one source of unsubsampled video.
Most of the recent videos at TASVideos.org are encoded in 8bit420 and 10bit444.
Subsampling artifacts are most noticeable in static, highly detailed areas with contrasting colors.
This probably happens more often in video games than real life sources.



Code:
#http://tasvideos.org/2078M.html
a=ffvideosource("supermetroid-tas-reversebossorder-saturn.mp4").converttorgb24.subtitle("420")
b=ffvideosource("supermetroid-tas-reversebossorder-saturn_10bit444.mp4").converttorgb24.subtitle("444")
stackhorizontal(a,b).trim(43950,43950)
gyth is offline   Reply With Quote
Old 5th September 2012, 16:04   #16  |  Link
mzso
Registered User
 
Join Date: Oct 2009
Posts: 838
Quote:
Originally Posted by turab View Post
I didn't mean to imply that x264 was a bad encoder... rather that chroma subsampling is a better solution to reduce data than lossy compression. Dark Shikari is saying it depends on the bitrate, and I suppose he meant that at high bitrates, it's actually better to avoid subsampling. That sounds about right.
Actually he said it depends on the codec. Because there are a lot of sucky/weak encoders. I'd imagine the ones that don't focus on encoding subsampled sources and neglect any optimizations for unsubsampled sources would/could result in a worse outcome on lower bitrates.
mzso is offline   Reply With Quote
Old 5th September 2012, 18:43   #17  |  Link
benwaggoner
Moderator
 
Join Date: Jan 2006
Location: Portland, OR
Posts: 2,928
Quote:
Originally Posted by Didée View Post
Ben, I'm fully with you concerning the drawbacks regarding chroma in interlaced 4:2:0. However, I don't see how MBAFF in H.264 could help to improve something? In case of (interlaced) 4:2:0 sampling, the (interlaced) chroma sampling is already in the source, before any encoder even gets its hands on the data. I understand MBAFF helps improving coding efficiency, but it doesn't change anything about the sampling of the source data.
I was assuming an encoder that took 4:2:2 input and thus was able to provide the "right" 4:2:0 samples for both progressive and interlaced macroblocks. Thus a interlaced block encoded from source frame lines 0, 2, 4, 8 and a progressive block encoded from source frame lines 0, 1, 2, 3 would both have perfect chroma samples.

Some MPEG-2 encoders can do this, but I don't know that x264 can.

One place where x264 could improve is by supporting input color spaces (both >4:2:0 and >8-bit) even with the output format is 8-bit 4:2:0, and using that higher precision in its internal optimizations. In the case of 10-bit sources, an encoder should be able to do a much more compression-friendly dither than a preprocessing dithering algorithm.

(At some point time back, I cracked my head about how MBAFF might handle the point of different chroma sample positions for [progressive] vs. [interlaced]. Days and headaches later, I realized that it just doesn't, because there's no need. Chroma sample positions play a role when 4:2:0 is created from a higher (chroma) resolution parent. But when the encoder gets into play, all is already fixed and done.)[/QUOTE]
__________________
Ben Waggoner
Principal Video Specialist, Amazon Prime Video

My Compression Book
benwaggoner is offline   Reply With Quote
Old 9th January 2013, 06:27   #18  |  Link
zinga
Registered User
 
Join Date: Sep 2006
Posts: 31
Bumping old thread.

Out of interest, has anyone done any comparisons of this for x264? I'm interested in what quality you could get from a fixed size with various options.
For example, out of these three, which would be optimal for quality?
- encoding as 4:2:0
- encoding as 4:4:4 but the chroma QP offset raised enough to give similar resulting filesize as the above
- encoding as 4:4:4 but raising crf to give similar resulting filesize
zinga is offline   Reply With Quote
Old 16th March 2013, 00:40   #19  |  Link
jq963152
Registered User
 
Join Date: Apr 2012
Posts: 691
Quote:
Originally Posted by mzso View Post
Hi!
After an argument I was wondering if chroma subsampling has any advantage outside speed.
From Dark Shikari from another thread:


Quote:
Originally Posted by Dark Shikari View Post
4:4:4 is more efficient than 4:2:0, in that lowering chroma resolution is a very inefficient way of saving bits on chroma. The main gain of 4:2:0 is improved performance, lower memory bandwidth requirements, and so on -- in practical situations, except at very low rates, it should be better to encode chroma with the same number of bits, but with a higher quantizer.

jq963152 is offline   Reply With Quote
Old 16th March 2013, 07:06   #20  |  Link
Poutnik
Useless idea generator
 
Poutnik's Avatar
 
Join Date: Apr 2004
Location: Europe, Czech Republic, Brno
Posts: 354
Note that for human faces HVS is very sensitive.

The subsampling seems to me to be safer
than possibly noticable color quantization, except for high bitrates...

I may try some simulation TESTS with JPG subsampling modes saving to the same size.
__________________
Vista64 Premium SP2 / C2D E4700 2.6GHz/ 6GB RAM/ Intel GMA 3100 / DTV Leadtek DONGLE GOLD USB2 /
focused to DVB-T MPEG2 PS capture -> ProjectX -> M2V/MP2 -> MeGUI/AVS -> MP4[AVC/AAC]

Last edited by Poutnik; 16th March 2013 at 07:32.
Poutnik 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 22:48.


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