gfx/ycbcr/yuv_row.h

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

     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.
     5 // yuv_row internal functions to handle YUV conversion and scaling to RGB.
     6 // These functions are used from both yuv_convert.cc and yuv_scale.cc.
     8 // TODO(fbarchard): Write function that can handle rotation and scaling.
    10 #ifndef MEDIA_BASE_YUV_ROW_H_
    11 #define MEDIA_BASE_YUV_ROW_H_
    13 #include "chromium_types.h"
    15 extern "C" {
    16 // Can only do 1x.
    17 // This is the second fastest of the scalers.
    18 void FastConvertYUVToRGB32Row(const uint8* y_buf,
    19                               const uint8* u_buf,
    20                               const uint8* v_buf,
    21                               uint8* rgb_buf,
    22                               int width);
    24 void FastConvertYUVToRGB32Row_C(const uint8* y_buf,
    25                                 const uint8* u_buf,
    26                                 const uint8* v_buf,
    27                                 uint8* rgb_buf,
    28                                 int width,
    29                                 unsigned int x_shift);
    31 void FastConvertYUVToRGB32Row(const uint8* y_buf,
    32                               const uint8* u_buf,
    33                               const uint8* v_buf,
    34                               uint8* rgb_buf,
    35                               int width);
    37 // Can do 1x, half size or any scale down by an integer amount.
    38 // Step can be negative (mirroring, rotate 180).
    39 // This is the third fastest of the scalers.
    40 // Only defined on Windows x86-32.
    41 void ConvertYUVToRGB32Row_SSE(const uint8* y_buf,
    42                               const uint8* u_buf,
    43                               const uint8* v_buf,
    44                               uint8* rgb_buf,
    45                               int width,
    46                               int step);
    48 // Rotate is like Convert, but applies different step to Y versus U and V.
    49 // This allows rotation by 90 or 270, by stepping by stride.
    50 // This is the forth fastest of the scalers.
    51 // Only defined on Windows x86-32.
    52 void RotateConvertYUVToRGB32Row_SSE(const uint8* y_buf,
    53                                     const uint8* u_buf,
    54                                     const uint8* v_buf,
    55                                     uint8* rgb_buf,
    56                                     int width,
    57                                     int ystep,
    58                                     int uvstep);
    60 // Doubler does 4 pixels at a time.  Each pixel is replicated.
    61 // This is the fastest of the scalers.
    62 // Only defined on Windows x86-32.
    63 void DoubleYUVToRGB32Row_SSE(const uint8* y_buf,
    64                              const uint8* u_buf,
    65                              const uint8* v_buf,
    66                              uint8* rgb_buf,
    67                              int width);
    69 // Handles arbitrary scaling up or down.
    70 // Mirroring is supported, but not 90 or 270 degree rotation.
    71 // Chroma is under sampled every 2 pixels for performance.
    72 void ScaleYUVToRGB32Row(const uint8* y_buf,
    73                         const uint8* u_buf,
    74                         const uint8* v_buf,
    75                         uint8* rgb_buf,
    76                         int width,
    77                         int source_dx);
    79 void ScaleYUVToRGB32Row(const uint8* y_buf,
    80                         const uint8* u_buf,
    81                         const uint8* v_buf,
    82                         uint8* rgb_buf,
    83                         int width,
    84                         int source_dx);
    86 void ScaleYUVToRGB32Row_C(const uint8* y_buf,
    87                           const uint8* u_buf,
    88                           const uint8* v_buf,
    89                           uint8* rgb_buf,
    90                           int width,
    91                           int source_dx);
    93 // Handles arbitrary scaling up or down with bilinear filtering.
    94 // Mirroring is supported, but not 90 or 270 degree rotation.
    95 // Chroma is under sampled every 2 pixels for performance.
    96 // This is the slowest of the scalers.
    97 void LinearScaleYUVToRGB32Row(const uint8* y_buf,
    98                               const uint8* u_buf,
    99                               const uint8* v_buf,
   100                               uint8* rgb_buf,
   101                               int width,
   102                               int source_dx);
   104 void LinearScaleYUVToRGB32Row(const uint8* y_buf,
   105                               const uint8* u_buf,
   106                               const uint8* v_buf,
   107                               uint8* rgb_buf,
   108                               int width,
   109                               int source_dx);
   111 void LinearScaleYUVToRGB32Row_C(const uint8* y_buf,
   112                                 const uint8* u_buf,
   113                                 const uint8* v_buf,
   114                                 uint8* rgb_buf,
   115                                 int width,
   116                                 int source_dx);
   119 #if defined(_MSC_VER)
   120 #define SIMD_ALIGNED(var) __declspec(align(16)) var
   121 #else
   122 #define SIMD_ALIGNED(var) var __attribute__((aligned(16)))
   123 #endif
   124 extern SIMD_ALIGNED(int16 kCoefficientsRgbY[768][4]);
   126 // x64 uses MMX2 (SSE) so emms is not required.
   127 // Warning C4799: function has no EMMS instruction.
   128 // EMMS() is slow and should be called by the calling function once per image.
   129 #if defined(ARCH_CPU_X86) && !defined(ARCH_CPU_X86_64)
   130 #if defined(_MSC_VER)
   131 #define EMMS() __asm emms
   132 #pragma warning(disable: 4799)
   133 #else
   134 #define EMMS() asm("emms")
   135 #endif
   136 #else
   137 #define EMMS() ((void)0)
   138 #endif
   140 }  // extern "C"
   142 #endif  // MEDIA_BASE_YUV_ROW_H_

mercurial