SDL_ChromaLocation(3type)
π SDL_ChromaLocation β a whole vibe check for chroma π
okay bestie, gather round, because we're talking about SDL_ChromaLocation(3type) from the SDL3 datatypes era π. This is the enum that tells you where the chroma samples live compared to the luma pixels. It's giving "colorspace chroma sample location" energy and honestly? iconic. π
No cap, if you've ever wondered why some video looks slightly cursed when you convert it between formats, it's probably this. Let's get into it. π
β¨ NAME β¨
SDL_ChromaLocation β Colorspace chroma sample location. π
β¨ SYNOPSIS β¨
#include <SDL3/SDL_pixels.h>
typedef enum SDL_ChromaLocation
{
SDL_CHROMA_LOCATION_NONE = 0, /**< RGB, no chroma sampling */
SDL_CHROMA_LOCATION_LEFT = 1, /**< In MPEG-2, MPEG-4, and AVC, Cb and Cr are taken on midpoint of the left-edge of the 2x2 square. In other words, they have the same horizontal location as the top-left pixel, but is shifted one-half pixel down vertically. */
SDL_CHROMA_LOCATION_CENTER = 2, /**< In JPEG/JFIF, H.261, and MPEG-1, Cb and Cr are taken at the center of the 2x2 square. In other words, they are offset one-half pixel to the right and one-half pixel down compared to the top-left pixel. */
SDL_CHROMA_LOCATION_TOPLEFT = 3 /**< In HEVC for BT.2020 and BT.2100 content (in particular on Blu-rays), Cb and Cr are sampled at the same location as the group's top-left Y pixel ("co-sited", "co-located"). */
} SDL_ChromaLocation;
β¨ DESCRIPTION β¨
so like, here's the tea β: in a lot of colorspaces, the chroma (that's Cb and Cr, the color part) doesn't get stored at the same resolution as the luma (Y, the brightness part). That's chroma subsampling, and it's literally everywhere. But when you subsample, you gotta decide where in that 2x2 block of pixels the chroma sample actually represents. That's this enum. π¦
Every value is an integer, and every one of them is doing its own little thing:
SDL_CHROMA_LOCATION_NONE=0β this is the RGB one, bestie. There's no chroma sampling at all. Nothing to locate. It's giving "we don't do that here" πSDL_CHROMA_LOCATION_LEFT=1β this is the MPEG-2, MPEG-4, and AVC behavior. Cb and Cr are taken on the midpoint of the left-edge of the 2x2 square. So basically they have the same horizontal location as the top-left pixel, but they get shifted one-half pixel down vertically. πSDL_CHROMA_LOCATION_CENTER=2β JPEG/JFIF, H.261, and MPEG-1 do it this way. Cb and Cr are taken at the center of the 2x2 square, meaning they're offset one-half pixel to the right and one-half pixel down compared to the top-left pixel. Dead center, main character energy π―SDL_CHROMA_LOCATION_TOPLEFT=3β this one's for HEVC with BT.2020 and BT.2100 content (especially on Blu-rays π). Cb and Cr are sampled at the same location as the group's top-left Y pixel. That's what people mean when they say "co-sited" or "co-located". β¨
πΈ heads up: these are positions, not opinions. Pick the wrong one and your colors drift half a pixel off in a way that's technically correct but emotionally devastating. π
β¨ AVAILABILITY β¨
This enum is available since SDL 3.2.0. π«Ά
and that's the whole page, bestie. go forth and sample responsibly πβ¨
Simple Directmedia Layer made this, it's SDL 3.4.18 in the SDL_ChromaLocation(3type) era, and that's the sign-off. mwah. π π
π¦ where this page comes from
- fedora 43: SDL3-devel 3.4.18-1.fc43 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 43: SDL3-devel 3.4.18-1.fc43 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 44: SDL3-devel 3.4.18-1.fc44 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 44: SDL3-devel 3.4.18-1.fc44 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms