godot/thirdparty/libwebp/src/dsp/upsampling_neon.c

// Copyright 2011 Google Inc. All Rights Reserved.
//
// Use of this source code is governed by a BSD-style license
// that can be found in the COPYING file in the root of the source
// tree. An additional intellectual property rights grant can be found
// in the file PATENTS. All contributing project authors may
// be found in the AUTHORS file in the root of the source tree.
// -----------------------------------------------------------------------------
//
// NEON version of YUV to RGB upsampling functions.
//
// Author: [email protected] (Mans Rullgard)
// Based on SSE code by: [email protected] (Somnath Banerjee)

#include "src/dsp/dsp.h"

#if defined(WEBP_USE_NEON)

#include <assert.h>
#include <arm_neon.h>
#include <string.h>
#include "src/dsp/neon.h"
#include "src/dsp/yuv.h"

#ifdef FANCY_UPSAMPLING

//-----------------------------------------------------------------------------
// U/V upsampling

// Loads 9 pixels each from rows r1 and r2 and generates 16 pixels.
#define UPSAMPLE_16PIXELS

// Turn the macro into a function for reducing code-size when non-critical
static void Upsample16Pixels_NEON(const uint8_t* r1, const uint8_t* r2,
                                  uint8_t* out) {
  UPSAMPLE_16PIXELS(r1, r2, out);
}

#define UPSAMPLE_LAST_BLOCK

//-----------------------------------------------------------------------------
// YUV->RGB conversion

// note: we represent the 33050 large constant as 32768 + 282
static const int16_t kCoeffs1[4] = { 19077, 26149, 6419, 13320 };

#define v255

#define STORE_Rgb

#define STORE_Bgr

#define STORE_Rgba

#define STORE_Bgra

#define STORE_Argb

#if (WEBP_SWAP_16BIT_CSP == 0)
#define ZIP_U8
#else
#define ZIP_U8
#endif

#define STORE_Rgba4444

#define STORE_Rgb565

#define CONVERT8

#define CONVERT1

#define CONVERT2RGB_8

#define CONVERT2RGB_1

#define NEON_UPSAMPLE_FUNC

// NEON variants of the fancy upsampler.
NEON_UPSAMPLE_FUNC(UpsampleRgbaLinePair_NEON, Rgba, 4)
NEON_UPSAMPLE_FUNC(UpsampleBgraLinePair_NEON, Bgra, 4)
#if !defined(WEBP_REDUCE_CSP)
NEON_UPSAMPLE_FUNC(UpsampleRgbLinePair_NEON,  Rgb,  3)
NEON_UPSAMPLE_FUNC(UpsampleBgrLinePair_NEON,  Bgr,  3)
NEON_UPSAMPLE_FUNC(UpsampleArgbLinePair_NEON, Argb, 4)
NEON_UPSAMPLE_FUNC(UpsampleRgba4444LinePair_NEON, Rgba4444, 2)
NEON_UPSAMPLE_FUNC(UpsampleRgb565LinePair_NEON, Rgb565, 2)
#endif   // WEBP_REDUCE_CSP

//------------------------------------------------------------------------------
// Entry point

extern WebPUpsampleLinePairFunc WebPUpsamplers[/* MODE_LAST */];

extern void WebPInitUpsamplersNEON(void);

WEBP_TSAN_IGNORE_FUNCTION void WebPInitUpsamplersNEON(void) {
  WebPUpsamplers[MODE_RGBA] = UpsampleRgbaLinePair_NEON;
  WebPUpsamplers[MODE_BGRA] = UpsampleBgraLinePair_NEON;
  WebPUpsamplers[MODE_rgbA] = UpsampleRgbaLinePair_NEON;
  WebPUpsamplers[MODE_bgrA] = UpsampleBgraLinePair_NEON;
#if !defined(WEBP_REDUCE_CSP)
  WebPUpsamplers[MODE_RGB]  = UpsampleRgbLinePair_NEON;
  WebPUpsamplers[MODE_BGR]  = UpsampleBgrLinePair_NEON;
  WebPUpsamplers[MODE_ARGB] = UpsampleArgbLinePair_NEON;
  WebPUpsamplers[MODE_Argb] = UpsampleArgbLinePair_NEON;
  WebPUpsamplers[MODE_RGB_565] = UpsampleRgb565LinePair_NEON;
  WebPUpsamplers[MODE_RGBA_4444] = UpsampleRgba4444LinePair_NEON;
  WebPUpsamplers[MODE_rgbA_4444] = UpsampleRgba4444LinePair_NEON;
#endif   // WEBP_REDUCE_CSP
}

#endif  // FANCY_UPSAMPLING

#endif  // WEBP_USE_NEON

#if !(defined(FANCY_UPSAMPLING) && defined(WEBP_USE_NEON))
WEBP_DSP_INIT_STUB(WebPInitUpsamplersNEON)
#endif