yuv_mips32.c 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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. #include "./dsp.h"
  15. #if defined(WEBP_USE_MIPS32)
  16. #include "./yuv.h"
  17. //------------------------------------------------------------------------------
  18. // simple point-sampling
  19. #define ROW_FUNC(FUNC_NAME, XSTEP, R, G, B, A) \
  20. static void FUNC_NAME(const uint8_t* y, \
  21. const uint8_t* u, const uint8_t* v, \
  22. uint8_t* dst, int len) { \
  23. int i, r, g, b; \
  24. int temp0, temp1, temp2, temp3, temp4; \
  25. for (i = 0; i < (len >> 1); i++) { \
  26. temp1 = MultHi(v[0], 26149); \
  27. temp3 = MultHi(v[0], 13320); \
  28. temp2 = MultHi(u[0], 6419); \
  29. temp4 = MultHi(u[0], 33050); \
  30. temp0 = MultHi(y[0], 19077); \
  31. temp1 -= 14234; \
  32. temp3 -= 8708; \
  33. temp2 += temp3; \
  34. temp4 -= 17685; \
  35. r = VP8Clip8(temp0 + temp1); \
  36. g = VP8Clip8(temp0 - temp2); \
  37. b = VP8Clip8(temp0 + temp4); \
  38. temp0 = MultHi(y[1], 19077); \
  39. dst[R] = r; \
  40. dst[G] = g; \
  41. dst[B] = b; \
  42. if (A) dst[A] = 0xff; \
  43. r = VP8Clip8(temp0 + temp1); \
  44. g = VP8Clip8(temp0 - temp2); \
  45. b = VP8Clip8(temp0 + temp4); \
  46. dst[R + XSTEP] = r; \
  47. dst[G + XSTEP] = g; \
  48. dst[B + XSTEP] = b; \
  49. if (A) dst[A + XSTEP] = 0xff; \
  50. y += 2; \
  51. ++u; \
  52. ++v; \
  53. dst += 2 * XSTEP; \
  54. } \
  55. if (len & 1) { \
  56. temp1 = MultHi(v[0], 26149); \
  57. temp3 = MultHi(v[0], 13320); \
  58. temp2 = MultHi(u[0], 6419); \
  59. temp4 = MultHi(u[0], 33050); \
  60. temp0 = MultHi(y[0], 19077); \
  61. temp1 -= 14234; \
  62. temp3 -= 8708; \
  63. temp2 += temp3; \
  64. temp4 -= 17685; \
  65. r = VP8Clip8(temp0 + temp1); \
  66. g = VP8Clip8(temp0 - temp2); \
  67. b = VP8Clip8(temp0 + temp4); \
  68. dst[R] = r; \
  69. dst[G] = g; \
  70. dst[B] = b; \
  71. if (A) dst[A] = 0xff; \
  72. } \
  73. }
  74. ROW_FUNC(YuvToRgbRow_MIPS32, 3, 0, 1, 2, 0)
  75. ROW_FUNC(YuvToRgbaRow_MIPS32, 4, 0, 1, 2, 3)
  76. ROW_FUNC(YuvToBgrRow_MIPS32, 3, 2, 1, 0, 0)
  77. ROW_FUNC(YuvToBgraRow_MIPS32, 4, 2, 1, 0, 3)
  78. #undef ROW_FUNC
  79. //------------------------------------------------------------------------------
  80. // Entry point
  81. extern void WebPInitSamplersMIPS32(void);
  82. WEBP_TSAN_IGNORE_FUNCTION void WebPInitSamplersMIPS32(void) {
  83. WebPSamplers[MODE_RGB] = YuvToRgbRow_MIPS32;
  84. WebPSamplers[MODE_RGBA] = YuvToRgbaRow_MIPS32;
  85. WebPSamplers[MODE_BGR] = YuvToBgrRow_MIPS32;
  86. WebPSamplers[MODE_BGRA] = YuvToBgraRow_MIPS32;
  87. }
  88. #else // !WEBP_USE_MIPS32
  89. WEBP_DSP_INIT_STUB(WebPInitSamplersMIPS32)
  90. #endif // WEBP_USE_MIPS32