Path: blob/master/thirdparty/libwebp/src/dsp/alpha_processing.c
9913 views
// Copyright 2013 Google Inc. All Rights Reserved.1//2// Use of this source code is governed by a BSD-style license3// that can be found in the COPYING file in the root of the source4// tree. An additional intellectual property rights grant can be found5// in the file PATENTS. All contributing project authors may6// be found in the AUTHORS file in the root of the source tree.7// -----------------------------------------------------------------------------8//9// Utilities for processing transparent channel.10//11// Author: Skal ([email protected])1213#include <assert.h>14#include "src/dsp/dsp.h"1516// Tables can be faster on some platform but incur some extra binary size (~2k).17#if !defined(USE_TABLES_FOR_ALPHA_MULT)18#define USE_TABLES_FOR_ALPHA_MULT 0 // ALTERNATE_CODE19#endif202122// -----------------------------------------------------------------------------2324#define MFIX 24 // 24bit fixed-point arithmetic25#define HALF ((1u << MFIX) >> 1)26#define KINV_255 ((1u << MFIX) / 255u)2728static uint32_t Mult(uint8_t x, uint32_t mult) {29const uint32_t v = (x * mult + HALF) >> MFIX;30assert(v <= 255); // <- 24bit precision is enough to ensure that.31return v;32}3334#if (USE_TABLES_FOR_ALPHA_MULT == 1)3536static const uint32_t kMultTables[2][256] = {37{ // (255u << MFIX) / alpha380x00000000, 0xff000000, 0x7f800000, 0x55000000, 0x3fc00000, 0x33000000,390x2a800000, 0x246db6db, 0x1fe00000, 0x1c555555, 0x19800000, 0x172e8ba2,400x15400000, 0x139d89d8, 0x1236db6d, 0x11000000, 0x0ff00000, 0x0f000000,410x0e2aaaaa, 0x0d6bca1a, 0x0cc00000, 0x0c249249, 0x0b9745d1, 0x0b1642c8,420x0aa00000, 0x0a333333, 0x09cec4ec, 0x0971c71c, 0x091b6db6, 0x08cb08d3,430x08800000, 0x0839ce73, 0x07f80000, 0x07ba2e8b, 0x07800000, 0x07492492,440x07155555, 0x06e45306, 0x06b5e50d, 0x0689d89d, 0x06600000, 0x063831f3,450x06124924, 0x05ee23b8, 0x05cba2e8, 0x05aaaaaa, 0x058b2164, 0x056cefa8,460x05500000, 0x05343eb1, 0x05199999, 0x05000000, 0x04e76276, 0x04cfb2b7,470x04b8e38e, 0x04a2e8ba, 0x048db6db, 0x0479435e, 0x04658469, 0x045270d0,480x04400000, 0x042e29f7, 0x041ce739, 0x040c30c3, 0x03fc0000, 0x03ec4ec4,490x03dd1745, 0x03ce540f, 0x03c00000, 0x03b21642, 0x03a49249, 0x03976fc6,500x038aaaaa, 0x037e3f1f, 0x03722983, 0x03666666, 0x035af286, 0x034fcace,510x0344ec4e, 0x033a5440, 0x03300000, 0x0325ed09, 0x031c18f9, 0x0312818a,520x03092492, 0x03000000, 0x02f711dc, 0x02ee5846, 0x02e5d174, 0x02dd7baf,530x02d55555, 0x02cd5cd5, 0x02c590b2, 0x02bdef7b, 0x02b677d4, 0x02af286b,540x02a80000, 0x02a0fd5c, 0x029a1f58, 0x029364d9, 0x028ccccc, 0x0286562d,550x02800000, 0x0279c952, 0x0273b13b, 0x026db6db, 0x0267d95b, 0x026217ec,560x025c71c7, 0x0256e62a, 0x0251745d, 0x024c1bac, 0x0246db6d, 0x0241b2f9,570x023ca1af, 0x0237a6f4, 0x0232c234, 0x022df2df, 0x02293868, 0x02249249,580x02200000, 0x021b810e, 0x021714fb, 0x0212bb51, 0x020e739c, 0x020a3d70,590x02061861, 0x02020408, 0x01fe0000, 0x01fa0be8, 0x01f62762, 0x01f25213,600x01ee8ba2, 0x01ead3ba, 0x01e72a07, 0x01e38e38, 0x01e00000, 0x01dc7f10,610x01d90b21, 0x01d5a3e9, 0x01d24924, 0x01cefa8d, 0x01cbb7e3, 0x01c880e5,620x01c55555, 0x01c234f7, 0x01bf1f8f, 0x01bc14e5, 0x01b914c1, 0x01b61eed,630x01b33333, 0x01b05160, 0x01ad7943, 0x01aaaaaa, 0x01a7e567, 0x01a5294a,640x01a27627, 0x019fcbd2, 0x019d2a20, 0x019a90e7, 0x01980000, 0x01957741,650x0192f684, 0x01907da4, 0x018e0c7c, 0x018ba2e8, 0x018940c5, 0x0186e5f0,660x01849249, 0x018245ae, 0x01800000, 0x017dc11f, 0x017b88ee, 0x0179574e,670x01772c23, 0x01750750, 0x0172e8ba, 0x0170d045, 0x016ebdd7, 0x016cb157,680x016aaaaa, 0x0168a9b9, 0x0166ae6a, 0x0164b8a7, 0x0162c859, 0x0160dd67,690x015ef7bd, 0x015d1745, 0x015b3bea, 0x01596596, 0x01579435, 0x0155c7b4,700x01540000, 0x01523d03, 0x01507eae, 0x014ec4ec, 0x014d0fac, 0x014b5edc,710x0149b26c, 0x01480a4a, 0x01466666, 0x0144c6af, 0x01432b16, 0x0141938b,720x01400000, 0x013e7063, 0x013ce4a9, 0x013b5cc0, 0x0139d89d, 0x01385830,730x0136db6d, 0x01356246, 0x0133ecad, 0x01327a97, 0x01310bf6, 0x012fa0be,740x012e38e3, 0x012cd459, 0x012b7315, 0x012a150a, 0x0128ba2e, 0x01276276,750x01260dd6, 0x0124bc44, 0x01236db6, 0x01222222, 0x0120d97c, 0x011f93bc,760x011e50d7, 0x011d10c4, 0x011bd37a, 0x011a98ef, 0x0119611a, 0x01182bf2,770x0116f96f, 0x0115c988, 0x01149c34, 0x0113716a, 0x01124924, 0x01112358,780x01100000, 0x010edf12, 0x010dc087, 0x010ca458, 0x010b8a7d, 0x010a72f0,790x01095da8, 0x01084a9f, 0x010739ce, 0x01062b2e, 0x01051eb8, 0x01041465,800x01030c30, 0x01020612, 0x01010204, 0x01000000 },81{ // alpha * KINV_255820x00000000, 0x00010101, 0x00020202, 0x00030303, 0x00040404, 0x00050505,830x00060606, 0x00070707, 0x00080808, 0x00090909, 0x000a0a0a, 0x000b0b0b,840x000c0c0c, 0x000d0d0d, 0x000e0e0e, 0x000f0f0f, 0x00101010, 0x00111111,850x00121212, 0x00131313, 0x00141414, 0x00151515, 0x00161616, 0x00171717,860x00181818, 0x00191919, 0x001a1a1a, 0x001b1b1b, 0x001c1c1c, 0x001d1d1d,870x001e1e1e, 0x001f1f1f, 0x00202020, 0x00212121, 0x00222222, 0x00232323,880x00242424, 0x00252525, 0x00262626, 0x00272727, 0x00282828, 0x00292929,890x002a2a2a, 0x002b2b2b, 0x002c2c2c, 0x002d2d2d, 0x002e2e2e, 0x002f2f2f,900x00303030, 0x00313131, 0x00323232, 0x00333333, 0x00343434, 0x00353535,910x00363636, 0x00373737, 0x00383838, 0x00393939, 0x003a3a3a, 0x003b3b3b,920x003c3c3c, 0x003d3d3d, 0x003e3e3e, 0x003f3f3f, 0x00404040, 0x00414141,930x00424242, 0x00434343, 0x00444444, 0x00454545, 0x00464646, 0x00474747,940x00484848, 0x00494949, 0x004a4a4a, 0x004b4b4b, 0x004c4c4c, 0x004d4d4d,950x004e4e4e, 0x004f4f4f, 0x00505050, 0x00515151, 0x00525252, 0x00535353,960x00545454, 0x00555555, 0x00565656, 0x00575757, 0x00585858, 0x00595959,970x005a5a5a, 0x005b5b5b, 0x005c5c5c, 0x005d5d5d, 0x005e5e5e, 0x005f5f5f,980x00606060, 0x00616161, 0x00626262, 0x00636363, 0x00646464, 0x00656565,990x00666666, 0x00676767, 0x00686868, 0x00696969, 0x006a6a6a, 0x006b6b6b,1000x006c6c6c, 0x006d6d6d, 0x006e6e6e, 0x006f6f6f, 0x00707070, 0x00717171,1010x00727272, 0x00737373, 0x00747474, 0x00757575, 0x00767676, 0x00777777,1020x00787878, 0x00797979, 0x007a7a7a, 0x007b7b7b, 0x007c7c7c, 0x007d7d7d,1030x007e7e7e, 0x007f7f7f, 0x00808080, 0x00818181, 0x00828282, 0x00838383,1040x00848484, 0x00858585, 0x00868686, 0x00878787, 0x00888888, 0x00898989,1050x008a8a8a, 0x008b8b8b, 0x008c8c8c, 0x008d8d8d, 0x008e8e8e, 0x008f8f8f,1060x00909090, 0x00919191, 0x00929292, 0x00939393, 0x00949494, 0x00959595,1070x00969696, 0x00979797, 0x00989898, 0x00999999, 0x009a9a9a, 0x009b9b9b,1080x009c9c9c, 0x009d9d9d, 0x009e9e9e, 0x009f9f9f, 0x00a0a0a0, 0x00a1a1a1,1090x00a2a2a2, 0x00a3a3a3, 0x00a4a4a4, 0x00a5a5a5, 0x00a6a6a6, 0x00a7a7a7,1100x00a8a8a8, 0x00a9a9a9, 0x00aaaaaa, 0x00ababab, 0x00acacac, 0x00adadad,1110x00aeaeae, 0x00afafaf, 0x00b0b0b0, 0x00b1b1b1, 0x00b2b2b2, 0x00b3b3b3,1120x00b4b4b4, 0x00b5b5b5, 0x00b6b6b6, 0x00b7b7b7, 0x00b8b8b8, 0x00b9b9b9,1130x00bababa, 0x00bbbbbb, 0x00bcbcbc, 0x00bdbdbd, 0x00bebebe, 0x00bfbfbf,1140x00c0c0c0, 0x00c1c1c1, 0x00c2c2c2, 0x00c3c3c3, 0x00c4c4c4, 0x00c5c5c5,1150x00c6c6c6, 0x00c7c7c7, 0x00c8c8c8, 0x00c9c9c9, 0x00cacaca, 0x00cbcbcb,1160x00cccccc, 0x00cdcdcd, 0x00cecece, 0x00cfcfcf, 0x00d0d0d0, 0x00d1d1d1,1170x00d2d2d2, 0x00d3d3d3, 0x00d4d4d4, 0x00d5d5d5, 0x00d6d6d6, 0x00d7d7d7,1180x00d8d8d8, 0x00d9d9d9, 0x00dadada, 0x00dbdbdb, 0x00dcdcdc, 0x00dddddd,1190x00dedede, 0x00dfdfdf, 0x00e0e0e0, 0x00e1e1e1, 0x00e2e2e2, 0x00e3e3e3,1200x00e4e4e4, 0x00e5e5e5, 0x00e6e6e6, 0x00e7e7e7, 0x00e8e8e8, 0x00e9e9e9,1210x00eaeaea, 0x00ebebeb, 0x00ececec, 0x00ededed, 0x00eeeeee, 0x00efefef,1220x00f0f0f0, 0x00f1f1f1, 0x00f2f2f2, 0x00f3f3f3, 0x00f4f4f4, 0x00f5f5f5,1230x00f6f6f6, 0x00f7f7f7, 0x00f8f8f8, 0x00f9f9f9, 0x00fafafa, 0x00fbfbfb,1240x00fcfcfc, 0x00fdfdfd, 0x00fefefe, 0x00ffffff }125};126127static WEBP_INLINE uint32_t GetScale(uint32_t a, int inverse) {128return kMultTables[!inverse][a];129}130131#else132133static WEBP_INLINE uint32_t GetScale(uint32_t a, int inverse) {134return inverse ? (255u << MFIX) / a : a * KINV_255;135}136137#endif // USE_TABLES_FOR_ALPHA_MULT138139void WebPMultARGBRow_C(uint32_t* const ptr, int width, int inverse) {140int x;141for (x = 0; x < width; ++x) {142const uint32_t argb = ptr[x];143if (argb < 0xff000000u) { // alpha < 255144if (argb <= 0x00ffffffu) { // alpha == 0145ptr[x] = 0;146} else {147const uint32_t alpha = (argb >> 24) & 0xff;148const uint32_t scale = GetScale(alpha, inverse);149uint32_t out = argb & 0xff000000u;150out |= Mult(argb >> 0, scale) << 0;151out |= Mult(argb >> 8, scale) << 8;152out |= Mult(argb >> 16, scale) << 16;153ptr[x] = out;154}155}156}157}158159void WebPMultRow_C(uint8_t* WEBP_RESTRICT const ptr,160const uint8_t* WEBP_RESTRICT const alpha,161int width, int inverse) {162int x;163for (x = 0; x < width; ++x) {164const uint32_t a = alpha[x];165if (a != 255) {166if (a == 0) {167ptr[x] = 0;168} else {169const uint32_t scale = GetScale(a, inverse);170ptr[x] = Mult(ptr[x], scale);171}172}173}174}175176#undef KINV_255177#undef HALF178#undef MFIX179180void (*WebPMultARGBRow)(uint32_t* const ptr, int width, int inverse);181void (*WebPMultRow)(uint8_t* WEBP_RESTRICT const ptr,182const uint8_t* WEBP_RESTRICT const alpha,183int width, int inverse);184185//------------------------------------------------------------------------------186// Generic per-plane calls187188void WebPMultARGBRows(uint8_t* ptr, int stride, int width, int num_rows,189int inverse) {190int n;191for (n = 0; n < num_rows; ++n) {192WebPMultARGBRow((uint32_t*)ptr, width, inverse);193ptr += stride;194}195}196197void WebPMultRows(uint8_t* WEBP_RESTRICT ptr, int stride,198const uint8_t* WEBP_RESTRICT alpha, int alpha_stride,199int width, int num_rows, int inverse) {200int n;201for (n = 0; n < num_rows; ++n) {202WebPMultRow(ptr, alpha, width, inverse);203ptr += stride;204alpha += alpha_stride;205}206}207208//------------------------------------------------------------------------------209// Premultiplied modes210211// non dithered-modes212213// (x * a * 32897) >> 23 is bit-wise equivalent to (int)(x * a / 255.)214// for all 8bit x or a. For bit-wise equivalence to (int)(x * a / 255. + .5),215// one can use instead: (x * a * 65793 + (1 << 23)) >> 24216#if 1 // (int)(x * a / 255.)217#define MULTIPLIER(a) ((a) * 32897U)218#define PREMULTIPLY(x, m) (((x) * (m)) >> 23)219#else // (int)(x * a / 255. + .5)220#define MULTIPLIER(a) ((a) * 65793U)221#define PREMULTIPLY(x, m) (((x) * (m) + (1U << 23)) >> 24)222#endif223224#if !WEBP_NEON_OMIT_C_CODE225static void ApplyAlphaMultiply_C(uint8_t* rgba, int alpha_first,226int w, int h, int stride) {227while (h-- > 0) {228uint8_t* const rgb = rgba + (alpha_first ? 1 : 0);229const uint8_t* const alpha = rgba + (alpha_first ? 0 : 3);230int i;231for (i = 0; i < w; ++i) {232const uint32_t a = alpha[4 * i];233if (a != 0xff) {234const uint32_t mult = MULTIPLIER(a);235rgb[4 * i + 0] = PREMULTIPLY(rgb[4 * i + 0], mult);236rgb[4 * i + 1] = PREMULTIPLY(rgb[4 * i + 1], mult);237rgb[4 * i + 2] = PREMULTIPLY(rgb[4 * i + 2], mult);238}239}240rgba += stride;241}242}243#endif // !WEBP_NEON_OMIT_C_CODE244#undef MULTIPLIER245#undef PREMULTIPLY246247// rgbA4444248249#define MULTIPLIER(a) ((a) * 0x1111) // 0x1111 ~= (1 << 16) / 15250251static WEBP_INLINE uint8_t dither_hi(uint8_t x) {252return (x & 0xf0) | (x >> 4);253}254255static WEBP_INLINE uint8_t dither_lo(uint8_t x) {256return (x & 0x0f) | (x << 4);257}258259static WEBP_INLINE uint8_t multiply(uint8_t x, uint32_t m) {260return (x * m) >> 16;261}262263static WEBP_INLINE void ApplyAlphaMultiply4444_C(uint8_t* rgba4444,264int w, int h, int stride,265int rg_byte_pos /* 0 or 1 */) {266while (h-- > 0) {267int i;268for (i = 0; i < w; ++i) {269const uint32_t rg = rgba4444[2 * i + rg_byte_pos];270const uint32_t ba = rgba4444[2 * i + (rg_byte_pos ^ 1)];271const uint8_t a = ba & 0x0f;272const uint32_t mult = MULTIPLIER(a);273const uint8_t r = multiply(dither_hi(rg), mult);274const uint8_t g = multiply(dither_lo(rg), mult);275const uint8_t b = multiply(dither_hi(ba), mult);276rgba4444[2 * i + rg_byte_pos] = (r & 0xf0) | ((g >> 4) & 0x0f);277rgba4444[2 * i + (rg_byte_pos ^ 1)] = (b & 0xf0) | a;278}279rgba4444 += stride;280}281}282#undef MULTIPLIER283284static void ApplyAlphaMultiply_16b_C(uint8_t* rgba4444,285int w, int h, int stride) {286#if (WEBP_SWAP_16BIT_CSP == 1)287ApplyAlphaMultiply4444_C(rgba4444, w, h, stride, 1);288#else289ApplyAlphaMultiply4444_C(rgba4444, w, h, stride, 0);290#endif291}292293#if !WEBP_NEON_OMIT_C_CODE294static int DispatchAlpha_C(const uint8_t* WEBP_RESTRICT alpha, int alpha_stride,295int width, int height,296uint8_t* WEBP_RESTRICT dst, int dst_stride) {297uint32_t alpha_mask = 0xff;298int i, j;299300for (j = 0; j < height; ++j) {301for (i = 0; i < width; ++i) {302const uint32_t alpha_value = alpha[i];303dst[4 * i] = alpha_value;304alpha_mask &= alpha_value;305}306alpha += alpha_stride;307dst += dst_stride;308}309310return (alpha_mask != 0xff);311}312313static void DispatchAlphaToGreen_C(const uint8_t* WEBP_RESTRICT alpha,314int alpha_stride, int width, int height,315uint32_t* WEBP_RESTRICT dst,316int dst_stride) {317int i, j;318for (j = 0; j < height; ++j) {319for (i = 0; i < width; ++i) {320dst[i] = alpha[i] << 8; // leave A/R/B channels zero'd.321}322alpha += alpha_stride;323dst += dst_stride;324}325}326327static int ExtractAlpha_C(const uint8_t* WEBP_RESTRICT argb, int argb_stride,328int width, int height,329uint8_t* WEBP_RESTRICT alpha, int alpha_stride) {330uint8_t alpha_mask = 0xff;331int i, j;332333for (j = 0; j < height; ++j) {334for (i = 0; i < width; ++i) {335const uint8_t alpha_value = argb[4 * i];336alpha[i] = alpha_value;337alpha_mask &= alpha_value;338}339argb += argb_stride;340alpha += alpha_stride;341}342return (alpha_mask == 0xff);343}344345static void ExtractGreen_C(const uint32_t* WEBP_RESTRICT argb,346uint8_t* WEBP_RESTRICT alpha, int size) {347int i;348for (i = 0; i < size; ++i) alpha[i] = argb[i] >> 8;349}350#endif // !WEBP_NEON_OMIT_C_CODE351352//------------------------------------------------------------------------------353354static int HasAlpha8b_C(const uint8_t* src, int length) {355while (length-- > 0) if (*src++ != 0xff) return 1;356return 0;357}358359static int HasAlpha32b_C(const uint8_t* src, int length) {360int x;361for (x = 0; length-- > 0; x += 4) if (src[x] != 0xff) return 1;362return 0;363}364365static void AlphaReplace_C(uint32_t* src, int length, uint32_t color) {366int x;367for (x = 0; x < length; ++x) if ((src[x] >> 24) == 0) src[x] = color;368}369370//------------------------------------------------------------------------------371// Simple channel manipulations.372373static WEBP_INLINE uint32_t MakeARGB32(int a, int r, int g, int b) {374return (((uint32_t)a << 24) | (r << 16) | (g << 8) | b);375}376377#ifdef WORDS_BIGENDIAN378static void PackARGB_C(const uint8_t* WEBP_RESTRICT a,379const uint8_t* WEBP_RESTRICT r,380const uint8_t* WEBP_RESTRICT g,381const uint8_t* WEBP_RESTRICT b,382int len, uint32_t* WEBP_RESTRICT out) {383int i;384for (i = 0; i < len; ++i) {385out[i] = MakeARGB32(a[4 * i], r[4 * i], g[4 * i], b[4 * i]);386}387}388#endif389390static void PackRGB_C(const uint8_t* WEBP_RESTRICT r,391const uint8_t* WEBP_RESTRICT g,392const uint8_t* WEBP_RESTRICT b,393int len, int step, uint32_t* WEBP_RESTRICT out) {394int i, offset = 0;395for (i = 0; i < len; ++i) {396out[i] = MakeARGB32(0xff, r[offset], g[offset], b[offset]);397offset += step;398}399}400401void (*WebPApplyAlphaMultiply)(uint8_t*, int, int, int, int);402void (*WebPApplyAlphaMultiply4444)(uint8_t*, int, int, int);403int (*WebPDispatchAlpha)(const uint8_t* WEBP_RESTRICT, int, int, int,404uint8_t* WEBP_RESTRICT, int);405void (*WebPDispatchAlphaToGreen)(const uint8_t* WEBP_RESTRICT, int, int, int,406uint32_t* WEBP_RESTRICT, int);407int (*WebPExtractAlpha)(const uint8_t* WEBP_RESTRICT, int, int, int,408uint8_t* WEBP_RESTRICT, int);409void (*WebPExtractGreen)(const uint32_t* WEBP_RESTRICT argb,410uint8_t* WEBP_RESTRICT alpha, int size);411#ifdef WORDS_BIGENDIAN412void (*WebPPackARGB)(const uint8_t* a, const uint8_t* r, const uint8_t* g,413const uint8_t* b, int, uint32_t*);414#endif415void (*WebPPackRGB)(const uint8_t* WEBP_RESTRICT r,416const uint8_t* WEBP_RESTRICT g,417const uint8_t* WEBP_RESTRICT b,418int len, int step, uint32_t* WEBP_RESTRICT out);419420int (*WebPHasAlpha8b)(const uint8_t* src, int length);421int (*WebPHasAlpha32b)(const uint8_t* src, int length);422void (*WebPAlphaReplace)(uint32_t* src, int length, uint32_t color);423424//------------------------------------------------------------------------------425// Init function426427extern VP8CPUInfo VP8GetCPUInfo;428extern void WebPInitAlphaProcessingMIPSdspR2(void);429extern void WebPInitAlphaProcessingSSE2(void);430extern void WebPInitAlphaProcessingSSE41(void);431extern void WebPInitAlphaProcessingNEON(void);432433WEBP_DSP_INIT_FUNC(WebPInitAlphaProcessing) {434WebPMultARGBRow = WebPMultARGBRow_C;435WebPMultRow = WebPMultRow_C;436WebPApplyAlphaMultiply4444 = ApplyAlphaMultiply_16b_C;437438#ifdef WORDS_BIGENDIAN439WebPPackARGB = PackARGB_C;440#endif441WebPPackRGB = PackRGB_C;442#if !WEBP_NEON_OMIT_C_CODE443WebPApplyAlphaMultiply = ApplyAlphaMultiply_C;444WebPDispatchAlpha = DispatchAlpha_C;445WebPDispatchAlphaToGreen = DispatchAlphaToGreen_C;446WebPExtractAlpha = ExtractAlpha_C;447WebPExtractGreen = ExtractGreen_C;448#endif449450WebPHasAlpha8b = HasAlpha8b_C;451WebPHasAlpha32b = HasAlpha32b_C;452WebPAlphaReplace = AlphaReplace_C;453454// If defined, use CPUInfo() to overwrite some pointers with faster versions.455if (VP8GetCPUInfo != NULL) {456#if defined(WEBP_HAVE_SSE2)457if (VP8GetCPUInfo(kSSE2)) {458WebPInitAlphaProcessingSSE2();459#if defined(WEBP_HAVE_SSE41)460if (VP8GetCPUInfo(kSSE4_1)) {461WebPInitAlphaProcessingSSE41();462}463#endif464}465#endif466#if defined(WEBP_USE_MIPS_DSP_R2)467if (VP8GetCPUInfo(kMIPSdspR2)) {468WebPInitAlphaProcessingMIPSdspR2();469}470#endif471}472473#if defined(WEBP_HAVE_NEON)474if (WEBP_NEON_OMIT_C_CODE ||475(VP8GetCPUInfo != NULL && VP8GetCPUInfo(kNEON))) {476WebPInitAlphaProcessingNEON();477}478#endif479480assert(WebPMultARGBRow != NULL);481assert(WebPMultRow != NULL);482assert(WebPApplyAlphaMultiply != NULL);483assert(WebPApplyAlphaMultiply4444 != NULL);484assert(WebPDispatchAlpha != NULL);485assert(WebPDispatchAlphaToGreen != NULL);486assert(WebPExtractAlpha != NULL);487assert(WebPExtractGreen != NULL);488#ifdef WORDS_BIGENDIAN489assert(WebPPackARGB != NULL);490#endif491assert(WebPPackRGB != NULL);492assert(WebPHasAlpha8b != NULL);493assert(WebPHasAlpha32b != NULL);494assert(WebPAlphaReplace != NULL);495}496497498