static void draw_bar_yuv(AVFrame *out, const float *h, const float *rcp_h,

                         const ColorFloat *c, int bar_h)

{

    int x, y, yh, w = out->width;

    float mul, ht, rcp_bar_h = 1.0f / bar_h;

    uint8_t *vy = out->data[0], *vu = out->data[1], *vv = out->data[2];

    uint8_t *lpy, *lpu, *lpv;

    int lsy = out->linesize[0], lsu = out->linesize[1], lsv = out->linesize[2];

    int fmt = out->format;



    for (y = 0; y < bar_h; y += 2) {

        yh = (fmt == AV_PIX_FMT_YUV420P) ? y / 2 : y;

        ht = (bar_h - y) * rcp_bar_h;

        lpy = vy + y * lsy;

        lpu = vu + yh * lsu;

        lpv = vv + yh * lsv;

        for (x = 0; x < w; x += 2) {

            if (h[x] <= ht) {

                *lpy++ = 16;

                *lpu++ = 128;

                *lpv++ = 128;

            } else {

                mul = (h[x] - ht) * rcp_h[x];

                *lpy++ = mul * c[x].yuv.y + (1.0f - mul) * 16.0f + 0.5f;

                *lpu++ = mul * c[x].yuv.u + (1.0f - mul) * 128.0f + 0.5f;

                *lpv++ = mul * c[x].yuv.v + (1.0f - mul) * 128.0f + 0.5f;

            }

            /* u and v are skipped on yuv422p and yuv420p */

            if (fmt == AV_PIX_FMT_YUV444P) {

                if (h[x+1] <= ht) {

                    *lpy++ = 16;

                    *lpu++ = 128;

                    *lpv++ = 128;

                } else {

                    mul = (h[x+1] - ht) * rcp_h[x+1];

                    *lpy++ = mul * c[x+1].yuv.y + (1.0f - mul) * 16.0f + 0.5f;

                    *lpu++ = mul * c[x+1].yuv.u + (1.0f - mul) * 128.0f + 0.5f;

                    *lpv++ = mul * c[x+1].yuv.v + (1.0f - mul) * 128.0f + 0.5f;

                }

            } else {

                if (h[x+1] <= ht) {

                    *lpy++ = 16;

                } else {

                    mul = (h[x+1] - ht) * rcp_h[x+1];

                    *lpy++ = mul * c[x+1].yuv.y + (1.0f - mul) * 16.0f + 0.5f;

                }

            }

        }



        ht = (bar_h - (y+1)) * rcp_bar_h;

        lpy = vy + (y+1) * lsy;

        lpu = vu + (y+1) * lsu;

        lpv = vv + (y+1) * lsv;

        for (x = 0; x < w; x += 2) {

            /* u and v are skipped on yuv420p */

            if (fmt != AV_PIX_FMT_YUV420P) {

                if (h[x] <= ht) {

                    *lpy++ = 16;

                    *lpu++ = 128;

                    *lpv++ = 128;

                } else {

                    mul = (h[x] - ht) * rcp_h[x];

                    *lpy++ = mul * c[x].yuv.y + (1.0f - mul) * 16.0f + 0.5f;

                    *lpu++ = mul * c[x].yuv.u + (1.0f - mul) * 128.0f + 0.5f;

                    *lpv++ = mul * c[x].yuv.v + (1.0f - mul) * 128.0f + 0.5f;

                }

            } else {

                if (h[x] <= ht) {

                    *lpy++ = 16;

                } else {

                    mul = (h[x] - ht) * rcp_h[x];

                    *lpy++ = mul * c[x].yuv.y + (1.0f - mul) * 16.0f + 0.5f;

                }

            }

            /* u and v are skipped on yuv422p and yuv420p */

            if (out->format == AV_PIX_FMT_YUV444P) {

                if (h[x+1] <= ht) {

                    *lpy++ = 16;

                    *lpu++ = 128;

                    *lpv++ = 128;

                } else {

                    mul = (h[x+1] - ht) * rcp_h[x+1];

                    *lpy++ = mul * c[x+1].yuv.y + (1.0f - mul) * 16.0f + 0.5f;

                    *lpu++ = mul * c[x+1].yuv.u + (1.0f - mul) * 128.0f + 0.5f;

                    *lpv++ = mul * c[x+1].yuv.v + (1.0f - mul) * 128.0f + 0.5f;

                }

            } else {

                if (h[x+1] <= ht) {

                    *lpy++ = 16;

                } else {

                    mul = (h[x+1] - ht) * rcp_h[x+1];

                    *lpy++ = mul * c[x+1].yuv.y + (1.0f - mul) * 16.0f + 0.5f;

                }

            }

        }

    }

}

static void draw_bar_yuv(AVFrame *out, const float *h, const float *rcp_h,

                         const ColorFloat *c, int bar_h)

{

    int x, y, yh, w = out->width;

    float mul, ht, rcp_bar_h = 1.0f / bar_h;

    uint8_t *vy = out->data[0], *vu = out->data[1], *vv = out->data[2];

    uint8_t *lpy, *lpu, *lpv;

    int lsy = out->linesize[0], lsu = out->linesize[1], lsv = out->linesize[2];

    int fmt = out->format;



    for (y = 0; y < bar_h; y += 2) {

        yh = (fmt == AV_PIX_FMT_YUV420P) ? y / 2 : y;

        ht = (bar_h - y) * rcp_bar_h;

        lpy = vy + y * lsy;

        lpu = vu + yh * lsu;

        lpv = vv + yh * lsv;

        for (x = 0; x < w; x += 2) {

            if (h[x] <= ht) {

                *lpy++ = 16;

                *lpu++ = 128;

                *lpv++ = 128;

            } else {

                mul = (h[x] - ht) * rcp_h[x];

                *lpy++ = mul * c[x].yuv.y + (1.0f - mul) * 16.0f + 0.5f;

                *lpu++ = mul * c[x].yuv.u + (1.0f - mul) * 128.0f + 0.5f;

                *lpv++ = mul * c[x].yuv.v + (1.0f - mul) * 128.0f + 0.5f;

            }

            

            if (fmt == AV_PIX_FMT_YUV444P) {

                if (h[x+1] <= ht) {

                    *lpy++ = 16;

                    *lpu++ = 128;

                    *lpv++ = 128;

                } else {

                    mul = (h[x+1] - ht) * rcp_h[x+1];

                    *lpy++ = mul * c[x+1].yuv.y + (1.0f - mul) * 16.0f + 0.5f;

                    *lpu++ = mul * c[x+1].yuv.u + (1.0f - mul) * 128.0f + 0.5f;

                    *lpv++ = mul * c[x+1].yuv.v + (1.0f - mul) * 128.0f + 0.5f;

                }

            } else {

                if (h[x+1] <= ht) {

                    *lpy++ = 16;

                } else {

                    mul = (h[x+1] - ht) * rcp_h[x+1];

                    *lpy++ = mul * c[x+1].yuv.y + (1.0f - mul) * 16.0f + 0.5f;

                }

            }

        }



        ht = (bar_h - (y+1)) * rcp_bar_h;

        lpy = vy + (y+1) * lsy;

        lpu = vu + (y+1) * lsu;

        lpv = vv + (y+1) * lsv;

        for (x = 0; x < w; x += 2) {

            

            if (fmt != AV_PIX_FMT_YUV420P) {

                if (h[x] <= ht) {

                    *lpy++ = 16;

                    *lpu++ = 128;

                    *lpv++ = 128;

                } else {

                    mul = (h[x] - ht) * rcp_h[x];

                    *lpy++ = mul * c[x].yuv.y + (1.0f - mul) * 16.0f + 0.5f;

                    *lpu++ = mul * c[x].yuv.u + (1.0f - mul) * 128.0f + 0.5f;

                    *lpv++ = mul * c[x].yuv.v + (1.0f - mul) * 128.0f + 0.5f;

                }

            } else {

                if (h[x] <= ht) {

                    *lpy++ = 16;

                } else {

                    mul = (h[x] - ht) * rcp_h[x];

                    *lpy++ = mul * c[x].yuv.y + (1.0f - mul) * 16.0f + 0.5f;

                }

            }

            

            if (out->format == AV_PIX_FMT_YUV444P) {

                if (h[x+1] <= ht) {

                    *lpy++ = 16;

                    *lpu++ = 128;

                    *lpv++ = 128;

                } else {

                    mul = (h[x+1] - ht) * rcp_h[x+1];

                    *lpy++ = mul * c[x+1].yuv.y + (1.0f - mul) * 16.0f + 0.5f;

                    *lpu++ = mul * c[x+1].yuv.u + (1.0f - mul) * 128.0f + 0.5f;

                    *lpv++ = mul * c[x+1].yuv.v + (1.0f - mul) * 128.0f + 0.5f;

                }

            } else {

                if (h[x+1] <= ht) {

                    *lpy++ = 16;

                } else {

                    mul = (h[x+1] - ht) * rcp_h[x+1];

                    *lpy++ = mul * c[x+1].yuv.y + (1.0f - mul) * 16.0f + 0.5f;

                }

            }

        }

    }

}

static void FUNC_0(AVFrame *VAR_0, const float *VAR_1, const float *VAR_2,

                         const ColorFloat *VAR_3, int VAR_4)

{

    int VAR_5, VAR_6, VAR_7, VAR_8 = VAR_0->width;

    float VAR_9, VAR_10, VAR_11 = 1.0f / VAR_4;

    uint8_t *vy = VAR_0->data[0], *vu = VAR_0->data[1], *vv = VAR_0->data[2];

    uint8_t *lpy, *lpu, *lpv;

    int VAR_12 = VAR_0->linesize[0], VAR_13 = VAR_0->linesize[1], VAR_14 = VAR_0->linesize[2];

    int VAR_15 = VAR_0->format;



    for (VAR_6 = 0; VAR_6 < VAR_4; VAR_6 += 2) {

        VAR_7 = (VAR_15 == AV_PIX_FMT_YUV420P) ? VAR_6 / 2 : VAR_6;

        VAR_10 = (VAR_4 - VAR_6) * VAR_11;

        lpy = vy + VAR_6 * VAR_12;

        lpu = vu + VAR_7 * VAR_13;

        lpv = vv + VAR_7 * VAR_14;

        for (VAR_5 = 0; VAR_5 < VAR_8; VAR_5 += 2) {

            if (VAR_1[VAR_5] <= VAR_10) {

                *lpy++ = 16;

                *lpu++ = 128;

                *lpv++ = 128;

            } else {

                VAR_9 = (VAR_1[VAR_5] - VAR_10) * VAR_2[VAR_5];

                *lpy++ = VAR_9 * VAR_3[VAR_5].yuv.VAR_6 + (1.0f - VAR_9) * 16.0f + 0.5f;

                *lpu++ = VAR_9 * VAR_3[VAR_5].yuv.u + (1.0f - VAR_9) * 128.0f + 0.5f;

                *lpv++ = VAR_9 * VAR_3[VAR_5].yuv.v + (1.0f - VAR_9) * 128.0f + 0.5f;

            }

            

            if (VAR_15 == AV_PIX_FMT_YUV444P) {

                if (VAR_1[VAR_5+1] <= VAR_10) {

                    *lpy++ = 16;

                    *lpu++ = 128;

                    *lpv++ = 128;

                } else {

                    VAR_9 = (VAR_1[VAR_5+1] - VAR_10) * VAR_2[VAR_5+1];

                    *lpy++ = VAR_9 * VAR_3[VAR_5+1].yuv.VAR_6 + (1.0f - VAR_9) * 16.0f + 0.5f;

                    *lpu++ = VAR_9 * VAR_3[VAR_5+1].yuv.u + (1.0f - VAR_9) * 128.0f + 0.5f;

                    *lpv++ = VAR_9 * VAR_3[VAR_5+1].yuv.v + (1.0f - VAR_9) * 128.0f + 0.5f;

                }

            } else {

                if (VAR_1[VAR_5+1] <= VAR_10) {

                    *lpy++ = 16;

                } else {

                    VAR_9 = (VAR_1[VAR_5+1] - VAR_10) * VAR_2[VAR_5+1];

                    *lpy++ = VAR_9 * VAR_3[VAR_5+1].yuv.VAR_6 + (1.0f - VAR_9) * 16.0f + 0.5f;

                }

            }

        }



        VAR_10 = (VAR_4 - (VAR_6+1)) * VAR_11;

        lpy = vy + (VAR_6+1) * VAR_12;

        lpu = vu + (VAR_6+1) * VAR_13;

        lpv = vv + (VAR_6+1) * VAR_14;

        for (VAR_5 = 0; VAR_5 < VAR_8; VAR_5 += 2) {

            

            if (VAR_15 != AV_PIX_FMT_YUV420P) {

                if (VAR_1[VAR_5] <= VAR_10) {

                    *lpy++ = 16;

                    *lpu++ = 128;

                    *lpv++ = 128;

                } else {

                    VAR_9 = (VAR_1[VAR_5] - VAR_10) * VAR_2[VAR_5];

                    *lpy++ = VAR_9 * VAR_3[VAR_5].yuv.VAR_6 + (1.0f - VAR_9) * 16.0f + 0.5f;

                    *lpu++ = VAR_9 * VAR_3[VAR_5].yuv.u + (1.0f - VAR_9) * 128.0f + 0.5f;

                    *lpv++ = VAR_9 * VAR_3[VAR_5].yuv.v + (1.0f - VAR_9) * 128.0f + 0.5f;

                }

            } else {

                if (VAR_1[VAR_5] <= VAR_10) {

                    *lpy++ = 16;

                } else {

                    VAR_9 = (VAR_1[VAR_5] - VAR_10) * VAR_2[VAR_5];

                    *lpy++ = VAR_9 * VAR_3[VAR_5].yuv.VAR_6 + (1.0f - VAR_9) * 16.0f + 0.5f;

                }

            }

            

            if (VAR_0->format == AV_PIX_FMT_YUV444P) {

                if (VAR_1[VAR_5+1] <= VAR_10) {

                    *lpy++ = 16;

                    *lpu++ = 128;

                    *lpv++ = 128;

                } else {

                    VAR_9 = (VAR_1[VAR_5+1] - VAR_10) * VAR_2[VAR_5+1];

                    *lpy++ = VAR_9 * VAR_3[VAR_5+1].yuv.VAR_6 + (1.0f - VAR_9) * 16.0f + 0.5f;

                    *lpu++ = VAR_9 * VAR_3[VAR_5+1].yuv.u + (1.0f - VAR_9) * 128.0f + 0.5f;

                    *lpv++ = VAR_9 * VAR_3[VAR_5+1].yuv.v + (1.0f - VAR_9) * 128.0f + 0.5f;

                }

            } else {

                if (VAR_1[VAR_5+1] <= VAR_10) {

                    *lpy++ = 16;

                } else {

                    VAR_9 = (VAR_1[VAR_5+1] - VAR_10) * VAR_2[VAR_5+1];

                    *lpy++ = VAR_9 * VAR_3[VAR_5+1].yuv.VAR_6 + (1.0f - VAR_9) * 16.0f + 0.5f;

                }

            }

        }

    }

}

static void FUNC_0(AVFrame *VAR_0, const float *VAR_1, const float *VAR_2,
const ColorFloat *VAR_3, int VAR_4)
{ int VAR_5, VAR_6, VAR_7, VAR_8 = VAR_0->width; float VAR_9, VAR_10, VAR_11 = 1.0f / VAR_4; uint8_t *vy = VAR_0->data[0], *vu = VAR_0->data[1], *vv = VAR_0->data[2]; uint8_t *lpy, *lpu, *lpv; int VAR_12 = VAR_0->linesize[0], VAR_13 = VAR_0->linesize[1], VAR_14 = VAR_0->linesize[2]; int VAR_15 = VAR_0->format; for (VAR_6 = 0; VAR_6 < VAR_4; VAR_6 += 2) { VAR_7 = (VAR_15 == AV_PIX_FMT_YUV420P) ? VAR_6 / 2 : VAR_6; VAR_10 = (VAR_4 - VAR_6) * VAR_11; lpy = vy + VAR_6 * VAR_12; lpu = vu + VAR_7 * VAR_13; lpv = vv + VAR_7 * VAR_14; for (VAR_5 = 0; VAR_5 < VAR_8; VAR_5 += 2) { if (VAR_1[VAR_5] <= VAR_10) { *lpy++ = 16; *lpu++ = 128; *lpv++ = 128; } else { VAR_9 = (VAR_1[VAR_5] - VAR_10) * VAR_2[VAR_5]; *lpy++ = VAR_9 * VAR_3[VAR_5].yuv.VAR_6 + (1.0f - VAR_9) * 16.0f + 0.5f; *lpu++ = VAR_9 * VAR_3[VAR_5].yuv.u + (1.0f - VAR_9) * 128.0f + 0.5f; *lpv++ = VAR_9 * VAR_3[VAR_5].yuv.v + (1.0f - VAR_9) * 128.0f + 0.5f; } if (VAR_15 == AV_PIX_FMT_YUV444P) { if (VAR_1[VAR_5+1] <= VAR_10) { *lpy++ = 16; *lpu++ = 128; *lpv++ = 128; } else { VAR_9 = (VAR_1[VAR_5+1] - VAR_10) * VAR_2[VAR_5+1]; *lpy++ = VAR_9 * VAR_3[VAR_5+1].yuv.VAR_6 + (1.0f - VAR_9) * 16.0f + 0.5f; *lpu++ = VAR_9 * VAR_3[VAR_5+1].yuv.u + (1.0f - VAR_9) * 128.0f + 0.5f; *lpv++ = VAR_9 * VAR_3[VAR_5+1].yuv.v + (1.0f - VAR_9) * 128.0f + 0.5f; } } else { if (VAR_1[VAR_5+1] <= VAR_10) { *lpy++ = 16; } else { VAR_9 = (VAR_1[VAR_5+1] - VAR_10) * VAR_2[VAR_5+1]; *lpy++ = VAR_9 * VAR_3[VAR_5+1].yuv.VAR_6 + (1.0f - VAR_9) * 16.0f + 0.5f; } } } VAR_10 = (VAR_4 - (VAR_6+1)) * VAR_11; lpy = vy + (VAR_6+1) * VAR_12; lpu = vu + (VAR_6+1) * VAR_13; lpv = vv + (VAR_6+1) * VAR_14; for (VAR_5 = 0; VAR_5 < VAR_8; VAR_5 += 2) { if (VAR_15 != AV_PIX_FMT_YUV420P) { if (VAR_1[VAR_5] <= VAR_10) { *lpy++ = 16; *lpu++ = 128; *lpv++ = 128; } else { VAR_9 = (VAR_1[VAR_5] - VAR_10) * VAR_2[VAR_5]; *lpy++ = VAR_9 * VAR_3[VAR_5].yuv.VAR_6 + (1.0f - VAR_9) * 16.0f + 0.5f; *lpu++ = VAR_9 * VAR_3[VAR_5].yuv.u + (1.0f - VAR_9) * 128.0f + 0.5f; *lpv++ = VAR_9 * VAR_3[VAR_5].yuv.v + (1.0f - VAR_9) * 128.0f + 0.5f; } } else { if (VAR_1[VAR_5] <= VAR_10) { *lpy++ = 16; } else { VAR_9 = (VAR_1[VAR_5] - VAR_10) * VAR_2[VAR_5]; *lpy++ = VAR_9 * VAR_3[VAR_5].yuv.VAR_6 + (1.0f - VAR_9) * 16.0f + 0.5f; } } if (VAR_0->format == AV_PIX_FMT_YUV444P) { if (VAR_1[VAR_5+1] <= VAR_10) { *lpy++ = 16; *lpu++ = 128; *lpv++ = 128; } else { VAR_9 = (VAR_1[VAR_5+1] - VAR_10) * VAR_2[VAR_5+1]; *lpy++ = VAR_9 * VAR_3[VAR_5+1].yuv.VAR_6 + (1.0f - VAR_9) * 16.0f + 0.5f; *lpu++ = VAR_9 * VAR_3[VAR_5+1].yuv.u + (1.0f - VAR_9) * 128.0f + 0.5f; *lpv++ = VAR_9 * VAR_3[VAR_5+1].yuv.v + (1.0f - VAR_9) * 128.0f + 0.5f; } } else { if (VAR_1[VAR_5+1] <= VAR_10) { *lpy++ = 16; } else { VAR_9 = (VAR_1[VAR_5+1] - VAR_10) * VAR_2[VAR_5+1]; *lpy++ = VAR_9 * VAR_3[VAR_5+1].yuv.VAR_6 + (1.0f - VAR_9) * 16.0f + 0.5f; } } } } }