Closed Bug 1466408 Opened 6 years ago Closed 4 years ago

Incorrect YUV -> RGB on full range video

Categories

(Core :: Audio/Video: Playback, defect, P3)

62 Branch
Unspecified
Windows 10
defect

Tracking

()

RESOLVED DUPLICATE of bug 1459526
Tracking Status
firefox62 --- affected

People

(Reporter: kasper93, Unassigned)

References

(Blocks 1 open bug)

Details

Attachments

(2 files)

Attached video limited_range.mp4
Hi, 

This is long standing bug, but given that streaming services are more and more popular and full range videos are more common we might want to support them properly. Especially that Chrome support it properly, forcing people to use it instead... 

Basically what happens is that videos are always assumed to be 16-235 range resulting is incorrect range expansion on 0-255 videos. I am attaching two files full_range.mp4 and limited_range.mp4 they should render to be visually "similar", obviously one have less steps but that's not the point. On Firefox full_range video is expanded while it should not be, resulting in clipping in low and high area.

Back in the day I fixed similar issue in MPC-HC https://github.com/mpc-hc/mpc-hc/commit/7489c0d9934fea41456bf2456818425d80410f26 it is not quite nice workaround, but this is how it works and after this change conversion works as expected. I haven't looked and FF internals so this might be not related, but just throwing it here for reference.

Attached videos were created with following commands:
ffmpeg -f lavfi -i rgbtestsrc -pix_fmt yuvj420p -t 1 full_range.mp4
ffmpeg -f lavfi -i rgbtestsrc -pix_fmt yuv420p -t 1 limited_range.mp4

Regards,
Kacper
Attached video full_range.mp4
Jean-Yves does this fall into the HDR support bucket? Do we have a meta/tracking bug for HDR support already?
Rank: 25
Flags: needinfo?(jyavenard)
Priority: -- → P3
That's not HDR per say, just that our colour space handling is subpar. We have no code to distinguish full range from limited range.

In the bucket list I would add Colorspace improvements.

HDR task does have components in there.
Flags: needinfo?(jyavenard)
note that youtube streams HDR with both limited and full range
(In reply to Vittorio Giovara from comment #4)
> note that youtube streams HDR with both limited and full range

How do you choose between the two?
(In reply to Jean-Yves Avenard [:jya] from comment #5)
> (In reply to Vittorio Giovara from comment #4)
> > note that youtube streams HDR with both limited and full range
> 
> How do you choose between the two?

you need to check the codec string, the last value represents the color range

for example `vp09.02.10.10.01.09.16.09.00` means it's either unknown or limited range, `vp09.02.10.10.01.09.16.09.01` means it is full range

the same concept (unfortunately) applies to av1 too
We typically never relied on the codec string to perform any actions. They typically are inaccurate or just plain wrong (like the web author just copy paste a codec string he found on the net, not bother to verify the actual profile and so on)
if you don't trust the codec string, then you need to parse the file header and determine range and other color properties yourself

note that neither bt601, 709 nor bt2020 defines what full range YUV means and how it should be converted to RGB.

So one could argue we're doing it right :)

Type: enhancement → defect

JPEG defines full-range BT.601.

Status: UNCONFIRMED → RESOLVED
Closed: 4 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: