Home | History | Annotate | Download | only in libyuv
      1 /*
      2  *  Copyright 2011 The LibYuv Project Authors. All rights reserved.
      3  *
      4  *  Use of this source code is governed by a BSD-style license
      5  *  that can be found in the LICENSE file in the root of the source
      6  *  tree. An additional intellectual property rights grant can be found
      7  *  in the file PATENTS. All contributing project authors may
      8  *  be found in the AUTHORS file in the root of the source tree.
      9  */
     10 
     11 #ifndef INCLUDE_LIBYUV_SCALE_H_
     12 #define INCLUDE_LIBYUV_SCALE_H_
     13 
     14 #include "libyuv/basic_types.h"
     15 
     16 #ifdef __cplusplus
     17 namespace libyuv {
     18 extern "C" {
     19 #endif
     20 
     21 // Supported filtering.
     22 typedef enum FilterMode {
     23   kFilterNone = 0,      // Point sample; Fastest.
     24   kFilterLinear = 1,    // Filter horizontally only.
     25   kFilterBilinear = 2,  // Faster than box, but lower quality scaling down.
     26   kFilterBox = 3        // Highest quality.
     27 } FilterModeEnum;
     28 
     29 // Scale a YUV plane.
     30 LIBYUV_API
     31 void ScalePlane(const uint8* src,
     32                 int src_stride,
     33                 int src_width,
     34                 int src_height,
     35                 uint8* dst,
     36                 int dst_stride,
     37                 int dst_width,
     38                 int dst_height,
     39                 enum FilterMode filtering);
     40 
     41 LIBYUV_API
     42 void ScalePlane_16(const uint16* src,
     43                    int src_stride,
     44                    int src_width,
     45                    int src_height,
     46                    uint16* dst,
     47                    int dst_stride,
     48                    int dst_width,
     49                    int dst_height,
     50                    enum FilterMode filtering);
     51 
     52 // Scales a YUV 4:2:0 image from the src width and height to the
     53 // dst width and height.
     54 // If filtering is kFilterNone, a simple nearest-neighbor algorithm is
     55 // used. This produces basic (blocky) quality at the fastest speed.
     56 // If filtering is kFilterBilinear, interpolation is used to produce a better
     57 // quality image, at the expense of speed.
     58 // If filtering is kFilterBox, averaging is used to produce ever better
     59 // quality image, at further expense of speed.
     60 // Returns 0 if successful.
     61 
     62 LIBYUV_API
     63 int I420Scale(const uint8* src_y,
     64               int src_stride_y,
     65               const uint8* src_u,
     66               int src_stride_u,
     67               const uint8* src_v,
     68               int src_stride_v,
     69               int src_width,
     70               int src_height,
     71               uint8* dst_y,
     72               int dst_stride_y,
     73               uint8* dst_u,
     74               int dst_stride_u,
     75               uint8* dst_v,
     76               int dst_stride_v,
     77               int dst_width,
     78               int dst_height,
     79               enum FilterMode filtering);
     80 
     81 LIBYUV_API
     82 int I420Scale_16(const uint16* src_y,
     83                  int src_stride_y,
     84                  const uint16* src_u,
     85                  int src_stride_u,
     86                  const uint16* src_v,
     87                  int src_stride_v,
     88                  int src_width,
     89                  int src_height,
     90                  uint16* dst_y,
     91                  int dst_stride_y,
     92                  uint16* dst_u,
     93                  int dst_stride_u,
     94                  uint16* dst_v,
     95                  int dst_stride_v,
     96                  int dst_width,
     97                  int dst_height,
     98                  enum FilterMode filtering);
     99 
    100 #ifdef __cplusplus
    101 // Legacy API.  Deprecated.
    102 LIBYUV_API
    103 int Scale(const uint8* src_y,
    104           const uint8* src_u,
    105           const uint8* src_v,
    106           int src_stride_y,
    107           int src_stride_u,
    108           int src_stride_v,
    109           int src_width,
    110           int src_height,
    111           uint8* dst_y,
    112           uint8* dst_u,
    113           uint8* dst_v,
    114           int dst_stride_y,
    115           int dst_stride_u,
    116           int dst_stride_v,
    117           int dst_width,
    118           int dst_height,
    119           LIBYUV_BOOL interpolate);
    120 
    121 // Legacy API.  Deprecated.
    122 LIBYUV_API
    123 int ScaleOffset(const uint8* src_i420,
    124                 int src_width,
    125                 int src_height,
    126                 uint8* dst_i420,
    127                 int dst_width,
    128                 int dst_height,
    129                 int dst_yoffset,
    130                 LIBYUV_BOOL interpolate);
    131 
    132 // For testing, allow disabling of specialized scalers.
    133 LIBYUV_API
    134 void SetUseReferenceImpl(LIBYUV_BOOL use);
    135 #endif  // __cplusplus
    136 
    137 #ifdef __cplusplus
    138 }  // extern "C"
    139 }  // namespace libyuv
    140 #endif
    141 
    142 #endif  // INCLUDE_LIBYUV_SCALE_H_
    143