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 DSPr2 version of YUV to RGB upsampling functions. 11 // 12 // Author(s): Branimir Vasic (branimir.vasic@imgtec.com) 13 // Djordje Pesut (djordje.pesut@imgtec.com) 14 15 #include "./dsp.h" 16 17 // Code is disabled for now, in favor of the plain-C version 18 #if 0 // defined(WEBP_USE_MIPS_DSP_R2) 19 20 #include "./yuv.h" 21 22 //------------------------------------------------------------------------------ 23 // simple point-sampling 24 25 #define ROW_FUNC_PART_1() \ 26 "lbu %[temp3], 0(%[v]) \n\t" \ 27 "lbu %[temp4], 0(%[u]) \n\t" \ 28 "lbu %[temp0], 0(%[y]) \n\t" \ 29 "mul %[temp1], %[t_con_1], %[temp3] \n\t" \ 30 "mul %[temp3], %[t_con_2], %[temp3] \n\t" \ 31 "mul %[temp2], %[t_con_3], %[temp4] \n\t" \ 32 "mul %[temp4], %[t_con_4], %[temp4] \n\t" \ 33 "mul %[temp0], %[t_con_5], %[temp0] \n\t" \ 34 "addu %[temp1], %[temp1], %[t_con_6] \n\t" \ 35 "subu %[temp3], %[temp3], %[t_con_7] \n\t" \ 36 "addu %[temp2], %[temp2], %[temp3] \n\t" \ 37 "addu %[temp4], %[temp4], %[t_con_8] \n\t" \ 38 39 #define ROW_FUNC_PART_2(R, G, B, K) \ 40 "addu %[temp5], %[temp0], %[temp1] \n\t" \ 41 "subu %[temp6], %[temp0], %[temp2] \n\t" \ 42 "addu %[temp7], %[temp0], %[temp4] \n\t" \ 43 ".if " #K " \n\t" \ 44 "lbu %[temp0], 1(%[y]) \n\t" \ 45 ".endif \n\t" \ 46 "shll_s.w %[temp5], %[temp5], 9 \n\t" \ 47 "shll_s.w %[temp6], %[temp6], 9 \n\t" \ 48 ".if " #K " \n\t" \ 49 "mul %[temp0], %[t_con_5], %[temp0] \n\t" \ 50 ".endif \n\t" \ 51 "shll_s.w %[temp7], %[temp7], 9 \n\t" \ 52 "precrqu_s.qb.ph %[temp5], %[temp5], $zero \n\t" \ 53 "precrqu_s.qb.ph %[temp6], %[temp6], $zero \n\t" \ 54 "precrqu_s.qb.ph %[temp7], %[temp7], $zero \n\t" \ 55 "srl %[temp5], %[temp5], 24 \n\t" \ 56 "srl %[temp6], %[temp6], 24 \n\t" \ 57 "srl %[temp7], %[temp7], 24 \n\t" \ 58 "sb %[temp5], " #R "(%[dst]) \n\t" \ 59 "sb %[temp6], " #G "(%[dst]) \n\t" \ 60 "sb %[temp7], " #B "(%[dst]) \n\t" \ 61 62 #define ASM_CLOBBER_LIST() \ 63 : [temp0]"=&r"(temp0), [temp1]"=&r"(temp1), [temp2]"=&r"(temp2), \ 64 [temp3]"=&r"(temp3), [temp4]"=&r"(temp4), [temp5]"=&r"(temp5), \ 65 [temp6]"=&r"(temp6), [temp7]"=&r"(temp7) \ 66 : [t_con_1]"r"(t_con_1), [t_con_2]"r"(t_con_2), [t_con_3]"r"(t_con_3), \ 67 [t_con_4]"r"(t_con_4), [t_con_5]"r"(t_con_5), [t_con_6]"r"(t_con_6), \ 68 [u]"r"(u), [v]"r"(v), [y]"r"(y), [dst]"r"(dst), \ 69 [t_con_7]"r"(t_con_7), [t_con_8]"r"(t_con_8) \ 70 : "memory", "hi", "lo" \ 71 72 #define ROW_FUNC(FUNC_NAME, XSTEP, R, G, B, A) \ 73 static void FUNC_NAME(const uint8_t* y, \ 74 const uint8_t* u, const uint8_t* v, \ 75 uint8_t* dst, int len) { \ 76 int i; \ 77 uint32_t temp0, temp1, temp2, temp3, temp4, temp5, temp6, temp7; \ 78 const int t_con_1 = kVToR; \ 79 const int t_con_2 = kVToG; \ 80 const int t_con_3 = kUToG; \ 81 const int t_con_4 = kUToB; \ 82 const int t_con_5 = kYScale; \ 83 const int t_con_6 = kRCst; \ 84 const int t_con_7 = kGCst; \ 85 const int t_con_8 = kBCst; \ 86 for (i = 0; i < (len >> 1); i++) { \ 87 __asm__ volatile ( \ 88 ROW_FUNC_PART_1() \ 89 ROW_FUNC_PART_2(R, G, B, 1) \ 90 ROW_FUNC_PART_2(R + XSTEP, G + XSTEP, B + XSTEP, 0) \ 91 ASM_CLOBBER_LIST() \ 92 ); \ 93 if (A) dst[A] = dst[A + XSTEP] = 0xff; \ 94 y += 2; \ 95 ++u; \ 96 ++v; \ 97 dst += 2 * XSTEP; \ 98 } \ 99 if (len & 1) { \ 100 __asm__ volatile ( \ 101 ROW_FUNC_PART_1() \ 102 ROW_FUNC_PART_2(R, G, B, 0) \ 103 ASM_CLOBBER_LIST() \ 104 ); \ 105 if (A) dst[A] = 0xff; \ 106 } \ 107 } 108 109 ROW_FUNC(YuvToRgbRow, 3, 0, 1, 2, 0) 110 ROW_FUNC(YuvToRgbaRow, 4, 0, 1, 2, 3) 111 ROW_FUNC(YuvToBgrRow, 3, 2, 1, 0, 0) 112 ROW_FUNC(YuvToBgraRow, 4, 2, 1, 0, 3) 113 114 #undef ROW_FUNC 115 #undef ASM_CLOBBER_LIST 116 #undef ROW_FUNC_PART_2 117 #undef ROW_FUNC_PART_1 118 119 //------------------------------------------------------------------------------ 120 // Entry point 121 122 extern void WebPInitSamplersMIPSdspR2(void); 123 124 WEBP_TSAN_IGNORE_FUNCTION void WebPInitSamplersMIPSdspR2(void) { 125 WebPSamplers[MODE_RGB] = YuvToRgbRow; 126 WebPSamplers[MODE_RGBA] = YuvToRgbaRow; 127 WebPSamplers[MODE_BGR] = YuvToBgrRow; 128 WebPSamplers[MODE_BGRA] = YuvToBgraRow; 129 } 130 131 #else // !WEBP_USE_MIPS_DSP_R2 132 133 WEBP_DSP_INIT_STUB(WebPInitSamplersMIPSdspR2) 134 135 #endif // WEBP_USE_MIPS_DSP_R2 136