yuv_mips32.c 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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 = kVToR * v[0]; \
  27. temp3 = kVToG * v[0]; \
  28. temp2 = kUToG * u[0]; \
  29. temp4 = kUToB * u[0]; \
  30. temp0 = kYScale * y[0]; \
  31. temp1 += kRCst; \
  32. temp3 -= kGCst; \
  33. temp2 += temp3; \
  34. temp4 += kBCst; \
  35. r = VP8Clip8(temp0 + temp1); \
  36. g = VP8Clip8(temp0 - temp2); \
  37. b = VP8Clip8(temp0 + temp4); \
  38. temp0 = kYScale * y[1]; \
  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 = kVToR * v[0]; \
  57. temp3 = kVToG * v[0]; \
  58. temp2 = kUToG * u[0]; \
  59. temp4 = kUToB * u[0]; \
  60. temp0 = kYScale * y[0]; \
  61. temp1 += kRCst; \
  62. temp3 -= kGCst; \
  63. temp2 += temp3; \
  64. temp4 += kBCst; \
  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, 3, 0, 1, 2, 0)
  75. ROW_FUNC(YuvToRgbaRow, 4, 0, 1, 2, 3)
  76. ROW_FUNC(YuvToBgrRow, 3, 2, 1, 0, 0)
  77. ROW_FUNC(YuvToBgraRow, 4, 2, 1, 0, 3)
  78. #undef ROW_FUNC
  79. #endif // WEBP_USE_MIPS32
  80. //------------------------------------------------------------------------------
  81. extern void WebPInitSamplersMIPS32(void);
  82. void WebPInitSamplersMIPS32(void) {
  83. #if defined(WEBP_USE_MIPS32)
  84. WebPSamplers[MODE_RGB] = YuvToRgbRow;
  85. WebPSamplers[MODE_RGBA] = YuvToRgbaRow;
  86. WebPSamplers[MODE_BGR] = YuvToBgrRow;
  87. WebPSamplers[MODE_BGRA] = YuvToBgraRow;
  88. #endif // WEBP_USE_MIPS32
  89. }