chromium/third_party/libyuv/source/scale_uv.cc

/*
 *  Copyright 2020 The LibYuv Project Authors. All rights reserved.
 *
 *  Use of this source code is governed by a BSD-style license
 *  that can be found in the LICENSE 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.
 */

#include "libyuv/scale_uv.h"

#include <assert.h>
#include <string.h>

#include "libyuv/cpu_id.h"
#include "libyuv/planar_functions.h"  // For CopyUV
#include "libyuv/row.h"
#include "libyuv/scale_row.h"

#ifdef __cplusplus
namespace libyuv {
extern "C" {
#endif

// Macros to enable specialized scalers

#ifndef HAS_SCALEUVDOWN2
#define HAS_SCALEUVDOWN2
#endif
#ifndef HAS_SCALEUVDOWN4BOX
#define HAS_SCALEUVDOWN4BOX
#endif
#ifndef HAS_SCALEUVDOWNEVEN
#define HAS_SCALEUVDOWNEVEN
#endif
#ifndef HAS_SCALEUVBILINEARDOWN
#define HAS_SCALEUVBILINEARDOWN
#endif
#ifndef HAS_SCALEUVBILINEARUP
#define HAS_SCALEUVBILINEARUP
#endif
#ifndef HAS_UVCOPY
#define HAS_UVCOPY
#endif
#ifndef HAS_SCALEPLANEVERTICAL
#define HAS_SCALEPLANEVERTICAL
#endif

static __inline int Abs(int v) {}

// ScaleUV, 1/2
// This is an optimized version for scaling down a UV to 1/2 of
// its original size.
#if HAS_SCALEUVDOWN2
static void ScaleUVDown2(int src_width,
                         int src_height,
                         int dst_width,
                         int dst_height,
                         int src_stride,
                         int dst_stride,
                         const uint8_t* src_uv,
                         uint8_t* dst_uv,
                         int x,
                         int dx,
                         int y,
                         int dy,
                         enum FilterMode filtering) {}
#endif  // HAS_SCALEUVDOWN2

// ScaleUV, 1/4
// This is an optimized version for scaling down a UV to 1/4 of
// its original size.
#if HAS_SCALEUVDOWN4BOX
static int ScaleUVDown4Box(int src_width,
                           int src_height,
                           int dst_width,
                           int dst_height,
                           int src_stride,
                           int dst_stride,
                           const uint8_t* src_uv,
                           uint8_t* dst_uv,
                           int x,
                           int dx,
                           int y,
                           int dy) {}
#endif  // HAS_SCALEUVDOWN4BOX

// ScaleUV Even
// This is an optimized version for scaling down a UV to even
// multiple of its original size.
#if HAS_SCALEUVDOWNEVEN
static void ScaleUVDownEven(int src_width,
                            int src_height,
                            int dst_width,
                            int dst_height,
                            int src_stride,
                            int dst_stride,
                            const uint8_t* src_uv,
                            uint8_t* dst_uv,
                            int x,
                            int dx,
                            int y,
                            int dy,
                            enum FilterMode filtering) {}
#endif

// Scale UV down with bilinear interpolation.
#if HAS_SCALEUVBILINEARDOWN
static int ScaleUVBilinearDown(int src_width,
                               int src_height,
                               int dst_width,
                               int dst_height,
                               int src_stride,
                               int dst_stride,
                               const uint8_t* src_uv,
                               uint8_t* dst_uv,
                               int x,
                               int dx,
                               int y,
                               int dy,
                               enum FilterMode filtering) {}
#endif

// Scale UV up with bilinear interpolation.
#if HAS_SCALEUVBILINEARUP
static int ScaleUVBilinearUp(int src_width,
                             int src_height,
                             int dst_width,
                             int dst_height,
                             int src_stride,
                             int dst_stride,
                             const uint8_t* src_uv,
                             uint8_t* dst_uv,
                             int x,
                             int dx,
                             int y,
                             int dy,
                             enum FilterMode filtering) {}
#endif  // HAS_SCALEUVBILINEARUP

// Scale UV, horizontally up by 2 times.
// Uses linear filter horizontally, nearest vertically.
// This is an optimized version for scaling up a plane to 2 times of
// its original width, using linear interpolation.
// This is used to scale U and V planes of NV16 to NV24.
static void ScaleUVLinearUp2(int src_width,
                             int src_height,
                             int dst_width,
                             int dst_height,
                             int src_stride,
                             int dst_stride,
                             const uint8_t* src_uv,
                             uint8_t* dst_uv) {}

// Scale plane, up by 2 times.
// This is an optimized version for scaling up a plane to 2 times of
// its original size, using bilinear interpolation.
// This is used to scale U and V planes of NV12 to NV24.
static void ScaleUVBilinearUp2(int src_width,
                               int src_height,
                               int dst_width,
                               int dst_height,
                               int src_stride,
                               int dst_stride,
                               const uint8_t* src_ptr,
                               uint8_t* dst_ptr) {}

// Scale 16 bit UV, horizontally up by 2 times.
// Uses linear filter horizontally, nearest vertically.
// This is an optimized version for scaling up a plane to 2 times of
// its original width, using linear interpolation.
// This is used to scale U and V planes of P210 to P410.
static void ScaleUVLinearUp2_16(int src_width,
                                int src_height,
                                int dst_width,
                                int dst_height,
                                int src_stride,
                                int dst_stride,
                                const uint16_t* src_uv,
                                uint16_t* dst_uv) {}

// Scale 16 bit UV, up by 2 times.
// This is an optimized version for scaling up a plane to 2 times of
// its original size, using bilinear interpolation.
// This is used to scale U and V planes of P010 to P410.
static void ScaleUVBilinearUp2_16(int src_width,
                                  int src_height,
                                  int dst_width,
                                  int dst_height,
                                  int src_stride,
                                  int dst_stride,
                                  const uint16_t* src_ptr,
                                  uint16_t* dst_ptr) {}

// Scale UV to/from any dimensions, without interpolation.
// Fixed point math is used for performance: The upper 16 bits
// of x and dx is the integer part of the source position and
// the lower 16 bits are the fixed decimal part.

static void ScaleUVSimple(int src_width,
                          int src_height,
                          int dst_width,
                          int dst_height,
                          int src_stride,
                          int dst_stride,
                          const uint8_t* src_uv,
                          uint8_t* dst_uv,
                          int x,
                          int dx,
                          int y,
                          int dy) {}

// Copy UV with optional flipping
#if HAS_UVCOPY
static int UVCopy(const uint8_t* src_uv,
                  int src_stride_uv,
                  uint8_t* dst_uv,
                  int dst_stride_uv,
                  int width,
                  int height) {}

static int UVCopy_16(const uint16_t* src_uv,
                     int src_stride_uv,
                     uint16_t* dst_uv,
                     int dst_stride_uv,
                     int width,
                     int height) {}
#endif  // HAS_UVCOPY

// Scale a UV plane (from NV12)
// This function in turn calls a scaling function
// suitable for handling the desired resolutions.
static int ScaleUV(const uint8_t* src,
                   int src_stride,
                   int src_width,
                   int src_height,
                   uint8_t* dst,
                   int dst_stride,
                   int dst_width,
                   int dst_height,
                   int clip_x,
                   int clip_y,
                   int clip_width,
                   int clip_height,
                   enum FilterMode filtering) {}

// Scale an UV image.
LIBYUV_API
int UVScale(const uint8_t* src_uv,
            int src_stride_uv,
            int src_width,
            int src_height,
            uint8_t* dst_uv,
            int dst_stride_uv,
            int dst_width,
            int dst_height,
            enum FilterMode filtering) {}

// Scale a 16 bit UV image.
// This function is currently incomplete, it can't handle all cases.
LIBYUV_API
int UVScale_16(const uint16_t* src_uv,
               int src_stride_uv,
               int src_width,
               int src_height,
               uint16_t* dst_uv,
               int dst_stride_uv,
               int dst_width,
               int dst_height,
               enum FilterMode filtering) {}

#ifdef __cplusplus
}  // extern "C"
}  // namespace libyuv
#endif