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