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.

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

mercurial