v4l_bound_align_image(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’– v4l_bound_align_image β€” Kernel API Manual, bestie edition πŸ’–

okay so picture this: you're deep in the kernel, you've got a video image, and its dimensions are lowkey a mess. enter v4l_bound_align_image β€” the function that ✨adjusts your video dimensions according to a given constraints✨. yes bestie, the original NAME really does say "a given constraints" and I'm not fixing it, that's canon πŸ’…


✨ SYNOPSIS ✨

void v4l_bound_align_image (unsigned int *width , unsigned int wmin ,
unsigned int wmax , unsigned int walign , unsigned int *height ,
unsigned int hmin , unsigned int hmax , unsigned int halign , unsigned
int salign );

like, nine arguments. nine. she's got a lot going on but she's iconic for it πŸŽ€


🫢 ARGUMENTS 🫢

  • width β€” pointer to the width, which will be adjusted if needed. it's a pointer, so she gets edited in place, no cap 😭
  • wmin β€” the minimum width. the floor, the bare minimum, the "girl you deserve better than this" threshold.
  • wmax β€” the maximum width. the ceiling βœ‹
  • walign β€” least significant bit on width. yes, "least significant bit on width", that's the actual wording, keep it πŸ’€
  • height β€” pointer to the height, adjusted if needed. same deal as width, also in-place.
  • hmin β€” minimum height. short king protection clause.
  • hmax β€” maximum height. no vertical overachievers allowed.
  • halign β€” least significant bit on height.
  • salign β€” least significant bit for the image size, e.g. width * height. this one's about the whole vibe, not just one dimension 🌈

πŸ’… DESCRIPTION πŸ’…

So what she actually does: she clips an image so its width lands between wmin and wmax, and its height lands between hmin and hmax β€” inclusive, both ends, we're generous ✨

On top of that, the width will be a multiple of 2^{walign}, the height will be a multiple of 2^{halign}, and the overall size width * height will be a multiple of 2^{salign}. alignment for days, honestly πŸ‘‘

🚨 NOTE 🚨

read this part. seriously. don't skim it, bestie πŸ™ˆ

  1. The clipping rectangle may be shrunk or enlarged to fit the alignment constraints. it's not a one-way trip, she can go either direction.
  2. wmax must not be smaller than wmin. that's just physics.
  3. hmax must not be smaller than hmin. same energy.
  4. The alignments must not be so high that there are no possible image sizes within the allowed bounds. like, if you over-align yourself out of existence, that's on you πŸ’€
  5. wmin and hmin must be at least 1 β€” don't use 0. periodt.
  6. For walign, halign and salign, if you don't care about a certain alignment, specify 0, because 2^0 = 1 and one byte alignment is equivalent to no alignment. zero is the "idk, whatever" option πŸ¦‹
  7. If you only want to adjust downward, specify a maximum that's the same as the initial value. cute lil trick, no extra options needed πŸŽ€

🌸 SEE ALSO 🌸

Kernel file ./include/media/v4l2-common.h, plus the whole friend group:


ok that's the whole page, go align something πŸ’–

and that's the tea, bestie β€” this whole thing lives in ./include/media and it's dated October 2026, so like, future iconic energy β­πŸ¦‹ go forth and bound those images, mwah πŸ’œ

πŸ“¦ where this page comes from