jdmerge-altivec.c 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. /*
  2. * AltiVec optimizations for libjpeg-turbo
  3. *
  4. * Copyright (C) 2015, D. R. Commander. All Rights Reserved.
  5. *
  6. * This software is provided 'as-is', without any express or implied
  7. * warranty. In no event will the authors be held liable for any damages
  8. * arising from the use of this software.
  9. *
  10. * Permission is granted to anyone to use this software for any purpose,
  11. * including commercial applications, and to alter it and redistribute it
  12. * freely, subject to the following restrictions:
  13. *
  14. * 1. The origin of this software must not be misrepresented; you must not
  15. * claim that you wrote the original software. If you use this software
  16. * in a product, an acknowledgment in the product documentation would be
  17. * appreciated but is not required.
  18. * 2. Altered source versions must be plainly marked as such, and must not be
  19. * misrepresented as being the original software.
  20. * 3. This notice may not be removed or altered from any source distribution.
  21. */
  22. /* MERGED YCC --> RGB CONVERSION AND UPSAMPLING */
  23. #include "jsimd_altivec.h"
  24. #define F_0_344 22554 /* FIX(0.34414) */
  25. #define F_0_714 46802 /* FIX(0.71414) */
  26. #define F_1_402 91881 /* FIX(1.40200) */
  27. #define F_1_772 116130 /* FIX(1.77200) */
  28. #define F_0_402 (F_1_402 - 65536) /* FIX(1.40200) - FIX(1) */
  29. #define F_0_285 (65536 - F_0_714) /* FIX(1) - FIX(0.71414) */
  30. #define F_0_228 (131072 - F_1_772) /* FIX(2) - FIX(1.77200) */
  31. #define SCALEBITS 16
  32. #define ONE_HALF (1 << (SCALEBITS - 1))
  33. #define RGB_INDEX0 \
  34. { 0, 1, 8, 2, 3, 10, 4, 5, 12, 6, 7, 14, 16, 17, 24, 18 }
  35. #define RGB_INDEX1 \
  36. { 3, 10, 4, 5, 12, 6, 7, 14, 16, 17, 24, 18, 19, 26, 20, 21 }
  37. #define RGB_INDEX2 \
  38. { 12, 6, 7, 14, 16, 17, 24, 18, 19, 26, 20, 21, 28, 22, 23, 30 }
  39. #include "jdmrgext-altivec.c"
  40. #undef RGB_PIXELSIZE
  41. #define RGB_PIXELSIZE EXT_RGB_PIXELSIZE
  42. #define jsimd_h2v1_merged_upsample_altivec \
  43. jsimd_h2v1_extrgb_merged_upsample_altivec
  44. #define jsimd_h2v2_merged_upsample_altivec \
  45. jsimd_h2v2_extrgb_merged_upsample_altivec
  46. #include "jdmrgext-altivec.c"
  47. #undef RGB_PIXELSIZE
  48. #undef RGB_INDEX0
  49. #undef RGB_INDEX1
  50. #undef RGB_INDEX2
  51. #undef jsimd_h2v1_merged_upsample_altivec
  52. #undef jsimd_h2v2_merged_upsample_altivec
  53. #define RGB_PIXELSIZE EXT_RGBX_PIXELSIZE
  54. #define RGB_INDEX \
  55. { 0, 1, 8, 9, 2, 3, 10, 11, 4, 5, 12, 13, 6, 7, 14, 15 }
  56. #define jsimd_h2v1_merged_upsample_altivec \
  57. jsimd_h2v1_extrgbx_merged_upsample_altivec
  58. #define jsimd_h2v2_merged_upsample_altivec \
  59. jsimd_h2v2_extrgbx_merged_upsample_altivec
  60. #include "jdmrgext-altivec.c"
  61. #undef RGB_PIXELSIZE
  62. #undef RGB_INDEX
  63. #undef jsimd_h2v1_merged_upsample_altivec
  64. #undef jsimd_h2v2_merged_upsample_altivec
  65. #define RGB_PIXELSIZE EXT_BGR_PIXELSIZE
  66. #define RGB_INDEX0 \
  67. { 8, 1, 0, 10, 3, 2, 12, 5, 4, 14, 7, 6, 24, 17, 16, 26 }
  68. #define RGB_INDEX1 \
  69. { 3, 2, 12, 5, 4, 14, 7, 6, 24, 17, 16, 26, 19, 18, 28, 21 }
  70. #define RGB_INDEX2 \
  71. { 4, 14, 7, 6, 24, 17, 16, 26, 19, 18, 28, 21, 20, 30, 23, 22 }
  72. #define jsimd_h2v1_merged_upsample_altivec \
  73. jsimd_h2v1_extbgr_merged_upsample_altivec
  74. #define jsimd_h2v2_merged_upsample_altivec \
  75. jsimd_h2v2_extbgr_merged_upsample_altivec
  76. #include "jdmrgext-altivec.c"
  77. #undef RGB_PIXELSIZE
  78. #undef RGB_INDEX0
  79. #undef RGB_INDEX1
  80. #undef RGB_INDEX2
  81. #undef jsimd_h2v1_merged_upsample_altivec
  82. #undef jsimd_h2v2_merged_upsample_altivec
  83. #define RGB_PIXELSIZE EXT_BGRX_PIXELSIZE
  84. #define RGB_INDEX \
  85. { 8, 1, 0, 9, 10, 3, 2, 11, 12, 5, 4, 13, 14, 7, 6, 15 }
  86. #define jsimd_h2v1_merged_upsample_altivec \
  87. jsimd_h2v1_extbgrx_merged_upsample_altivec
  88. #define jsimd_h2v2_merged_upsample_altivec \
  89. jsimd_h2v2_extbgrx_merged_upsample_altivec
  90. #include "jdmrgext-altivec.c"
  91. #undef RGB_PIXELSIZE
  92. #undef RGB_INDEX
  93. #undef jsimd_h2v1_merged_upsample_altivec
  94. #undef jsimd_h2v2_merged_upsample_altivec
  95. #define RGB_PIXELSIZE EXT_XBGR_PIXELSIZE
  96. #define RGB_INDEX \
  97. { 9, 8, 1, 0, 11, 10, 3, 2, 13, 12, 5, 4, 15, 14, 7, 6 }
  98. #define jsimd_h2v1_merged_upsample_altivec \
  99. jsimd_h2v1_extxbgr_merged_upsample_altivec
  100. #define jsimd_h2v2_merged_upsample_altivec \
  101. jsimd_h2v2_extxbgr_merged_upsample_altivec
  102. #include "jdmrgext-altivec.c"
  103. #undef RGB_PIXELSIZE
  104. #undef RGB_INDEX
  105. #undef jsimd_h2v1_merged_upsample_altivec
  106. #undef jsimd_h2v2_merged_upsample_altivec
  107. #define RGB_PIXELSIZE EXT_XRGB_PIXELSIZE
  108. #define RGB_INDEX \
  109. { 9, 0, 1, 8, 11, 2, 3, 10, 13, 4, 5, 12, 15, 6, 7, 14 }
  110. #define jsimd_h2v1_merged_upsample_altivec \
  111. jsimd_h2v1_extxrgb_merged_upsample_altivec
  112. #define jsimd_h2v2_merged_upsample_altivec \
  113. jsimd_h2v2_extxrgb_merged_upsample_altivec
  114. #include "jdmrgext-altivec.c"
  115. #undef RGB_PIXELSIZE
  116. #undef RGB_INDEX
  117. #undef jsimd_h2v1_merged_upsample_altivec
  118. #undef jsimd_h2v2_merged_upsample_altivec