Snowknight26
13th June 2013, 05:03
I noticed a couple of years ago that x264 seemed to be converting color ranges incorrectly.
Using a Fraps sample (YV12, full range) from this zip (http://stfcc.org/misc/x264%20range%20test.zip), I ran a few conversion tests with x264, only changing input and output color ranges between tests. The following screenshots were taken with MPC-HC.
original.avi
http://stfcc.org/pics/i/5fb562a02831375243475b34851afbe6_th.jpg (http://stfcc.org/pics/i/5fb562a02831375243475b34851afbe6.png)
input range=pc, output range=pc
http://stfcc.org/pics/i/7638d69bf21b48c5c78372c2e3b34add_th.jpg (http://stfcc.org/pics/i/7638d69bf21b48c5c78372c2e3b34add.png)
input range=pc, output range=tv
http://stfcc.org/pics/i/614ff8c65c3abda5b7a0357eeb40cc6c_th.jpg (http://stfcc.org/pics/i/614ff8c65c3abda5b7a0357eeb40cc6c.png)
input range=tv, output range=pc
http://stfcc.org/pics/i/21d0a5c84925632123afc4b256cec53a_th.jpg (http://stfcc.org/pics/i/21d0a5c84925632123afc4b256cec53a.png)
input range=tv, output range=tv
http://stfcc.org/pics/i/5c549f6c5ccd5b9ff2286744abb59021_th.jpg (http://stfcc.org/pics/i/5c549f6c5ccd5b9ff2286744abb59021.png)
ffmpeg detects the pixel format of original.avi as yuvj420p and it can correctly convert it to Huffyuv without the problematic color range, so libavformat can be ruled out.
At first I thought it was because video_full_range_flag wasn't set, but both video_signal_type_present_flag and video_full_range_flag were set to 1 in the output H.264 streams' SPS headers when specifying '--range pc.'
It's clear that only the 2nd encoded sample has the correct color levels, but shouldn't only the first one (and last?), seeing as the input's color range is 0-255 and I'm specifying 0-255 as the output?
Because of all this, a few browsers render the samples with the wrong color ranges. In them, the first and last sample are displayed correctly, the 2nd's levels are washed out and the 3rd's are too dark. The depressing part is that that doesn't match how players such as MPC-HC display the samples. So what on earth is going on?
Using a Fraps sample (YV12, full range) from this zip (http://stfcc.org/misc/x264%20range%20test.zip), I ran a few conversion tests with x264, only changing input and output color ranges between tests. The following screenshots were taken with MPC-HC.
original.avi
http://stfcc.org/pics/i/5fb562a02831375243475b34851afbe6_th.jpg (http://stfcc.org/pics/i/5fb562a02831375243475b34851afbe6.png)
input range=pc, output range=pc
http://stfcc.org/pics/i/7638d69bf21b48c5c78372c2e3b34add_th.jpg (http://stfcc.org/pics/i/7638d69bf21b48c5c78372c2e3b34add.png)
input range=pc, output range=tv
http://stfcc.org/pics/i/614ff8c65c3abda5b7a0357eeb40cc6c_th.jpg (http://stfcc.org/pics/i/614ff8c65c3abda5b7a0357eeb40cc6c.png)
input range=tv, output range=pc
http://stfcc.org/pics/i/21d0a5c84925632123afc4b256cec53a_th.jpg (http://stfcc.org/pics/i/21d0a5c84925632123afc4b256cec53a.png)
input range=tv, output range=tv
http://stfcc.org/pics/i/5c549f6c5ccd5b9ff2286744abb59021_th.jpg (http://stfcc.org/pics/i/5c549f6c5ccd5b9ff2286744abb59021.png)
ffmpeg detects the pixel format of original.avi as yuvj420p and it can correctly convert it to Huffyuv without the problematic color range, so libavformat can be ruled out.
At first I thought it was because video_full_range_flag wasn't set, but both video_signal_type_present_flag and video_full_range_flag were set to 1 in the output H.264 streams' SPS headers when specifying '--range pc.'
It's clear that only the 2nd encoded sample has the correct color levels, but shouldn't only the first one (and last?), seeing as the input's color range is 0-255 and I'm specifying 0-255 as the output?
Because of all this, a few browsers render the samples with the wrong color ranges. In them, the first and last sample are displayed correctly, the 2nd's levels are washed out and the 3rd's are too dark. The depressing part is that that doesn't match how players such as MPC-HC display the samples. So what on earth is going on?