1 // Copyright 2014 Google Inc. All Rights Reserved.
2 //
3 // Use of this source code is governed by a BSD-style license
4 // that can be found in the COPYING file in the root of the source
5 // tree. An additional intellectual property rights grant can be found
6 // in the file PATENTS. All contributing project authors may
7 // be found in the AUTHORS file in the root of the source tree.
8 // -----------------------------------------------------------------------------
9 //
10 // MIPS version of YUV to RGB upsampling functions.
11 //
12 // Author(s): Djordje Pesut (djordje.pesut@imgtec.com)
13 // Jovan Zelincevic (jovan.zelincevic@imgtec.com)
14
15 #include "./dsp.h"
16
17 #if defined(WEBP_USE_MIPS32)
18
19 #include "./yuv.h"
20
21 //------------------------------------------------------------------------------
22 // simple point-sampling
23
24 #define ROW_FUNC(FUNC_NAME, XSTEP, R, G, B, A) \
25 static void FUNC_NAME(const uint8_t* y, \
26 const uint8_t* u, const uint8_t* v, \
27 uint8_t* dst, int len) { \
28 int i, r, g, b; \
29 int temp0, temp1, temp2, temp3, temp4; \
30 for (i = 0; i < (len >> 1); i++) { \
31 temp1 = kVToR * v[0]; \
32 temp3 = kVToG * v[0]; \
33 temp2 = kUToG * u[0]; \
34 temp4 = kUToB * u[0]; \
35 temp0 = kYScale * y[0]; \
36 temp1 += kRCst; \
37 temp3 -= kGCst; \
38 temp2 += temp3; \
39 temp4 += kBCst; \
40 r = VP8Clip8(temp0 + temp1); \
41 g = VP8Clip8(temp0 - temp2); \
42 b = VP8Clip8(temp0 + temp4); \
43 temp0 = kYScale * y[1]; \
44 dst[R] = r; \
45 dst[G] = g; \
46 dst[B] = b; \
47 if (A) dst[A] = 0xff; \
48 r = VP8Clip8(temp0 + temp1); \
49 g = VP8Clip8(temp0 - temp2); \
50 b = VP8Clip8(temp0 + temp4); \
51 dst[R + XSTEP] = r; \
52 dst[G + XSTEP] = g; \
53 dst[B + XSTEP] = b; \
54 if (A) dst[A + XSTEP] = 0xff; \
55 y += 2; \
56 ++u; \
57 ++v; \
58 dst += 2 * XSTEP; \
59 } \
60 if (len & 1) { \
61 temp1 = kVToR * v[0]; \
62 temp3 = kVToG * v[0]; \
63 temp2 = kUToG * u[0]; \
64 temp4 = kUToB * u[0]; \
65 temp0 = kYScale * y[0]; \
66 temp1 += kRCst; \
67 temp3 -= kGCst; \
68 temp2 += temp3; \
69 temp4 += kBCst; \
70 r = VP8Clip8(temp0 + temp1); \
71 g = VP8Clip8(temp0 - temp2); \
72 b = VP8Clip8(temp0 + temp4); \
73 dst[R] = r; \
74 dst[G] = g; \
75 dst[B] = b; \
76 if (A) dst[A] = 0xff; \
77 } \
78 }
79
80 ROW_FUNC(YuvToRgbRow, 3, 0, 1, 2, 0)
81 ROW_FUNC(YuvToRgbaRow, 4, 0, 1, 2, 3)
82 ROW_FUNC(YuvToBgrRow, 3, 2, 1, 0, 0)
83 ROW_FUNC(YuvToBgraRow, 4, 2, 1, 0, 3)
84
85 #undef ROW_FUNC
86
87 #endif // WEBP_USE_MIPS32
88
89 //------------------------------------------------------------------------------
90
91 extern void WebPInitSamplersMIPS32(void);
92
WebPInitSamplersMIPS32(void)93 void WebPInitSamplersMIPS32(void) {
94 #if defined(WEBP_USE_MIPS32)
95 WebPSamplers[MODE_RGB] = YuvToRgbRow;
96 WebPSamplers[MODE_RGBA] = YuvToRgbaRow;
97 WebPSamplers[MODE_BGR] = YuvToBgrRow;
98 WebPSamplers[MODE_BGRA] = YuvToBgraRow;
99 #endif // WEBP_USE_MIPS32
100 }
101