static int send_sub_rect(VncState *vs, int x, int y, int w, int h)

{

    VncPalette *palette = &color_count_palette;

    uint32_t bg = 0, fg = 0;

    int colors;

    int ret = 0;

#ifdef CONFIG_VNC_JPEG

    bool force_jpeg = false;

    bool allow_jpeg = true;

#endif



    vnc_framebuffer_update(vs, x, y, w, h, vs->tight.type);



    vnc_tight_start(vs);

    vnc_raw_send_framebuffer_update(vs, x, y, w, h);

    vnc_tight_stop(vs);



#ifdef CONFIG_VNC_JPEG

    if (!vs->vd->non_adaptive && vs->tight.quality != (uint8_t)-1) {

        double freq = vnc_update_freq(vs, x, y, w, h);



        if (freq < tight_jpeg_conf[vs->tight.quality].jpeg_freq_min) {

            allow_jpeg = false;

        }

        if (freq >= tight_jpeg_conf[vs->tight.quality].jpeg_freq_threshold) {

            force_jpeg = true;

            vnc_sent_lossy_rect(vs, x, y, w, h);

        }

    }

#endif



    colors = tight_fill_palette(vs, x, y, w * h, &bg, &fg, palette);



#ifdef CONFIG_VNC_JPEG

    if (allow_jpeg && vs->tight.quality != (uint8_t)-1) {

        ret = send_sub_rect_jpeg(vs, x, y, w, h, bg, fg, colors, palette,

                                 force_jpeg);

    } else {

        ret = send_sub_rect_nojpeg(vs, x, y, w, h, bg, fg, colors, palette);

    }

#else

    ret = send_sub_rect_nojpeg(vs, x, y, w, h, bg, fg, colors, palette);

#endif



    return ret;

}

static int send_sub_rect(VncState *vs, int x, int y, int w, int h)

{

    VncPalette *palette = &color_count_palette;

    uint32_t bg = 0, fg = 0;

    int colors;

    int ret = 0;

#ifdef CONFIG_VNC_JPEG

    bool force_jpeg = false;

    bool allow_jpeg = true;

#endif



    vnc_framebuffer_update(vs, x, y, w, h, vs->tight.type);



    vnc_tight_start(vs);

    vnc_raw_send_framebuffer_update(vs, x, y, w, h);

    vnc_tight_stop(vs);



#ifdef CONFIG_VNC_JPEG

    if (!vs->vd->non_adaptive && vs->tight.quality != (uint8_t)-1) {

        double freq = vnc_update_freq(vs, x, y, w, h);



        if (freq < tight_jpeg_conf[vs->tight.quality].jpeg_freq_min) {

            allow_jpeg = false;

        }

        if (freq >= tight_jpeg_conf[vs->tight.quality].jpeg_freq_threshold) {

            force_jpeg = true;

            vnc_sent_lossy_rect(vs, x, y, w, h);

        }

    }

#endif



    colors = tight_fill_palette(vs, x, y, w * h, &bg, &fg, palette);



#ifdef CONFIG_VNC_JPEG

    if (allow_jpeg && vs->tight.quality != (uint8_t)-1) {

        ret = send_sub_rect_jpeg(vs, x, y, w, h, bg, fg, colors, palette,

                                 force_jpeg);

    } else {

        ret = send_sub_rect_nojpeg(vs, x, y, w, h, bg, fg, colors, palette);

    }

#else

    ret = send_sub_rect_nojpeg(vs, x, y, w, h, bg, fg, colors, palette);

#endif



    return ret;

}

static int FUNC_0(VncState *VAR_0, int VAR_1, int VAR_2, int VAR_3, int VAR_4)

{

    VncPalette *palette = &color_count_palette;

    uint32_t bg = 0, fg = 0;

    int VAR_5;

    int VAR_6 = 0;

#ifdef CONFIG_VNC_JPEG

    bool force_jpeg = false;

    bool allow_jpeg = true;

#endif



    vnc_framebuffer_update(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4, VAR_0->tight.type);



    vnc_tight_start(VAR_0);

    vnc_raw_send_framebuffer_update(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4);

    vnc_tight_stop(VAR_0);



#ifdef CONFIG_VNC_JPEG

    if (!VAR_0->vd->non_adaptive && VAR_0->tight.quality != (uint8_t)-1) {

        double freq = vnc_update_freq(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4);



        if (freq < tight_jpeg_conf[VAR_0->tight.quality].jpeg_freq_min) {

            allow_jpeg = false;

        }

        if (freq >= tight_jpeg_conf[VAR_0->tight.quality].jpeg_freq_threshold) {

            force_jpeg = true;

            vnc_sent_lossy_rect(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4);

        }

    }

#endif



    VAR_5 = tight_fill_palette(VAR_0, VAR_1, VAR_2, VAR_3 * VAR_4, &bg, &fg, palette);



#ifdef CONFIG_VNC_JPEG

    if (allow_jpeg && VAR_0->tight.quality != (uint8_t)-1) {

        VAR_6 = send_sub_rect_jpeg(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4, bg, fg, VAR_5, palette,

                                 force_jpeg);

    } else {

        VAR_6 = send_sub_rect_nojpeg(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4, bg, fg, VAR_5, palette);

    }

#else

    VAR_6 = send_sub_rect_nojpeg(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4, bg, fg, VAR_5, palette);

#endif



    return VAR_6;

}

static int FUNC_0(VncState *VAR_0, int VAR_1, int VAR_2, int VAR_3, int VAR_4)
{ VncPalette *palette = &color_count_palette; uint32_t bg = 0, fg = 0; int VAR_5; int VAR_6 = 0; #ifdef CONFIG_VNC_JPEG
bool force_jpeg = false; bool allow_jpeg = true; #endif
vnc_framebuffer_update(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4, VAR_0->tight.type); vnc_tight_start(VAR_0); vnc_raw_send_framebuffer_update(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4); vnc_tight_stop(VAR_0); #ifdef CONFIG_VNC_JPEG
if (!VAR_0->vd->non_adaptive && VAR_0->tight.quality != (uint8_t)-1) { double freq = vnc_update_freq(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4); if (freq < tight_jpeg_conf[VAR_0->tight.quality].jpeg_freq_min) { allow_jpeg = false; } if (freq >= tight_jpeg_conf[VAR_0->tight.quality].jpeg_freq_threshold) { force_jpeg = true; vnc_sent_lossy_rect(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4); } } #endif
VAR_5 = tight_fill_palette(VAR_0, VAR_1, VAR_2, VAR_3 * VAR_4, &bg, &fg, palette); #ifdef CONFIG_VNC_JPEG
if (allow_jpeg && VAR_0->tight.quality != (uint8_t)-1) { VAR_6 = send_sub_rect_jpeg(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4, bg, fg, VAR_5, palette,
force_jpeg); } else { VAR_6 = send_sub_rect_nojpeg(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4, bg, fg, VAR_5, palette); } #else
VAR_6 = send_sub_rect_nojpeg(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4, bg, fg, VAR_5, palette); #endif
return VAR_6; }