Path: blob/master/thirdparty/libwebp/src/dsp/lossless.c
21350 views
// Copyright 2012 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// Image transforms and color space conversion methods for lossless decoder.10//11// Authors: Vikas Arora ([email protected])12// Jyrki Alakuijala ([email protected])13// Urvang Joshi ([email protected])1415#include "src/dsp/lossless.h"1617#include <assert.h>18#include <stdlib.h>19#include <string.h>2021#include "src/dec/vp8li_dec.h"22#include "src/dsp/cpu.h"23#include "src/dsp/dsp.h"24#include "src/dsp/lossless_common.h"25#include "src/utils/endian_inl_utils.h"26#include "src/utils/utils.h"27#include "src/webp/decode.h"28#include "src/webp/format_constants.h"29#include "src/webp/types.h"3031//------------------------------------------------------------------------------32// Image transforms.3334static WEBP_INLINE uint32_t Average2(uint32_t a0, uint32_t a1) {35return (((a0 ^ a1) & 0xfefefefeu) >> 1) + (a0 & a1);36}3738static WEBP_INLINE uint32_t Average3(uint32_t a0, uint32_t a1, uint32_t a2) {39return Average2(Average2(a0, a2), a1);40}4142static WEBP_INLINE uint32_t Average4(uint32_t a0, uint32_t a1,43uint32_t a2, uint32_t a3) {44return Average2(Average2(a0, a1), Average2(a2, a3));45}4647static WEBP_INLINE uint32_t Clip255(uint32_t a) {48if (a < 256) {49return a;50}51// return 0, when a is a negative integer.52// return 255, when a is positive.53return ~a >> 24;54}5556static WEBP_INLINE int AddSubtractComponentFull(int a, int b, int c) {57return Clip255((uint32_t)(a + b - c));58}5960static WEBP_INLINE uint32_t ClampedAddSubtractFull(uint32_t c0, uint32_t c1,61uint32_t c2) {62const int a = AddSubtractComponentFull(c0 >> 24, c1 >> 24, c2 >> 24);63const int r = AddSubtractComponentFull((c0 >> 16) & 0xff,64(c1 >> 16) & 0xff,65(c2 >> 16) & 0xff);66const int g = AddSubtractComponentFull((c0 >> 8) & 0xff,67(c1 >> 8) & 0xff,68(c2 >> 8) & 0xff);69const int b = AddSubtractComponentFull(c0 & 0xff, c1 & 0xff, c2 & 0xff);70return ((uint32_t)a << 24) | (r << 16) | (g << 8) | b;71}7273static WEBP_INLINE int AddSubtractComponentHalf(int a, int b) {74return Clip255((uint32_t)(a + (a - b) / 2));75}7677static WEBP_INLINE uint32_t ClampedAddSubtractHalf(uint32_t c0, uint32_t c1,78uint32_t c2) {79const uint32_t ave = Average2(c0, c1);80const int a = AddSubtractComponentHalf(ave >> 24, c2 >> 24);81const int r = AddSubtractComponentHalf((ave >> 16) & 0xff, (c2 >> 16) & 0xff);82const int g = AddSubtractComponentHalf((ave >> 8) & 0xff, (c2 >> 8) & 0xff);83const int b = AddSubtractComponentHalf((ave >> 0) & 0xff, (c2 >> 0) & 0xff);84return ((uint32_t)a << 24) | (r << 16) | (g << 8) | b;85}8687// gcc <= 4.9 on ARM generates incorrect code in Select() when Sub3() is88// inlined.89#if defined(__arm__) && defined(__GNUC__) && LOCAL_GCC_VERSION <= 0x40990# define LOCAL_INLINE __attribute__ ((noinline))91#else92# define LOCAL_INLINE WEBP_INLINE93#endif9495static LOCAL_INLINE int Sub3(int a, int b, int c) {96const int pb = b - c;97const int pa = a - c;98return abs(pb) - abs(pa);99}100101#undef LOCAL_INLINE102103static WEBP_INLINE uint32_t Select(uint32_t a, uint32_t b, uint32_t c) {104const int pa_minus_pb =105Sub3((a >> 24) , (b >> 24) , (c >> 24) ) +106Sub3((a >> 16) & 0xff, (b >> 16) & 0xff, (c >> 16) & 0xff) +107Sub3((a >> 8) & 0xff, (b >> 8) & 0xff, (c >> 8) & 0xff) +108Sub3((a ) & 0xff, (b ) & 0xff, (c ) & 0xff);109return (pa_minus_pb <= 0) ? a : b;110}111112//------------------------------------------------------------------------------113// Predictors114115static uint32_t VP8LPredictor0_C(const uint32_t* const left,116const uint32_t* const top) {117(void)top;118(void)left;119return ARGB_BLACK;120}121static uint32_t VP8LPredictor1_C(const uint32_t* const left,122const uint32_t* const top) {123(void)top;124return *left;125}126uint32_t VP8LPredictor2_C(const uint32_t* const left,127const uint32_t* const top) {128(void)left;129return top[0];130}131uint32_t VP8LPredictor3_C(const uint32_t* const left,132const uint32_t* const top) {133(void)left;134return top[1];135}136uint32_t VP8LPredictor4_C(const uint32_t* const left,137const uint32_t* const top) {138(void)left;139return top[-1];140}141uint32_t VP8LPredictor5_C(const uint32_t* const left,142const uint32_t* const top) {143const uint32_t pred = Average3(*left, top[0], top[1]);144return pred;145}146uint32_t VP8LPredictor6_C(const uint32_t* const left,147const uint32_t* const top) {148const uint32_t pred = Average2(*left, top[-1]);149return pred;150}151uint32_t VP8LPredictor7_C(const uint32_t* const left,152const uint32_t* const top) {153const uint32_t pred = Average2(*left, top[0]);154return pred;155}156uint32_t VP8LPredictor8_C(const uint32_t* const left,157const uint32_t* const top) {158const uint32_t pred = Average2(top[-1], top[0]);159(void)left;160return pred;161}162uint32_t VP8LPredictor9_C(const uint32_t* const left,163const uint32_t* const top) {164const uint32_t pred = Average2(top[0], top[1]);165(void)left;166return pred;167}168uint32_t VP8LPredictor10_C(const uint32_t* const left,169const uint32_t* const top) {170const uint32_t pred = Average4(*left, top[-1], top[0], top[1]);171return pred;172}173uint32_t VP8LPredictor11_C(const uint32_t* const left,174const uint32_t* const top) {175const uint32_t pred = Select(top[0], *left, top[-1]);176return pred;177}178uint32_t VP8LPredictor12_C(const uint32_t* const left,179const uint32_t* const top) {180const uint32_t pred = ClampedAddSubtractFull(*left, top[0], top[-1]);181return pred;182}183uint32_t VP8LPredictor13_C(const uint32_t* const left,184const uint32_t* const top) {185const uint32_t pred = ClampedAddSubtractHalf(*left, top[0], top[-1]);186return pred;187}188189static void PredictorAdd0_C(const uint32_t* in, const uint32_t* upper,190int num_pixels, uint32_t* WEBP_RESTRICT out) {191int x;192(void)upper;193for (x = 0; x < num_pixels; ++x) out[x] = VP8LAddPixels(in[x], ARGB_BLACK);194}195static void PredictorAdd1_C(const uint32_t* in, const uint32_t* upper,196int num_pixels, uint32_t* WEBP_RESTRICT out) {197int i;198uint32_t left = out[-1];199(void)upper;200for (i = 0; i < num_pixels; ++i) {201out[i] = left = VP8LAddPixels(in[i], left);202}203}204GENERATE_PREDICTOR_ADD(VP8LPredictor2_C, PredictorAdd2_C)205GENERATE_PREDICTOR_ADD(VP8LPredictor3_C, PredictorAdd3_C)206GENERATE_PREDICTOR_ADD(VP8LPredictor4_C, PredictorAdd4_C)207GENERATE_PREDICTOR_ADD(VP8LPredictor5_C, PredictorAdd5_C)208GENERATE_PREDICTOR_ADD(VP8LPredictor6_C, PredictorAdd6_C)209GENERATE_PREDICTOR_ADD(VP8LPredictor7_C, PredictorAdd7_C)210GENERATE_PREDICTOR_ADD(VP8LPredictor8_C, PredictorAdd8_C)211GENERATE_PREDICTOR_ADD(VP8LPredictor9_C, PredictorAdd9_C)212GENERATE_PREDICTOR_ADD(VP8LPredictor10_C, PredictorAdd10_C)213GENERATE_PREDICTOR_ADD(VP8LPredictor11_C, PredictorAdd11_C)214GENERATE_PREDICTOR_ADD(VP8LPredictor12_C, PredictorAdd12_C)215GENERATE_PREDICTOR_ADD(VP8LPredictor13_C, PredictorAdd13_C)216217//------------------------------------------------------------------------------218219// Inverse prediction.220static void PredictorInverseTransform_C(const VP8LTransform* const transform,221int y_start, int y_end,222const uint32_t* in, uint32_t* out) {223const int width = transform->xsize;224if (y_start == 0) { // First Row follows the L (mode=1) mode.225PredictorAdd0_C(in, NULL, 1, out);226PredictorAdd1_C(in + 1, NULL, width - 1, out + 1);227in += width;228out += width;229++y_start;230}231232{233int y = y_start;234const int tile_width = 1 << transform->bits;235const int mask = tile_width - 1;236const int tiles_per_row = VP8LSubSampleSize(width, transform->bits);237const uint32_t* pred_mode_base =238transform->data + (y >> transform->bits) * tiles_per_row;239240while (y < y_end) {241const uint32_t* pred_mode_src = pred_mode_base;242int x = 1;243// First pixel follows the T (mode=2) mode.244PredictorAdd2_C(in, out - width, 1, out);245// .. the rest:246while (x < width) {247const VP8LPredictorAddSubFunc pred_func =248VP8LPredictorsAdd[((*pred_mode_src++) >> 8) & 0xf];249int x_end = (x & ~mask) + tile_width;250if (x_end > width) x_end = width;251pred_func(in + x, out + x - width, x_end - x, out + x);252x = x_end;253}254in += width;255out += width;256++y;257if ((y & mask) == 0) { // Use the same mask, since tiles are squares.258pred_mode_base += tiles_per_row;259}260}261}262}263264// Add green to blue and red channels (i.e. perform the inverse transform of265// 'subtract green').266void VP8LAddGreenToBlueAndRed_C(const uint32_t* src, int num_pixels,267uint32_t* dst) {268int i;269for (i = 0; i < num_pixels; ++i) {270const uint32_t argb = src[i];271const uint32_t green = ((argb >> 8) & 0xff);272uint32_t red_blue = (argb & 0x00ff00ffu);273red_blue += (green << 16) | green;274red_blue &= 0x00ff00ffu;275dst[i] = (argb & 0xff00ff00u) | red_blue;276}277}278279static WEBP_INLINE int ColorTransformDelta(int8_t color_pred,280int8_t color) {281return ((int)color_pred * color) >> 5;282}283284static WEBP_INLINE void ColorCodeToMultipliers(uint32_t color_code,285VP8LMultipliers* const m) {286m->green_to_red = (color_code >> 0) & 0xff;287m->green_to_blue = (color_code >> 8) & 0xff;288m->red_to_blue = (color_code >> 16) & 0xff;289}290291void VP8LTransformColorInverse_C(const VP8LMultipliers* const m,292const uint32_t* src, int num_pixels,293uint32_t* dst) {294int i;295for (i = 0; i < num_pixels; ++i) {296const uint32_t argb = src[i];297const int8_t green = (int8_t)(argb >> 8);298const uint32_t red = argb >> 16;299int new_red = red & 0xff;300int new_blue = argb & 0xff;301new_red += ColorTransformDelta((int8_t)m->green_to_red, green);302new_red &= 0xff;303new_blue += ColorTransformDelta((int8_t)m->green_to_blue, green);304new_blue += ColorTransformDelta((int8_t)m->red_to_blue, (int8_t)new_red);305new_blue &= 0xff;306dst[i] = (argb & 0xff00ff00u) | (new_red << 16) | (new_blue);307}308}309310// Color space inverse transform.311static void ColorSpaceInverseTransform_C(const VP8LTransform* const transform,312int y_start, int y_end,313const uint32_t* src, uint32_t* dst) {314const int width = transform->xsize;315const int tile_width = 1 << transform->bits;316const int mask = tile_width - 1;317const int safe_width = width & ~mask;318const int remaining_width = width - safe_width;319const int tiles_per_row = VP8LSubSampleSize(width, transform->bits);320int y = y_start;321const uint32_t* pred_row =322transform->data + (y >> transform->bits) * tiles_per_row;323324while (y < y_end) {325const uint32_t* pred = pred_row;326VP8LMultipliers m = { 0, 0, 0 };327const uint32_t* const src_safe_end = src + safe_width;328const uint32_t* const src_end = src + width;329while (src < src_safe_end) {330ColorCodeToMultipliers(*pred++, &m);331VP8LTransformColorInverse(&m, src, tile_width, dst);332src += tile_width;333dst += tile_width;334}335if (src < src_end) { // Left-overs using C-version.336ColorCodeToMultipliers(*pred++, &m);337VP8LTransformColorInverse(&m, src, remaining_width, dst);338src += remaining_width;339dst += remaining_width;340}341++y;342if ((y & mask) == 0) pred_row += tiles_per_row;343}344}345346// Separate out pixels packed together using pixel-bundling.347// We define two methods for ARGB data (uint32_t) and alpha-only data (uint8_t).348#define COLOR_INDEX_INVERSE(FUNC_NAME, F_NAME, STATIC_DECL, TYPE, BIT_SUFFIX, \349GET_INDEX, GET_VALUE) \350static void F_NAME(const TYPE* src, const uint32_t* const color_map, \351TYPE* dst, int y_start, int y_end, int width) { \352int y; \353for (y = y_start; y < y_end; ++y) { \354int x; \355for (x = 0; x < width; ++x) { \356*dst++ = GET_VALUE(color_map[GET_INDEX(*src++)]); \357} \358} \359} \360STATIC_DECL void FUNC_NAME(const VP8LTransform* const transform, \361int y_start, int y_end, const TYPE* src, \362TYPE* dst) { \363int y; \364const int bits_per_pixel = 8 >> transform->bits; \365const int width = transform->xsize; \366const uint32_t* const color_map = transform->data; \367if (bits_per_pixel < 8) { \368const int pixels_per_byte = 1 << transform->bits; \369const int count_mask = pixels_per_byte - 1; \370const uint32_t bit_mask = (1 << bits_per_pixel) - 1; \371for (y = y_start; y < y_end; ++y) { \372uint32_t packed_pixels = 0; \373int x; \374for (x = 0; x < width; ++x) { \375/* We need to load fresh 'packed_pixels' once every */ \376/* 'pixels_per_byte' increments of x. Fortunately, pixels_per_byte */ \377/* is a power of 2, so can just use a mask for that, instead of */ \378/* decrementing a counter. */ \379if ((x & count_mask) == 0) packed_pixels = GET_INDEX(*src++); \380*dst++ = GET_VALUE(color_map[packed_pixels & bit_mask]); \381packed_pixels >>= bits_per_pixel; \382} \383} \384} else { \385VP8LMapColor##BIT_SUFFIX(src, color_map, dst, y_start, y_end, width); \386} \387}388389COLOR_INDEX_INVERSE(ColorIndexInverseTransform_C, MapARGB_C, static,390uint32_t, 32b, VP8GetARGBIndex, VP8GetARGBValue)391COLOR_INDEX_INVERSE(VP8LColorIndexInverseTransformAlpha, MapAlpha_C, ,392uint8_t, 8b, VP8GetAlphaIndex, VP8GetAlphaValue)393394#undef COLOR_INDEX_INVERSE395396void VP8LInverseTransform(const VP8LTransform* const transform,397int row_start, int row_end,398const uint32_t* const in, uint32_t* const out) {399const int width = transform->xsize;400assert(row_start < row_end);401assert(row_end <= transform->ysize);402switch (transform->type) {403case SUBTRACT_GREEN_TRANSFORM:404VP8LAddGreenToBlueAndRed(in, (row_end - row_start) * width, out);405break;406case PREDICTOR_TRANSFORM:407PredictorInverseTransform_C(transform, row_start, row_end, in, out);408if (row_end != transform->ysize) {409// The last predicted row in this iteration will be the top-pred row410// for the first row in next iteration.411memcpy(out - width, out + (row_end - row_start - 1) * width,412width * sizeof(*out));413}414break;415case CROSS_COLOR_TRANSFORM:416ColorSpaceInverseTransform_C(transform, row_start, row_end, in, out);417break;418case COLOR_INDEXING_TRANSFORM:419if (in == out && transform->bits > 0) {420// Move packed pixels to the end of unpacked region, so that unpacking421// can occur seamlessly.422// Also, note that this is the only transform that applies on423// the effective width of VP8LSubSampleSize(xsize, bits). All other424// transforms work on effective width of 'xsize'.425const int out_stride = (row_end - row_start) * width;426const int in_stride = (row_end - row_start) *427VP8LSubSampleSize(transform->xsize, transform->bits);428uint32_t* const src = out + out_stride - in_stride;429memmove(src, out, in_stride * sizeof(*src));430ColorIndexInverseTransform_C(transform, row_start, row_end, src, out);431} else {432ColorIndexInverseTransform_C(transform, row_start, row_end, in, out);433}434break;435}436}437438//------------------------------------------------------------------------------439// Color space conversion.440441static int is_big_endian(void) {442static const union {443uint16_t w;444uint8_t b[2];445} tmp = { 1 };446return (tmp.b[0] != 1);447}448449void VP8LConvertBGRAToRGB_C(const uint32_t* WEBP_RESTRICT src,450int num_pixels, uint8_t* WEBP_RESTRICT dst) {451const uint32_t* const src_end = src + num_pixels;452while (src < src_end) {453const uint32_t argb = *src++;454*dst++ = (argb >> 16) & 0xff;455*dst++ = (argb >> 8) & 0xff;456*dst++ = (argb >> 0) & 0xff;457}458}459460void VP8LConvertBGRAToRGBA_C(const uint32_t* WEBP_RESTRICT src,461int num_pixels, uint8_t* WEBP_RESTRICT dst) {462const uint32_t* const src_end = src + num_pixels;463while (src < src_end) {464const uint32_t argb = *src++;465*dst++ = (argb >> 16) & 0xff;466*dst++ = (argb >> 8) & 0xff;467*dst++ = (argb >> 0) & 0xff;468*dst++ = (argb >> 24) & 0xff;469}470}471472void VP8LConvertBGRAToRGBA4444_C(const uint32_t* WEBP_RESTRICT src,473int num_pixels, uint8_t* WEBP_RESTRICT dst) {474const uint32_t* const src_end = src + num_pixels;475while (src < src_end) {476const uint32_t argb = *src++;477const uint8_t rg = ((argb >> 16) & 0xf0) | ((argb >> 12) & 0xf);478const uint8_t ba = ((argb >> 0) & 0xf0) | ((argb >> 28) & 0xf);479#if (WEBP_SWAP_16BIT_CSP == 1)480*dst++ = ba;481*dst++ = rg;482#else483*dst++ = rg;484*dst++ = ba;485#endif486}487}488489void VP8LConvertBGRAToRGB565_C(const uint32_t* WEBP_RESTRICT src,490int num_pixels, uint8_t* WEBP_RESTRICT dst) {491const uint32_t* const src_end = src + num_pixels;492while (src < src_end) {493const uint32_t argb = *src++;494const uint8_t rg = ((argb >> 16) & 0xf8) | ((argb >> 13) & 0x7);495const uint8_t gb = ((argb >> 5) & 0xe0) | ((argb >> 3) & 0x1f);496#if (WEBP_SWAP_16BIT_CSP == 1)497*dst++ = gb;498*dst++ = rg;499#else500*dst++ = rg;501*dst++ = gb;502#endif503}504}505506void VP8LConvertBGRAToBGR_C(const uint32_t* WEBP_RESTRICT src,507int num_pixels, uint8_t* WEBP_RESTRICT dst) {508const uint32_t* const src_end = src + num_pixels;509while (src < src_end) {510const uint32_t argb = *src++;511*dst++ = (argb >> 0) & 0xff;512*dst++ = (argb >> 8) & 0xff;513*dst++ = (argb >> 16) & 0xff;514}515}516517static void CopyOrSwap(const uint32_t* WEBP_RESTRICT src, int num_pixels,518uint8_t* WEBP_RESTRICT dst, int swap_on_big_endian) {519if (is_big_endian() == swap_on_big_endian) {520const uint32_t* const src_end = src + num_pixels;521while (src < src_end) {522const uint32_t argb = *src++;523WebPUint32ToMem(dst, BSwap32(argb));524dst += sizeof(argb);525}526} else {527memcpy(dst, src, num_pixels * sizeof(*src));528}529}530531void VP8LConvertFromBGRA(const uint32_t* const in_data, int num_pixels,532WEBP_CSP_MODE out_colorspace, uint8_t* const rgba) {533switch (out_colorspace) {534case MODE_RGB:535VP8LConvertBGRAToRGB(in_data, num_pixels, rgba);536break;537case MODE_RGBA:538VP8LConvertBGRAToRGBA(in_data, num_pixels, rgba);539break;540case MODE_rgbA:541VP8LConvertBGRAToRGBA(in_data, num_pixels, rgba);542WebPApplyAlphaMultiply(rgba, 0, num_pixels, 1, 0);543break;544case MODE_BGR:545VP8LConvertBGRAToBGR(in_data, num_pixels, rgba);546break;547case MODE_BGRA:548CopyOrSwap(in_data, num_pixels, rgba, 1);549break;550case MODE_bgrA:551CopyOrSwap(in_data, num_pixels, rgba, 1);552WebPApplyAlphaMultiply(rgba, 0, num_pixels, 1, 0);553break;554case MODE_ARGB:555CopyOrSwap(in_data, num_pixels, rgba, 0);556break;557case MODE_Argb:558CopyOrSwap(in_data, num_pixels, rgba, 0);559WebPApplyAlphaMultiply(rgba, 1, num_pixels, 1, 0);560break;561case MODE_RGBA_4444:562VP8LConvertBGRAToRGBA4444(in_data, num_pixels, rgba);563break;564case MODE_rgbA_4444:565VP8LConvertBGRAToRGBA4444(in_data, num_pixels, rgba);566WebPApplyAlphaMultiply4444(rgba, num_pixels, 1, 0);567break;568case MODE_RGB_565:569VP8LConvertBGRAToRGB565(in_data, num_pixels, rgba);570break;571default:572assert(0); // Code flow should not reach here.573}574}575576//------------------------------------------------------------------------------577578VP8LProcessDecBlueAndRedFunc VP8LAddGreenToBlueAndRed;579VP8LProcessDecBlueAndRedFunc VP8LAddGreenToBlueAndRed_SSE;580VP8LPredictorAddSubFunc VP8LPredictorsAdd[16];581VP8LPredictorAddSubFunc VP8LPredictorsAdd_SSE[16];582VP8LPredictorFunc VP8LPredictors[16];583584// exposed plain-C implementations585VP8LPredictorAddSubFunc VP8LPredictorsAdd_C[16];586587VP8LTransformColorInverseFunc VP8LTransformColorInverse;588VP8LTransformColorInverseFunc VP8LTransformColorInverse_SSE;589590VP8LConvertFunc VP8LConvertBGRAToRGB;591VP8LConvertFunc VP8LConvertBGRAToRGB_SSE;592VP8LConvertFunc VP8LConvertBGRAToRGBA;593VP8LConvertFunc VP8LConvertBGRAToRGBA_SSE;594VP8LConvertFunc VP8LConvertBGRAToRGBA4444;595VP8LConvertFunc VP8LConvertBGRAToRGB565;596VP8LConvertFunc VP8LConvertBGRAToBGR;597598VP8LMapARGBFunc VP8LMapColor32b;599VP8LMapAlphaFunc VP8LMapColor8b;600601extern VP8CPUInfo VP8GetCPUInfo;602extern void VP8LDspInitSSE2(void);603extern void VP8LDspInitSSE41(void);604extern void VP8LDspInitAVX2(void);605extern void VP8LDspInitNEON(void);606extern void VP8LDspInitMIPSdspR2(void);607extern void VP8LDspInitMSA(void);608609#define COPY_PREDICTOR_ARRAY(IN, OUT) do { \610(OUT)[0] = IN##0_C; \611(OUT)[1] = IN##1_C; \612(OUT)[2] = IN##2_C; \613(OUT)[3] = IN##3_C; \614(OUT)[4] = IN##4_C; \615(OUT)[5] = IN##5_C; \616(OUT)[6] = IN##6_C; \617(OUT)[7] = IN##7_C; \618(OUT)[8] = IN##8_C; \619(OUT)[9] = IN##9_C; \620(OUT)[10] = IN##10_C; \621(OUT)[11] = IN##11_C; \622(OUT)[12] = IN##12_C; \623(OUT)[13] = IN##13_C; \624(OUT)[14] = IN##0_C; /* <- padding security sentinels*/ \625(OUT)[15] = IN##0_C; \626} while (0);627628WEBP_DSP_INIT_FUNC(VP8LDspInit) {629COPY_PREDICTOR_ARRAY(VP8LPredictor, VP8LPredictors)630COPY_PREDICTOR_ARRAY(PredictorAdd, VP8LPredictorsAdd)631COPY_PREDICTOR_ARRAY(PredictorAdd, VP8LPredictorsAdd_C)632633#if !WEBP_NEON_OMIT_C_CODE634VP8LAddGreenToBlueAndRed = VP8LAddGreenToBlueAndRed_C;635636VP8LTransformColorInverse = VP8LTransformColorInverse_C;637638VP8LConvertBGRAToRGBA = VP8LConvertBGRAToRGBA_C;639VP8LConvertBGRAToRGB = VP8LConvertBGRAToRGB_C;640VP8LConvertBGRAToBGR = VP8LConvertBGRAToBGR_C;641#endif642643VP8LConvertBGRAToRGBA4444 = VP8LConvertBGRAToRGBA4444_C;644VP8LConvertBGRAToRGB565 = VP8LConvertBGRAToRGB565_C;645646VP8LMapColor32b = MapARGB_C;647VP8LMapColor8b = MapAlpha_C;648649// If defined, use CPUInfo() to overwrite some pointers with faster versions.650if (VP8GetCPUInfo != NULL) {651#if defined(WEBP_HAVE_SSE2)652if (VP8GetCPUInfo(kSSE2)) {653VP8LDspInitSSE2();654#if defined(WEBP_HAVE_SSE41)655if (VP8GetCPUInfo(kSSE4_1)) {656VP8LDspInitSSE41();657#if defined(WEBP_HAVE_AVX2)658if (VP8GetCPUInfo(kAVX2)) {659VP8LDspInitAVX2();660}661#endif662}663#endif664}665#endif666#if defined(WEBP_USE_MIPS_DSP_R2)667if (VP8GetCPUInfo(kMIPSdspR2)) {668VP8LDspInitMIPSdspR2();669}670#endif671#if defined(WEBP_USE_MSA)672if (VP8GetCPUInfo(kMSA)) {673VP8LDspInitMSA();674}675#endif676}677678#if defined(WEBP_HAVE_NEON)679if (WEBP_NEON_OMIT_C_CODE ||680(VP8GetCPUInfo != NULL && VP8GetCPUInfo(kNEON))) {681VP8LDspInitNEON();682}683#endif684685assert(VP8LAddGreenToBlueAndRed != NULL);686assert(VP8LTransformColorInverse != NULL);687assert(VP8LConvertBGRAToRGBA != NULL);688assert(VP8LConvertBGRAToRGB != NULL);689assert(VP8LConvertBGRAToBGR != NULL);690assert(VP8LConvertBGRAToRGBA4444 != NULL);691assert(VP8LConvertBGRAToRGB565 != NULL);692assert(VP8LMapColor32b != NULL);693assert(VP8LMapColor8b != NULL);694}695#undef COPY_PREDICTOR_ARRAY696697//------------------------------------------------------------------------------698699700