static void color16(WaveformContext *s, AVFrame *in, AVFrame *out,

                    int component, int intensity, int offset, int column)

{

    const int plane = s->desc->comp[component].plane;

    const int mirror = s->mirror;

    const int limit = s->size - 1;

    const uint16_t *c0_data = (const uint16_t *)in->data[plane + 0];

    const uint16_t *c1_data = (const uint16_t *)in->data[(plane + 1) % s->ncomp];

    const uint16_t *c2_data = (const uint16_t *)in->data[(plane + 2) % s->ncomp];

    const int c0_linesize = in->linesize[ plane + 0 ] / 2;

    const int c1_linesize = in->linesize[(plane + 1) % s->ncomp] / 2;

    const int c2_linesize = in->linesize[(plane + 2) % s->ncomp] / 2;

    const int d0_linesize = out->linesize[ plane + 0 ] / 2;

    const int d1_linesize = out->linesize[(plane + 1) % s->ncomp] / 2;

    const int d2_linesize = out->linesize[(plane + 2) % s->ncomp] / 2;

    const int src_h = in->height;

    const int src_w = in->width;

    int x, y;



    if (s->mode) {

        const int d0_signed_linesize = d0_linesize * (mirror == 1 ? -1 : 1);

        const int d1_signed_linesize = d1_linesize * (mirror == 1 ? -1 : 1);

        const int d2_signed_linesize = d2_linesize * (mirror == 1 ? -1 : 1);

        uint16_t *d0_data = (uint16_t *)out->data[plane] + offset * d0_linesize;

        uint16_t *d1_data = (uint16_t *)out->data[(plane + 1) % s->ncomp] + offset * d1_linesize;

        uint16_t *d2_data = (uint16_t *)out->data[(plane + 2) % s->ncomp] + offset * d2_linesize;

        uint16_t * const d0_bottom_line = d0_data + d0_linesize * (s->size - 1);

        uint16_t * const d0 = (mirror ? d0_bottom_line : d0_data);

        uint16_t * const d1_bottom_line = d1_data + d1_linesize * (s->size - 1);

        uint16_t * const d1 = (mirror ? d1_bottom_line : d1_data);

        uint16_t * const d2_bottom_line = d2_data + d2_linesize * (s->size - 1);

        uint16_t * const d2 = (mirror ? d2_bottom_line : d2_data);



        for (y = 0; y < src_h; y++) {

            for (x = 0; x < src_w; x++) {

                const int c0 = FFMIN(c0_data[x], limit);

                const int c1 = c1_data[x];

                const int c2 = c2_data[x];



                *(d0 + d0_signed_linesize * c0 + x) = c0;

                *(d1 + d1_signed_linesize * c0 + x) = c1;

                *(d2 + d2_signed_linesize * c0 + x) = c2;

            }



            c0_data += c0_linesize;

            c1_data += c1_linesize;

            c2_data += c2_linesize;

            d0_data += d0_linesize;

            d1_data += d1_linesize;

            d2_data += d2_linesize;

        }

    } else {

        uint16_t *d0_data = (uint16_t *)out->data[plane] + offset;

        uint16_t *d1_data = (uint16_t *)out->data[(plane + 1) % s->ncomp] + offset;

        uint16_t *d2_data = (uint16_t *)out->data[(plane + 2) % s->ncomp] + offset;



        if (mirror) {

            d0_data += s->size - 1;

            d1_data += s->size - 1;

            d2_data += s->size - 1;

        }



        for (y = 0; y < src_h; y++) {

            for (x = 0; x < src_w; x++) {

                const int c0 = FFMIN(c0_data[x], limit);

                const int c1 = c1_data[x];

                const int c2 = c2_data[x];



                if (mirror) {

                    *(d0_data - c0) = c0;

                    *(d1_data - c0) = c1;

                    *(d2_data - c0) = c2;

                } else {

                    *(d0_data + c0) = c0;

                    *(d1_data + c0) = c1;

                    *(d2_data + c0) = c2;

                }

            }



            c0_data += c0_linesize;

            c1_data += c1_linesize;

            c2_data += c2_linesize;

            d0_data += d0_linesize;

            d1_data += d1_linesize;

            d2_data += d2_linesize;

        }

    }



    envelope16(s, out, plane, plane);

}

static void color16(WaveformContext *s, AVFrame *in, AVFrame *out,

                    int component, int intensity, int offset, int column)

{

    const int plane = s->desc->comp[component].plane;

    const int mirror = s->mirror;

    const int limit = s->size - 1;

    const uint16_t *c0_data = (const uint16_t *)in->data[plane + 0];

    const uint16_t *c1_data = (const uint16_t *)in->data[(plane + 1) % s->ncomp];

    const uint16_t *c2_data = (const uint16_t *)in->data[(plane + 2) % s->ncomp];

    const int c0_linesize = in->linesize[ plane + 0 ] / 2;

    const int c1_linesize = in->linesize[(plane + 1) % s->ncomp] / 2;

    const int c2_linesize = in->linesize[(plane + 2) % s->ncomp] / 2;

    const int d0_linesize = out->linesize[ plane + 0 ] / 2;

    const int d1_linesize = out->linesize[(plane + 1) % s->ncomp] / 2;

    const int d2_linesize = out->linesize[(plane + 2) % s->ncomp] / 2;

    const int src_h = in->height;

    const int src_w = in->width;

    int x, y;



    if (s->mode) {

        const int d0_signed_linesize = d0_linesize * (mirror == 1 ? -1 : 1);

        const int d1_signed_linesize = d1_linesize * (mirror == 1 ? -1 : 1);

        const int d2_signed_linesize = d2_linesize * (mirror == 1 ? -1 : 1);

        uint16_t *d0_data = (uint16_t *)out->data[plane] + offset * d0_linesize;

        uint16_t *d1_data = (uint16_t *)out->data[(plane + 1) % s->ncomp] + offset * d1_linesize;

        uint16_t *d2_data = (uint16_t *)out->data[(plane + 2) % s->ncomp] + offset * d2_linesize;

        uint16_t * const d0_bottom_line = d0_data + d0_linesize * (s->size - 1);

        uint16_t * const d0 = (mirror ? d0_bottom_line : d0_data);

        uint16_t * const d1_bottom_line = d1_data + d1_linesize * (s->size - 1);

        uint16_t * const d1 = (mirror ? d1_bottom_line : d1_data);

        uint16_t * const d2_bottom_line = d2_data + d2_linesize * (s->size - 1);

        uint16_t * const d2 = (mirror ? d2_bottom_line : d2_data);



        for (y = 0; y < src_h; y++) {

            for (x = 0; x < src_w; x++) {

                const int c0 = FFMIN(c0_data[x], limit);

                const int c1 = c1_data[x];

                const int c2 = c2_data[x];



                *(d0 + d0_signed_linesize * c0 + x) = c0;

                *(d1 + d1_signed_linesize * c0 + x) = c1;

                *(d2 + d2_signed_linesize * c0 + x) = c2;

            }



            c0_data += c0_linesize;

            c1_data += c1_linesize;

            c2_data += c2_linesize;

            d0_data += d0_linesize;

            d1_data += d1_linesize;

            d2_data += d2_linesize;

        }

    } else {

        uint16_t *d0_data = (uint16_t *)out->data[plane] + offset;

        uint16_t *d1_data = (uint16_t *)out->data[(plane + 1) % s->ncomp] + offset;

        uint16_t *d2_data = (uint16_t *)out->data[(plane + 2) % s->ncomp] + offset;



        if (mirror) {

            d0_data += s->size - 1;

            d1_data += s->size - 1;

            d2_data += s->size - 1;

        }



        for (y = 0; y < src_h; y++) {

            for (x = 0; x < src_w; x++) {

                const int c0 = FFMIN(c0_data[x], limit);

                const int c1 = c1_data[x];

                const int c2 = c2_data[x];



                if (mirror) {

                    *(d0_data - c0) = c0;

                    *(d1_data - c0) = c1;

                    *(d2_data - c0) = c2;

                } else {

                    *(d0_data + c0) = c0;

                    *(d1_data + c0) = c1;

                    *(d2_data + c0) = c2;

                }

            }



            c0_data += c0_linesize;

            c1_data += c1_linesize;

            c2_data += c2_linesize;

            d0_data += d0_linesize;

            d1_data += d1_linesize;

            d2_data += d2_linesize;

        }

    }



    envelope16(s, out, plane, plane);

}

static void FUNC_0(WaveformContext *VAR_0, AVFrame *VAR_1, AVFrame *VAR_2,

                    int VAR_3, int VAR_4, int VAR_5, int VAR_6)

{

    const int VAR_7 = VAR_0->desc->comp[VAR_3].VAR_7;

    const int VAR_8 = VAR_0->VAR_8;

    const int VAR_9 = VAR_0->size - 1;

    const uint16_t *VAR_10 = (const uint16_t *)VAR_1->data[VAR_7 + 0];

    const uint16_t *VAR_11 = (const uint16_t *)VAR_1->data[(VAR_7 + 1) % VAR_0->ncomp];

    const uint16_t *VAR_12 = (const uint16_t *)VAR_1->data[(VAR_7 + 2) % VAR_0->ncomp];

    const int VAR_13 = VAR_1->linesize[ VAR_7 + 0 ] / 2;

    const int VAR_14 = VAR_1->linesize[(VAR_7 + 1) % VAR_0->ncomp] / 2;

    const int VAR_15 = VAR_1->linesize[(VAR_7 + 2) % VAR_0->ncomp] / 2;

    const int VAR_16 = VAR_2->linesize[ VAR_7 + 0 ] / 2;

    const int VAR_17 = VAR_2->linesize[(VAR_7 + 1) % VAR_0->ncomp] / 2;

    const int VAR_18 = VAR_2->linesize[(VAR_7 + 2) % VAR_0->ncomp] / 2;

    const int VAR_19 = VAR_1->height;

    const int VAR_20 = VAR_1->width;

    int VAR_21, VAR_22;



    if (VAR_0->mode) {

        const int VAR_23 = VAR_16 * (VAR_8 == 1 ? -1 : 1);

        const int VAR_24 = VAR_17 * (VAR_8 == 1 ? -1 : 1);

        const int VAR_25 = VAR_18 * (VAR_8 == 1 ? -1 : 1);

        uint16_t *d0_data = (uint16_t *)VAR_2->data[VAR_7] + VAR_5 * VAR_16;

        uint16_t *d1_data = (uint16_t *)VAR_2->data[(VAR_7 + 1) % VAR_0->ncomp] + VAR_5 * VAR_17;

        uint16_t *d2_data = (uint16_t *)VAR_2->data[(VAR_7 + 2) % VAR_0->ncomp] + VAR_5 * VAR_18;

        uint16_t * const d0_bottom_line = d0_data + VAR_16 * (VAR_0->size - 1);

        uint16_t * const d0 = (VAR_8 ? d0_bottom_line : d0_data);

        uint16_t * const d1_bottom_line = d1_data + VAR_17 * (VAR_0->size - 1);

        uint16_t * const d1 = (VAR_8 ? d1_bottom_line : d1_data);

        uint16_t * const d2_bottom_line = d2_data + VAR_18 * (VAR_0->size - 1);

        uint16_t * const d2 = (VAR_8 ? d2_bottom_line : d2_data);



        for (VAR_22 = 0; VAR_22 < VAR_19; VAR_22++) {

            for (VAR_21 = 0; VAR_21 < VAR_20; VAR_21++) {

                const int VAR_29 = FFMIN(VAR_10[VAR_21], VAR_9);

                const int VAR_29 = VAR_11[VAR_21];

                const int VAR_29 = VAR_12[VAR_21];



                *(d0 + VAR_23 * VAR_29 + VAR_21) = VAR_29;

                *(d1 + VAR_24 * VAR_29 + VAR_21) = VAR_29;

                *(d2 + VAR_25 * VAR_29 + VAR_21) = VAR_29;

            }



            VAR_10 += VAR_13;

            VAR_11 += VAR_14;

            VAR_12 += VAR_15;

            d0_data += VAR_16;

            d1_data += VAR_17;

            d2_data += VAR_18;

        }

    } else {

        uint16_t *d0_data = (uint16_t *)VAR_2->data[VAR_7] + VAR_5;

        uint16_t *d1_data = (uint16_t *)VAR_2->data[(VAR_7 + 1) % VAR_0->ncomp] + VAR_5;

        uint16_t *d2_data = (uint16_t *)VAR_2->data[(VAR_7 + 2) % VAR_0->ncomp] + VAR_5;



        if (VAR_8) {

            d0_data += VAR_0->size - 1;

            d1_data += VAR_0->size - 1;

            d2_data += VAR_0->size - 1;

        }



        for (VAR_22 = 0; VAR_22 < VAR_19; VAR_22++) {

            for (VAR_21 = 0; VAR_21 < VAR_20; VAR_21++) {

                const int VAR_29 = FFMIN(VAR_10[VAR_21], VAR_9);

                const int VAR_29 = VAR_11[VAR_21];

                const int VAR_29 = VAR_12[VAR_21];



                if (VAR_8) {

                    *(d0_data - VAR_29) = VAR_29;

                    *(d1_data - VAR_29) = VAR_29;

                    *(d2_data - VAR_29) = VAR_29;

                } else {

                    *(d0_data + VAR_29) = VAR_29;

                    *(d1_data + VAR_29) = VAR_29;

                    *(d2_data + VAR_29) = VAR_29;

                }

            }



            VAR_10 += VAR_13;

            VAR_11 += VAR_14;

            VAR_12 += VAR_15;

            d0_data += VAR_16;

            d1_data += VAR_17;

            d2_data += VAR_18;

        }

    }



    envelope16(VAR_0, VAR_2, VAR_7, VAR_7);

}

static void FUNC_0(WaveformContext *VAR_0, AVFrame *VAR_1, AVFrame *VAR_2,
int VAR_3, int VAR_4, int VAR_5, int VAR_6)
{ const int VAR_7 = VAR_0->desc->comp[VAR_3].VAR_7; const int VAR_8 = VAR_0->VAR_8; const int VAR_9 = VAR_0->size - 1; const uint16_t *VAR_10 = (const uint16_t *)VAR_1->data[VAR_7 + 0]; const uint16_t *VAR_11 = (const uint16_t *)VAR_1->data[(VAR_7 + 1) % VAR_0->ncomp]; const uint16_t *VAR_12 = (const uint16_t *)VAR_1->data[(VAR_7 + 2) % VAR_0->ncomp]; const int VAR_13 = VAR_1->linesize[ VAR_7 + 0 ] / 2; const int VAR_14 = VAR_1->linesize[(VAR_7 + 1) % VAR_0->ncomp] / 2; const int VAR_15 = VAR_1->linesize[(VAR_7 + 2) % VAR_0->ncomp] / 2; const int VAR_16 = VAR_2->linesize[ VAR_7 + 0 ] / 2; const int VAR_17 = VAR_2->linesize[(VAR_7 + 1) % VAR_0->ncomp] / 2; const int VAR_18 = VAR_2->linesize[(VAR_7 + 2) % VAR_0->ncomp] / 2; const int VAR_19 = VAR_1->height; const int VAR_20 = VAR_1->width; int VAR_21, VAR_22; if (VAR_0->mode) { const int VAR_23 = VAR_16 * (VAR_8 == 1 ? -1 : 1); const int VAR_24 = VAR_17 * (VAR_8 == 1 ? -1 : 1); const int VAR_25 = VAR_18 * (VAR_8 == 1 ? -1 : 1); uint16_t *d0_data = (uint16_t *)VAR_2->data[VAR_7] + VAR_5 * VAR_16; uint16_t *d1_data = (uint16_t *)VAR_2->data[(VAR_7 + 1) % VAR_0->ncomp] + VAR_5 * VAR_17; uint16_t *d2_data = (uint16_t *)VAR_2->data[(VAR_7 + 2) % VAR_0->ncomp] + VAR_5 * VAR_18; uint16_t * const d0_bottom_line = d0_data + VAR_16 * (VAR_0->size - 1); uint16_t * const d0 = (VAR_8 ? d0_bottom_line : d0_data); uint16_t * const d1_bottom_line = d1_data + VAR_17 * (VAR_0->size - 1); uint16_t * const d1 = (VAR_8 ? d1_bottom_line : d1_data); uint16_t * const d2_bottom_line = d2_data + VAR_18 * (VAR_0->size - 1); uint16_t * const d2 = (VAR_8 ? d2_bottom_line : d2_data); for (VAR_22 = 0; VAR_22 < VAR_19; VAR_22++) { for (VAR_21 = 0; VAR_21 < VAR_20; VAR_21++) { const int VAR_29 = FFMIN(VAR_10[VAR_21], VAR_9); const int VAR_29 = VAR_11[VAR_21]; const int VAR_29 = VAR_12[VAR_21]; *(d0 + VAR_23 * VAR_29 + VAR_21) = VAR_29; *(d1 + VAR_24 * VAR_29 + VAR_21) = VAR_29; *(d2 + VAR_25 * VAR_29 + VAR_21) = VAR_29; } VAR_10 += VAR_13; VAR_11 += VAR_14; VAR_12 += VAR_15; d0_data += VAR_16; d1_data += VAR_17; d2_data += VAR_18; } } else { uint16_t *d0_data = (uint16_t *)VAR_2->data[VAR_7] + VAR_5; uint16_t *d1_data = (uint16_t *)VAR_2->data[(VAR_7 + 1) % VAR_0->ncomp] + VAR_5; uint16_t *d2_data = (uint16_t *)VAR_2->data[(VAR_7 + 2) % VAR_0->ncomp] + VAR_5; if (VAR_8) { d0_data += VAR_0->size - 1; d1_data += VAR_0->size - 1; d2_data += VAR_0->size - 1; } for (VAR_22 = 0; VAR_22 < VAR_19; VAR_22++) { for (VAR_21 = 0; VAR_21 < VAR_20; VAR_21++) { const int VAR_29 = FFMIN(VAR_10[VAR_21], VAR_9); const int VAR_29 = VAR_11[VAR_21]; const int VAR_29 = VAR_12[VAR_21]; if (VAR_8) { *(d0_data - VAR_29) = VAR_29; *(d1_data - VAR_29) = VAR_29; *(d2_data - VAR_29) = VAR_29; } else { *(d0_data + VAR_29) = VAR_29; *(d1_data + VAR_29) = VAR_29; *(d2_data + VAR_29) = VAR_29; } } VAR_10 += VAR_13; VAR_11 += VAR_14; VAR_12 += VAR_15; d0_data += VAR_16; d1_data += VAR_17; d2_data += VAR_18; } } envelope16(VAR_0, VAR_2, VAR_7, VAR_7); }