1 # HG changeset patch |
|
2 # User A. Wilcox <AWilcox@Wilcox-Tech.com> |
|
3 # Date 1543674229 0 |
|
4 # Sat Dec 01 14:23:49 2018 +0000 |
|
5 # Node ID 0309ff19e46b126c527e633518d7de8570442114 |
|
6 # Parent ba2c9b0542c95cc5ee26c264e8338fc9ba94c958 |
|
7 Bug 1511604 - Swizzle YCbCr->RGB data on big-endian machines |
|
8 Taken from https://bugzilla.mozilla.org/show_bug.cgi?id=1511604 |
|
9 |
|
10 This is very closely related to mozilla-bmo1504834 |
|
11 |
|
12 Again, input for skia is swizzled to LE, as skia only understands LE. |
|
13 |
|
14 diff --git a/gfx/ycbcr/YCbCrUtils.cpp b/gfx/ycbcr/YCbCrUtils.cpp |
|
15 --- a/gfx/ycbcr/YCbCrUtils.cpp |
|
16 +++ b/gfx/ycbcr/YCbCrUtils.cpp |
|
17 @@ -1,14 +1,16 @@ |
|
18 /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- |
|
19 * This Source Code Form is subject to the terms of the Mozilla Public |
|
20 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
21 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
22 |
|
23 +#include "mozilla/EndianUtils.h" |
|
24 #include "gfx2DGlue.h" |
|
25 +#include "mozilla/gfx/Swizzle.h" |
|
26 |
|
27 #include "YCbCrUtils.h" |
|
28 #include "yuv_convert.h" |
|
29 #include "ycbcr_to_rgb565.h" |
|
30 |
|
31 namespace mozilla { |
|
32 namespace gfx { |
|
33 |
|
34 @@ -231,16 +233,23 @@ ConvertYCbCrToRGB(const layers::PlanarYC |
|
35 srcData.mPicSize.width, |
|
36 srcData.mPicSize.height, |
|
37 srcData.mYStride, |
|
38 srcData.mCbCrStride, |
|
39 aStride, |
|
40 yuvtype, |
|
41 srcData.mYUVColorSpace); |
|
42 } |
|
43 +#if MOZ_BIG_ENDIAN |
|
44 + // libyuv makes endian-correct result, which needs to be swapped to BGRX |
|
45 + if (aDestFormat != SurfaceFormat::R5G6B5_UINT16) |
|
46 + gfx::SwizzleData(aDestBuffer, aStride, gfx::SurfaceFormat::X8R8G8B8, |
|
47 + aDestBuffer, aStride, gfx::SurfaceFormat::B8G8R8X8, |
|
48 + srcData.mPicSize); |
|
49 +#endif |
|
50 } |
|
51 |
|
52 void |
|
53 ConvertYCbCrAToARGB(const uint8_t* aSrcY, |
|
54 const uint8_t* aSrcU, |
|
55 const uint8_t* aSrcV, |
|
56 const uint8_t* aSrcA, |
|
57 int aSrcStrideYA, int aSrcStrideUV, |
|
58 @@ -252,12 +261,18 @@ ConvertYCbCrAToARGB(const uint8_t* aSrcY |
|
59 aSrcV, |
|
60 aSrcA, |
|
61 aDstARGB, |
|
62 aWidth, |
|
63 aHeight, |
|
64 aSrcStrideYA, |
|
65 aSrcStrideUV, |
|
66 aDstStrideARGB); |
|
67 +#if MOZ_BIG_ENDIAN |
|
68 + // libyuv makes endian-correct result, which needs to be swapped to BGRA |
|
69 + gfx::SwizzleData(aDstARGB, aDstStrideARGB, gfx::SurfaceFormat::A8R8G8B8, |
|
70 + aDstARGB, aDstStrideARGB, gfx::SurfaceFormat::B8G8R8A8, |
|
71 + IntSize(aWidth, aHeight)); |
|
72 +#endif |
|
73 } |
|
74 |
|
75 } // namespace gfx |
|
76 } // namespace mozilla |
|