Bug 1255655 - Const-ify kCoefficientRgbY. r=jrmuizel.
authorNicholas Nethercote <nnethercote@mozilla.com>
Fri, 11 Mar 2016 13:00:06 +1100
changeset 288852 318273f25e6d460d8e267353efe4f72406587ca1
parent 288851 87dc4355a517fdd4b4273ed0043195a3c2610efd
child 288853 82c47146e4ac3c7cf312db01d2b63f10f5bf09a6
push id30091
push usercbook@mozilla.com
push dateWed, 16 Mar 2016 09:56:40 +0000
treeherdermozilla-central@341344bdec8f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjrmuizel
bugs1255655
milestone48.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1255655 - Const-ify kCoefficientRgbY. r=jrmuizel. This allows it to be shared between processes.
gfx/ycbcr/yuv_row.h
gfx/ycbcr/yuv_row_posix.cpp
gfx/ycbcr/yuv_row_table.cpp
gfx/ycbcr/yuv_row_win64.cpp
--- a/gfx/ycbcr/yuv_row.h
+++ b/gfx/ycbcr/yuv_row.h
@@ -116,17 +116,17 @@ void LinearScaleYUVToRGB32Row_C(const ui
                                 int source_dx);
 
 
 #if defined(_MSC_VER)
 #define SIMD_ALIGNED(var) __declspec(align(16)) var
 #else
 #define SIMD_ALIGNED(var) var __attribute__((aligned(16)))
 #endif
-extern SIMD_ALIGNED(int16 kCoefficientsRgbY[768][4]);
+extern SIMD_ALIGNED(const int16 kCoefficientsRgbY[768][4]);
 
 // x64 uses MMX2 (SSE) so emms is not required.
 // Warning C4799: function has no EMMS instruction.
 // EMMS() is slow and should be called by the calling function once per image.
 #if defined(ARCH_CPU_X86) && !defined(ARCH_CPU_X86_64)
 #if defined(_MSC_VER)
 #define EMMS() __asm emms
 #pragma warning(disable: 4799)
--- a/gfx/ycbcr/yuv_row_posix.cpp
+++ b/gfx/ycbcr/yuv_row_posix.cpp
@@ -566,17 +566,17 @@ void LinearScaleYUVToRGB32Row(const uint
 
 #elif defined(MOZILLA_MAY_SUPPORT_SSE) && defined(ARCH_CPU_X86_32) && defined(__PIC__)
 
 void PICConvertYUVToRGB32Row_SSE(const uint8* y_buf,
                                  const uint8* u_buf,
                                  const uint8* v_buf,
                                  uint8* rgb_buf,
                                  int width,
-                                 int16 *kCoefficientsRgbY);
+                                 const int16 *kCoefficientsRgbY);
 
   asm(
   ".text\n"
 #if defined(XP_MACOSX)
 "_PICConvertYUVToRGB32Row_SSE:\n"
 #else
 "PICConvertYUVToRGB32Row_SSE:\n"
 #endif
@@ -649,17 +649,17 @@ void FastConvertYUVToRGB32Row(const uint
 }
 
 void PICScaleYUVToRGB32Row_SSE(const uint8* y_buf,
                                const uint8* u_buf,
                                const uint8* v_buf,
                                uint8* rgb_buf,
                                int width,
                                int source_dx,
-                               int16 *kCoefficientsRgbY);
+                               const int16 *kCoefficientsRgbY);
 
   asm(
   ".text\n"
 #if defined(XP_MACOSX)
 "_PICScaleYUVToRGB32Row_SSE:\n"
 #else
 "PICScaleYUVToRGB32Row_SSE:\n"
 #endif
@@ -747,17 +747,17 @@ void ScaleYUVToRGB32Row(const uint8* y_b
 }
 
 void PICLinearScaleYUVToRGB32Row_SSE(const uint8* y_buf,
                                      const uint8* u_buf,
                                      const uint8* v_buf,
                                      uint8* rgb_buf,
                                      int width,
                                      int source_dx,
-                                     int16 *kCoefficientsRgbY);
+                                     const int16 *kCoefficientsRgbY);
 
   asm(
   ".text\n"
 #if defined(XP_MACOSX)
 "_PICLinearScaleYUVToRGB32Row_SSE:\n"
 #else
 "PICLinearScaleYUVToRGB32Row_SSE:\n"
 #endif
--- a/gfx/ycbcr/yuv_row_table.cpp
+++ b/gfx/ycbcr/yuv_row_table.cpp
@@ -22,17 +22,17 @@ extern "C" {
 
 #define RGBV(i) { \
   0, \
   static_cast<int16>(-0.813 * 64 * (i - 128) + 0.5), \
   static_cast<int16>(1.596 * 64 * (i - 128) + 0.5), \
   0 \
 }
 
-SIMD_ALIGNED(int16 kCoefficientsRgbY[256 * 3][4]) = {
+SIMD_ALIGNED(const int16 kCoefficientsRgbY[256 * 3][4]) = {
   RGBY(0x00), RGBY(0x01), RGBY(0x02), RGBY(0x03),
   RGBY(0x04), RGBY(0x05), RGBY(0x06), RGBY(0x07),
   RGBY(0x08), RGBY(0x09), RGBY(0x0A), RGBY(0x0B),
   RGBY(0x0C), RGBY(0x0D), RGBY(0x0E), RGBY(0x0F),
   RGBY(0x10), RGBY(0x11), RGBY(0x12), RGBY(0x13),
   RGBY(0x14), RGBY(0x15), RGBY(0x16), RGBY(0x17),
   RGBY(0x18), RGBY(0x19), RGBY(0x1A), RGBY(0x1B),
   RGBY(0x1C), RGBY(0x1D), RGBY(0x1E), RGBY(0x1F),
--- a/gfx/ycbcr/yuv_row_win64.cpp
+++ b/gfx/ycbcr/yuv_row_win64.cpp
@@ -3,53 +3,53 @@
 // found in the LICENSE file.
 
 #include "yuv_row.h"
 
 extern "C" {
 
 // x64 compiler doesn't support MMX and inline assembler.  Use SSE2 intrinsics.
 
-#define kCoefficientsRgbU (reinterpret_cast<uint8*>(kCoefficientsRgbY) + 2048)
-#define kCoefficientsRgbV (reinterpret_cast<uint8*>(kCoefficientsRgbY) + 4096)
+#define kCoefficientsRgbU (reinterpret_cast<const uint8*>(kCoefficientsRgbY) + 2048)
+#define kCoefficientsRgbV (reinterpret_cast<const uint8*>(kCoefficientsRgbY) + 4096)
 
 #include <emmintrin.h>
 
 static void FastConvertYUVToRGB32Row_SSE2(const uint8* y_buf,
                                           const uint8* u_buf,
                                           const uint8* v_buf,
                                           uint8* rgb_buf,
                                           int width) {
   __m128i xmm0, xmmY1, xmmY2;
   __m128  xmmY;
 
   while (width >= 2) {
-    xmm0 = _mm_adds_epi16(_mm_loadl_epi64(reinterpret_cast<__m128i*>(kCoefficientsRgbU + 8 * *u_buf++)),
-                          _mm_loadl_epi64(reinterpret_cast<__m128i*>(kCoefficientsRgbV + 8 * *v_buf++)));
+    xmm0 = _mm_adds_epi16(_mm_loadl_epi64(reinterpret_cast<const __m128i*>(kCoefficientsRgbU + 8 * *u_buf++)),
+                          _mm_loadl_epi64(reinterpret_cast<const __m128i*>(kCoefficientsRgbV + 8 * *v_buf++)));
 
-    xmmY1 = _mm_loadl_epi64(reinterpret_cast<__m128i*>(reinterpret_cast<uint8*>(kCoefficientsRgbY) + 8 * *y_buf++));
+    xmmY1 = _mm_loadl_epi64(reinterpret_cast<const __m128i*>(reinterpret_cast<const uint8*>(kCoefficientsRgbY) + 8 * *y_buf++));
     xmmY1 = _mm_adds_epi16(xmmY1, xmm0);
 
-    xmmY2 = _mm_loadl_epi64(reinterpret_cast<__m128i*>(reinterpret_cast<uint8*>(kCoefficientsRgbY) + 8 * *y_buf++));
+    xmmY2 = _mm_loadl_epi64(reinterpret_cast<const __m128i*>(reinterpret_cast<const uint8*>(kCoefficientsRgbY) + 8 * *y_buf++));
     xmmY2 = _mm_adds_epi16(xmmY2, xmm0);
 
     xmmY = _mm_shuffle_ps(_mm_castsi128_ps(xmmY1), _mm_castsi128_ps(xmmY2),
                           0x44);
     xmmY1 = _mm_srai_epi16(_mm_castps_si128(xmmY), 6);
     xmmY1 = _mm_packus_epi16(xmmY1, xmmY1);
 
     _mm_storel_epi64(reinterpret_cast<__m128i*>(rgb_buf), xmmY1);
     rgb_buf += 8;
     width -= 2;
   }
 
   if (width) {
-    xmm0 = _mm_adds_epi16(_mm_loadl_epi64(reinterpret_cast<__m128i*>(kCoefficientsRgbU + 8 * *u_buf)),
-                          _mm_loadl_epi64(reinterpret_cast<__m128i*>(kCoefficientsRgbV + 8 * *v_buf)));
-    xmmY1 = _mm_loadl_epi64(reinterpret_cast<__m128i*>(reinterpret_cast<uint8*>(kCoefficientsRgbY) + 8 * *y_buf));
+    xmm0 = _mm_adds_epi16(_mm_loadl_epi64(reinterpret_cast<const __m128i*>(kCoefficientsRgbU + 8 * *u_buf)),
+                          _mm_loadl_epi64(reinterpret_cast<const __m128i*>(kCoefficientsRgbV + 8 * *v_buf)));
+    xmmY1 = _mm_loadl_epi64(reinterpret_cast<const __m128i*>(reinterpret_cast<const uint8*>(kCoefficientsRgbY) + 8 * *y_buf));
     xmmY1 = _mm_adds_epi16(xmmY1, xmm0);
     xmmY1 = _mm_srai_epi16(xmmY1, 6);
     xmmY1 = _mm_packus_epi16(xmmY1, xmmY1);
     *reinterpret_cast<uint32*>(rgb_buf) = _mm_cvtsi128_si32(xmmY1);
   }
 }
 
 static void ScaleYUVToRGB32Row_SSE2(const uint8* y_buf,
@@ -64,25 +64,25 @@ static void ScaleYUVToRGB32Row_SSE2(cons
   int x = 0;
 
   while (width >= 2) {
     u = u_buf[x >> 17];
     v = v_buf[x >> 17];
     y = y_buf[x >> 16];
     x += source_dx;
 
-    xmm0 = _mm_adds_epi16(_mm_loadl_epi64(reinterpret_cast<__m128i*>(kCoefficientsRgbU + 8 * u)),
-                          _mm_loadl_epi64(reinterpret_cast<__m128i*>(kCoefficientsRgbV + 8 * v)));
-    xmmY1 = _mm_loadl_epi64(reinterpret_cast<__m128i*>(reinterpret_cast<uint8*>(kCoefficientsRgbY) + 8 * y));
+    xmm0 = _mm_adds_epi16(_mm_loadl_epi64(reinterpret_cast<const __m128i*>(kCoefficientsRgbU + 8 * u)),
+                          _mm_loadl_epi64(reinterpret_cast<const __m128i*>(kCoefficientsRgbV + 8 * v)));
+    xmmY1 = _mm_loadl_epi64(reinterpret_cast<const __m128i*>(reinterpret_cast<const uint8*>(kCoefficientsRgbY) + 8 * y));
     xmmY1 = _mm_adds_epi16(xmmY1, xmm0);
 
     y = y_buf[x >> 16];
     x += source_dx;
 
-    xmmY2 = _mm_loadl_epi64(reinterpret_cast<__m128i*>(reinterpret_cast<uint8*>(kCoefficientsRgbY) + 8 * y));
+    xmmY2 = _mm_loadl_epi64(reinterpret_cast<const __m128i*>(reinterpret_cast<const uint8*>(kCoefficientsRgbY) + 8 * y));
     xmmY2 = _mm_adds_epi16(xmmY2, xmm0);
 
     xmmY = _mm_shuffle_ps(_mm_castsi128_ps(xmmY1), _mm_castsi128_ps(xmmY2),
                           0x44);
     xmmY1 = _mm_srai_epi16(_mm_castps_si128(xmmY), 6);
     xmmY1 = _mm_packus_epi16(xmmY1, xmmY1);
 
     _mm_storel_epi64(reinterpret_cast<__m128i*>(rgb_buf), xmmY1);
@@ -90,19 +90,19 @@ static void ScaleYUVToRGB32Row_SSE2(cons
     width -= 2;
   }
 
   if (width) {
     u = u_buf[x >> 17];
     v = v_buf[x >> 17];
     y = y_buf[x >> 16];
 
-    xmm0 = _mm_adds_epi16(_mm_loadl_epi64(reinterpret_cast<__m128i*>(kCoefficientsRgbU + 8 * u)),
-                          _mm_loadl_epi64(reinterpret_cast<__m128i*>(kCoefficientsRgbV + 8 * v)));
-    xmmY1 = _mm_loadl_epi64(reinterpret_cast<__m128i*>(reinterpret_cast<uint8*>(kCoefficientsRgbY) + 8 * y));
+    xmm0 = _mm_adds_epi16(_mm_loadl_epi64(reinterpret_cast<const __m128i*>(kCoefficientsRgbU + 8 * u)),
+                          _mm_loadl_epi64(reinterpret_cast<const __m128i*>(kCoefficientsRgbV + 8 * v)));
+    xmmY1 = _mm_loadl_epi64(reinterpret_cast<const __m128i*>(reinterpret_cast<const uint8*>(kCoefficientsRgbY) + 8 * y));
     xmmY1 = _mm_adds_epi16(xmmY1, xmm0);
     xmmY1 = _mm_srai_epi16(xmmY1, 6);
     xmmY1 = _mm_packus_epi16(xmmY1, xmmY1);
     *reinterpret_cast<uint32*>(rgb_buf) = _mm_cvtsi128_si32(xmmY1);
   }
 }
 
 static void LinearScaleYUVToRGB32Row_SSE2(const uint8* y_buf,
@@ -130,28 +130,28 @@ static void LinearScaleYUVToRGB32Row_SSE
     y1 = y_buf[(x >> 16) + 1];
     uv_frac = (x & 0x1fffe);
     y_frac = (x & 0xffff);
     u = (uv_frac * u1 + (uv_frac ^ 0x1fffe) * u0) >> 17;
     v = (uv_frac * v1 + (uv_frac ^ 0x1fffe) * v0) >> 17;
     y = (y_frac * y1 + (y_frac ^ 0xffff) * y0) >> 16;
     x += source_dx;
 
-    xmm0 = _mm_adds_epi16(_mm_loadl_epi64(reinterpret_cast<__m128i*>(kCoefficientsRgbU + 8 * u)),
-                          _mm_loadl_epi64(reinterpret_cast<__m128i*>(kCoefficientsRgbV + 8 * v)));
-    xmmY1 = _mm_loadl_epi64(reinterpret_cast<__m128i*>(reinterpret_cast<uint8*>(kCoefficientsRgbY) + 8 * y));
+    xmm0 = _mm_adds_epi16(_mm_loadl_epi64(reinterpret_cast<const __m128i*>(kCoefficientsRgbU + 8 * u)),
+                          _mm_loadl_epi64(reinterpret_cast<const __m128i*>(kCoefficientsRgbV + 8 * v)));
+    xmmY1 = _mm_loadl_epi64(reinterpret_cast<const __m128i*>(reinterpret_cast<const uint8*>(kCoefficientsRgbY) + 8 * y));
     xmmY1 = _mm_adds_epi16(xmmY1, xmm0);
 
     y0 = y_buf[x >> 16];
     y1 = y_buf[(x >> 16) + 1];
     y_frac = (x & 0xffff);
     y = (y_frac * y1 + (y_frac ^ 0xffff) * y0) >> 16;
     x += source_dx;
 
-    xmmY2 = _mm_loadl_epi64(reinterpret_cast<__m128i*>(reinterpret_cast<uint8*>(kCoefficientsRgbY) + 8 * y));
+    xmmY2 = _mm_loadl_epi64(reinterpret_cast<const __m128i*>(reinterpret_cast<const uint8*>(kCoefficientsRgbY) + 8 * y));
     xmmY2 = _mm_adds_epi16(xmmY2, xmm0);
 
     xmmY = _mm_shuffle_ps(_mm_castsi128_ps(xmmY1), _mm_castsi128_ps(xmmY2),
                           0x44);
     xmmY1 = _mm_srai_epi16(_mm_castps_si128(xmmY), 6);
     xmmY1 = _mm_packus_epi16(xmmY1, xmmY1);
 
     _mm_storel_epi64(reinterpret_cast<__m128i*>(rgb_buf), xmmY1);
@@ -159,19 +159,19 @@ static void LinearScaleYUVToRGB32Row_SSE
     width -= 2;
   }
 
   if (width) {
     u = u_buf[x >> 17];
     v = v_buf[x >> 17];
     y = y_buf[x >> 16];
 
-    xmm0 = _mm_adds_epi16(_mm_loadl_epi64(reinterpret_cast<__m128i*>(kCoefficientsRgbU + 8 * u)),
-                          _mm_loadl_epi64(reinterpret_cast<__m128i*>(kCoefficientsRgbV + 8 * v)));
-    xmmY1 = _mm_loadl_epi64(reinterpret_cast<__m128i*>(reinterpret_cast<uint8*>(kCoefficientsRgbY) + 8 * y));
+    xmm0 = _mm_adds_epi16(_mm_loadl_epi64(reinterpret_cast<const __m128i*>(kCoefficientsRgbU + 8 * u)),
+                          _mm_loadl_epi64(reinterpret_cast<const __m128i*>(kCoefficientsRgbV + 8 * v)));
+    xmmY1 = _mm_loadl_epi64(reinterpret_cast<const __m128i*>(reinterpret_cast<const uint8*>(kCoefficientsRgbY) + 8 * y));
 
     xmmY1 = _mm_adds_epi16(xmmY1, xmm0);
     xmmY1 = _mm_srai_epi16(xmmY1, 6);
     xmmY1 = _mm_packus_epi16(xmmY1, xmmY1);
     *reinterpret_cast<uint32*>(rgb_buf) = _mm_cvtsi128_si32(xmmY1);
   }
 }