static void envelope_instant16(WaveformContext *s, AVFrame *out, int plane, int component)

{

    const int dst_linesize = out->linesize[component] / 2;

    const int bg = s->bg_color[component] * (s->size / 256);

    const int limit = s->size - 1;

    const int is_chroma = (component == 1 || component == 2);

    const int shift_w = (is_chroma ? s->desc->log2_chroma_w : 0);

    const int shift_h = (is_chroma ? s->desc->log2_chroma_h : 0);

    const int dst_h = FF_CEIL_RSHIFT(out->height, shift_h);

    const int dst_w = FF_CEIL_RSHIFT(out->width, shift_w);

    const int start = s->estart[plane];

    const int end = s->eend[plane];

    uint16_t *dst;

    int x, y;



    if (s->mode) {

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

            for (y = start; y < end; y++) {

                dst = (uint16_t *)out->data[component] + y * dst_linesize + x;

                if (dst[0] != bg) {

                    dst[0] = limit;

                    break;

                }

            }

            for (y = end - 1; y >= start; y--) {

                dst = (uint16_t *)out->data[component] + y * dst_linesize + x;

                if (dst[0] != bg) {

                    dst[0] = limit;

                    break;

                }

            }

        }

    } else {

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

            dst = (uint16_t *)out->data[component] + y * dst_linesize;

            for (x = start; x < end; x++) {

                if (dst[x] != bg) {

                    dst[x] = limit;

                    break;

                }

            }

            for (x = end - 1; x >= start; x--) {

                if (dst[x] != bg) {

                    dst[x] = limit;

                    break;

                }

            }

        }

    }

}

static void envelope_instant16(WaveformContext *s, AVFrame *out, int plane, int component)

{

    const int dst_linesize = out->linesize[component] / 2;

    const int bg = s->bg_color[component] * (s->size / 256);

    const int limit = s->size - 1;

    const int is_chroma = (component == 1 || component == 2);

    const int shift_w = (is_chroma ? s->desc->log2_chroma_w : 0);

    const int shift_h = (is_chroma ? s->desc->log2_chroma_h : 0);

    const int dst_h = FF_CEIL_RSHIFT(out->height, shift_h);

    const int dst_w = FF_CEIL_RSHIFT(out->width, shift_w);

    const int start = s->estart[plane];

    const int end = s->eend[plane];

    uint16_t *dst;

    int x, y;



    if (s->mode) {

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

            for (y = start; y < end; y++) {

                dst = (uint16_t *)out->data[component] + y * dst_linesize + x;

                if (dst[0] != bg) {

                    dst[0] = limit;

                    break;

                }

            }

            for (y = end - 1; y >= start; y--) {

                dst = (uint16_t *)out->data[component] + y * dst_linesize + x;

                if (dst[0] != bg) {

                    dst[0] = limit;

                    break;

                }

            }

        }

    } else {

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

            dst = (uint16_t *)out->data[component] + y * dst_linesize;

            for (x = start; x < end; x++) {

                if (dst[x] != bg) {

                    dst[x] = limit;

                    break;

                }

            }

            for (x = end - 1; x >= start; x--) {

                if (dst[x] != bg) {

                    dst[x] = limit;

                    break;

                }

            }

        }

    }

}

static void FUNC_0(WaveformContext *VAR_0, AVFrame *VAR_1, int VAR_2, int VAR_3)

{

    const int VAR_4 = VAR_1->linesize[VAR_3] / 2;

    const int VAR_5 = VAR_0->bg_color[VAR_3] * (VAR_0->size / 256);

    const int VAR_6 = VAR_0->size - 1;

    const int VAR_7 = (VAR_3 == 1 || VAR_3 == 2);

    const int VAR_8 = (VAR_7 ? VAR_0->desc->log2_chroma_w : 0);

    const int VAR_9 = (VAR_7 ? VAR_0->desc->log2_chroma_h : 0);

    const int VAR_10 = FF_CEIL_RSHIFT(VAR_1->height, VAR_9);

    const int VAR_11 = FF_CEIL_RSHIFT(VAR_1->width, VAR_8);

    const int VAR_12 = VAR_0->estart[VAR_2];

    const int VAR_13 = VAR_0->eend[VAR_2];

    uint16_t *dst;

    int VAR_14, VAR_15;



    if (VAR_0->mode) {

        for (VAR_14 = 0; VAR_14 < VAR_11; VAR_14++) {

            for (VAR_15 = VAR_12; VAR_15 < VAR_13; VAR_15++) {

                dst = (uint16_t *)VAR_1->data[VAR_3] + VAR_15 * VAR_4 + VAR_14;

                if (dst[0] != VAR_5) {

                    dst[0] = VAR_6;

                    break;

                }

            }

            for (VAR_15 = VAR_13 - 1; VAR_15 >= VAR_12; VAR_15--) {

                dst = (uint16_t *)VAR_1->data[VAR_3] + VAR_15 * VAR_4 + VAR_14;

                if (dst[0] != VAR_5) {

                    dst[0] = VAR_6;

                    break;

                }

            }

        }

    } else {

        for (VAR_15 = 0; VAR_15 < VAR_10; VAR_15++) {

            dst = (uint16_t *)VAR_1->data[VAR_3] + VAR_15 * VAR_4;

            for (VAR_14 = VAR_12; VAR_14 < VAR_13; VAR_14++) {

                if (dst[VAR_14] != VAR_5) {

                    dst[VAR_14] = VAR_6;

                    break;

                }

            }

            for (VAR_14 = VAR_13 - 1; VAR_14 >= VAR_12; VAR_14--) {

                if (dst[VAR_14] != VAR_5) {

                    dst[VAR_14] = VAR_6;

                    break;

                }

            }

        }

    }

}

static void FUNC_0(WaveformContext *VAR_0, AVFrame *VAR_1, int VAR_2, int VAR_3)
{ const int VAR_4 = VAR_1->linesize[VAR_3] / 2; const int VAR_5 = VAR_0->bg_color[VAR_3] * (VAR_0->size / 256); const int VAR_6 = VAR_0->size - 1; const int VAR_7 = (VAR_3 == 1 || VAR_3 == 2); const int VAR_8 = (VAR_7 ? VAR_0->desc->log2_chroma_w : 0); const int VAR_9 = (VAR_7 ? VAR_0->desc->log2_chroma_h : 0); const int VAR_10 = FF_CEIL_RSHIFT(VAR_1->height, VAR_9); const int VAR_11 = FF_CEIL_RSHIFT(VAR_1->width, VAR_8); const int VAR_12 = VAR_0->estart[VAR_2]; const int VAR_13 = VAR_0->eend[VAR_2]; uint16_t *dst; int VAR_14, VAR_15; if (VAR_0->mode) { for (VAR_14 = 0; VAR_14 < VAR_11; VAR_14++) { for (VAR_15 = VAR_12; VAR_15 < VAR_13; VAR_15++) { dst = (uint16_t *)VAR_1->data[VAR_3] + VAR_15 * VAR_4 + VAR_14; if (dst[0] != VAR_5) { dst[0] = VAR_6; break; } } for (VAR_15 = VAR_13 - 1; VAR_15 >= VAR_12; VAR_15--) { dst = (uint16_t *)VAR_1->data[VAR_3] + VAR_15 * VAR_4 + VAR_14; if (dst[0] != VAR_5) { dst[0] = VAR_6; break; } } } } else { for (VAR_15 = 0; VAR_15 < VAR_10; VAR_15++) { dst = (uint16_t *)VAR_1->data[VAR_3] + VAR_15 * VAR_4; for (VAR_14 = VAR_12; VAR_14 < VAR_13; VAR_14++) { if (dst[VAR_14] != VAR_5) { dst[VAR_14] = VAR_6; break; } } for (VAR_14 = VAR_13 - 1; VAR_14 >= VAR_12; VAR_14--) { if (dst[VAR_14] != VAR_5) { dst[VAR_14] = VAR_6; break; } } } } }