static void paint_mouse_pointer(XImage *image, AVFormatContext *s1)

{

    X11GrabContext *s = s1->priv_data;

    int x_off    = s->x_off;

    int y_off    = s->y_off;

    int width    = s->width;

    int height   = s->height;

    Display *dpy = s->dpy;

    XFixesCursorImage *xcim;

    int x, y;

    int line, column;

    int to_line, to_column;

    int pixstride = image->bits_per_pixel >> 3;

    /* Warning: in its insanity, xlib provides unsigned image data through a

     * char* pointer, so we have to make it uint8_t to make things not break.

     * Anyone who performs further investigation of the xlib API likely risks

     * permanent brain damage. */

    uint8_t *pix = image->data;

    Window root;

    XSetWindowAttributes attr;



    /* Code doesn't currently support 16-bit or PAL8 */

    if (image->bits_per_pixel != 24 && image->bits_per_pixel != 32)

        return;



    if (!s->c)

        s->c = XCreateFontCursor(dpy, XC_left_ptr);

    root = DefaultRootWindow(dpy);

    attr.cursor = s->c;

    XChangeWindowAttributes(dpy, root, CWCursor, &attr);



    xcim = XFixesGetCursorImage(dpy);

    if (!xcim) {

        av_log(s1, AV_LOG_WARNING,

               "XFixes extension not available, impossible to draw cursor\n");

        s->draw_mouse = 0;

        return;

    }



    x = xcim->x - xcim->xhot;

    y = xcim->y - xcim->yhot;



    to_line   = FFMIN((y + xcim->height), (height + y_off));

    to_column = FFMIN((x + xcim->width),  (width  + x_off));



    for (line = FFMAX(y, y_off); line < to_line; line++) {

        for (column = FFMAX(x, x_off); column < to_column; column++) {

            int xcim_addr  = (line  - y)     * xcim->width + column - x;

            int image_addr = ((line - y_off) * width       + column - x_off) * pixstride;

            int r          = (uint8_t)(xcim->pixels[xcim_addr] >>  0);

            int g          = (uint8_t)(xcim->pixels[xcim_addr] >>  8);

            int b          = (uint8_t)(xcim->pixels[xcim_addr] >> 16);

            int a          = (uint8_t)(xcim->pixels[xcim_addr] >> 24);



            if (a == 255) {

                pix[image_addr + 0] = r;

                pix[image_addr + 1] = g;

                pix[image_addr + 2] = b;

            } else if (a) {

                /* pixel values from XFixesGetCursorImage come premultiplied by alpha */

                pix[image_addr + 0] = r + (pix[image_addr + 0] * (255 - a) + 255 / 2) / 255;

                pix[image_addr + 1] = g + (pix[image_addr + 1] * (255 - a) + 255 / 2) / 255;

                pix[image_addr + 2] = b + (pix[image_addr + 2] * (255 - a) + 255 / 2) / 255;

            }

        }

    }



    XFree(xcim);

    xcim = NULL;

}

static void paint_mouse_pointer(XImage *image, AVFormatContext *s1)

{

    X11GrabContext *s = s1->priv_data;

    int x_off    = s->x_off;

    int y_off    = s->y_off;

    int width    = s->width;

    int height   = s->height;

    Display *dpy = s->dpy;

    XFixesCursorImage *xcim;

    int x, y;

    int line, column;

    int to_line, to_column;

    int pixstride = image->bits_per_pixel >> 3;

    







    uint8_t *pix = image->data;

    Window root;

    XSetWindowAttributes attr;



    

    if (image->bits_per_pixel != 24 && image->bits_per_pixel != 32)

        return;



    if (!s->c)

        s->c = XCreateFontCursor(dpy, XC_left_ptr);

    root = DefaultRootWindow(dpy);

    attr.cursor = s->c;

    XChangeWindowAttributes(dpy, root, CWCursor, &attr);



    xcim = XFixesGetCursorImage(dpy);

    if (!xcim) {

        av_log(s1, AV_LOG_WARNING,

               "XFixes extension not available, impossible to draw cursor\n");

        s->draw_mouse = 0;

        return;

    }



    x = xcim->x - xcim->xhot;

    y = xcim->y - xcim->yhot;



    to_line   = FFMIN((y + xcim->height), (height + y_off));

    to_column = FFMIN((x + xcim->width),  (width  + x_off));



    for (line = FFMAX(y, y_off); line < to_line; line++) {

        for (column = FFMAX(x, x_off); column < to_column; column++) {

            int xcim_addr  = (line  - y)     * xcim->width + column - x;

            int image_addr = ((line - y_off) * width       + column - x_off) * pixstride;

            int r          = (uint8_t)(xcim->pixels[xcim_addr] >>  0);

            int g          = (uint8_t)(xcim->pixels[xcim_addr] >>  8);

            int b          = (uint8_t)(xcim->pixels[xcim_addr] >> 16);

            int a          = (uint8_t)(xcim->pixels[xcim_addr] >> 24);



            if (a == 255) {

                pix[image_addr + 0] = r;

                pix[image_addr + 1] = g;

                pix[image_addr + 2] = b;

            } else if (a) {

                

                pix[image_addr + 0] = r + (pix[image_addr + 0] * (255 - a) + 255 / 2) / 255;

                pix[image_addr + 1] = g + (pix[image_addr + 1] * (255 - a) + 255 / 2) / 255;

                pix[image_addr + 2] = b + (pix[image_addr + 2] * (255 - a) + 255 / 2) / 255;

            }

        }

    }



    XFree(xcim);

    xcim = NULL;

}

static void FUNC_0(XImage *VAR_0, AVFormatContext *VAR_1)

{

    X11GrabContext *s = VAR_1->priv_data;

    int VAR_2    = s->VAR_2;

    int VAR_3    = s->VAR_3;

    int VAR_4    = s->VAR_4;

    int VAR_5   = s->VAR_5;

    Display *dpy = s->dpy;

    XFixesCursorImage *xcim;

    int VAR_6, VAR_7;

    int VAR_8, VAR_9;

    int VAR_10, VAR_11;

    int VAR_12 = VAR_0->bits_per_pixel >> 3;

    







    uint8_t *pix = VAR_0->data;

    Window root;

    XSetWindowAttributes attr;



    

    if (VAR_0->bits_per_pixel != 24 && VAR_0->bits_per_pixel != 32)

        return;



    if (!s->c)

        s->c = XCreateFontCursor(dpy, XC_left_ptr);

    root = DefaultRootWindow(dpy);

    attr.cursor = s->c;

    XChangeWindowAttributes(dpy, root, CWCursor, &attr);



    xcim = XFixesGetCursorImage(dpy);

    if (!xcim) {

        av_log(VAR_1, AV_LOG_WARNING,

               "XFixes extension not available, impossible to draw cursor\n");

        s->draw_mouse = 0;

        return;

    }



    VAR_6 = xcim->VAR_6 - xcim->xhot;

    VAR_7 = xcim->VAR_7 - xcim->yhot;



    VAR_10   = FFMIN((VAR_7 + xcim->VAR_5), (VAR_5 + VAR_3));

    VAR_11 = FFMIN((VAR_6 + xcim->VAR_4),  (VAR_4  + VAR_2));



    for (VAR_8 = FFMAX(VAR_7, VAR_3); VAR_8 < VAR_10; VAR_8++) {

        for (VAR_9 = FFMAX(VAR_6, VAR_2); VAR_9 < VAR_11; VAR_9++) {

            int VAR_13  = (VAR_8  - VAR_7)     * xcim->VAR_4 + VAR_9 - VAR_6;

            int VAR_14 = ((VAR_8 - VAR_3) * VAR_4       + VAR_9 - VAR_2) * VAR_12;

            int VAR_15          = (uint8_t)(xcim->pixels[VAR_13] >>  0);

            int VAR_16          = (uint8_t)(xcim->pixels[VAR_13] >>  8);

            int VAR_17          = (uint8_t)(xcim->pixels[VAR_13] >> 16);

            int VAR_18          = (uint8_t)(xcim->pixels[VAR_13] >> 24);



            if (VAR_18 == 255) {

                pix[VAR_14 + 0] = VAR_15;

                pix[VAR_14 + 1] = VAR_16;

                pix[VAR_14 + 2] = VAR_17;

            } else if (VAR_18) {

                

                pix[VAR_14 + 0] = VAR_15 + (pix[VAR_14 + 0] * (255 - VAR_18) + 255 / 2) / 255;

                pix[VAR_14 + 1] = VAR_16 + (pix[VAR_14 + 1] * (255 - VAR_18) + 255 / 2) / 255;

                pix[VAR_14 + 2] = VAR_17 + (pix[VAR_14 + 2] * (255 - VAR_18) + 255 / 2) / 255;

            }

        }

    }



    XFree(xcim);

    xcim = NULL;

}

static void FUNC_0(XImage *VAR_0, AVFormatContext *VAR_1)
{ X11GrabContext *s = VAR_1->priv_data; int VAR_2    = s->VAR_2; int VAR_3    = s->VAR_3; int VAR_4    = s->VAR_4; int VAR_5   = s->VAR_5; Display *dpy = s->dpy; XFixesCursorImage *xcim; int VAR_6, VAR_7; int VAR_8, VAR_9; int VAR_10, VAR_11; int VAR_12 = VAR_0->bits_per_pixel >> 3; uint8_t *pix = VAR_0->data; Window root; XSetWindowAttributes attr; if (VAR_0->bits_per_pixel != 24 && VAR_0->bits_per_pixel != 32)
return; if (!s->c)
s->c = XCreateFontCursor(dpy, XC_left_ptr); root = DefaultRootWindow(dpy); attr.cursor = s->c; XChangeWindowAttributes(dpy, root, CWCursor, &attr); xcim = XFixesGetCursorImage(dpy); if (!xcim) { av_log(VAR_1, AV_LOG_WARNING,
"XFixes extension not available, impossible to draw cursor\n"); s->draw_mouse = 0; return; } VAR_6 = xcim->VAR_6 - xcim->xhot; VAR_7 = xcim->VAR_7 - xcim->yhot; VAR_10   = FFMIN((VAR_7 + xcim->VAR_5), (VAR_5 + VAR_3)); VAR_11 = FFMIN((VAR_6 + xcim->VAR_4),  (VAR_4  + VAR_2)); for (VAR_8 = FFMAX(VAR_7, VAR_3); VAR_8 < VAR_10; VAR_8++) { for (VAR_9 = FFMAX(VAR_6, VAR_2); VAR_9 < VAR_11; VAR_9++) { int VAR_13  = (VAR_8  - VAR_7)     * xcim->VAR_4 + VAR_9 - VAR_6; int VAR_14 = ((VAR_8 - VAR_3) * VAR_4       + VAR_9 - VAR_2) * VAR_12; int VAR_15          = (uint8_t)(xcim->pixels[VAR_13] >>  0); int VAR_16          = (uint8_t)(xcim->pixels[VAR_13] >>  8); int VAR_17          = (uint8_t)(xcim->pixels[VAR_13] >> 16); int VAR_18          = (uint8_t)(xcim->pixels[VAR_13] >> 24); if (VAR_18 == 255) { pix[VAR_14 + 0] = VAR_15; pix[VAR_14 + 1] = VAR_16; pix[VAR_14 + 2] = VAR_17; } else if (VAR_18) { pix[VAR_14 + 0] = VAR_15 + (pix[VAR_14 + 0] * (255 - VAR_18) + 255 / 2) / 255; pix[VAR_14 + 1] = VAR_16 + (pix[VAR_14 + 1] * (255 - VAR_18) + 255 / 2) / 255; pix[VAR_14 + 2] = VAR_17 + (pix[VAR_14 + 2] * (255 - VAR_18) + 255 / 2) / 255; } } } XFree(xcim); xcim = NULL; }