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_PLANAR_FUNCTIONS_H_  // NOLINT
     12 #define INCLUDE_LIBYUV_PLANAR_FUNCTIONS_H_
     13 
     14 #include "libyuv/basic_types.h"
     15 
     16 // TODO(fbarchard): Remove the following headers includes.
     17 #include "libyuv/convert.h"
     18 #include "libyuv/convert_argb.h"
     19 
     20 #ifdef __cplusplus
     21 namespace libyuv {
     22 extern "C" {
     23 #endif
     24 
     25 LIBYUV_API
     26 void SetPlane(uint8* dst_y, int dst_stride_y,
     27               int width, int height,
     28               uint32 value);
     29 
     30 // Alias.
     31 #define I400ToI400 CopyPlane
     32 
     33 // Copy a plane of data (I420 to I400).
     34 LIBYUV_API
     35 void CopyPlane(const uint8* src_y, int src_stride_y,
     36                uint8* dst_y, int dst_stride_y,
     37                int width, int height);
     38 
     39 // Convert YUY2 to I422.
     40 LIBYUV_API
     41 int YUY2ToI422(const uint8* src_yuy2, int src_stride_yuy2,
     42                uint8* dst_y, int dst_stride_y,
     43                uint8* dst_u, int dst_stride_u,
     44                uint8* dst_v, int dst_stride_v,
     45                int width, int height);
     46 
     47 // Convert UYVY to I422.
     48 int UYVYToI422(const uint8* src_uyvy, int src_stride_uyvy,
     49                uint8* dst_y, int dst_stride_y,
     50                uint8* dst_u, int dst_stride_u,
     51                uint8* dst_v, int dst_stride_v,
     52                int width, int height);
     53 
     54 // Convert I420 to I400. (calls CopyPlane ignoring u/v).
     55 LIBYUV_API
     56 int I420ToI400(const uint8* src_y, int src_stride_y,
     57                uint8* dst_y, int dst_stride_y,
     58                uint8* dst_u, int dst_stride_u,
     59                uint8* dst_v, int dst_stride_v,
     60                int width, int height);
     61 
     62 // I420 mirror.
     63 LIBYUV_API
     64 int I420Mirror(const uint8* src_y, int src_stride_y,
     65                const uint8* src_u, int src_stride_u,
     66                const uint8* src_v, int src_stride_v,
     67                uint8* dst_y, int dst_stride_y,
     68                uint8* dst_u, int dst_stride_u,
     69                uint8* dst_v, int dst_stride_v,
     70                int width, int height);
     71 
     72 // ARGB mirror.
     73 LIBYUV_API
     74 int ARGBMirror(const uint8* src_argb, int src_stride_argb,
     75                uint8* dst_argb, int dst_stride_argb,
     76                int width, int height);
     77 
     78 // Convert NV12 to RGB565.
     79 LIBYUV_API
     80 int NV12ToRGB565(const uint8* src_y, int src_stride_y,
     81                  const uint8* src_uv, int src_stride_uv,
     82                  uint8* dst_rgb565, int dst_stride_rgb565,
     83                  int width, int height);
     84 
     85 // Convert NV21 to RGB565.
     86 LIBYUV_API
     87 int NV21ToRGB565(const uint8* src_y, int src_stride_y,
     88                  const uint8* src_uv, int src_stride_uv,
     89                  uint8* dst_rgb565, int dst_stride_rgb565,
     90                  int width, int height);
     91 
     92 // Aliases.
     93 #define ARGBToBGRA BGRAToARGB
     94 #define ARGBToABGR ABGRToARGB
     95 
     96 // Convert ARGB To RGBA.
     97 LIBYUV_API
     98 int ARGBToRGBA(const uint8* src_frame, int src_stride_frame,
     99                uint8* dst_argb, int dst_stride_argb,
    100                int width, int height);
    101 
    102 // Convert ARGB To RGB24.
    103 LIBYUV_API
    104 int ARGBToRGB24(const uint8* src_argb, int src_stride_argb,
    105                 uint8* dst_rgb24, int dst_stride_rgb24,
    106                 int width, int height);
    107 
    108 // Convert ARGB To RAW.
    109 LIBYUV_API
    110 int ARGBToRAW(const uint8* src_argb, int src_stride_argb,
    111               uint8* dst_rgb, int dst_stride_rgb,
    112               int width, int height);
    113 
    114 // Convert ARGB To RGB565.
    115 LIBYUV_API
    116 int ARGBToRGB565(const uint8* src_argb, int src_stride_argb,
    117                  uint8* dst_rgb565, int dst_stride_rgb565,
    118                  int width, int height);
    119 
    120 // Convert ARGB To ARGB1555.
    121 LIBYUV_API
    122 int ARGBToARGB1555(const uint8* src_argb, int src_stride_argb,
    123                    uint8* dst_argb1555, int dst_stride_argb1555,
    124                    int width, int height);
    125 
    126 // Convert ARGB To ARGB4444.
    127 LIBYUV_API
    128 int ARGBToARGB4444(const uint8* src_argb, int src_stride_argb,
    129                    uint8* dst_argb4444, int dst_stride_argb4444,
    130                    int width, int height);
    131 
    132 // Convert ARGB to I400.
    133 LIBYUV_API
    134 int ARGBToI400(const uint8* src_argb, int src_stride_argb,
    135                uint8* dst_y, int dst_stride_y,
    136                int width, int height);
    137 
    138 // ARGB little endian (bgra in memory) to I422.
    139 LIBYUV_API
    140 int ARGBToI422(const uint8* src_frame, int src_stride_frame,
    141                uint8* dst_y, int dst_stride_y,
    142                uint8* dst_u, int dst_stride_u,
    143                uint8* dst_v, int dst_stride_v,
    144                int width, int height);
    145 
    146 // I422ToARGB is in convert_argb.h
    147 // Convert I422 to BGRA.
    148 LIBYUV_API
    149 int I422ToBGRA(const uint8* src_y, int src_stride_y,
    150                const uint8* src_u, int src_stride_u,
    151                const uint8* src_v, int src_stride_v,
    152                uint8* dst_bgra, int dst_stride_bgra,
    153                int width, int height);
    154 
    155 // Convert I422 to ABGR.
    156 LIBYUV_API
    157 int I422ToABGR(const uint8* src_y, int src_stride_y,
    158                const uint8* src_u, int src_stride_u,
    159                const uint8* src_v, int src_stride_v,
    160                uint8* dst_abgr, int dst_stride_abgr,
    161                int width, int height);
    162 
    163 // Convert I422 to RGBA.
    164 LIBYUV_API
    165 int I422ToRGBA(const uint8* src_y, int src_stride_y,
    166                const uint8* src_u, int src_stride_u,
    167                const uint8* src_v, int src_stride_v,
    168                uint8* dst_rgba, int dst_stride_rgba,
    169                int width, int height);
    170 
    171 // Draw a rectangle into I420.
    172 LIBYUV_API
    173 int I420Rect(uint8* dst_y, int dst_stride_y,
    174              uint8* dst_u, int dst_stride_u,
    175              uint8* dst_v, int dst_stride_v,
    176              int x, int y, int width, int height,
    177              int value_y, int value_u, int value_v);
    178 
    179 // Draw a rectangle into ARGB.
    180 LIBYUV_API
    181 int ARGBRect(uint8* dst_argb, int dst_stride_argb,
    182              int x, int y, int width, int height, uint32 value);
    183 
    184 // Convert ARGB to gray scale ARGB.
    185 LIBYUV_API
    186 int ARGBGrayTo(const uint8* src_argb, int src_stride_argb,
    187                uint8* dst_argb, int dst_stride_argb,
    188                int width, int height);
    189 
    190 // Make a rectangle of ARGB gray scale.
    191 LIBYUV_API
    192 int ARGBGray(uint8* dst_argb, int dst_stride_argb,
    193              int x, int y, int width, int height);
    194 
    195 // Make a rectangle of ARGB Sepia tone.
    196 LIBYUV_API
    197 int ARGBSepia(uint8* dst_argb, int dst_stride_argb,
    198               int x, int y, int width, int height);
    199 
    200 // Apply a matrix rotation to each ARGB pixel.
    201 // matrix_argb is 3 signed ARGB values. -128 to 127 representing -1 to 1.
    202 // The first 4 coefficients apply to B, G, R, A and produce B of the output.
    203 // The next 4 coefficients apply to B, G, R, A and produce G of the output.
    204 // The last 4 coefficients apply to B, G, R, A and produce R of the output.
    205 LIBYUV_API
    206 int ARGBColorMatrix(uint8* dst_argb, int dst_stride_argb,
    207                     const int8* matrix_argb,
    208                     int x, int y, int width, int height);
    209 
    210 // Apply a color table each ARGB pixel.
    211 // Table contains 256 ARGB values.
    212 LIBYUV_API
    213 int ARGBColorTable(uint8* dst_argb, int dst_stride_argb,
    214                    const uint8* table_argb,
    215                    int x, int y, int width, int height);
    216 
    217 // Quantize a rectangle of ARGB. Alpha unaffected.
    218 // scale is a 16 bit fractional fixed point scaler between 0 and 65535.
    219 // interval_size should be a value between 1 and 255.
    220 // interval_offset should be a value between 0 and 255.
    221 LIBYUV_API
    222 int ARGBQuantize(uint8* dst_argb, int dst_stride_argb,
    223                  int scale, int interval_size, int interval_offset,
    224                  int x, int y, int width, int height);
    225 
    226 // Copy ARGB to ARGB.
    227 LIBYUV_API
    228 int ARGBCopy(const uint8* src_argb, int src_stride_argb,
    229              uint8* dst_argb, int dst_stride_argb,
    230              int width, int height);
    231 
    232 typedef void (*ARGBBlendRow)(const uint8* src_argb0, const uint8* src_argb1,
    233                              uint8* dst_argb, int width);
    234 
    235 // Get function to Alpha Blend ARGB pixels and store to destination.
    236 LIBYUV_API
    237 ARGBBlendRow GetARGBBlend();
    238 
    239 // Alpha Blend ARGB images and store to destination.
    240 // Alpha of destination is set to 255.
    241 LIBYUV_API
    242 int ARGBBlend(const uint8* src_argb0, int src_stride_argb0,
    243               const uint8* src_argb1, int src_stride_argb1,
    244               uint8* dst_argb, int dst_stride_argb,
    245               int width, int height);
    246 
    247 // Convert I422 to YUY2.
    248 LIBYUV_API
    249 int I422ToYUY2(const uint8* src_y, int src_stride_y,
    250                const uint8* src_u, int src_stride_u,
    251                const uint8* src_v, int src_stride_v,
    252                uint8* dst_frame, int dst_stride_frame,
    253                int width, int height);
    254 
    255 // Convert I422 to UYVY.
    256 LIBYUV_API
    257 int I422ToUYVY(const uint8* src_y, int src_stride_y,
    258                const uint8* src_u, int src_stride_u,
    259                const uint8* src_v, int src_stride_v,
    260                uint8* dst_frame, int dst_stride_frame,
    261                int width, int height);
    262 
    263 // Convert unattentuated ARGB to preattenuated ARGB.
    264 LIBYUV_API
    265 int ARGBAttenuate(const uint8* src_argb, int src_stride_argb,
    266                   uint8* dst_argb, int dst_stride_argb,
    267                   int width, int height);
    268 
    269 // Convert preattentuated ARGB to unattenuated ARGB.
    270 LIBYUV_API
    271 int ARGBUnattenuate(const uint8* src_argb, int src_stride_argb,
    272                     uint8* dst_argb, int dst_stride_argb,
    273                     int width, int height);
    274 
    275 // Convert MJPG to ARGB.
    276 LIBYUV_API
    277 int MJPGToARGB(const uint8* sample, size_t sample_size,
    278                uint8* argb, int argb_stride,
    279                int w, int h, int dw, int dh);
    280 
    281 // Computes table of cumulative sum for image where the value is the sum
    282 // of all values above and to the left of the entry. Used by ARGBBlur.
    283 LIBYUV_API
    284 int ARGBComputeCumulativeSum(const uint8* src_argb, int src_stride_argb,
    285                              int32* dst_cumsum, int dst_stride32_cumsum,
    286                              int width, int height);
    287 
    288 // Blur ARGB image.
    289 // Caller should allocate dst_cumsum table of width * height * 16 bytes aligned
    290 // to 16 byte boundary.
    291 LIBYUV_API
    292 int ARGBBlur(const uint8* src_argb, int src_stride_argb,
    293              uint8* dst_argb, int dst_stride_argb,
    294              int32* dst_cumsum, int dst_stride32_cumsum,
    295              int width, int height, int radius);
    296 
    297 // Multiply ARGB image by ARGB value.
    298 LIBYUV_API
    299 int ARGBShade(const uint8* src_argb, int src_stride_argb,
    300               uint8* dst_argb, int dst_stride_argb,
    301               int width, int height, uint32 value);
    302 
    303 // Interpolate between two ARGB images using specified amount of interpolation
    304 // (0 to 255) and store to destination.
    305 // 'interpolation' is specified as 8 bit fraction where 0 means 100% src_argb0
    306 // and 255 means 1% src_argb0 and 99% src_argb1.
    307 // Internally uses ARGBScale bilinear filtering.
    308 // Caveat: This function will write up to 16 bytes beyond the end of dst_argb.
    309 LIBYUV_API
    310 int ARGBInterpolate(const uint8* src_argb0, int src_stride_argb0,
    311                     const uint8* src_argb1, int src_stride_argb1,
    312                     uint8* dst_argb, int dst_stride_argb,
    313                     int width, int height, int interpolation);
    314 
    315 #if defined(__CLR_VER) || defined(COVERAGE_ENABLED) || \
    316     defined(TARGET_IPHONE_SIMULATOR)
    317 #define YUV_DISABLE_ASM
    318 #endif
    319 // Row functions for copying a pixels from a source with a slope to a row
    320 // of destination. Useful for scaling, rotation, mirror, texture mapping.
    321 LIBYUV_API
    322 void ARGBAffineRow_C(const uint8* src_argb, int src_argb_stride,
    323                      uint8* dst_argb, const float* uv_dudv, int width);
    324 // The following are available on all x86 platforms:
    325 #if !defined(YUV_DISABLE_ASM) && \
    326     (defined(_M_IX86) || defined(__x86_64__) || defined(__i386__))
    327 LIBYUV_API
    328 void ARGBAffineRow_SSE2(const uint8* src_argb, int src_argb_stride,
    329                         uint8* dst_argb, const float* uv_dudv, int width);
    330 #define HAS_ARGBAFFINEROW_SSE2
    331 #endif
    332 
    333 #ifdef __cplusplus
    334 }  // extern "C"
    335 }  // namespace libyuv
    336 #endif
    337 
    338 #endif  // INCLUDE_LIBYUV_PLANAR_FUNCTIONS_H_  NOLINT
    339