rgb16_32ToUV_half_c_template(uint8_t *dstU, uint8_t *dstV,

                             const uint8_t *src, int width,

                             enum PixelFormat origin,

                             int shr,   int shg,   int shb, int shp,

                             int maskr, int maskg, int maskb,

                             int rsh,   int gsh,   int bsh, int S)

{

    const int ru = RU << rsh, gu = GU << gsh, bu = BU << bsh,

              rv = RV << rsh, gv = GV << gsh, bv = BV << bsh,

              rnd = 257 << S, maskgx = ~(maskr | maskb);

    int i;



    maskr |= maskr << 1; maskb |= maskb << 1; maskg |= maskg << 1;

    for (i = 0; i < width; i++) {

        int px0 = input_pixel(2 * i + 0) >> shp;

        int px1 = input_pixel(2 * i + 1) >> shp;

        int b, r, g = (px0 & maskgx) + (px1 & maskgx);

        int rb = px0 + px1 - g;



        b = (rb & maskb) >> shb;

        if (shp || origin == PIX_FMT_BGR565LE || origin == PIX_FMT_BGR565BE ||

            origin == PIX_FMT_RGB565LE || origin == PIX_FMT_RGB565BE) {

            g >>= shg;

        } else {

            g = (g  & maskg) >> shg;

        }

        r = (rb & maskr) >> shr;



        dstU[i] = (ru * r + gu * g + bu * b + rnd) >> (S + 1);

        dstV[i] = (rv * r + gv * g + bv * b + rnd) >> (S + 1);

    }

}

rgb16_32ToUV_half_c_template(uint8_t *dstU, uint8_t *dstV,

                             const uint8_t *src, int width,

                             enum PixelFormat origin,

                             int shr,   int shg,   int shb, int shp,

                             int maskr, int maskg, int maskb,

                             int rsh,   int gsh,   int bsh, int S)

{

    const int ru = RU << rsh, gu = GU << gsh, bu = BU << bsh,

              rv = RV << rsh, gv = GV << gsh, bv = BV << bsh,

              rnd = 257 << S, maskgx = ~(maskr | maskb);

    int i;



    maskr |= maskr << 1; maskb |= maskb << 1; maskg |= maskg << 1;

    for (i = 0; i < width; i++) {

        int px0 = input_pixel(2 * i + 0) >> shp;

        int px1 = input_pixel(2 * i + 1) >> shp;

        int b, r, g = (px0 & maskgx) + (px1 & maskgx);

        int rb = px0 + px1 - g;



        b = (rb & maskb) >> shb;

        if (shp || origin == PIX_FMT_BGR565LE || origin == PIX_FMT_BGR565BE ||

            origin == PIX_FMT_RGB565LE || origin == PIX_FMT_RGB565BE) {

            g >>= shg;

        } else {

            g = (g  & maskg) >> shg;

        }

        r = (rb & maskr) >> shr;



        dstU[i] = (ru * r + gu * g + bu * b + rnd) >> (S + 1);

        dstV[i] = (rv * r + gv * g + bv * b + rnd) >> (S + 1);

    }

}

              rv = RV << rsh, gv = GV << gsh, bv = BV << bsh,               rnd = 257 << S, maskgx = ~(maskr | maskb);
FUNC_0(uint8_t *VAR_0, uint8_t *VAR_1,

                             const uint8_t *VAR_2, int VAR_3,

                             enum PixelFormat VAR_4,

                             int VAR_5,   int VAR_6,   int VAR_7, int VAR_8,

                             int VAR_9, int VAR_10, int VAR_11,

                             int VAR_12,   int VAR_13,   int VAR_14, int VAR_15)

{

    const int VAR_16 = RU << VAR_12, VAR_17 = GU << VAR_13, VAR_18 = BU << VAR_14,

              VAR_19 = RV << VAR_12, VAR_20 = GV << VAR_13, VAR_21 = BV << VAR_14,

              VAR_22 = 257 << VAR_15, VAR_23 = ~(VAR_9 | VAR_11);

    int VAR_24;



    VAR_9 |= VAR_9 << 1; VAR_11 |= VAR_11 << 1; VAR_10 |= VAR_10 << 1;

    for (VAR_24 = 0; VAR_24 < VAR_3; VAR_24++) {

        int VAR_25 = input_pixel(2 * VAR_24 + 0) >> VAR_8;

        int VAR_26 = input_pixel(2 * VAR_24 + 1) >> VAR_8;

        int VAR_27, VAR_28, VAR_29 = (VAR_25 & VAR_23) + (VAR_26 & VAR_23);

        int VAR_30 = VAR_25 + VAR_26 - VAR_29;



        VAR_27 = (VAR_30 & VAR_11) >> VAR_7;

        if (VAR_8 || VAR_4 == PIX_FMT_BGR565LE || VAR_4 == PIX_FMT_BGR565BE ||

            VAR_4 == PIX_FMT_RGB565LE || VAR_4 == PIX_FMT_RGB565BE) {

            VAR_29 >>= VAR_6;

        } else {

            VAR_29 = (VAR_29  & VAR_10) >> VAR_6;

        }

        VAR_28 = (VAR_30 & VAR_9) >> VAR_5;



        VAR_0[VAR_24] = (VAR_16 * VAR_28 + VAR_17 * VAR_29 + VAR_18 * VAR_27 + VAR_22) >> (VAR_15 + 1);

        VAR_1[VAR_24] = (VAR_19 * VAR_28 + VAR_20 * VAR_29 + VAR_21 * VAR_27 + VAR_22) >> (VAR_15 + 1);

    }

}

FUNC_0(uint8_t *VAR_0, uint8_t *VAR_1,
const uint8_t *VAR_2, int VAR_3,
enum PixelFormat VAR_4,
int VAR_5,   int VAR_6,   int VAR_7, int VAR_8,
int VAR_9, int VAR_10, int VAR_11,
int VAR_12,   int VAR_13,   int VAR_14, int VAR_15)
{ const int VAR_16 = RU << VAR_12, VAR_17 = GU << VAR_13, VAR_18 = BU << VAR_14,
VAR_19 = RV << VAR_12, VAR_20 = GV << VAR_13, VAR_21 = BV << VAR_14,
VAR_22 = 257 << VAR_15, VAR_23 = ~(VAR_9 | VAR_11); int VAR_24; VAR_9 |= VAR_9 << 1; VAR_11 |= VAR_11 << 1; VAR_10 |= VAR_10 << 1; for (VAR_24 = 0; VAR_24 < VAR_3; VAR_24++) { int VAR_25 = input_pixel(2 * VAR_24 + 0) >> VAR_8; int VAR_26 = input_pixel(2 * VAR_24 + 1) >> VAR_8; int VAR_27, VAR_28, VAR_29 = (VAR_25 & VAR_23) + (VAR_26 & VAR_23); int VAR_30 = VAR_25 + VAR_26 - VAR_29; VAR_27 = (VAR_30 & VAR_11) >> VAR_7; if (VAR_8 || VAR_4 == PIX_FMT_BGR565LE || VAR_4 == PIX_FMT_BGR565BE ||
VAR_4 == PIX_FMT_RGB565LE || VAR_4 == PIX_FMT_RGB565BE) { VAR_29 >>= VAR_6; } else { VAR_29 = (VAR_29  & VAR_10) >> VAR_6; } VAR_28 = (VAR_30 & VAR_9) >> VAR_5; VAR_0[VAR_24] = (VAR_16 * VAR_28 + VAR_17 * VAR_29 + VAR_18 * VAR_27 + VAR_22) >> (VAR_15 + 1); VAR_1[VAR_24] = (VAR_19 * VAR_28 + VAR_20 * VAR_29 + VAR_21 * VAR_27 + VAR_22) >> (VAR_15 + 1); } }