tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

yuv_convert.h (4753B)


      1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 
      5 // clang-format off
      6 
      7 #ifndef MEDIA_BASE_YUV_CONVERT_H_
      8 #define MEDIA_BASE_YUV_CONVERT_H_
      9 
     10 #include "ErrorList.h"
     11 #include "chromium_types.h"
     12 #include "mozilla/gfx/Types.h"
     13 
     14 namespace mozilla {
     15 
     16 namespace gfx {
     17 
     18 // Type of YUV surface.
     19 // The value of these enums matter as they are used to shift vertical indices.
     20 enum YUVType {
     21  YV12 = 0,           // YV12 is half width and half height chroma channels.
     22  YV16 = 1,           // YV16 is half width and full height chroma channels.
     23  YV24 = 2,           // YV24 is full width and full height chroma channels.
     24  Y8 = 3              // Y8 is monochrome: no chroma channels.
     25 };
     26 
     27 // Mirror means flip the image horizontally, as in looking in a mirror.
     28 // Rotate happens after mirroring.
     29 enum Rotate {
     30  ROTATE_0,           // Rotation off.
     31  ROTATE_90,          // Rotate clockwise.
     32  ROTATE_180,         // Rotate upside down.
     33  ROTATE_270,         // Rotate counter clockwise.
     34  MIRROR_ROTATE_0,    // Mirror horizontally.
     35  MIRROR_ROTATE_90,   // Mirror then Rotate clockwise.
     36  MIRROR_ROTATE_180,  // Mirror vertically.
     37  MIRROR_ROTATE_270   // Transpose.
     38 };
     39 
     40 // Filter affects how scaling looks.
     41 enum ScaleFilter {
     42  FILTER_NONE = 0,        // No filter (point sampled).
     43  FILTER_BILINEAR_H = 1,  // Bilinear horizontal filter.
     44  FILTER_BILINEAR_V = 2,  // Bilinear vertical filter.
     45  FILTER_BILINEAR = 3     // Bilinear filter.
     46 };
     47 
     48 nsresult ToNSResult(int aLibyuvResult);
     49 
     50 enum RGB32Type {
     51  ARGB = 0,
     52  ABGR = 1
     53 };
     54 // Convert a frame of YUV to 32 bit ARGB or ABGR.
     55 // Pass in YV16/YV12 depending on source format
     56 nsresult
     57 ConvertYCbCrToRGB32(const uint8_t* yplane,
     58                    const uint8_t* uplane,
     59                    const uint8_t* vplane,
     60                    uint8_t* rgbframe,
     61                    int pic_x,
     62                    int pic_y,
     63                    int pic_width,
     64                    int pic_height,
     65                    int ystride,
     66                    int uvstride,
     67                    int rgbstride,
     68                    YUVType yuv_type,
     69                    YUVColorSpace yuv_color_space,
     70                    ColorRange color_range,
     71                    RGB32Type rgb32_type);
     72 
     73 nsresult
     74 ConvertYCbCrToRGB32_deprecated(const uint8_t* yplane,
     75                               const uint8_t* uplane,
     76                               const uint8_t* vplane,
     77                               uint8_t* rgbframe,
     78                               int pic_x,
     79                               int pic_y,
     80                               int pic_width,
     81                               int pic_height,
     82                               int ystride,
     83                               int uvstride,
     84                               int rgbstride,
     85                               YUVType yuv_type,
     86                              RGB32Type rgb32_type);
     87 
     88 // Scale a frame of YUV to 32 bit ARGB.
     89 // Supports rotation and mirroring.
     90 nsresult
     91 ScaleYCbCrToRGB32(const uint8_t* yplane,
     92                  const uint8_t* uplane,
     93                  const uint8_t* vplane,
     94                  uint8_t* rgbframe,
     95                  int source_width,
     96                  int source_height,
     97                  int width,
     98                  int height,
     99                  int ystride,
    100                  int uvstride,
    101                  int rgbstride,
    102                  YUVType yuv_type,
    103                  YUVColorSpace yuv_color_space,
    104                  ScaleFilter filter);
    105 
    106 nsresult
    107 ScaleYCbCrToRGB32_deprecated(const uint8_t* yplane,
    108                             const uint8_t* uplane,
    109                             const uint8_t* vplane,
    110                             uint8_t* rgbframe,
    111                             int source_width,
    112                             int source_height,
    113                             int width,
    114                             int height,
    115                             int ystride,
    116                             int uvstride,
    117                             int rgbstride,
    118                             YUVType yuv_type,
    119                             Rotate view_rotate,
    120                             ScaleFilter filter);
    121 
    122 nsresult
    123 ConvertI420AlphaToARGB32(const uint8_t* yplane,
    124                         const uint8_t* uplane,
    125                         const uint8_t* vplane,
    126                         const uint8_t* aplane,
    127                         uint8_t* argbframe,
    128                         int pic_width,
    129                         int pic_height,
    130                         int yastride,
    131                         int uvstride,
    132                         int argbstride);
    133 
    134 } // namespace gfx
    135 } // namespace mozilla
    136 
    137 #endif  // MEDIA_BASE_YUV_CONVERT_H_