KhronosGroup / KhronosGroup/KTX-Software
samplePositions possibly incorrect for single-plane 4:2:2 YUV formats
- Dominant language
- C++
- Stars
- 1.4k
- Forks
- 317
- Avg merge
- 20h 12m
- Merged PRs (30d)
- 3
Description
In https://github.com/KhronosGroup/KTX-Software/pull/864#discussion_r1528458923, @aqnuep wrote that currently for the single-plane 4:2:2 YUV formats (YUYV) we set the sample positions to (Y: 64, 128, 0, 0; U: 64, 128, 0, 0; Y: 192, 128, 0, 0; V: 64, 128, 0, 0). @fluppeteer gave the following response suggesting perhaps this choice is wrong. Further discussion is needed.
---
For a 422 format, Y should be 0, and one of the X values should be 0 - the indexing should be happening relative to the minimum coordinate of any sample (which I didn't explicitly say, I suspect). If you're doing a texture lookup that places the sample location at a half-pixel offset relative to the coordinate space (which is common), that's a separate transformation, although it would be helpful to have made that explicit in the introduction somewhere. I'll try to get that in with the next update.
The Y(/G) samples should be at X = 0 and 1. The Cb and CR (/B and R) samples will likely be either at X = 0 or X = 0.5, depending on the representation (for 4:2:0 formats, typical JPEG and MPEG disagree, for example); Vulkan doesn't embed that in the format, it's in the samplerYCbCrConversion, so you may have to pick a representation that may be inaccurate if the format is the only thing you have access to.
I'll look as soon as I've had lunch to see whether that 0.5 offset you mentioned is still there and what's causing it.
What I'm referring to here is running on a big-endian architecture, at which point you have multiple samples representing each channel (in order to handle the non-contiguous bits when seen in little-endian canonical order). If you had a big-endian 16-bit-per-channel YUV422 format and looked at it on a little-endian machine (or used the nominally canonical little-endian representation) then you'd have 8 samples, with two each for each channel, so a total of four covering the two Y samples. Is anyone actually supporting this? Questionable. I suspect there are more urgent things to fix.
---
Read the rest of https://github.com/KhronosGroup/KTX-Software/pull/864#discussion_r1528458923 for more details.
This may turn out to be a specification issue.
Contributor guide
Research direction
Start by reading the full discussion in pull request #864, especially discussion_r1528458923, to understand the expected sample positions for single-plane 4:2:2 YUV formats. Determine whether the current values are incorrect or reflect a specification issue; the work is done when the expected representation and any required project change are agreed.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- computer-graphics
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100