XvListImageFormats(3)

๐Ÿ“ฆ
version 1.0.13 ยท 3 versions
, in alpine 3.22, alpine 3.23, alpine 3.24, arch rolling, fedora 43, fedora 44, ubuntu resolute, ubuntu stonking

โœจ XvListImageFormats โœจ

okay bestie, welcome to XvListImageFormats โ€” a lil function from the libXv crew (that's part of X Version 11, we're fancy here ๐Ÿ’…). She's a libXv Function and she's about to spill the whole tea on what image formats a video port can handle. no cap.


๐ŸŒธ NAME ๐ŸŒธ

XvListImageFormats โ€” gimme the list of image formats that a video port supports, bestie ๐Ÿ“‹โœจ


๐ŸŽ€ SYNTAX ๐ŸŽ€

#include <X11/extensions/Xvlib.h>

XvImageFormatValues * XvListImageFormats (Display *dpy,
                 XvPortID port,  int *p_num_formats);

like, that's the whole incantation. copy it exactly, don't freestyle it ๐Ÿ’–


๐Ÿฆ‹ ARGUMENTS ๐Ÿฆ‹

  • dpy โ€” the connection to the X server. your whole vibe link to the server, basically ๐Ÿ”Œ
  • port โ€” the port whose adaptor we're gonna interrogate about its list of attributes. we're asking this one specifically, main character energy ๐Ÿ‘‘
  • p_num_formats โ€” a pointer to where the number of formats returned in the array gets written. so she hands you the array, and she writes the count over here so you know how many you got ๐Ÿงฎ

๐Ÿ’– DESCRIPTION ๐Ÿ’–

XvListImageFormats(3) returns the XvImageFormatValues that the specified port supports. that's it, that's the whole job. she ate and left no crumbs ๐Ÿ”ฅ

โš ๏ธ important bestie: this list needs to be freed with XFree(3). she's handing you malloc'd memory, so you gotta let her go. don't just leave her hanging ๐Ÿ˜ญ

๐ŸŒˆ RETURN VALUES ๐ŸŒˆ

XvImageFormatValues has the following structure, and it's literally giving struct realness:

typedef struct {
  int id;                      /* Unique descriptor for the format */
  int type;                    /* XvRGB, XvYUV */
  int byte_order;              /* LSBFirst, MSBFirst */
  char guid[16];               /* Globally Unique IDentifier */
  int bits_per_pixel;
  int format;                  /* XvPacked, XvPlanar */
  int num_planes;

  /* for RGB formats */
  int depth;
  unsigned int red_mask;
  unsigned int green_mask;
  unsigned int blue_mask;

  /* for YUV formats */
  unsigned int y_sample_bits;
  unsigned int u_sample_bits;
  unsigned int v_sample_bits;
  unsigned int horz_y_period;
  unsigned int horz_u_period;
  unsigned int horz_v_period;
  unsigned int vert_y_period;
  unsigned int vert_u_period;
  unsigned int vert_v_period;
  char component_order[32];    /* eg. UYVY */
  int scanline_order;          /* XvTopToBottom, XvBottomToTop */
} XvImageFormatValues;

and now, field by field, because every single one matters ๐Ÿซถ

  • id โ€” a unique descriptor for the format. it's often the FOURCC for the format, when that applies. this id is what describes the format when you're doing XvImage creation. it's her government name fr fr ๐Ÿชช
  • type โ€” XvRGB or XvYUV. pick your fighter ๐ŸŒˆ
  • byte_order โ€” the byte order of the image. either LSBFirst or MSBFirst. which way do the bytes go, bestie? ๐Ÿค”
  • guid โ€” the Globally Unique IDentifier (aka the Universally Unique IDentifier, same thing, different wig). when it's not applicable, all the characters are NULL. so like, empty. nothing. void. ๐Ÿ’€
  • bits_per_pixel โ€” the bits taken up (but not necessarily used) by each pixel. and heads up: for some planar formats with fractional bits per pixel (like IF09) this number may be rounded _down_. rounded down!! keep that in your notes ๐Ÿ“
  • format โ€” XvPacked or XvPlanar โœจ
  • num_planes โ€” the number of planes in planar formats. planes on planes on planes โœˆ๏ธ
  • depth โ€” significant bits per pixel ๐Ÿง 
  • red_mask, green_mask, blue_mask โ€” the red, green and blue bitmasks. RGB formats only, so if you're on YUV this part is not for you ๐Ÿšซ
  • ?_sample_bits โ€” the size of each sample in bits. YUV formats only ๐Ÿ’œ
  • horz_?_period, vert_?_period โ€” the period (in pixels) on which samples occur in the horizontal and vertical directions. YUV formats only ๐Ÿ“
  • component_order โ€” upper case ascii characters representing the order that samples are stored within packed formats. for planar formats, this represents the ordering of the planes. so like, UYVY vibes ๐Ÿ”ค
  • scanline_order โ€” XvTopToBottom or XvBottomToTop. which way do we scroll? โฌ†๏ธโฌ‡๏ธ

โญ NOTES โญ

since some formats (particularly some planar YUV formats) may not be completely defined by the parameters above, the guid โ€” when it's available โ€” should give you the most accurate description of the format. so when in doubt, trust the guid, she knows ๐Ÿ’…


๐Ÿšจ DIAGNOSTICS ๐Ÿšจ

  • [XvBadPort] โ€” generated if the requested port does not exist. you asked for a port that isn't real, bestie, and the server said no ๐Ÿ™ˆ

๐Ÿ‘€ SEE ALSO ๐Ÿ‘€

go read those next, iykyk ๐Ÿ“šโœจ


k bye ily, that's the whole page ๐Ÿ’– โ€” this was libXv 1.0.13 from X Version 11, dated whenever this got shipped, and you just read XvListImageFormats(3). slay, go free that array with XFree(3) ๐ŸŽ€๐Ÿฆ‹

๐Ÿ“ฆ where this page comes from