int ff_sws_alphablendaway(SwsContext *c, const uint8_t *src[],

                          int srcStride[], int srcSliceY, int srcSliceH,

                          uint8_t *dst[], int dstStride[])

{

    const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(c->srcFormat);

    int nb_components = desc->nb_components;

    int plane, x, y;

    int plane_count = isGray(c->srcFormat) ? 1 : 3;

    int sixteen_bits = desc->comp[0].depth_minus1 >= 8;

    unsigned off    = 1<<desc->comp[0].depth_minus1;

    unsigned shift  = desc->comp[0].depth_minus1 + 1;

    unsigned max    = (1<<shift) - 1;



    av_assert0(plane_count == nb_components - 1);

    if (desc->flags & AV_PIX_FMT_FLAG_PLANAR) {

        for (plane = 0; plane < plane_count; plane++) {

            int w = plane ? c->chrSrcW : c->srcW;

            int y_subsample = plane ? desc->log2_chroma_h: 0;

            for (y = srcSliceY >> y_subsample; y < FF_CEIL_RSHIFT(srcSliceH, y_subsample); y++) {

                if (sixteen_bits) {

                    const uint16_t *s = src[plane      ] + srcStride[plane] * y;

                    const uint16_t *a = src[plane_count] + srcStride[plane_count] * y;

                          uint16_t *d = dst[plane      ] + dstStride[plane] * y;

                    unsigned target = plane && !(desc->flags & AV_PIX_FMT_FLAG_RGB) ? 1<<desc->comp[0].depth_minus1 : 0;

                    if ((!isBE(c->srcFormat)) == !HAVE_BIGENDIAN) {

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

                            unsigned u = s[x]*a[x] + target*(max-a[x]) + off;

                            d[x] = av_clip((u + (u >> shift)) >> shift, 0, max);

                        }

                    } else {

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

                            unsigned aswap =av_bswap16(a[x]);

                            unsigned u = av_bswap16(s[x])*aswap + target*(max-aswap) + off;

                            d[x] = av_clip((u + (u >> shift)) >> shift, 0, max);

                        }

                    }

                } else {

                    const uint8_t *s = src[plane      ] + srcStride[plane] * y;

                    const uint8_t *a = src[plane_count] + srcStride[plane_count] * y;

                          uint8_t *d = dst[plane      ] + dstStride[plane] * y;

                    unsigned target = plane && !(desc->flags & AV_PIX_FMT_FLAG_RGB) ? 128 : 0;

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

                        unsigned u = s[x]*a[x] + target*(255-a[x]) + 128;

                        d[x] = (257*u) >> 16;

                    }

                }

            }

        }

    } else {

        int alpha_pos = desc->comp[plane_count].offset_plus1 - 1;

        int w = c->srcW;

        for (y = srcSliceY; y < srcSliceH; y++) {

            if (sixteen_bits) {

                const uint16_t *s = src[0] + srcStride[0] * y + 2*!alpha_pos;

                const uint16_t *a = src[0] + srcStride[0] * y + alpha_pos;

                        uint16_t *d = dst[0] + dstStride[0] * y;

                if ((!isBE(c->srcFormat)) == !HAVE_BIGENDIAN) {

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

                        for (plane = 0; plane < plane_count; plane++) {

                            unsigned target = plane && !(desc->flags & AV_PIX_FMT_FLAG_RGB) ? 1<<desc->comp[0].depth_minus1 : 0;

                            int x_index = (plane_count + 1) * x;

                            unsigned u = s[x_index + plane]*a[x_index] + target*(max-a[x_index]) + off;

                            d[plane_count*x + plane] = av_clip((u + (u >> shift)) >> shift, 0, max);

                        }

                    }

                } else {

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

                        for (plane = 0; plane < plane_count; plane++) {

                            unsigned target = plane && !(desc->flags & AV_PIX_FMT_FLAG_RGB) ? 1<<desc->comp[0].depth_minus1 : 0;

                            int x_index = (plane_count + 1) * x;

                            unsigned aswap =av_bswap16(a[x_index]);

                            unsigned u = av_bswap16(s[x_index + plane])*aswap + target*(max-aswap) + off;

                            d[plane_count*x + plane] = av_clip((u + (u >> shift)) >> shift, 0, max);

                        }

                    }

                }

            } else {

                const uint8_t *s = src[0] + srcStride[0] * y + !alpha_pos;

                const uint8_t *a = src[0] + srcStride[0] * y + alpha_pos;

                      uint8_t *d = dst[0] + dstStride[0] * y;

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

                    for (plane = 0; plane < plane_count; plane++) {

                        unsigned target = plane && !(desc->flags & AV_PIX_FMT_FLAG_RGB) ? 128 : 0;

                        int x_index = (plane_count + 1) * x;

                        unsigned u = s[x_index + plane]*a[x_index] + target*(255-a[x_index]) + 128;

                        d[plane_count*x + plane] = (257*u) >> 16;

                    }

                }

            }

        }

    }



    return 0;

}

int ff_sws_alphablendaway(SwsContext *c, const uint8_t *src[],

                          int srcStride[], int srcSliceY, int srcSliceH,

                          uint8_t *dst[], int dstStride[])

{

    const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(c->srcFormat);

    int nb_components = desc->nb_components;

    int plane, x, y;

    int plane_count = isGray(c->srcFormat) ? 1 : 3;

    int sixteen_bits = desc->comp[0].depth_minus1 >= 8;

    unsigned off    = 1<<desc->comp[0].depth_minus1;

    unsigned shift  = desc->comp[0].depth_minus1 + 1;

    unsigned max    = (1<<shift) - 1;



    av_assert0(plane_count == nb_components - 1);

    if (desc->flags & AV_PIX_FMT_FLAG_PLANAR) {

        for (plane = 0; plane < plane_count; plane++) {

            int w = plane ? c->chrSrcW : c->srcW;

            int y_subsample = plane ? desc->log2_chroma_h: 0;

            for (y = srcSliceY >> y_subsample; y < FF_CEIL_RSHIFT(srcSliceH, y_subsample); y++) {

                if (sixteen_bits) {

                    const uint16_t *s = src[plane      ] + srcStride[plane] * y;

                    const uint16_t *a = src[plane_count] + srcStride[plane_count] * y;

                          uint16_t *d = dst[plane      ] + dstStride[plane] * y;

                    unsigned target = plane && !(desc->flags & AV_PIX_FMT_FLAG_RGB) ? 1<<desc->comp[0].depth_minus1 : 0;

                    if ((!isBE(c->srcFormat)) == !HAVE_BIGENDIAN) {

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

                            unsigned u = s[x]*a[x] + target*(max-a[x]) + off;

                            d[x] = av_clip((u + (u >> shift)) >> shift, 0, max);

                        }

                    } else {

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

                            unsigned aswap =av_bswap16(a[x]);

                            unsigned u = av_bswap16(s[x])*aswap + target*(max-aswap) + off;

                            d[x] = av_clip((u + (u >> shift)) >> shift, 0, max);

                        }

                    }

                } else {

                    const uint8_t *s = src[plane      ] + srcStride[plane] * y;

                    const uint8_t *a = src[plane_count] + srcStride[plane_count] * y;

                          uint8_t *d = dst[plane      ] + dstStride[plane] * y;

                    unsigned target = plane && !(desc->flags & AV_PIX_FMT_FLAG_RGB) ? 128 : 0;

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

                        unsigned u = s[x]*a[x] + target*(255-a[x]) + 128;

                        d[x] = (257*u) >> 16;

                    }

                }

            }

        }

    } else {

        int alpha_pos = desc->comp[plane_count].offset_plus1 - 1;

        int w = c->srcW;

        for (y = srcSliceY; y < srcSliceH; y++) {

            if (sixteen_bits) {

                const uint16_t *s = src[0] + srcStride[0] * y + 2*!alpha_pos;

                const uint16_t *a = src[0] + srcStride[0] * y + alpha_pos;

                        uint16_t *d = dst[0] + dstStride[0] * y;

                if ((!isBE(c->srcFormat)) == !HAVE_BIGENDIAN) {

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

                        for (plane = 0; plane < plane_count; plane++) {

                            unsigned target = plane && !(desc->flags & AV_PIX_FMT_FLAG_RGB) ? 1<<desc->comp[0].depth_minus1 : 0;

                            int x_index = (plane_count + 1) * x;

                            unsigned u = s[x_index + plane]*a[x_index] + target*(max-a[x_index]) + off;

                            d[plane_count*x + plane] = av_clip((u + (u >> shift)) >> shift, 0, max);

                        }

                    }

                } else {

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

                        for (plane = 0; plane < plane_count; plane++) {

                            unsigned target = plane && !(desc->flags & AV_PIX_FMT_FLAG_RGB) ? 1<<desc->comp[0].depth_minus1 : 0;

                            int x_index = (plane_count + 1) * x;

                            unsigned aswap =av_bswap16(a[x_index]);

                            unsigned u = av_bswap16(s[x_index + plane])*aswap + target*(max-aswap) + off;

                            d[plane_count*x + plane] = av_clip((u + (u >> shift)) >> shift, 0, max);

                        }

                    }

                }

            } else {

                const uint8_t *s = src[0] + srcStride[0] * y + !alpha_pos;

                const uint8_t *a = src[0] + srcStride[0] * y + alpha_pos;

                      uint8_t *d = dst[0] + dstStride[0] * y;

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

                    for (plane = 0; plane < plane_count; plane++) {

                        unsigned target = plane && !(desc->flags & AV_PIX_FMT_FLAG_RGB) ? 128 : 0;

                        int x_index = (plane_count + 1) * x;

                        unsigned u = s[x_index + plane]*a[x_index] + target*(255-a[x_index]) + 128;

                        d[plane_count*x + plane] = (257*u) >> 16;

                    }

                }

            }

        }

    }



    return 0;

}

int FUNC_0(SwsContext *VAR_0, const uint8_t *VAR_1[],

                          int VAR_2[], int VAR_3, int VAR_4,

                          uint8_t *VAR_5[], int VAR_6[])

{

    const AVPixFmtDescriptor *VAR_7 = av_pix_fmt_desc_get(VAR_0->srcFormat);

    int VAR_8 = VAR_7->VAR_8;

    int VAR_9, VAR_10, VAR_11;

    int VAR_12 = isGray(VAR_0->srcFormat) ? 1 : 3;

    int VAR_13 = VAR_7->comp[0].depth_minus1 >= 8;

    unsigned VAR_14    = 1<<VAR_7->comp[0].depth_minus1;

    unsigned VAR_15  = VAR_7->comp[0].depth_minus1 + 1;

    unsigned VAR_16    = (1<<VAR_15) - 1;



    av_assert0(VAR_12 == VAR_8 - 1);

    if (VAR_7->flags & AV_PIX_FMT_FLAG_PLANAR) {

        for (VAR_9 = 0; VAR_9 < VAR_12; VAR_9++) {

            int VAR_25 = VAR_9 ? VAR_0->chrSrcW : VAR_0->srcW;

            int VAR_18 = VAR_9 ? VAR_7->log2_chroma_h: 0;

            for (VAR_11 = VAR_3 >> VAR_18; VAR_11 < FF_CEIL_RSHIFT(VAR_4, VAR_18); VAR_11++) {

                if (VAR_13) {

                    const uint16_t *VAR_26 = VAR_1[VAR_9      ] + VAR_2[VAR_9] * VAR_11;

                    const uint16_t *VAR_26 = VAR_1[VAR_12] + VAR_2[VAR_12] * VAR_11;

                          uint16_t *d = VAR_5[VAR_9      ] + VAR_6[VAR_9] * VAR_11;

                    unsigned VAR_26 = VAR_9 && !(VAR_7->flags & AV_PIX_FMT_FLAG_RGB) ? 1<<VAR_7->comp[0].depth_minus1 : 0;

                    if ((!isBE(VAR_0->srcFormat)) == !HAVE_BIGENDIAN) {

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

                            unsigned VAR_26 = VAR_26[VAR_10]*VAR_26[VAR_10] + VAR_26*(VAR_16-VAR_26[VAR_10]) + VAR_14;

                            d[VAR_10] = av_clip((VAR_26 + (VAR_26 >> VAR_15)) >> VAR_15, 0, VAR_16);

                        }

                    } else {

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

                            unsigned VAR_26 =av_bswap16(VAR_26[VAR_10]);

                            unsigned VAR_26 = av_bswap16(VAR_26[VAR_10])*VAR_26 + VAR_26*(VAR_16-VAR_26) + VAR_14;

                            d[VAR_10] = av_clip((VAR_26 + (VAR_26 >> VAR_15)) >> VAR_15, 0, VAR_16);

                        }

                    }

                } else {

                    const uint8_t *VAR_26 = VAR_1[VAR_9      ] + VAR_2[VAR_9] * VAR_11;

                    const uint8_t *VAR_26 = VAR_1[VAR_12] + VAR_2[VAR_12] * VAR_11;

                          uint8_t *d = VAR_5[VAR_9      ] + VAR_6[VAR_9] * VAR_11;

                    unsigned VAR_26 = VAR_9 && !(VAR_7->flags & AV_PIX_FMT_FLAG_RGB) ? 128 : 0;

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

                        unsigned VAR_26 = VAR_26[VAR_10]*VAR_26[VAR_10] + VAR_26*(255-VAR_26[VAR_10]) + 128;

                        d[VAR_10] = (257*VAR_26) >> 16;

                    }

                }

            }

        }

    } else {

        int VAR_24 = VAR_7->comp[VAR_12].offset_plus1 - 1;

        int VAR_25 = VAR_0->srcW;

        for (VAR_11 = VAR_3; VAR_11 < VAR_4; VAR_11++) {

            if (VAR_13) {

                const uint16_t *VAR_26 = VAR_1[0] + VAR_2[0] * VAR_11 + 2*!VAR_24;

                const uint16_t *VAR_26 = VAR_1[0] + VAR_2[0] * VAR_11 + VAR_24;

                        uint16_t *d = VAR_5[0] + VAR_6[0] * VAR_11;

                if ((!isBE(VAR_0->srcFormat)) == !HAVE_BIGENDIAN) {

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

                        for (VAR_9 = 0; VAR_9 < VAR_12; VAR_9++) {

                            unsigned VAR_26 = VAR_9 && !(VAR_7->flags & AV_PIX_FMT_FLAG_RGB) ? 1<<VAR_7->comp[0].depth_minus1 : 0;

                            int VAR_26 = (VAR_12 + 1) * VAR_10;

                            unsigned VAR_26 = VAR_26[VAR_26 + VAR_9]*VAR_26[VAR_26] + VAR_26*(VAR_16-VAR_26[VAR_26]) + VAR_14;

                            d[VAR_12*VAR_10 + VAR_9] = av_clip((VAR_26 + (VAR_26 >> VAR_15)) >> VAR_15, 0, VAR_16);

                        }

                    }

                } else {

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

                        for (VAR_9 = 0; VAR_9 < VAR_12; VAR_9++) {

                            unsigned VAR_26 = VAR_9 && !(VAR_7->flags & AV_PIX_FMT_FLAG_RGB) ? 1<<VAR_7->comp[0].depth_minus1 : 0;

                            int VAR_26 = (VAR_12 + 1) * VAR_10;

                            unsigned VAR_26 =av_bswap16(VAR_26[VAR_26]);

                            unsigned VAR_26 = av_bswap16(VAR_26[VAR_26 + VAR_9])*VAR_26 + VAR_26*(VAR_16-VAR_26) + VAR_14;

                            d[VAR_12*VAR_10 + VAR_9] = av_clip((VAR_26 + (VAR_26 >> VAR_15)) >> VAR_15, 0, VAR_16);

                        }

                    }

                }

            } else {

                const uint8_t *VAR_26 = VAR_1[0] + VAR_2[0] * VAR_11 + !VAR_24;

                const uint8_t *VAR_26 = VAR_1[0] + VAR_2[0] * VAR_11 + VAR_24;

                      uint8_t *d = VAR_5[0] + VAR_6[0] * VAR_11;

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

                    for (VAR_9 = 0; VAR_9 < VAR_12; VAR_9++) {

                        unsigned VAR_26 = VAR_9 && !(VAR_7->flags & AV_PIX_FMT_FLAG_RGB) ? 128 : 0;

                        int VAR_26 = (VAR_12 + 1) * VAR_10;

                        unsigned VAR_26 = VAR_26[VAR_26 + VAR_9]*VAR_26[VAR_26] + VAR_26*(255-VAR_26[VAR_26]) + 128;

                        d[VAR_12*VAR_10 + VAR_9] = (257*VAR_26) >> 16;

                    }

                }

            }

        }

    }



    return 0;

}

int FUNC_0(SwsContext *VAR_0, const uint8_t *VAR_1[],
int VAR_2[], int VAR_3, int VAR_4,
uint8_t *VAR_5[], int VAR_6[])
{ const AVPixFmtDescriptor *VAR_7 = av_pix_fmt_desc_get(VAR_0->srcFormat); int VAR_8 = VAR_7->VAR_8; int VAR_9, VAR_10, VAR_11; int VAR_12 = isGray(VAR_0->srcFormat) ? 1 : 3; int VAR_13 = VAR_7->comp[0].depth_minus1 >= 8; unsigned VAR_14    = 1<<VAR_7->comp[0].depth_minus1; unsigned VAR_15  = VAR_7->comp[0].depth_minus1 + 1; unsigned VAR_16    = (1<<VAR_15) - 1; av_assert0(VAR_12 == VAR_8 - 1); if (VAR_7->flags & AV_PIX_FMT_FLAG_PLANAR) { for (VAR_9 = 0; VAR_9 < VAR_12; VAR_9++) { int VAR_25 = VAR_9 ? VAR_0->chrSrcW : VAR_0->srcW; int VAR_18 = VAR_9 ? VAR_7->log2_chroma_h: 0; for (VAR_11 = VAR_3 >> VAR_18; VAR_11 < FF_CEIL_RSHIFT(VAR_4, VAR_18); VAR_11++) { if (VAR_13) { const uint16_t *VAR_26 = VAR_1[VAR_9      ] + VAR_2[VAR_9] * VAR_11; const uint16_t *VAR_26 = VAR_1[VAR_12] + VAR_2[VAR_12] * VAR_11; uint16_t *d = VAR_5[VAR_9      ] + VAR_6[VAR_9] * VAR_11; unsigned VAR_26 = VAR_9 && !(VAR_7->flags & AV_PIX_FMT_FLAG_RGB) ? 1<<VAR_7->comp[0].depth_minus1 : 0; if ((!isBE(VAR_0->srcFormat)) == !HAVE_BIGENDIAN) { for (VAR_10 = 0; VAR_10 < VAR_25; VAR_10++) { unsigned VAR_26 = VAR_26[VAR_10]*VAR_26[VAR_10] + VAR_26*(VAR_16-VAR_26[VAR_10]) + VAR_14; d[VAR_10] = av_clip((VAR_26 + (VAR_26 >> VAR_15)) >> VAR_15, 0, VAR_16); } } else { for (VAR_10 = 0; VAR_10 < VAR_25; VAR_10++) { unsigned VAR_26 =av_bswap16(VAR_26[VAR_10]); unsigned VAR_26 = av_bswap16(VAR_26[VAR_10])*VAR_26 + VAR_26*(VAR_16-VAR_26) + VAR_14; d[VAR_10] = av_clip((VAR_26 + (VAR_26 >> VAR_15)) >> VAR_15, 0, VAR_16); } } } else { const uint8_t *VAR_26 = VAR_1[VAR_9      ] + VAR_2[VAR_9] * VAR_11; const uint8_t *VAR_26 = VAR_1[VAR_12] + VAR_2[VAR_12] * VAR_11; uint8_t *d = VAR_5[VAR_9      ] + VAR_6[VAR_9] * VAR_11; unsigned VAR_26 = VAR_9 && !(VAR_7->flags & AV_PIX_FMT_FLAG_RGB) ? 128 : 0; for (VAR_10 = 0; VAR_10 < VAR_25; VAR_10++) { unsigned VAR_26 = VAR_26[VAR_10]*VAR_26[VAR_10] + VAR_26*(255-VAR_26[VAR_10]) + 128; d[VAR_10] = (257*VAR_26) >> 16; } } } } } else { int VAR_24 = VAR_7->comp[VAR_12].offset_plus1 - 1; int VAR_25 = VAR_0->srcW; for (VAR_11 = VAR_3; VAR_11 < VAR_4; VAR_11++) { if (VAR_13) { const uint16_t *VAR_26 = VAR_1[0] + VAR_2[0] * VAR_11 + 2*!VAR_24; const uint16_t *VAR_26 = VAR_1[0] + VAR_2[0] * VAR_11 + VAR_24; uint16_t *d = VAR_5[0] + VAR_6[0] * VAR_11; if ((!isBE(VAR_0->srcFormat)) == !HAVE_BIGENDIAN) { for (VAR_10 = 0; VAR_10 < VAR_25; VAR_10++) { for (VAR_9 = 0; VAR_9 < VAR_12; VAR_9++) { unsigned VAR_26 = VAR_9 && !(VAR_7->flags & AV_PIX_FMT_FLAG_RGB) ? 1<<VAR_7->comp[0].depth_minus1 : 0; int VAR_26 = (VAR_12 + 1) * VAR_10; unsigned VAR_26 = VAR_26[VAR_26 + VAR_9]*VAR_26[VAR_26] + VAR_26*(VAR_16-VAR_26[VAR_26]) + VAR_14; d[VAR_12*VAR_10 + VAR_9] = av_clip((VAR_26 + (VAR_26 >> VAR_15)) >> VAR_15, 0, VAR_16); } } } else { for (VAR_10 = 0; VAR_10 < VAR_25; VAR_10++) { for (VAR_9 = 0; VAR_9 < VAR_12; VAR_9++) { unsigned VAR_26 = VAR_9 && !(VAR_7->flags & AV_PIX_FMT_FLAG_RGB) ? 1<<VAR_7->comp[0].depth_minus1 : 0; int VAR_26 = (VAR_12 + 1) * VAR_10; unsigned VAR_26 =av_bswap16(VAR_26[VAR_26]); unsigned VAR_26 = av_bswap16(VAR_26[VAR_26 + VAR_9])*VAR_26 + VAR_26*(VAR_16-VAR_26) + VAR_14; d[VAR_12*VAR_10 + VAR_9] = av_clip((VAR_26 + (VAR_26 >> VAR_15)) >> VAR_15, 0, VAR_16); } } } } else { const uint8_t *VAR_26 = VAR_1[0] + VAR_2[0] * VAR_11 + !VAR_24; const uint8_t *VAR_26 = VAR_1[0] + VAR_2[0] * VAR_11 + VAR_24; uint8_t *d = VAR_5[0] + VAR_6[0] * VAR_11; for (VAR_10 = 0; VAR_10 < VAR_25; VAR_10++) { for (VAR_9 = 0; VAR_9 < VAR_12; VAR_9++) { unsigned VAR_26 = VAR_9 && !(VAR_7->flags & AV_PIX_FMT_FLAG_RGB) ? 128 : 0; int VAR_26 = (VAR_12 + 1) * VAR_10; unsigned VAR_26 = VAR_26[VAR_26 + VAR_9]*VAR_26[VAR_26] + VAR_26*(255-VAR_26[VAR_26]) + 128; d[VAR_12*VAR_10 + VAR_9] = (257*VAR_26) >> 16; } } } } } return 0; }