Home | History | Annotate | Line # | Download | only in files
      1 /*
      2  * This file generated automatically from xv.xml by c_client.py.
      3  * Edit at your peril.
      4  */
      5 
      6 #ifdef HAVE_CONFIG_H
      7 #include "config.h"
      8 #endif
      9 #include <stdlib.h>
     10 #include <string.h>
     11 #include <assert.h>
     12 #include <stddef.h>  /* for offsetof() */
     13 #include "xcbext.h"
     14 #include "xv.h"
     15 
     16 #define ALIGNOF(type) offsetof(struct { char dummy; type member; }, member)
     17 #include "xproto.h"
     18 #include "shm.h"
     19 
     20 xcb_extension_t xcb_xv_id = { "XVideo", 0 };
     21 
     22 void
     23 xcb_xv_port_next (xcb_xv_port_iterator_t *i)
     24 {
     25     --i->rem;
     26     ++i->data;
     27     i->index += sizeof(xcb_xv_port_t);
     28 }
     29 
     30 xcb_generic_iterator_t
     31 xcb_xv_port_end (xcb_xv_port_iterator_t i)
     32 {
     33     xcb_generic_iterator_t ret;
     34     ret.data = i.data + i.rem;
     35     ret.index = i.index + ((char *) ret.data - (char *) i.data);
     36     ret.rem = 0;
     37     return ret;
     38 }
     39 
     40 void
     41 xcb_xv_encoding_next (xcb_xv_encoding_iterator_t *i)
     42 {
     43     --i->rem;
     44     ++i->data;
     45     i->index += sizeof(xcb_xv_encoding_t);
     46 }
     47 
     48 xcb_generic_iterator_t
     49 xcb_xv_encoding_end (xcb_xv_encoding_iterator_t i)
     50 {
     51     xcb_generic_iterator_t ret;
     52     ret.data = i.data + i.rem;
     53     ret.index = i.index + ((char *) ret.data - (char *) i.data);
     54     ret.rem = 0;
     55     return ret;
     56 }
     57 
     58 void
     59 xcb_xv_rational_next (xcb_xv_rational_iterator_t *i)
     60 {
     61     --i->rem;
     62     ++i->data;
     63     i->index += sizeof(xcb_xv_rational_t);
     64 }
     65 
     66 xcb_generic_iterator_t
     67 xcb_xv_rational_end (xcb_xv_rational_iterator_t i)
     68 {
     69     xcb_generic_iterator_t ret;
     70     ret.data = i.data + i.rem;
     71     ret.index = i.index + ((char *) ret.data - (char *) i.data);
     72     ret.rem = 0;
     73     return ret;
     74 }
     75 
     76 void
     77 xcb_xv_format_next (xcb_xv_format_iterator_t *i)
     78 {
     79     --i->rem;
     80     ++i->data;
     81     i->index += sizeof(xcb_xv_format_t);
     82 }
     83 
     84 xcb_generic_iterator_t
     85 xcb_xv_format_end (xcb_xv_format_iterator_t i)
     86 {
     87     xcb_generic_iterator_t ret;
     88     ret.data = i.data + i.rem;
     89     ret.index = i.index + ((char *) ret.data - (char *) i.data);
     90     ret.rem = 0;
     91     return ret;
     92 }
     93 
     94 int
     95 xcb_xv_adaptor_info_sizeof (const void  *_buffer)
     96 {
     97     char *xcb_tmp = (char *)_buffer;
     98     const xcb_xv_adaptor_info_t *_aux = (xcb_xv_adaptor_info_t *)_buffer;
     99     unsigned int xcb_buffer_len = 0;
    100     unsigned int xcb_block_len = 0;
    101     unsigned int xcb_pad = 0;
    102     unsigned int xcb_align_to = 0;
    103 
    104 
    105     xcb_block_len += sizeof(xcb_xv_adaptor_info_t);
    106     xcb_tmp += xcb_block_len;
    107     xcb_buffer_len += xcb_block_len;
    108     xcb_block_len = 0;
    109     /* name */
    110     xcb_block_len += _aux->name_size * sizeof(char);
    111     xcb_tmp += xcb_block_len;
    112     xcb_align_to = ALIGNOF(char);
    113     xcb_align_to = 4;
    114     /* insert padding */
    115     xcb_pad = -xcb_block_len & (xcb_align_to - 1);
    116     xcb_buffer_len += xcb_block_len + xcb_pad;
    117     if (0 != xcb_pad) {
    118         xcb_tmp += xcb_pad;
    119         xcb_pad = 0;
    120     }
    121     xcb_block_len = 0;
    122     /* insert padding */
    123     xcb_pad = -xcb_block_len & (xcb_align_to - 1);
    124     xcb_buffer_len += xcb_block_len + xcb_pad;
    125     if (0 != xcb_pad) {
    126         xcb_tmp += xcb_pad;
    127         xcb_pad = 0;
    128     }
    129     xcb_block_len = 0;
    130     /* formats */
    131     xcb_block_len += _aux->num_formats * sizeof(xcb_xv_format_t);
    132     xcb_tmp += xcb_block_len;
    133     xcb_align_to = ALIGNOF(xcb_xv_format_t);
    134     /* insert padding */
    135     xcb_pad = -xcb_block_len & (xcb_align_to - 1);
    136     xcb_buffer_len += xcb_block_len + xcb_pad;
    137     if (0 != xcb_pad) {
    138         xcb_tmp += xcb_pad;
    139         xcb_pad = 0;
    140     }
    141     xcb_block_len = 0;
    142 
    143     return xcb_buffer_len;
    144 }
    145 
    146 char *
    147 xcb_xv_adaptor_info_name (const xcb_xv_adaptor_info_t *R)
    148 {
    149     return (char *) (R + 1);
    150 }
    151 
    152 int
    153 xcb_xv_adaptor_info_name_length (const xcb_xv_adaptor_info_t *R)
    154 {
    155     return R->name_size;
    156 }
    157 
    158 xcb_generic_iterator_t
    159 xcb_xv_adaptor_info_name_end (const xcb_xv_adaptor_info_t *R)
    160 {
    161     xcb_generic_iterator_t i;
    162     i.data = ((char *) (R + 1)) + (R->name_size);
    163     i.rem = 0;
    164     i.index = (char *) i.data - (char *) R;
    165     return i;
    166 }
    167 
    168 xcb_xv_format_t *
    169 xcb_xv_adaptor_info_formats (const xcb_xv_adaptor_info_t *R)
    170 {
    171     xcb_generic_iterator_t prev = xcb_xv_adaptor_info_name_end(R);
    172     return (xcb_xv_format_t *) ((char *) prev.data + ((-prev.index) & (4 - 1)) + 0);
    173 }
    174 
    175 int
    176 xcb_xv_adaptor_info_formats_length (const xcb_xv_adaptor_info_t *R)
    177 {
    178     return R->num_formats;
    179 }
    180 
    181 xcb_xv_format_iterator_t
    182 xcb_xv_adaptor_info_formats_iterator (const xcb_xv_adaptor_info_t *R)
    183 {
    184     xcb_xv_format_iterator_t i;
    185     xcb_generic_iterator_t prev = xcb_xv_adaptor_info_name_end(R);
    186     i.data = (xcb_xv_format_t *) ((char *) prev.data + ((-prev.index) & (4 - 1)));
    187     i.rem = R->num_formats;
    188     i.index = (char *) i.data - (char *) R;
    189     return i;
    190 }
    191 
    192 void
    193 xcb_xv_adaptor_info_next (xcb_xv_adaptor_info_iterator_t *i)
    194 {
    195     xcb_xv_adaptor_info_t *R = i->data;
    196     xcb_generic_iterator_t child;
    197     child.data = (xcb_xv_adaptor_info_t *)(((char *)R) + xcb_xv_adaptor_info_sizeof(R));
    198     i->index = (char *) child.data - (char *) i->data;
    199     --i->rem;
    200     i->data = (xcb_xv_adaptor_info_t *) child.data;
    201 }
    202 
    203 xcb_generic_iterator_t
    204 xcb_xv_adaptor_info_end (xcb_xv_adaptor_info_iterator_t i)
    205 {
    206     xcb_generic_iterator_t ret;
    207     while(i.rem > 0)
    208         xcb_xv_adaptor_info_next(&i);
    209     ret.data = i.data;
    210     ret.rem = i.rem;
    211     ret.index = i.index;
    212     return ret;
    213 }
    214 
    215 int
    216 xcb_xv_encoding_info_sizeof (const void  *_buffer)
    217 {
    218     char *xcb_tmp = (char *)_buffer;
    219     const xcb_xv_encoding_info_t *_aux = (xcb_xv_encoding_info_t *)_buffer;
    220     unsigned int xcb_buffer_len = 0;
    221     unsigned int xcb_block_len = 0;
    222     unsigned int xcb_pad = 0;
    223     unsigned int xcb_align_to = 0;
    224 
    225 
    226     xcb_block_len += sizeof(xcb_xv_encoding_info_t);
    227     xcb_tmp += xcb_block_len;
    228     xcb_buffer_len += xcb_block_len;
    229     xcb_block_len = 0;
    230     /* name */
    231     xcb_block_len += _aux->name_size * sizeof(char);
    232     xcb_tmp += xcb_block_len;
    233     xcb_align_to = ALIGNOF(char);
    234     xcb_align_to = 4;
    235     /* insert padding */
    236     xcb_pad = -xcb_block_len & (xcb_align_to - 1);
    237     xcb_buffer_len += xcb_block_len + xcb_pad;
    238     if (0 != xcb_pad) {
    239         xcb_tmp += xcb_pad;
    240         xcb_pad = 0;
    241     }
    242     xcb_block_len = 0;
    243     /* insert padding */
    244     xcb_pad = -xcb_block_len & (xcb_align_to - 1);
    245     xcb_buffer_len += xcb_block_len + xcb_pad;
    246     if (0 != xcb_pad) {
    247         xcb_tmp += xcb_pad;
    248         xcb_pad = 0;
    249     }
    250     xcb_block_len = 0;
    251 
    252     return xcb_buffer_len;
    253 }
    254 
    255 char *
    256 xcb_xv_encoding_info_name (const xcb_xv_encoding_info_t *R)
    257 {
    258     return (char *) (R + 1);
    259 }
    260 
    261 int
    262 xcb_xv_encoding_info_name_length (const xcb_xv_encoding_info_t *R)
    263 {
    264     return R->name_size;
    265 }
    266 
    267 xcb_generic_iterator_t
    268 xcb_xv_encoding_info_name_end (const xcb_xv_encoding_info_t *R)
    269 {
    270     xcb_generic_iterator_t i;
    271     i.data = ((char *) (R + 1)) + (R->name_size);
    272     i.rem = 0;
    273     i.index = (char *) i.data - (char *) R;
    274     return i;
    275 }
    276 
    277 void
    278 xcb_xv_encoding_info_next (xcb_xv_encoding_info_iterator_t *i)
    279 {
    280     xcb_xv_encoding_info_t *R = i->data;
    281     xcb_generic_iterator_t child;
    282     child.data = (xcb_xv_encoding_info_t *)(((char *)R) + xcb_xv_encoding_info_sizeof(R));
    283     i->index = (char *) child.data - (char *) i->data;
    284     --i->rem;
    285     i->data = (xcb_xv_encoding_info_t *) child.data;
    286 }
    287 
    288 xcb_generic_iterator_t
    289 xcb_xv_encoding_info_end (xcb_xv_encoding_info_iterator_t i)
    290 {
    291     xcb_generic_iterator_t ret;
    292     while(i.rem > 0)
    293         xcb_xv_encoding_info_next(&i);
    294     ret.data = i.data;
    295     ret.rem = i.rem;
    296     ret.index = i.index;
    297     return ret;
    298 }
    299 
    300 int
    301 xcb_xv_image_sizeof (const void  *_buffer)
    302 {
    303     char *xcb_tmp = (char *)_buffer;
    304     const xcb_xv_image_t *_aux = (xcb_xv_image_t *)_buffer;
    305     unsigned int xcb_buffer_len = 0;
    306     unsigned int xcb_block_len = 0;
    307     unsigned int xcb_pad = 0;
    308     unsigned int xcb_align_to = 0;
    309 
    310 
    311     xcb_block_len += sizeof(xcb_xv_image_t);
    312     xcb_tmp += xcb_block_len;
    313     xcb_buffer_len += xcb_block_len;
    314     xcb_block_len = 0;
    315     /* pitches */
    316     xcb_block_len += _aux->num_planes * sizeof(uint32_t);
    317     xcb_tmp += xcb_block_len;
    318     xcb_align_to = ALIGNOF(uint32_t);
    319     /* insert padding */
    320     xcb_pad = -xcb_block_len & (xcb_align_to - 1);
    321     xcb_buffer_len += xcb_block_len + xcb_pad;
    322     if (0 != xcb_pad) {
    323         xcb_tmp += xcb_pad;
    324         xcb_pad = 0;
    325     }
    326     xcb_block_len = 0;
    327     /* offsets */
    328     xcb_block_len += _aux->num_planes * sizeof(uint32_t);
    329     xcb_tmp += xcb_block_len;
    330     xcb_align_to = ALIGNOF(uint32_t);
    331     /* insert padding */
    332     xcb_pad = -xcb_block_len & (xcb_align_to - 1);
    333     xcb_buffer_len += xcb_block_len + xcb_pad;
    334     if (0 != xcb_pad) {
    335         xcb_tmp += xcb_pad;
    336         xcb_pad = 0;
    337     }
    338     xcb_block_len = 0;
    339     /* data */
    340     xcb_block_len += _aux->data_size * sizeof(uint8_t);
    341     xcb_tmp += xcb_block_len;
    342     xcb_align_to = ALIGNOF(uint8_t);
    343     /* insert padding */
    344     xcb_pad = -xcb_block_len & (xcb_align_to - 1);
    345     xcb_buffer_len += xcb_block_len + xcb_pad;
    346     if (0 != xcb_pad) {
    347         xcb_tmp += xcb_pad;
    348         xcb_pad = 0;
    349     }
    350     xcb_block_len = 0;
    351 
    352     return xcb_buffer_len;
    353 }
    354 
    355 uint32_t *
    356 xcb_xv_image_pitches (const xcb_xv_image_t *R)
    357 {
    358     return (uint32_t *) (R + 1);
    359 }
    360 
    361 int
    362 xcb_xv_image_pitches_length (const xcb_xv_image_t *R)
    363 {
    364     return R->num_planes;
    365 }
    366 
    367 xcb_generic_iterator_t
    368 xcb_xv_image_pitches_end (const xcb_xv_image_t *R)
    369 {
    370     xcb_generic_iterator_t i;
    371     i.data = ((uint32_t *) (R + 1)) + (R->num_planes);
    372     i.rem = 0;
    373     i.index = (char *) i.data - (char *) R;
    374     return i;
    375 }
    376 
    377 uint32_t *
    378 xcb_xv_image_offsets (const xcb_xv_image_t *R)
    379 {
    380     xcb_generic_iterator_t prev = xcb_xv_image_pitches_end(R);
    381     return (uint32_t *) ((char *) prev.data + XCB_TYPE_PAD(uint32_t, prev.index) + 0);
    382 }
    383 
    384 int
    385 xcb_xv_image_offsets_length (const xcb_xv_image_t *R)
    386 {
    387     return R->num_planes;
    388 }
    389 
    390 xcb_generic_iterator_t
    391 xcb_xv_image_offsets_end (const xcb_xv_image_t *R)
    392 {
    393     xcb_generic_iterator_t i;
    394     xcb_generic_iterator_t prev = xcb_xv_image_pitches_end(R);
    395     i.data = ((uint32_t *) ((char*) prev.data + XCB_TYPE_PAD(uint32_t, prev.index))) + (R->num_planes);
    396     i.rem = 0;
    397     i.index = (char *) i.data - (char *) R;
    398     return i;
    399 }
    400 
    401 uint8_t *
    402 xcb_xv_image_data (const xcb_xv_image_t *R)
    403 {
    404     xcb_generic_iterator_t prev = xcb_xv_image_offsets_end(R);
    405     return (uint8_t *) ((char *) prev.data + XCB_TYPE_PAD(uint8_t, prev.index) + 0);
    406 }
    407 
    408 int
    409 xcb_xv_image_data_length (const xcb_xv_image_t *R)
    410 {
    411     return R->data_size;
    412 }
    413 
    414 xcb_generic_iterator_t
    415 xcb_xv_image_data_end (const xcb_xv_image_t *R)
    416 {
    417     xcb_generic_iterator_t i;
    418     xcb_generic_iterator_t prev = xcb_xv_image_offsets_end(R);
    419     i.data = ((uint8_t *) ((char*) prev.data + XCB_TYPE_PAD(uint8_t, prev.index))) + (R->data_size);
    420     i.rem = 0;
    421     i.index = (char *) i.data - (char *) R;
    422     return i;
    423 }
    424 
    425 void
    426 xcb_xv_image_next (xcb_xv_image_iterator_t *i)
    427 {
    428     xcb_xv_image_t *R = i->data;
    429     xcb_generic_iterator_t child;
    430     child.data = (xcb_xv_image_t *)(((char *)R) + xcb_xv_image_sizeof(R));
    431     i->index = (char *) child.data - (char *) i->data;
    432     --i->rem;
    433     i->data = (xcb_xv_image_t *) child.data;
    434 }
    435 
    436 xcb_generic_iterator_t
    437 xcb_xv_image_end (xcb_xv_image_iterator_t i)
    438 {
    439     xcb_generic_iterator_t ret;
    440     while(i.rem > 0)
    441         xcb_xv_image_next(&i);
    442     ret.data = i.data;
    443     ret.rem = i.rem;
    444     ret.index = i.index;
    445     return ret;
    446 }
    447 
    448 int
    449 xcb_xv_attribute_info_sizeof (const void  *_buffer)
    450 {
    451     char *xcb_tmp = (char *)_buffer;
    452     const xcb_xv_attribute_info_t *_aux = (xcb_xv_attribute_info_t *)_buffer;
    453     unsigned int xcb_buffer_len = 0;
    454     unsigned int xcb_block_len = 0;
    455     unsigned int xcb_pad = 0;
    456     unsigned int xcb_align_to = 0;
    457 
    458 
    459     xcb_block_len += sizeof(xcb_xv_attribute_info_t);
    460     xcb_tmp += xcb_block_len;
    461     xcb_buffer_len += xcb_block_len;
    462     xcb_block_len = 0;
    463     /* name */
    464     xcb_block_len += _aux->size * sizeof(char);
    465     xcb_tmp += xcb_block_len;
    466     xcb_align_to = ALIGNOF(char);
    467     xcb_align_to = 4;
    468     /* insert padding */
    469     xcb_pad = -xcb_block_len & (xcb_align_to - 1);
    470     xcb_buffer_len += xcb_block_len + xcb_pad;
    471     if (0 != xcb_pad) {
    472         xcb_tmp += xcb_pad;
    473         xcb_pad = 0;
    474     }
    475     xcb_block_len = 0;
    476     /* insert padding */
    477     xcb_pad = -xcb_block_len & (xcb_align_to - 1);
    478     xcb_buffer_len += xcb_block_len + xcb_pad;
    479     if (0 != xcb_pad) {
    480         xcb_tmp += xcb_pad;
    481         xcb_pad = 0;
    482     }
    483     xcb_block_len = 0;
    484 
    485     return xcb_buffer_len;
    486 }
    487 
    488 char *
    489 xcb_xv_attribute_info_name (const xcb_xv_attribute_info_t *R)
    490 {
    491     return (char *) (R + 1);
    492 }
    493 
    494 int
    495 xcb_xv_attribute_info_name_length (const xcb_xv_attribute_info_t *R)
    496 {
    497     return R->size;
    498 }
    499 
    500 xcb_generic_iterator_t
    501 xcb_xv_attribute_info_name_end (const xcb_xv_attribute_info_t *R)
    502 {
    503     xcb_generic_iterator_t i;
    504     i.data = ((char *) (R + 1)) + (R->size);
    505     i.rem = 0;
    506     i.index = (char *) i.data - (char *) R;
    507     return i;
    508 }
    509 
    510 void
    511 xcb_xv_attribute_info_next (xcb_xv_attribute_info_iterator_t *i)
    512 {
    513     xcb_xv_attribute_info_t *R = i->data;
    514     xcb_generic_iterator_t child;
    515     child.data = (xcb_xv_attribute_info_t *)(((char *)R) + xcb_xv_attribute_info_sizeof(R));
    516     i->index = (char *) child.data - (char *) i->data;
    517     --i->rem;
    518     i->data = (xcb_xv_attribute_info_t *) child.data;
    519 }
    520 
    521 xcb_generic_iterator_t
    522 xcb_xv_attribute_info_end (xcb_xv_attribute_info_iterator_t i)
    523 {
    524     xcb_generic_iterator_t ret;
    525     while(i.rem > 0)
    526         xcb_xv_attribute_info_next(&i);
    527     ret.data = i.data;
    528     ret.rem = i.rem;
    529     ret.index = i.index;
    530     return ret;
    531 }
    532 
    533 void
    534 xcb_xv_image_format_info_next (xcb_xv_image_format_info_iterator_t *i)
    535 {
    536     --i->rem;
    537     ++i->data;
    538     i->index += sizeof(xcb_xv_image_format_info_t);
    539 }
    540 
    541 xcb_generic_iterator_t
    542 xcb_xv_image_format_info_end (xcb_xv_image_format_info_iterator_t i)
    543 {
    544     xcb_generic_iterator_t ret;
    545     ret.data = i.data + i.rem;
    546     ret.index = i.index + ((char *) ret.data - (char *) i.data);
    547     ret.rem = 0;
    548     return ret;
    549 }
    550 
    551 xcb_xv_query_extension_cookie_t
    552 xcb_xv_query_extension (xcb_connection_t *c)
    553 {
    554     static const xcb_protocol_request_t xcb_req = {
    555         .count = 2,
    556         .ext = &xcb_xv_id,
    557         .opcode = XCB_XV_QUERY_EXTENSION,
    558         .isvoid = 0
    559     };
    560 
    561     struct iovec xcb_parts[4];
    562     xcb_xv_query_extension_cookie_t xcb_ret;
    563     xcb_xv_query_extension_request_t xcb_out;
    564 
    565 
    566     xcb_parts[2].iov_base = (char *) &xcb_out;
    567     xcb_parts[2].iov_len = sizeof(xcb_out);
    568     xcb_parts[3].iov_base = 0;
    569     xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;
    570 
    571     xcb_ret.sequence = xcb_send_request(c, XCB_REQUEST_CHECKED, xcb_parts + 2, &xcb_req);
    572     return xcb_ret;
    573 }
    574 
    575 xcb_xv_query_extension_cookie_t
    576 xcb_xv_query_extension_unchecked (xcb_connection_t *c)
    577 {
    578     static const xcb_protocol_request_t xcb_req = {
    579         .count = 2,
    580         .ext = &xcb_xv_id,
    581         .opcode = XCB_XV_QUERY_EXTENSION,
    582         .isvoid = 0
    583     };
    584 
    585     struct iovec xcb_parts[4];
    586     xcb_xv_query_extension_cookie_t xcb_ret;
    587     xcb_xv_query_extension_request_t xcb_out;
    588 
    589 
    590     xcb_parts[2].iov_base = (char *) &xcb_out;
    591     xcb_parts[2].iov_len = sizeof(xcb_out);
    592     xcb_parts[3].iov_base = 0;
    593     xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;
    594 
    595     xcb_ret.sequence = xcb_send_request(c, 0, xcb_parts + 2, &xcb_req);
    596     return xcb_ret;
    597 }
    598 
    599 xcb_xv_query_extension_reply_t *
    600 xcb_xv_query_extension_reply (xcb_connection_t                 *c,
    601                               xcb_xv_query_extension_cookie_t   cookie  /**< */,
    602                               xcb_generic_error_t             **e)
    603 {
    604     return (xcb_xv_query_extension_reply_t *) xcb_wait_for_reply(c, cookie.sequence, e);
    605 }
    606 
    607 int
    608 xcb_xv_query_adaptors_sizeof (const void  *_buffer)
    609 {
    610     char *xcb_tmp = (char *)_buffer;
    611     const xcb_xv_query_adaptors_reply_t *_aux = (xcb_xv_query_adaptors_reply_t *)_buffer;
    612     unsigned int xcb_buffer_len = 0;
    613     unsigned int xcb_block_len = 0;
    614     unsigned int xcb_pad = 0;
    615     unsigned int xcb_align_to = 0;
    616 
    617     unsigned int i;
    618     unsigned int xcb_tmp_len;
    619 
    620     xcb_block_len += sizeof(xcb_xv_query_adaptors_reply_t);
    621     xcb_tmp += xcb_block_len;
    622     xcb_buffer_len += xcb_block_len;
    623     xcb_block_len = 0;
    624     /* info */
    625     for(i=0; i<_aux->num_adaptors; i++) {
    626         xcb_tmp_len = xcb_xv_adaptor_info_sizeof(xcb_tmp);
    627         xcb_block_len += xcb_tmp_len;
    628         xcb_tmp += xcb_tmp_len;
    629     }
    630     xcb_align_to = ALIGNOF(xcb_xv_adaptor_info_t);
    631     /* insert padding */
    632     xcb_pad = -xcb_block_len & (xcb_align_to - 1);
    633     xcb_buffer_len += xcb_block_len + xcb_pad;
    634     if (0 != xcb_pad) {
    635         xcb_tmp += xcb_pad;
    636         xcb_pad = 0;
    637     }
    638     xcb_block_len = 0;
    639 
    640     return xcb_buffer_len;
    641 }
    642 
    643 xcb_xv_query_adaptors_cookie_t
    644 xcb_xv_query_adaptors (xcb_connection_t *c,
    645                        xcb_window_t      window)
    646 {
    647     static const xcb_protocol_request_t xcb_req = {
    648         .count = 2,
    649         .ext = &xcb_xv_id,
    650         .opcode = XCB_XV_QUERY_ADAPTORS,
    651         .isvoid = 0
    652     };
    653 
    654     struct iovec xcb_parts[4];
    655     xcb_xv_query_adaptors_cookie_t xcb_ret;
    656     xcb_xv_query_adaptors_request_t xcb_out;
    657 
    658     xcb_out.window = window;
    659 
    660     xcb_parts[2].iov_base = (char *) &xcb_out;
    661     xcb_parts[2].iov_len = sizeof(xcb_out);
    662     xcb_parts[3].iov_base = 0;
    663     xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;
    664 
    665     xcb_ret.sequence = xcb_send_request(c, XCB_REQUEST_CHECKED, xcb_parts + 2, &xcb_req);
    666     return xcb_ret;
    667 }
    668 
    669 xcb_xv_query_adaptors_cookie_t
    670 xcb_xv_query_adaptors_unchecked (xcb_connection_t *c,
    671                                  xcb_window_t      window)
    672 {
    673     static const xcb_protocol_request_t xcb_req = {
    674         .count = 2,
    675         .ext = &xcb_xv_id,
    676         .opcode = XCB_XV_QUERY_ADAPTORS,
    677         .isvoid = 0
    678     };
    679 
    680     struct iovec xcb_parts[4];
    681     xcb_xv_query_adaptors_cookie_t xcb_ret;
    682     xcb_xv_query_adaptors_request_t xcb_out;
    683 
    684     xcb_out.window = window;
    685 
    686     xcb_parts[2].iov_base = (char *) &xcb_out;
    687     xcb_parts[2].iov_len = sizeof(xcb_out);
    688     xcb_parts[3].iov_base = 0;
    689     xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;
    690 
    691     xcb_ret.sequence = xcb_send_request(c, 0, xcb_parts + 2, &xcb_req);
    692     return xcb_ret;
    693 }
    694 
    695 int
    696 xcb_xv_query_adaptors_info_length (const xcb_xv_query_adaptors_reply_t *R)
    697 {
    698     return R->num_adaptors;
    699 }
    700 
    701 xcb_xv_adaptor_info_iterator_t
    702 xcb_xv_query_adaptors_info_iterator (const xcb_xv_query_adaptors_reply_t *R)
    703 {
    704     xcb_xv_adaptor_info_iterator_t i;
    705     i.data = (xcb_xv_adaptor_info_t *) (R + 1);
    706     i.rem = R->num_adaptors;
    707     i.index = (char *) i.data - (char *) R;
    708     return i;
    709 }
    710 
    711 xcb_xv_query_adaptors_reply_t *
    712 xcb_xv_query_adaptors_reply (xcb_connection_t                *c,
    713                              xcb_xv_query_adaptors_cookie_t   cookie  /**< */,
    714                              xcb_generic_error_t            **e)
    715 {
    716     return (xcb_xv_query_adaptors_reply_t *) xcb_wait_for_reply(c, cookie.sequence, e);
    717 }
    718 
    719 int
    720 xcb_xv_query_encodings_sizeof (const void  *_buffer)
    721 {
    722     char *xcb_tmp = (char *)_buffer;
    723     const xcb_xv_query_encodings_reply_t *_aux = (xcb_xv_query_encodings_reply_t *)_buffer;
    724     unsigned int xcb_buffer_len = 0;
    725     unsigned int xcb_block_len = 0;
    726     unsigned int xcb_pad = 0;
    727     unsigned int xcb_align_to = 0;
    728 
    729     unsigned int i;
    730     unsigned int xcb_tmp_len;
    731 
    732     xcb_block_len += sizeof(xcb_xv_query_encodings_reply_t);
    733     xcb_tmp += xcb_block_len;
    734     xcb_buffer_len += xcb_block_len;
    735     xcb_block_len = 0;
    736     /* info */
    737     for(i=0; i<_aux->num_encodings; i++) {
    738         xcb_tmp_len = xcb_xv_encoding_info_sizeof(xcb_tmp);
    739         xcb_block_len += xcb_tmp_len;
    740         xcb_tmp += xcb_tmp_len;
    741     }
    742     xcb_align_to = ALIGNOF(xcb_xv_encoding_info_t);
    743     /* insert padding */
    744     xcb_pad = -xcb_block_len & (xcb_align_to - 1);
    745     xcb_buffer_len += xcb_block_len + xcb_pad;
    746     if (0 != xcb_pad) {
    747         xcb_tmp += xcb_pad;
    748         xcb_pad = 0;
    749     }
    750     xcb_block_len = 0;
    751 
    752     return xcb_buffer_len;
    753 }
    754 
    755 xcb_xv_query_encodings_cookie_t
    756 xcb_xv_query_encodings (xcb_connection_t *c,
    757                         xcb_xv_port_t     port)
    758 {
    759     static const xcb_protocol_request_t xcb_req = {
    760         .count = 2,
    761         .ext = &xcb_xv_id,
    762         .opcode = XCB_XV_QUERY_ENCODINGS,
    763         .isvoid = 0
    764     };
    765 
    766     struct iovec xcb_parts[4];
    767     xcb_xv_query_encodings_cookie_t xcb_ret;
    768     xcb_xv_query_encodings_request_t xcb_out;
    769 
    770     xcb_out.port = port;
    771 
    772     xcb_parts[2].iov_base = (char *) &xcb_out;
    773     xcb_parts[2].iov_len = sizeof(xcb_out);
    774     xcb_parts[3].iov_base = 0;
    775     xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;
    776 
    777     xcb_ret.sequence = xcb_send_request(c, XCB_REQUEST_CHECKED, xcb_parts + 2, &xcb_req);
    778     return xcb_ret;
    779 }
    780 
    781 xcb_xv_query_encodings_cookie_t
    782 xcb_xv_query_encodings_unchecked (xcb_connection_t *c,
    783                                   xcb_xv_port_t     port)
    784 {
    785     static const xcb_protocol_request_t xcb_req = {
    786         .count = 2,
    787         .ext = &xcb_xv_id,
    788         .opcode = XCB_XV_QUERY_ENCODINGS,
    789         .isvoid = 0
    790     };
    791 
    792     struct iovec xcb_parts[4];
    793     xcb_xv_query_encodings_cookie_t xcb_ret;
    794     xcb_xv_query_encodings_request_t xcb_out;
    795 
    796     xcb_out.port = port;
    797 
    798     xcb_parts[2].iov_base = (char *) &xcb_out;
    799     xcb_parts[2].iov_len = sizeof(xcb_out);
    800     xcb_parts[3].iov_base = 0;
    801     xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;
    802 
    803     xcb_ret.sequence = xcb_send_request(c, 0, xcb_parts + 2, &xcb_req);
    804     return xcb_ret;
    805 }
    806 
    807 int
    808 xcb_xv_query_encodings_info_length (const xcb_xv_query_encodings_reply_t *R)
    809 {
    810     return R->num_encodings;
    811 }
    812 
    813 xcb_xv_encoding_info_iterator_t
    814 xcb_xv_query_encodings_info_iterator (const xcb_xv_query_encodings_reply_t *R)
    815 {
    816     xcb_xv_encoding_info_iterator_t i;
    817     i.data = (xcb_xv_encoding_info_t *) (R + 1);
    818     i.rem = R->num_encodings;
    819     i.index = (char *) i.data - (char *) R;
    820     return i;
    821 }
    822 
    823 xcb_xv_query_encodings_reply_t *
    824 xcb_xv_query_encodings_reply (xcb_connection_t                 *c,
    825                               xcb_xv_query_encodings_cookie_t   cookie  /**< */,
    826                               xcb_generic_error_t             **e)
    827 {
    828     return (xcb_xv_query_encodings_reply_t *) xcb_wait_for_reply(c, cookie.sequence, e);
    829 }
    830 
    831 xcb_xv_grab_port_cookie_t
    832 xcb_xv_grab_port (xcb_connection_t *c,
    833                   xcb_xv_port_t     port,
    834                   xcb_timestamp_t   time)
    835 {
    836     static const xcb_protocol_request_t xcb_req = {
    837         .count = 2,
    838         .ext = &xcb_xv_id,
    839         .opcode = XCB_XV_GRAB_PORT,
    840         .isvoid = 0
    841     };
    842 
    843     struct iovec xcb_parts[4];
    844     xcb_xv_grab_port_cookie_t xcb_ret;
    845     xcb_xv_grab_port_request_t xcb_out;
    846 
    847     xcb_out.port = port;
    848     xcb_out.time = time;
    849 
    850     xcb_parts[2].iov_base = (char *) &xcb_out;
    851     xcb_parts[2].iov_len = sizeof(xcb_out);
    852     xcb_parts[3].iov_base = 0;
    853     xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;
    854 
    855     xcb_ret.sequence = xcb_send_request(c, XCB_REQUEST_CHECKED, xcb_parts + 2, &xcb_req);
    856     return xcb_ret;
    857 }
    858 
    859 xcb_xv_grab_port_cookie_t
    860 xcb_xv_grab_port_unchecked (xcb_connection_t *c,
    861                             xcb_xv_port_t     port,
    862                             xcb_timestamp_t   time)
    863 {
    864     static const xcb_protocol_request_t xcb_req = {
    865         .count = 2,
    866         .ext = &xcb_xv_id,
    867         .opcode = XCB_XV_GRAB_PORT,
    868         .isvoid = 0
    869     };
    870 
    871     struct iovec xcb_parts[4];
    872     xcb_xv_grab_port_cookie_t xcb_ret;
    873     xcb_xv_grab_port_request_t xcb_out;
    874 
    875     xcb_out.port = port;
    876     xcb_out.time = time;
    877 
    878     xcb_parts[2].iov_base = (char *) &xcb_out;
    879     xcb_parts[2].iov_len = sizeof(xcb_out);
    880     xcb_parts[3].iov_base = 0;
    881     xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;
    882 
    883     xcb_ret.sequence = xcb_send_request(c, 0, xcb_parts + 2, &xcb_req);
    884     return xcb_ret;
    885 }
    886 
    887 xcb_xv_grab_port_reply_t *
    888 xcb_xv_grab_port_reply (xcb_connection_t           *c,
    889                         xcb_xv_grab_port_cookie_t   cookie  /**< */,
    890                         xcb_generic_error_t       **e)
    891 {
    892     return (xcb_xv_grab_port_reply_t *) xcb_wait_for_reply(c, cookie.sequence, e);
    893 }
    894 
    895 xcb_void_cookie_t
    896 xcb_xv_ungrab_port_checked (xcb_connection_t *c,
    897                             xcb_xv_port_t     port,
    898                             xcb_timestamp_t   time)
    899 {
    900     static const xcb_protocol_request_t xcb_req = {
    901         .count = 2,
    902         .ext = &xcb_xv_id,
    903         .opcode = XCB_XV_UNGRAB_PORT,
    904         .isvoid = 1
    905     };
    906 
    907     struct iovec xcb_parts[4];
    908     xcb_void_cookie_t xcb_ret;
    909     xcb_xv_ungrab_port_request_t xcb_out;
    910 
    911     xcb_out.port = port;
    912     xcb_out.time = time;
    913 
    914     xcb_parts[2].iov_base = (char *) &xcb_out;
    915     xcb_parts[2].iov_len = sizeof(xcb_out);
    916     xcb_parts[3].iov_base = 0;
    917     xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;
    918 
    919     xcb_ret.sequence = xcb_send_request(c, XCB_REQUEST_CHECKED, xcb_parts + 2, &xcb_req);
    920     return xcb_ret;
    921 }
    922 
    923 xcb_void_cookie_t
    924 xcb_xv_ungrab_port (xcb_connection_t *c,
    925                     xcb_xv_port_t     port,
    926                     xcb_timestamp_t   time)
    927 {
    928     static const xcb_protocol_request_t xcb_req = {
    929         .count = 2,
    930         .ext = &xcb_xv_id,
    931         .opcode = XCB_XV_UNGRAB_PORT,
    932         .isvoid = 1
    933     };
    934 
    935     struct iovec xcb_parts[4];
    936     xcb_void_cookie_t xcb_ret;
    937     xcb_xv_ungrab_port_request_t xcb_out;
    938 
    939     xcb_out.port = port;
    940     xcb_out.time = time;
    941 
    942     xcb_parts[2].iov_base = (char *) &xcb_out;
    943     xcb_parts[2].iov_len = sizeof(xcb_out);
    944     xcb_parts[3].iov_base = 0;
    945     xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;
    946 
    947     xcb_ret.sequence = xcb_send_request(c, 0, xcb_parts + 2, &xcb_req);
    948     return xcb_ret;
    949 }
    950 
    951 xcb_void_cookie_t
    952 xcb_xv_put_video_checked (xcb_connection_t *c,
    953                           xcb_xv_port_t     port,
    954                           xcb_drawable_t    drawable,
    955                           xcb_gcontext_t    gc,
    956                           int16_t           vid_x,
    957                           int16_t           vid_y,
    958                           uint16_t          vid_w,
    959                           uint16_t          vid_h,
    960                           int16_t           drw_x,
    961                           int16_t           drw_y,
    962                           uint16_t          drw_w,
    963                           uint16_t          drw_h)
    964 {
    965     static const xcb_protocol_request_t xcb_req = {
    966         .count = 2,
    967         .ext = &xcb_xv_id,
    968         .opcode = XCB_XV_PUT_VIDEO,
    969         .isvoid = 1
    970     };
    971 
    972     struct iovec xcb_parts[4];
    973     xcb_void_cookie_t xcb_ret;
    974     xcb_xv_put_video_request_t xcb_out;
    975 
    976     xcb_out.port = port;
    977     xcb_out.drawable = drawable;
    978     xcb_out.gc = gc;
    979     xcb_out.vid_x = vid_x;
    980     xcb_out.vid_y = vid_y;
    981     xcb_out.vid_w = vid_w;
    982     xcb_out.vid_h = vid_h;
    983     xcb_out.drw_x = drw_x;
    984     xcb_out.drw_y = drw_y;
    985     xcb_out.drw_w = drw_w;
    986     xcb_out.drw_h = drw_h;
    987 
    988     xcb_parts[2].iov_base = (char *) &xcb_out;
    989     xcb_parts[2].iov_len = sizeof(xcb_out);
    990     xcb_parts[3].iov_base = 0;
    991     xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;
    992 
    993     xcb_ret.sequence = xcb_send_request(c, XCB_REQUEST_CHECKED, xcb_parts + 2, &xcb_req);
    994     return xcb_ret;
    995 }
    996 
    997 xcb_void_cookie_t
    998 xcb_xv_put_video (xcb_connection_t *c,
    999                   xcb_xv_port_t     port,
   1000                   xcb_drawable_t    drawable,
   1001                   xcb_gcontext_t    gc,
   1002                   int16_t           vid_x,
   1003                   int16_t           vid_y,
   1004                   uint16_t          vid_w,
   1005                   uint16_t          vid_h,
   1006                   int16_t           drw_x,
   1007                   int16_t           drw_y,
   1008                   uint16_t          drw_w,
   1009                   uint16_t          drw_h)
   1010 {
   1011     static const xcb_protocol_request_t xcb_req = {
   1012         .count = 2,
   1013         .ext = &xcb_xv_id,
   1014         .opcode = XCB_XV_PUT_VIDEO,
   1015         .isvoid = 1
   1016     };
   1017 
   1018     struct iovec xcb_parts[4];
   1019     xcb_void_cookie_t xcb_ret;
   1020     xcb_xv_put_video_request_t xcb_out;
   1021 
   1022     xcb_out.port = port;
   1023     xcb_out.drawable = drawable;
   1024     xcb_out.gc = gc;
   1025     xcb_out.vid_x = vid_x;
   1026     xcb_out.vid_y = vid_y;
   1027     xcb_out.vid_w = vid_w;
   1028     xcb_out.vid_h = vid_h;
   1029     xcb_out.drw_x = drw_x;
   1030     xcb_out.drw_y = drw_y;
   1031     xcb_out.drw_w = drw_w;
   1032     xcb_out.drw_h = drw_h;
   1033 
   1034     xcb_parts[2].iov_base = (char *) &xcb_out;
   1035     xcb_parts[2].iov_len = sizeof(xcb_out);
   1036     xcb_parts[3].iov_base = 0;
   1037     xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;
   1038 
   1039     xcb_ret.sequence = xcb_send_request(c, 0, xcb_parts + 2, &xcb_req);
   1040     return xcb_ret;
   1041 }
   1042 
   1043 xcb_void_cookie_t
   1044 xcb_xv_put_still_checked (xcb_connection_t *c,
   1045                           xcb_xv_port_t     port,
   1046                           xcb_drawable_t    drawable,
   1047                           xcb_gcontext_t    gc,
   1048                           int16_t           vid_x,
   1049                           int16_t           vid_y,
   1050                           uint16_t          vid_w,
   1051                           uint16_t          vid_h,
   1052                           int16_t           drw_x,
   1053                           int16_t           drw_y,
   1054                           uint16_t          drw_w,
   1055                           uint16_t          drw_h)
   1056 {
   1057     static const xcb_protocol_request_t xcb_req = {
   1058         .count = 2,
   1059         .ext = &xcb_xv_id,
   1060         .opcode = XCB_XV_PUT_STILL,
   1061         .isvoid = 1
   1062     };
   1063 
   1064     struct iovec xcb_parts[4];
   1065     xcb_void_cookie_t xcb_ret;
   1066     xcb_xv_put_still_request_t xcb_out;
   1067 
   1068     xcb_out.port = port;
   1069     xcb_out.drawable = drawable;
   1070     xcb_out.gc = gc;
   1071     xcb_out.vid_x = vid_x;
   1072     xcb_out.vid_y = vid_y;
   1073     xcb_out.vid_w = vid_w;
   1074     xcb_out.vid_h = vid_h;
   1075     xcb_out.drw_x = drw_x;
   1076     xcb_out.drw_y = drw_y;
   1077     xcb_out.drw_w = drw_w;
   1078     xcb_out.drw_h = drw_h;
   1079 
   1080     xcb_parts[2].iov_base = (char *) &xcb_out;
   1081     xcb_parts[2].iov_len = sizeof(xcb_out);
   1082     xcb_parts[3].iov_base = 0;
   1083     xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;
   1084 
   1085     xcb_ret.sequence = xcb_send_request(c, XCB_REQUEST_CHECKED, xcb_parts + 2, &xcb_req);
   1086     return xcb_ret;
   1087 }
   1088 
   1089 xcb_void_cookie_t
   1090 xcb_xv_put_still (xcb_connection_t *c,
   1091                   xcb_xv_port_t     port,
   1092                   xcb_drawable_t    drawable,
   1093                   xcb_gcontext_t    gc,
   1094                   int16_t           vid_x,
   1095                   int16_t           vid_y,
   1096                   uint16_t          vid_w,
   1097                   uint16_t          vid_h,
   1098                   int16_t           drw_x,
   1099                   int16_t           drw_y,
   1100                   uint16_t          drw_w,
   1101                   uint16_t          drw_h)
   1102 {
   1103     static const xcb_protocol_request_t xcb_req = {
   1104         .count = 2,
   1105         .ext = &xcb_xv_id,
   1106         .opcode = XCB_XV_PUT_STILL,
   1107         .isvoid = 1
   1108     };
   1109 
   1110     struct iovec xcb_parts[4];
   1111     xcb_void_cookie_t xcb_ret;
   1112     xcb_xv_put_still_request_t xcb_out;
   1113 
   1114     xcb_out.port = port;
   1115     xcb_out.drawable = drawable;
   1116     xcb_out.gc = gc;
   1117     xcb_out.vid_x = vid_x;
   1118     xcb_out.vid_y = vid_y;
   1119     xcb_out.vid_w = vid_w;
   1120     xcb_out.vid_h = vid_h;
   1121     xcb_out.drw_x = drw_x;
   1122     xcb_out.drw_y = drw_y;
   1123     xcb_out.drw_w = drw_w;
   1124     xcb_out.drw_h = drw_h;
   1125 
   1126     xcb_parts[2].iov_base = (char *) &xcb_out;
   1127     xcb_parts[2].iov_len = sizeof(xcb_out);
   1128     xcb_parts[3].iov_base = 0;
   1129     xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;
   1130 
   1131     xcb_ret.sequence = xcb_send_request(c, 0, xcb_parts + 2, &xcb_req);
   1132     return xcb_ret;
   1133 }
   1134 
   1135 xcb_void_cookie_t
   1136 xcb_xv_get_video_checked (xcb_connection_t *c,
   1137                           xcb_xv_port_t     port,
   1138                           xcb_drawable_t    drawable,
   1139                           xcb_gcontext_t    gc,
   1140                           int16_t           vid_x,
   1141                           int16_t           vid_y,
   1142                           uint16_t          vid_w,
   1143                           uint16_t          vid_h,
   1144                           int16_t           drw_x,
   1145                           int16_t           drw_y,
   1146                           uint16_t          drw_w,
   1147                           uint16_t          drw_h)
   1148 {
   1149     static const xcb_protocol_request_t xcb_req = {
   1150         .count = 2,
   1151         .ext = &xcb_xv_id,
   1152         .opcode = XCB_XV_GET_VIDEO,
   1153         .isvoid = 1
   1154     };
   1155 
   1156     struct iovec xcb_parts[4];
   1157     xcb_void_cookie_t xcb_ret;
   1158     xcb_xv_get_video_request_t xcb_out;
   1159 
   1160     xcb_out.port = port;
   1161     xcb_out.drawable = drawable;
   1162     xcb_out.gc = gc;
   1163     xcb_out.vid_x = vid_x;
   1164     xcb_out.vid_y = vid_y;
   1165     xcb_out.vid_w = vid_w;
   1166     xcb_out.vid_h = vid_h;
   1167     xcb_out.drw_x = drw_x;
   1168     xcb_out.drw_y = drw_y;
   1169     xcb_out.drw_w = drw_w;
   1170     xcb_out.drw_h = drw_h;
   1171 
   1172     xcb_parts[2].iov_base = (char *) &xcb_out;
   1173     xcb_parts[2].iov_len = sizeof(xcb_out);
   1174     xcb_parts[3].iov_base = 0;
   1175     xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;
   1176 
   1177     xcb_ret.sequence = xcb_send_request(c, XCB_REQUEST_CHECKED, xcb_parts + 2, &xcb_req);
   1178     return xcb_ret;
   1179 }
   1180 
   1181 xcb_void_cookie_t
   1182 xcb_xv_get_video (xcb_connection_t *c,
   1183                   xcb_xv_port_t     port,
   1184                   xcb_drawable_t    drawable,
   1185                   xcb_gcontext_t    gc,
   1186                   int16_t           vid_x,
   1187                   int16_t           vid_y,
   1188                   uint16_t          vid_w,
   1189                   uint16_t          vid_h,
   1190                   int16_t           drw_x,
   1191                   int16_t           drw_y,
   1192                   uint16_t          drw_w,
   1193                   uint16_t          drw_h)
   1194 {
   1195     static const xcb_protocol_request_t xcb_req = {
   1196         .count = 2,
   1197         .ext = &xcb_xv_id,
   1198         .opcode = XCB_XV_GET_VIDEO,
   1199         .isvoid = 1
   1200     };
   1201 
   1202     struct iovec xcb_parts[4];
   1203     xcb_void_cookie_t xcb_ret;
   1204     xcb_xv_get_video_request_t xcb_out;
   1205 
   1206     xcb_out.port = port;
   1207     xcb_out.drawable = drawable;
   1208     xcb_out.gc = gc;
   1209     xcb_out.vid_x = vid_x;
   1210     xcb_out.vid_y = vid_y;
   1211     xcb_out.vid_w = vid_w;
   1212     xcb_out.vid_h = vid_h;
   1213     xcb_out.drw_x = drw_x;
   1214     xcb_out.drw_y = drw_y;
   1215     xcb_out.drw_w = drw_w;
   1216     xcb_out.drw_h = drw_h;
   1217 
   1218     xcb_parts[2].iov_base = (char *) &xcb_out;
   1219     xcb_parts[2].iov_len = sizeof(xcb_out);
   1220     xcb_parts[3].iov_base = 0;
   1221     xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;
   1222 
   1223     xcb_ret.sequence = xcb_send_request(c, 0, xcb_parts + 2, &xcb_req);
   1224     return xcb_ret;
   1225 }
   1226 
   1227 xcb_void_cookie_t
   1228 xcb_xv_get_still_checked (xcb_connection_t *c,
   1229                           xcb_xv_port_t     port,
   1230                           xcb_drawable_t    drawable,
   1231                           xcb_gcontext_t    gc,
   1232                           int16_t           vid_x,
   1233                           int16_t           vid_y,
   1234                           uint16_t          vid_w,
   1235                           uint16_t          vid_h,
   1236                           int16_t           drw_x,
   1237                           int16_t           drw_y,
   1238                           uint16_t          drw_w,
   1239                           uint16_t          drw_h)
   1240 {
   1241     static const xcb_protocol_request_t xcb_req = {
   1242         .count = 2,
   1243         .ext = &xcb_xv_id,
   1244         .opcode = XCB_XV_GET_STILL,
   1245         .isvoid = 1
   1246     };
   1247 
   1248     struct iovec xcb_parts[4];
   1249     xcb_void_cookie_t xcb_ret;
   1250     xcb_xv_get_still_request_t xcb_out;
   1251 
   1252     xcb_out.port = port;
   1253     xcb_out.drawable = drawable;
   1254     xcb_out.gc = gc;
   1255     xcb_out.vid_x = vid_x;
   1256     xcb_out.vid_y = vid_y;
   1257     xcb_out.vid_w = vid_w;
   1258     xcb_out.vid_h = vid_h;
   1259     xcb_out.drw_x = drw_x;
   1260     xcb_out.drw_y = drw_y;
   1261     xcb_out.drw_w = drw_w;
   1262     xcb_out.drw_h = drw_h;
   1263 
   1264     xcb_parts[2].iov_base = (char *) &xcb_out;
   1265     xcb_parts[2].iov_len = sizeof(xcb_out);
   1266     xcb_parts[3].iov_base = 0;
   1267     xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;
   1268 
   1269     xcb_ret.sequence = xcb_send_request(c, XCB_REQUEST_CHECKED, xcb_parts + 2, &xcb_req);
   1270     return xcb_ret;
   1271 }
   1272 
   1273 xcb_void_cookie_t
   1274 xcb_xv_get_still (xcb_connection_t *c,
   1275                   xcb_xv_port_t     port,
   1276                   xcb_drawable_t    drawable,
   1277                   xcb_gcontext_t    gc,
   1278                   int16_t           vid_x,
   1279                   int16_t           vid_y,
   1280                   uint16_t          vid_w,
   1281                   uint16_t          vid_h,
   1282                   int16_t           drw_x,
   1283                   int16_t           drw_y,
   1284                   uint16_t          drw_w,
   1285                   uint16_t          drw_h)
   1286 {
   1287     static const xcb_protocol_request_t xcb_req = {
   1288         .count = 2,
   1289         .ext = &xcb_xv_id,
   1290         .opcode = XCB_XV_GET_STILL,
   1291         .isvoid = 1
   1292     };
   1293 
   1294     struct iovec xcb_parts[4];
   1295     xcb_void_cookie_t xcb_ret;
   1296     xcb_xv_get_still_request_t xcb_out;
   1297 
   1298     xcb_out.port = port;
   1299     xcb_out.drawable = drawable;
   1300     xcb_out.gc = gc;
   1301     xcb_out.vid_x = vid_x;
   1302     xcb_out.vid_y = vid_y;
   1303     xcb_out.vid_w = vid_w;
   1304     xcb_out.vid_h = vid_h;
   1305     xcb_out.drw_x = drw_x;
   1306     xcb_out.drw_y = drw_y;
   1307     xcb_out.drw_w = drw_w;
   1308     xcb_out.drw_h = drw_h;
   1309 
   1310     xcb_parts[2].iov_base = (char *) &xcb_out;
   1311     xcb_parts[2].iov_len = sizeof(xcb_out);
   1312     xcb_parts[3].iov_base = 0;
   1313     xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;
   1314 
   1315     xcb_ret.sequence = xcb_send_request(c, 0, xcb_parts + 2, &xcb_req);
   1316     return xcb_ret;
   1317 }
   1318 
   1319 xcb_void_cookie_t
   1320 xcb_xv_stop_video_checked (xcb_connection_t *c,
   1321                            xcb_xv_port_t     port,
   1322                            xcb_drawable_t    drawable)
   1323 {
   1324     static const xcb_protocol_request_t xcb_req = {
   1325         .count = 2,
   1326         .ext = &xcb_xv_id,
   1327         .opcode = XCB_XV_STOP_VIDEO,
   1328         .isvoid = 1
   1329     };
   1330 
   1331     struct iovec xcb_parts[4];
   1332     xcb_void_cookie_t xcb_ret;
   1333     xcb_xv_stop_video_request_t xcb_out;
   1334 
   1335     xcb_out.port = port;
   1336     xcb_out.drawable = drawable;
   1337 
   1338     xcb_parts[2].iov_base = (char *) &xcb_out;
   1339     xcb_parts[2].iov_len = sizeof(xcb_out);
   1340     xcb_parts[3].iov_base = 0;
   1341     xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;
   1342 
   1343     xcb_ret.sequence = xcb_send_request(c, XCB_REQUEST_CHECKED, xcb_parts + 2, &xcb_req);
   1344     return xcb_ret;
   1345 }
   1346 
   1347 xcb_void_cookie_t
   1348 xcb_xv_stop_video (xcb_connection_t *c,
   1349                    xcb_xv_port_t     port,
   1350                    xcb_drawable_t    drawable)
   1351 {
   1352     static const xcb_protocol_request_t xcb_req = {
   1353         .count = 2,
   1354         .ext = &xcb_xv_id,
   1355         .opcode = XCB_XV_STOP_VIDEO,
   1356         .isvoid = 1
   1357     };
   1358 
   1359     struct iovec xcb_parts[4];
   1360     xcb_void_cookie_t xcb_ret;
   1361     xcb_xv_stop_video_request_t xcb_out;
   1362 
   1363     xcb_out.port = port;
   1364     xcb_out.drawable = drawable;
   1365 
   1366     xcb_parts[2].iov_base = (char *) &xcb_out;
   1367     xcb_parts[2].iov_len = sizeof(xcb_out);
   1368     xcb_parts[3].iov_base = 0;
   1369     xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;
   1370 
   1371     xcb_ret.sequence = xcb_send_request(c, 0, xcb_parts + 2, &xcb_req);
   1372     return xcb_ret;
   1373 }
   1374 
   1375 xcb_void_cookie_t
   1376 xcb_xv_select_video_notify_checked (xcb_connection_t *c,
   1377                                     xcb_drawable_t    drawable,
   1378                                     uint8_t           onoff)
   1379 {
   1380     static const xcb_protocol_request_t xcb_req = {
   1381         .count = 2,
   1382         .ext = &xcb_xv_id,
   1383         .opcode = XCB_XV_SELECT_VIDEO_NOTIFY,
   1384         .isvoid = 1
   1385     };
   1386 
   1387     struct iovec xcb_parts[4];
   1388     xcb_void_cookie_t xcb_ret;
   1389     xcb_xv_select_video_notify_request_t xcb_out;
   1390 
   1391     xcb_out.drawable = drawable;
   1392     xcb_out.onoff = onoff;
   1393     memset(xcb_out.pad0, 0, 3);
   1394 
   1395     xcb_parts[2].iov_base = (char *) &xcb_out;
   1396     xcb_parts[2].iov_len = sizeof(xcb_out);
   1397     xcb_parts[3].iov_base = 0;
   1398     xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;
   1399 
   1400     xcb_ret.sequence = xcb_send_request(c, XCB_REQUEST_CHECKED, xcb_parts + 2, &xcb_req);
   1401     return xcb_ret;
   1402 }
   1403 
   1404 xcb_void_cookie_t
   1405 xcb_xv_select_video_notify (xcb_connection_t *c,
   1406                             xcb_drawable_t    drawable,
   1407                             uint8_t           onoff)
   1408 {
   1409     static const xcb_protocol_request_t xcb_req = {
   1410         .count = 2,
   1411         .ext = &xcb_xv_id,
   1412         .opcode = XCB_XV_SELECT_VIDEO_NOTIFY,
   1413         .isvoid = 1
   1414     };
   1415 
   1416     struct iovec xcb_parts[4];
   1417     xcb_void_cookie_t xcb_ret;
   1418     xcb_xv_select_video_notify_request_t xcb_out;
   1419 
   1420     xcb_out.drawable = drawable;
   1421     xcb_out.onoff = onoff;
   1422     memset(xcb_out.pad0, 0, 3);
   1423 
   1424     xcb_parts[2].iov_base = (char *) &xcb_out;
   1425     xcb_parts[2].iov_len = sizeof(xcb_out);
   1426     xcb_parts[3].iov_base = 0;
   1427     xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;
   1428 
   1429     xcb_ret.sequence = xcb_send_request(c, 0, xcb_parts + 2, &xcb_req);
   1430     return xcb_ret;
   1431 }
   1432 
   1433 xcb_void_cookie_t
   1434 xcb_xv_select_port_notify_checked (xcb_connection_t *c,
   1435                                    xcb_xv_port_t     port,
   1436                                    uint8_t           onoff)
   1437 {
   1438     static const xcb_protocol_request_t xcb_req = {
   1439         .count = 2,
   1440         .ext = &xcb_xv_id,
   1441         .opcode = XCB_XV_SELECT_PORT_NOTIFY,
   1442         .isvoid = 1
   1443     };
   1444 
   1445     struct iovec xcb_parts[4];
   1446     xcb_void_cookie_t xcb_ret;
   1447     xcb_xv_select_port_notify_request_t xcb_out;
   1448 
   1449     xcb_out.port = port;
   1450     xcb_out.onoff = onoff;
   1451     memset(xcb_out.pad0, 0, 3);
   1452 
   1453     xcb_parts[2].iov_base = (char *) &xcb_out;
   1454     xcb_parts[2].iov_len = sizeof(xcb_out);
   1455     xcb_parts[3].iov_base = 0;
   1456     xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;
   1457 
   1458     xcb_ret.sequence = xcb_send_request(c, XCB_REQUEST_CHECKED, xcb_parts + 2, &xcb_req);
   1459     return xcb_ret;
   1460 }
   1461 
   1462 xcb_void_cookie_t
   1463 xcb_xv_select_port_notify (xcb_connection_t *c,
   1464                            xcb_xv_port_t     port,
   1465                            uint8_t           onoff)
   1466 {
   1467     static const xcb_protocol_request_t xcb_req = {
   1468         .count = 2,
   1469         .ext = &xcb_xv_id,
   1470         .opcode = XCB_XV_SELECT_PORT_NOTIFY,
   1471         .isvoid = 1
   1472     };
   1473 
   1474     struct iovec xcb_parts[4];
   1475     xcb_void_cookie_t xcb_ret;
   1476     xcb_xv_select_port_notify_request_t xcb_out;
   1477 
   1478     xcb_out.port = port;
   1479     xcb_out.onoff = onoff;
   1480     memset(xcb_out.pad0, 0, 3);
   1481 
   1482     xcb_parts[2].iov_base = (char *) &xcb_out;
   1483     xcb_parts[2].iov_len = sizeof(xcb_out);
   1484     xcb_parts[3].iov_base = 0;
   1485     xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;
   1486 
   1487     xcb_ret.sequence = xcb_send_request(c, 0, xcb_parts + 2, &xcb_req);
   1488     return xcb_ret;
   1489 }
   1490 
   1491 xcb_xv_query_best_size_cookie_t
   1492 xcb_xv_query_best_size (xcb_connection_t *c,
   1493                         xcb_xv_port_t     port,
   1494                         uint16_t          vid_w,
   1495                         uint16_t          vid_h,
   1496                         uint16_t          drw_w,
   1497                         uint16_t          drw_h,
   1498                         uint8_t           motion)
   1499 {
   1500     static const xcb_protocol_request_t xcb_req = {
   1501         .count = 2,
   1502         .ext = &xcb_xv_id,
   1503         .opcode = XCB_XV_QUERY_BEST_SIZE,
   1504         .isvoid = 0
   1505     };
   1506 
   1507     struct iovec xcb_parts[4];
   1508     xcb_xv_query_best_size_cookie_t xcb_ret;
   1509     xcb_xv_query_best_size_request_t xcb_out;
   1510 
   1511     xcb_out.port = port;
   1512     xcb_out.vid_w = vid_w;
   1513     xcb_out.vid_h = vid_h;
   1514     xcb_out.drw_w = drw_w;
   1515     xcb_out.drw_h = drw_h;
   1516     xcb_out.motion = motion;
   1517     memset(xcb_out.pad0, 0, 3);
   1518 
   1519     xcb_parts[2].iov_base = (char *) &xcb_out;
   1520     xcb_parts[2].iov_len = sizeof(xcb_out);
   1521     xcb_parts[3].iov_base = 0;
   1522     xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;
   1523 
   1524     xcb_ret.sequence = xcb_send_request(c, XCB_REQUEST_CHECKED, xcb_parts + 2, &xcb_req);
   1525     return xcb_ret;
   1526 }
   1527 
   1528 xcb_xv_query_best_size_cookie_t
   1529 xcb_xv_query_best_size_unchecked (xcb_connection_t *c,
   1530                                   xcb_xv_port_t     port,
   1531                                   uint16_t          vid_w,
   1532                                   uint16_t          vid_h,
   1533                                   uint16_t          drw_w,
   1534                                   uint16_t          drw_h,
   1535                                   uint8_t           motion)
   1536 {
   1537     static const xcb_protocol_request_t xcb_req = {
   1538         .count = 2,
   1539         .ext = &xcb_xv_id,
   1540         .opcode = XCB_XV_QUERY_BEST_SIZE,
   1541         .isvoid = 0
   1542     };
   1543 
   1544     struct iovec xcb_parts[4];
   1545     xcb_xv_query_best_size_cookie_t xcb_ret;
   1546     xcb_xv_query_best_size_request_t xcb_out;
   1547 
   1548     xcb_out.port = port;
   1549     xcb_out.vid_w = vid_w;
   1550     xcb_out.vid_h = vid_h;
   1551     xcb_out.drw_w = drw_w;
   1552     xcb_out.drw_h = drw_h;
   1553     xcb_out.motion = motion;
   1554     memset(xcb_out.pad0, 0, 3);
   1555 
   1556     xcb_parts[2].iov_base = (char *) &xcb_out;
   1557     xcb_parts[2].iov_len = sizeof(xcb_out);
   1558     xcb_parts[3].iov_base = 0;
   1559     xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;
   1560 
   1561     xcb_ret.sequence = xcb_send_request(c, 0, xcb_parts + 2, &xcb_req);
   1562     return xcb_ret;
   1563 }
   1564 
   1565 xcb_xv_query_best_size_reply_t *
   1566 xcb_xv_query_best_size_reply (xcb_connection_t                 *c,
   1567                               xcb_xv_query_best_size_cookie_t   cookie  /**< */,
   1568                               xcb_generic_error_t             **e)
   1569 {
   1570     return (xcb_xv_query_best_size_reply_t *) xcb_wait_for_reply(c, cookie.sequence, e);
   1571 }
   1572 
   1573 xcb_void_cookie_t
   1574 xcb_xv_set_port_attribute_checked (xcb_connection_t *c,
   1575                                    xcb_xv_port_t     port,
   1576                                    xcb_atom_t        attribute,
   1577                                    int32_t           value)
   1578 {
   1579     static const xcb_protocol_request_t xcb_req = {
   1580         .count = 2,
   1581         .ext = &xcb_xv_id,
   1582         .opcode = XCB_XV_SET_PORT_ATTRIBUTE,
   1583         .isvoid = 1
   1584     };
   1585 
   1586     struct iovec xcb_parts[4];
   1587     xcb_void_cookie_t xcb_ret;
   1588     xcb_xv_set_port_attribute_request_t xcb_out;
   1589 
   1590     xcb_out.port = port;
   1591     xcb_out.attribute = attribute;
   1592     xcb_out.value = value;
   1593 
   1594     xcb_parts[2].iov_base = (char *) &xcb_out;
   1595     xcb_parts[2].iov_len = sizeof(xcb_out);
   1596     xcb_parts[3].iov_base = 0;
   1597     xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;
   1598 
   1599     xcb_ret.sequence = xcb_send_request(c, XCB_REQUEST_CHECKED, xcb_parts + 2, &xcb_req);
   1600     return xcb_ret;
   1601 }
   1602 
   1603 xcb_void_cookie_t
   1604 xcb_xv_set_port_attribute (xcb_connection_t *c,
   1605                            xcb_xv_port_t     port,
   1606                            xcb_atom_t        attribute,
   1607                            int32_t           value)
   1608 {
   1609     static const xcb_protocol_request_t xcb_req = {
   1610         .count = 2,
   1611         .ext = &xcb_xv_id,
   1612         .opcode = XCB_XV_SET_PORT_ATTRIBUTE,
   1613         .isvoid = 1
   1614     };
   1615 
   1616     struct iovec xcb_parts[4];
   1617     xcb_void_cookie_t xcb_ret;
   1618     xcb_xv_set_port_attribute_request_t xcb_out;
   1619 
   1620     xcb_out.port = port;
   1621     xcb_out.attribute = attribute;
   1622     xcb_out.value = value;
   1623 
   1624     xcb_parts[2].iov_base = (char *) &xcb_out;
   1625     xcb_parts[2].iov_len = sizeof(xcb_out);
   1626     xcb_parts[3].iov_base = 0;
   1627     xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;
   1628 
   1629     xcb_ret.sequence = xcb_send_request(c, 0, xcb_parts + 2, &xcb_req);
   1630     return xcb_ret;
   1631 }
   1632 
   1633 xcb_xv_get_port_attribute_cookie_t
   1634 xcb_xv_get_port_attribute (xcb_connection_t *c,
   1635                            xcb_xv_port_t     port,
   1636                            xcb_atom_t        attribute)
   1637 {
   1638     static const xcb_protocol_request_t xcb_req = {
   1639         .count = 2,
   1640         .ext = &xcb_xv_id,
   1641         .opcode = XCB_XV_GET_PORT_ATTRIBUTE,
   1642         .isvoid = 0
   1643     };
   1644 
   1645     struct iovec xcb_parts[4];
   1646     xcb_xv_get_port_attribute_cookie_t xcb_ret;
   1647     xcb_xv_get_port_attribute_request_t xcb_out;
   1648 
   1649     xcb_out.port = port;
   1650     xcb_out.attribute = attribute;
   1651 
   1652     xcb_parts[2].iov_base = (char *) &xcb_out;
   1653     xcb_parts[2].iov_len = sizeof(xcb_out);
   1654     xcb_parts[3].iov_base = 0;
   1655     xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;
   1656 
   1657     xcb_ret.sequence = xcb_send_request(c, XCB_REQUEST_CHECKED, xcb_parts + 2, &xcb_req);
   1658     return xcb_ret;
   1659 }
   1660 
   1661 xcb_xv_get_port_attribute_cookie_t
   1662 xcb_xv_get_port_attribute_unchecked (xcb_connection_t *c,
   1663                                      xcb_xv_port_t     port,
   1664                                      xcb_atom_t        attribute)
   1665 {
   1666     static const xcb_protocol_request_t xcb_req = {
   1667         .count = 2,
   1668         .ext = &xcb_xv_id,
   1669         .opcode = XCB_XV_GET_PORT_ATTRIBUTE,
   1670         .isvoid = 0
   1671     };
   1672 
   1673     struct iovec xcb_parts[4];
   1674     xcb_xv_get_port_attribute_cookie_t xcb_ret;
   1675     xcb_xv_get_port_attribute_request_t xcb_out;
   1676 
   1677     xcb_out.port = port;
   1678     xcb_out.attribute = attribute;
   1679 
   1680     xcb_parts[2].iov_base = (char *) &xcb_out;
   1681     xcb_parts[2].iov_len = sizeof(xcb_out);
   1682     xcb_parts[3].iov_base = 0;
   1683     xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;
   1684 
   1685     xcb_ret.sequence = xcb_send_request(c, 0, xcb_parts + 2, &xcb_req);
   1686     return xcb_ret;
   1687 }
   1688 
   1689 xcb_xv_get_port_attribute_reply_t *
   1690 xcb_xv_get_port_attribute_reply (xcb_connection_t                    *c,
   1691                                  xcb_xv_get_port_attribute_cookie_t   cookie  /**< */,
   1692                                  xcb_generic_error_t                **e)
   1693 {
   1694     return (xcb_xv_get_port_attribute_reply_t *) xcb_wait_for_reply(c, cookie.sequence, e);
   1695 }
   1696 
   1697 int
   1698 xcb_xv_query_port_attributes_sizeof (const void  *_buffer)
   1699 {
   1700     char *xcb_tmp = (char *)_buffer;
   1701     const xcb_xv_query_port_attributes_reply_t *_aux = (xcb_xv_query_port_attributes_reply_t *)_buffer;
   1702     unsigned int xcb_buffer_len = 0;
   1703     unsigned int xcb_block_len = 0;
   1704     unsigned int xcb_pad = 0;
   1705     unsigned int xcb_align_to = 0;
   1706 
   1707     unsigned int i;
   1708     unsigned int xcb_tmp_len;
   1709 
   1710     xcb_block_len += sizeof(xcb_xv_query_port_attributes_reply_t);
   1711     xcb_tmp += xcb_block_len;
   1712     xcb_buffer_len += xcb_block_len;
   1713     xcb_block_len = 0;
   1714     /* attributes */
   1715     for(i=0; i<_aux->num_attributes; i++) {
   1716         xcb_tmp_len = xcb_xv_attribute_info_sizeof(xcb_tmp);
   1717         xcb_block_len += xcb_tmp_len;
   1718         xcb_tmp += xcb_tmp_len;
   1719     }
   1720     xcb_align_to = ALIGNOF(xcb_xv_attribute_info_t);
   1721     /* insert padding */
   1722     xcb_pad = -xcb_block_len & (xcb_align_to - 1);
   1723     xcb_buffer_len += xcb_block_len + xcb_pad;
   1724     if (0 != xcb_pad) {
   1725         xcb_tmp += xcb_pad;
   1726         xcb_pad = 0;
   1727     }
   1728     xcb_block_len = 0;
   1729 
   1730     return xcb_buffer_len;
   1731 }
   1732 
   1733 xcb_xv_query_port_attributes_cookie_t
   1734 xcb_xv_query_port_attributes (xcb_connection_t *c,
   1735                               xcb_xv_port_t     port)
   1736 {
   1737     static const xcb_protocol_request_t xcb_req = {
   1738         .count = 2,
   1739         .ext = &xcb_xv_id,
   1740         .opcode = XCB_XV_QUERY_PORT_ATTRIBUTES,
   1741         .isvoid = 0
   1742     };
   1743 
   1744     struct iovec xcb_parts[4];
   1745     xcb_xv_query_port_attributes_cookie_t xcb_ret;
   1746     xcb_xv_query_port_attributes_request_t xcb_out;
   1747 
   1748     xcb_out.port = port;
   1749 
   1750     xcb_parts[2].iov_base = (char *) &xcb_out;
   1751     xcb_parts[2].iov_len = sizeof(xcb_out);
   1752     xcb_parts[3].iov_base = 0;
   1753     xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;
   1754 
   1755     xcb_ret.sequence = xcb_send_request(c, XCB_REQUEST_CHECKED, xcb_parts + 2, &xcb_req);
   1756     return xcb_ret;
   1757 }
   1758 
   1759 xcb_xv_query_port_attributes_cookie_t
   1760 xcb_xv_query_port_attributes_unchecked (xcb_connection_t *c,
   1761                                         xcb_xv_port_t     port)
   1762 {
   1763     static const xcb_protocol_request_t xcb_req = {
   1764         .count = 2,
   1765         .ext = &xcb_xv_id,
   1766         .opcode = XCB_XV_QUERY_PORT_ATTRIBUTES,
   1767         .isvoid = 0
   1768     };
   1769 
   1770     struct iovec xcb_parts[4];
   1771     xcb_xv_query_port_attributes_cookie_t xcb_ret;
   1772     xcb_xv_query_port_attributes_request_t xcb_out;
   1773 
   1774     xcb_out.port = port;
   1775 
   1776     xcb_parts[2].iov_base = (char *) &xcb_out;
   1777     xcb_parts[2].iov_len = sizeof(xcb_out);
   1778     xcb_parts[3].iov_base = 0;
   1779     xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;
   1780 
   1781     xcb_ret.sequence = xcb_send_request(c, 0, xcb_parts + 2, &xcb_req);
   1782     return xcb_ret;
   1783 }
   1784 
   1785 int
   1786 xcb_xv_query_port_attributes_attributes_length (const xcb_xv_query_port_attributes_reply_t *R)
   1787 {
   1788     return R->num_attributes;
   1789 }
   1790 
   1791 xcb_xv_attribute_info_iterator_t
   1792 xcb_xv_query_port_attributes_attributes_iterator (const xcb_xv_query_port_attributes_reply_t *R)
   1793 {
   1794     xcb_xv_attribute_info_iterator_t i;
   1795     i.data = (xcb_xv_attribute_info_t *) (R + 1);
   1796     i.rem = R->num_attributes;
   1797     i.index = (char *) i.data - (char *) R;
   1798     return i;
   1799 }
   1800 
   1801 xcb_xv_query_port_attributes_reply_t *
   1802 xcb_xv_query_port_attributes_reply (xcb_connection_t                       *c,
   1803                                     xcb_xv_query_port_attributes_cookie_t   cookie  /**< */,
   1804                                     xcb_generic_error_t                   **e)
   1805 {
   1806     return (xcb_xv_query_port_attributes_reply_t *) xcb_wait_for_reply(c, cookie.sequence, e);
   1807 }
   1808 
   1809 int
   1810 xcb_xv_list_image_formats_sizeof (const void  *_buffer)
   1811 {
   1812     char *xcb_tmp = (char *)_buffer;
   1813     const xcb_xv_list_image_formats_reply_t *_aux = (xcb_xv_list_image_formats_reply_t *)_buffer;
   1814     unsigned int xcb_buffer_len = 0;
   1815     unsigned int xcb_block_len = 0;
   1816     unsigned int xcb_pad = 0;
   1817     unsigned int xcb_align_to = 0;
   1818 
   1819 
   1820     xcb_block_len += sizeof(xcb_xv_list_image_formats_reply_t);
   1821     xcb_tmp += xcb_block_len;
   1822     xcb_buffer_len += xcb_block_len;
   1823     xcb_block_len = 0;
   1824     /* format */
   1825     xcb_block_len += _aux->num_formats * sizeof(xcb_xv_image_format_info_t);
   1826     xcb_tmp += xcb_block_len;
   1827     xcb_align_to = ALIGNOF(xcb_xv_image_format_info_t);
   1828     /* insert padding */
   1829     xcb_pad = -xcb_block_len & (xcb_align_to - 1);
   1830     xcb_buffer_len += xcb_block_len + xcb_pad;
   1831     if (0 != xcb_pad) {
   1832         xcb_tmp += xcb_pad;
   1833         xcb_pad = 0;
   1834     }
   1835     xcb_block_len = 0;
   1836 
   1837     return xcb_buffer_len;
   1838 }
   1839 
   1840 xcb_xv_list_image_formats_cookie_t
   1841 xcb_xv_list_image_formats (xcb_connection_t *c,
   1842                            xcb_xv_port_t     port)
   1843 {
   1844     static const xcb_protocol_request_t xcb_req = {
   1845         .count = 2,
   1846         .ext = &xcb_xv_id,
   1847         .opcode = XCB_XV_LIST_IMAGE_FORMATS,
   1848         .isvoid = 0
   1849     };
   1850 
   1851     struct iovec xcb_parts[4];
   1852     xcb_xv_list_image_formats_cookie_t xcb_ret;
   1853     xcb_xv_list_image_formats_request_t xcb_out;
   1854 
   1855     xcb_out.port = port;
   1856 
   1857     xcb_parts[2].iov_base = (char *) &xcb_out;
   1858     xcb_parts[2].iov_len = sizeof(xcb_out);
   1859     xcb_parts[3].iov_base = 0;
   1860     xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;
   1861 
   1862     xcb_ret.sequence = xcb_send_request(c, XCB_REQUEST_CHECKED, xcb_parts + 2, &xcb_req);
   1863     return xcb_ret;
   1864 }
   1865 
   1866 xcb_xv_list_image_formats_cookie_t
   1867 xcb_xv_list_image_formats_unchecked (xcb_connection_t *c,
   1868                                      xcb_xv_port_t     port)
   1869 {
   1870     static const xcb_protocol_request_t xcb_req = {
   1871         .count = 2,
   1872         .ext = &xcb_xv_id,
   1873         .opcode = XCB_XV_LIST_IMAGE_FORMATS,
   1874         .isvoid = 0
   1875     };
   1876 
   1877     struct iovec xcb_parts[4];
   1878     xcb_xv_list_image_formats_cookie_t xcb_ret;
   1879     xcb_xv_list_image_formats_request_t xcb_out;
   1880 
   1881     xcb_out.port = port;
   1882 
   1883     xcb_parts[2].iov_base = (char *) &xcb_out;
   1884     xcb_parts[2].iov_len = sizeof(xcb_out);
   1885     xcb_parts[3].iov_base = 0;
   1886     xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;
   1887 
   1888     xcb_ret.sequence = xcb_send_request(c, 0, xcb_parts + 2, &xcb_req);
   1889     return xcb_ret;
   1890 }
   1891 
   1892 xcb_xv_image_format_info_t *
   1893 xcb_xv_list_image_formats_format (const xcb_xv_list_image_formats_reply_t *R)
   1894 {
   1895     return (xcb_xv_image_format_info_t *) (R + 1);
   1896 }
   1897 
   1898 int
   1899 xcb_xv_list_image_formats_format_length (const xcb_xv_list_image_formats_reply_t *R)
   1900 {
   1901     return R->num_formats;
   1902 }
   1903 
   1904 xcb_xv_image_format_info_iterator_t
   1905 xcb_xv_list_image_formats_format_iterator (const xcb_xv_list_image_formats_reply_t *R)
   1906 {
   1907     xcb_xv_image_format_info_iterator_t i;
   1908     i.data = (xcb_xv_image_format_info_t *) (R + 1);
   1909     i.rem = R->num_formats;
   1910     i.index = (char *) i.data - (char *) R;
   1911     return i;
   1912 }
   1913 
   1914 xcb_xv_list_image_formats_reply_t *
   1915 xcb_xv_list_image_formats_reply (xcb_connection_t                    *c,
   1916                                  xcb_xv_list_image_formats_cookie_t   cookie  /**< */,
   1917                                  xcb_generic_error_t                **e)
   1918 {
   1919     return (xcb_xv_list_image_formats_reply_t *) xcb_wait_for_reply(c, cookie.sequence, e);
   1920 }
   1921 
   1922 int
   1923 xcb_xv_query_image_attributes_sizeof (const void  *_buffer)
   1924 {
   1925     char *xcb_tmp = (char *)_buffer;
   1926     const xcb_xv_query_image_attributes_reply_t *_aux = (xcb_xv_query_image_attributes_reply_t *)_buffer;
   1927     unsigned int xcb_buffer_len = 0;
   1928     unsigned int xcb_block_len = 0;
   1929     unsigned int xcb_pad = 0;
   1930     unsigned int xcb_align_to = 0;
   1931 
   1932 
   1933     xcb_block_len += sizeof(xcb_xv_query_image_attributes_reply_t);
   1934     xcb_tmp += xcb_block_len;
   1935     xcb_buffer_len += xcb_block_len;
   1936     xcb_block_len = 0;
   1937     /* pitches */
   1938     xcb_block_len += _aux->num_planes * sizeof(uint32_t);
   1939     xcb_tmp += xcb_block_len;
   1940     xcb_align_to = ALIGNOF(uint32_t);
   1941     /* insert padding */
   1942     xcb_pad = -xcb_block_len & (xcb_align_to - 1);
   1943     xcb_buffer_len += xcb_block_len + xcb_pad;
   1944     if (0 != xcb_pad) {
   1945         xcb_tmp += xcb_pad;
   1946         xcb_pad = 0;
   1947     }
   1948     xcb_block_len = 0;
   1949     /* offsets */
   1950     xcb_block_len += _aux->num_planes * sizeof(uint32_t);
   1951     xcb_tmp += xcb_block_len;
   1952     xcb_align_to = ALIGNOF(uint32_t);
   1953     /* insert padding */
   1954     xcb_pad = -xcb_block_len & (xcb_align_to - 1);
   1955     xcb_buffer_len += xcb_block_len + xcb_pad;
   1956     if (0 != xcb_pad) {
   1957         xcb_tmp += xcb_pad;
   1958         xcb_pad = 0;
   1959     }
   1960     xcb_block_len = 0;
   1961 
   1962     return xcb_buffer_len;
   1963 }
   1964 
   1965 xcb_xv_query_image_attributes_cookie_t
   1966 xcb_xv_query_image_attributes (xcb_connection_t *c,
   1967                                xcb_xv_port_t     port,
   1968                                uint32_t          id,
   1969                                uint16_t          width,
   1970                                uint16_t          height)
   1971 {
   1972     static const xcb_protocol_request_t xcb_req = {
   1973         .count = 2,
   1974         .ext = &xcb_xv_id,
   1975         .opcode = XCB_XV_QUERY_IMAGE_ATTRIBUTES,
   1976         .isvoid = 0
   1977     };
   1978 
   1979     struct iovec xcb_parts[4];
   1980     xcb_xv_query_image_attributes_cookie_t xcb_ret;
   1981     xcb_xv_query_image_attributes_request_t xcb_out;
   1982 
   1983     xcb_out.port = port;
   1984     xcb_out.id = id;
   1985     xcb_out.width = width;
   1986     xcb_out.height = height;
   1987 
   1988     xcb_parts[2].iov_base = (char *) &xcb_out;
   1989     xcb_parts[2].iov_len = sizeof(xcb_out);
   1990     xcb_parts[3].iov_base = 0;
   1991     xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;
   1992 
   1993     xcb_ret.sequence = xcb_send_request(c, XCB_REQUEST_CHECKED, xcb_parts + 2, &xcb_req);
   1994     return xcb_ret;
   1995 }
   1996 
   1997 xcb_xv_query_image_attributes_cookie_t
   1998 xcb_xv_query_image_attributes_unchecked (xcb_connection_t *c,
   1999                                          xcb_xv_port_t     port,
   2000                                          uint32_t          id,
   2001                                          uint16_t          width,
   2002                                          uint16_t          height)
   2003 {
   2004     static const xcb_protocol_request_t xcb_req = {
   2005         .count = 2,
   2006         .ext = &xcb_xv_id,
   2007         .opcode = XCB_XV_QUERY_IMAGE_ATTRIBUTES,
   2008         .isvoid = 0
   2009     };
   2010 
   2011     struct iovec xcb_parts[4];
   2012     xcb_xv_query_image_attributes_cookie_t xcb_ret;
   2013     xcb_xv_query_image_attributes_request_t xcb_out;
   2014 
   2015     xcb_out.port = port;
   2016     xcb_out.id = id;
   2017     xcb_out.width = width;
   2018     xcb_out.height = height;
   2019 
   2020     xcb_parts[2].iov_base = (char *) &xcb_out;
   2021     xcb_parts[2].iov_len = sizeof(xcb_out);
   2022     xcb_parts[3].iov_base = 0;
   2023     xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;
   2024 
   2025     xcb_ret.sequence = xcb_send_request(c, 0, xcb_parts + 2, &xcb_req);
   2026     return xcb_ret;
   2027 }
   2028 
   2029 uint32_t *
   2030 xcb_xv_query_image_attributes_pitches (const xcb_xv_query_image_attributes_reply_t *R)
   2031 {
   2032     return (uint32_t *) (R + 1);
   2033 }
   2034 
   2035 int
   2036 xcb_xv_query_image_attributes_pitches_length (const xcb_xv_query_image_attributes_reply_t *R)
   2037 {
   2038     return R->num_planes;
   2039 }
   2040 
   2041 xcb_generic_iterator_t
   2042 xcb_xv_query_image_attributes_pitches_end (const xcb_xv_query_image_attributes_reply_t *R)
   2043 {
   2044     xcb_generic_iterator_t i;
   2045     i.data = ((uint32_t *) (R + 1)) + (R->num_planes);
   2046     i.rem = 0;
   2047     i.index = (char *) i.data - (char *) R;
   2048     return i;
   2049 }
   2050 
   2051 uint32_t *
   2052 xcb_xv_query_image_attributes_offsets (const xcb_xv_query_image_attributes_reply_t *R)
   2053 {
   2054     xcb_generic_iterator_t prev = xcb_xv_query_image_attributes_pitches_end(R);
   2055     return (uint32_t *) ((char *) prev.data + XCB_TYPE_PAD(uint32_t, prev.index) + 0);
   2056 }
   2057 
   2058 int
   2059 xcb_xv_query_image_attributes_offsets_length (const xcb_xv_query_image_attributes_reply_t *R)
   2060 {
   2061     return R->num_planes;
   2062 }
   2063 
   2064 xcb_generic_iterator_t
   2065 xcb_xv_query_image_attributes_offsets_end (const xcb_xv_query_image_attributes_reply_t *R)
   2066 {
   2067     xcb_generic_iterator_t i;
   2068     xcb_generic_iterator_t prev = xcb_xv_query_image_attributes_pitches_end(R);
   2069     i.data = ((uint32_t *) ((char*) prev.data + XCB_TYPE_PAD(uint32_t, prev.index))) + (R->num_planes);
   2070     i.rem = 0;
   2071     i.index = (char *) i.data - (char *) R;
   2072     return i;
   2073 }
   2074 
   2075 xcb_xv_query_image_attributes_reply_t *
   2076 xcb_xv_query_image_attributes_reply (xcb_connection_t                        *c,
   2077                                      xcb_xv_query_image_attributes_cookie_t   cookie  /**< */,
   2078                                      xcb_generic_error_t                    **e)
   2079 {
   2080     return (xcb_xv_query_image_attributes_reply_t *) xcb_wait_for_reply(c, cookie.sequence, e);
   2081 }
   2082 
   2083 int
   2084 xcb_xv_put_image_sizeof (const void  *_buffer,
   2085                          uint32_t     data_len)
   2086 {
   2087     char *xcb_tmp = (char *)_buffer;
   2088     unsigned int xcb_buffer_len = 0;
   2089     unsigned int xcb_block_len = 0;
   2090     unsigned int xcb_pad = 0;
   2091     unsigned int xcb_align_to = 0;
   2092 
   2093 
   2094     xcb_block_len += sizeof(xcb_xv_put_image_request_t);
   2095     xcb_tmp += xcb_block_len;
   2096     xcb_buffer_len += xcb_block_len;
   2097     xcb_block_len = 0;
   2098     /* data */
   2099     xcb_block_len += data_len * sizeof(uint8_t);
   2100     xcb_tmp += xcb_block_len;
   2101     xcb_align_to = ALIGNOF(uint8_t);
   2102     /* insert padding */
   2103     xcb_pad = -xcb_block_len & (xcb_align_to - 1);
   2104     xcb_buffer_len += xcb_block_len + xcb_pad;
   2105     if (0 != xcb_pad) {
   2106         xcb_tmp += xcb_pad;
   2107         xcb_pad = 0;
   2108     }
   2109     xcb_block_len = 0;
   2110 
   2111     return xcb_buffer_len;
   2112 }
   2113 
   2114 xcb_void_cookie_t
   2115 xcb_xv_put_image_checked (xcb_connection_t *c,
   2116                           xcb_xv_port_t     port,
   2117                           xcb_drawable_t    drawable,
   2118                           xcb_gcontext_t    gc,
   2119                           uint32_t          id,
   2120                           int16_t           src_x,
   2121                           int16_t           src_y,
   2122                           uint16_t          src_w,
   2123                           uint16_t          src_h,
   2124                           int16_t           drw_x,
   2125                           int16_t           drw_y,
   2126                           uint16_t          drw_w,
   2127                           uint16_t          drw_h,
   2128                           uint16_t          width,
   2129                           uint16_t          height,
   2130                           uint32_t          data_len,
   2131                           const uint8_t    *data)
   2132 {
   2133     static const xcb_protocol_request_t xcb_req = {
   2134         .count = 4,
   2135         .ext = &xcb_xv_id,
   2136         .opcode = XCB_XV_PUT_IMAGE,
   2137         .isvoid = 1
   2138     };
   2139 
   2140     struct iovec xcb_parts[6];
   2141     xcb_void_cookie_t xcb_ret;
   2142     xcb_xv_put_image_request_t xcb_out;
   2143 
   2144     xcb_out.port = port;
   2145     xcb_out.drawable = drawable;
   2146     xcb_out.gc = gc;
   2147     xcb_out.id = id;
   2148     xcb_out.src_x = src_x;
   2149     xcb_out.src_y = src_y;
   2150     xcb_out.src_w = src_w;
   2151     xcb_out.src_h = src_h;
   2152     xcb_out.drw_x = drw_x;
   2153     xcb_out.drw_y = drw_y;
   2154     xcb_out.drw_w = drw_w;
   2155     xcb_out.drw_h = drw_h;
   2156     xcb_out.width = width;
   2157     xcb_out.height = height;
   2158 
   2159     xcb_parts[2].iov_base = (char *) &xcb_out;
   2160     xcb_parts[2].iov_len = sizeof(xcb_out);
   2161     xcb_parts[3].iov_base = 0;
   2162     xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;
   2163     /* uint8_t data */
   2164     xcb_parts[4].iov_base = (char *) data;
   2165     xcb_parts[4].iov_len = data_len * sizeof(uint8_t);
   2166     xcb_parts[5].iov_base = 0;
   2167     xcb_parts[5].iov_len = -xcb_parts[4].iov_len & 3;
   2168 
   2169     xcb_ret.sequence = xcb_send_request(c, XCB_REQUEST_CHECKED, xcb_parts + 2, &xcb_req);
   2170     return xcb_ret;
   2171 }
   2172 
   2173 xcb_void_cookie_t
   2174 xcb_xv_put_image (xcb_connection_t *c,
   2175                   xcb_xv_port_t     port,
   2176                   xcb_drawable_t    drawable,
   2177                   xcb_gcontext_t    gc,
   2178                   uint32_t          id,
   2179                   int16_t           src_x,
   2180                   int16_t           src_y,
   2181                   uint16_t          src_w,
   2182                   uint16_t          src_h,
   2183                   int16_t           drw_x,
   2184                   int16_t           drw_y,
   2185                   uint16_t          drw_w,
   2186                   uint16_t          drw_h,
   2187                   uint16_t          width,
   2188                   uint16_t          height,
   2189                   uint32_t          data_len,
   2190                   const uint8_t    *data)
   2191 {
   2192     static const xcb_protocol_request_t xcb_req = {
   2193         .count = 4,
   2194         .ext = &xcb_xv_id,
   2195         .opcode = XCB_XV_PUT_IMAGE,
   2196         .isvoid = 1
   2197     };
   2198 
   2199     struct iovec xcb_parts[6];
   2200     xcb_void_cookie_t xcb_ret;
   2201     xcb_xv_put_image_request_t xcb_out;
   2202 
   2203     xcb_out.port = port;
   2204     xcb_out.drawable = drawable;
   2205     xcb_out.gc = gc;
   2206     xcb_out.id = id;
   2207     xcb_out.src_x = src_x;
   2208     xcb_out.src_y = src_y;
   2209     xcb_out.src_w = src_w;
   2210     xcb_out.src_h = src_h;
   2211     xcb_out.drw_x = drw_x;
   2212     xcb_out.drw_y = drw_y;
   2213     xcb_out.drw_w = drw_w;
   2214     xcb_out.drw_h = drw_h;
   2215     xcb_out.width = width;
   2216     xcb_out.height = height;
   2217 
   2218     xcb_parts[2].iov_base = (char *) &xcb_out;
   2219     xcb_parts[2].iov_len = sizeof(xcb_out);
   2220     xcb_parts[3].iov_base = 0;
   2221     xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;
   2222     /* uint8_t data */
   2223     xcb_parts[4].iov_base = (char *) data;
   2224     xcb_parts[4].iov_len = data_len * sizeof(uint8_t);
   2225     xcb_parts[5].iov_base = 0;
   2226     xcb_parts[5].iov_len = -xcb_parts[4].iov_len & 3;
   2227 
   2228     xcb_ret.sequence = xcb_send_request(c, 0, xcb_parts + 2, &xcb_req);
   2229     return xcb_ret;
   2230 }
   2231 
   2232 uint8_t *
   2233 xcb_xv_put_image_data (const xcb_xv_put_image_request_t *R)
   2234 {
   2235     return (uint8_t *) (R + 1);
   2236 }
   2237 
   2238 int
   2239 xcb_xv_put_image_data_length (const xcb_xv_put_image_request_t *R)
   2240 {
   2241     return (((R->length * 4) - sizeof(xcb_xv_put_image_request_t))/sizeof(uint8_t));
   2242 }
   2243 
   2244 xcb_generic_iterator_t
   2245 xcb_xv_put_image_data_end (const xcb_xv_put_image_request_t *R)
   2246 {
   2247     xcb_generic_iterator_t i;
   2248     i.data = ((uint8_t *) (R + 1)) + ((((R->length * 4) - sizeof(xcb_xv_put_image_request_t))/sizeof(uint8_t)));
   2249     i.rem = 0;
   2250     i.index = (char *) i.data - (char *) R;
   2251     return i;
   2252 }
   2253 
   2254 xcb_void_cookie_t
   2255 xcb_xv_shm_put_image_checked (xcb_connection_t *c,
   2256                               xcb_xv_port_t     port,
   2257                               xcb_drawable_t    drawable,
   2258                               xcb_gcontext_t    gc,
   2259                               xcb_shm_seg_t     shmseg,
   2260                               uint32_t          id,
   2261                               uint32_t          offset,
   2262                               int16_t           src_x,
   2263                               int16_t           src_y,
   2264                               uint16_t          src_w,
   2265                               uint16_t          src_h,
   2266                               int16_t           drw_x,
   2267                               int16_t           drw_y,
   2268                               uint16_t          drw_w,
   2269                               uint16_t          drw_h,
   2270                               uint16_t          width,
   2271                               uint16_t          height,
   2272                               uint8_t           send_event)
   2273 {
   2274     static const xcb_protocol_request_t xcb_req = {
   2275         .count = 2,
   2276         .ext = &xcb_xv_id,
   2277         .opcode = XCB_XV_SHM_PUT_IMAGE,
   2278         .isvoid = 1
   2279     };
   2280 
   2281     struct iovec xcb_parts[4];
   2282     xcb_void_cookie_t xcb_ret;
   2283     xcb_xv_shm_put_image_request_t xcb_out;
   2284 
   2285     xcb_out.port = port;
   2286     xcb_out.drawable = drawable;
   2287     xcb_out.gc = gc;
   2288     xcb_out.shmseg = shmseg;
   2289     xcb_out.id = id;
   2290     xcb_out.offset = offset;
   2291     xcb_out.src_x = src_x;
   2292     xcb_out.src_y = src_y;
   2293     xcb_out.src_w = src_w;
   2294     xcb_out.src_h = src_h;
   2295     xcb_out.drw_x = drw_x;
   2296     xcb_out.drw_y = drw_y;
   2297     xcb_out.drw_w = drw_w;
   2298     xcb_out.drw_h = drw_h;
   2299     xcb_out.width = width;
   2300     xcb_out.height = height;
   2301     xcb_out.send_event = send_event;
   2302     memset(xcb_out.pad0, 0, 3);
   2303 
   2304     xcb_parts[2].iov_base = (char *) &xcb_out;
   2305     xcb_parts[2].iov_len = sizeof(xcb_out);
   2306     xcb_parts[3].iov_base = 0;
   2307     xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;
   2308 
   2309     xcb_ret.sequence = xcb_send_request(c, XCB_REQUEST_CHECKED, xcb_parts + 2, &xcb_req);
   2310     return xcb_ret;
   2311 }
   2312 
   2313 xcb_void_cookie_t
   2314 xcb_xv_shm_put_image (xcb_connection_t *c,
   2315                       xcb_xv_port_t     port,
   2316                       xcb_drawable_t    drawable,
   2317                       xcb_gcontext_t    gc,
   2318                       xcb_shm_seg_t     shmseg,
   2319                       uint32_t          id,
   2320                       uint32_t          offset,
   2321                       int16_t           src_x,
   2322                       int16_t           src_y,
   2323                       uint16_t          src_w,
   2324                       uint16_t          src_h,
   2325                       int16_t           drw_x,
   2326                       int16_t           drw_y,
   2327                       uint16_t          drw_w,
   2328                       uint16_t          drw_h,
   2329                       uint16_t          width,
   2330                       uint16_t          height,
   2331                       uint8_t           send_event)
   2332 {
   2333     static const xcb_protocol_request_t xcb_req = {
   2334         .count = 2,
   2335         .ext = &xcb_xv_id,
   2336         .opcode = XCB_XV_SHM_PUT_IMAGE,
   2337         .isvoid = 1
   2338     };
   2339 
   2340     struct iovec xcb_parts[4];
   2341     xcb_void_cookie_t xcb_ret;
   2342     xcb_xv_shm_put_image_request_t xcb_out;
   2343 
   2344     xcb_out.port = port;
   2345     xcb_out.drawable = drawable;
   2346     xcb_out.gc = gc;
   2347     xcb_out.shmseg = shmseg;
   2348     xcb_out.id = id;
   2349     xcb_out.offset = offset;
   2350     xcb_out.src_x = src_x;
   2351     xcb_out.src_y = src_y;
   2352     xcb_out.src_w = src_w;
   2353     xcb_out.src_h = src_h;
   2354     xcb_out.drw_x = drw_x;
   2355     xcb_out.drw_y = drw_y;
   2356     xcb_out.drw_w = drw_w;
   2357     xcb_out.drw_h = drw_h;
   2358     xcb_out.width = width;
   2359     xcb_out.height = height;
   2360     xcb_out.send_event = send_event;
   2361     memset(xcb_out.pad0, 0, 3);
   2362 
   2363     xcb_parts[2].iov_base = (char *) &xcb_out;
   2364     xcb_parts[2].iov_len = sizeof(xcb_out);
   2365     xcb_parts[3].iov_base = 0;
   2366     xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;
   2367 
   2368     xcb_ret.sequence = xcb_send_request(c, 0, xcb_parts + 2, &xcb_req);
   2369     return xcb_ret;
   2370 }
   2371 
   2372