jdmerge-mmi.c 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. /*
  2. * Loongson MMI optimizations for libjpeg-turbo
  3. *
  4. * Copyright (C) 2011, 2015, D. R. Commander. All Rights Reserved.
  5. * Copyright (C) 2016-2018, Loongson Technology Corporation Limited, BeiJing.
  6. * All Rights Reserved.
  7. * Authors: ZhangLixia <zhanglixia-hf@loongson.cn>
  8. *
  9. * This software is provided 'as-is', without any express or implied
  10. * warranty. In no event will the authors be held liable for any damages
  11. * arising from the use of this software.
  12. *
  13. * Permission is granted to anyone to use this software for any purpose,
  14. * including commercial applications, and to alter it and redistribute it
  15. * freely, subject to the following restrictions:
  16. *
  17. * 1. The origin of this software must not be misrepresented; you must not
  18. * claim that you wrote the original software. If you use this software
  19. * in a product, an acknowledgment in the product documentation would be
  20. * appreciated but is not required.
  21. * 2. Altered source versions must be plainly marked as such, and must not be
  22. * misrepresented as being the original software.
  23. * 3. This notice may not be removed or altered from any source distribution.
  24. */
  25. /* YCC --> RGB CONVERSION */
  26. #include "jsimd_mmi.h"
  27. #define F_0_344 ((short)22554) /* FIX(0.34414) */
  28. #define F_0_402 ((short)26345) /* FIX(1.40200) - FIX(1) */
  29. #define F_0_285 ((short)18734) /* FIX(1) - FIX(0.71414) */
  30. #define F_0_228 ((short)14942) /* FIX(2) - FIX(1.77200) */
  31. enum const_index {
  32. index_PW_ONE,
  33. index_PW_F0402,
  34. index_PW_MF0228,
  35. index_PW_MF0344_F0285,
  36. index_PD_ONEHALF
  37. };
  38. static uint64_t const_value[] = {
  39. _uint64_set_pi16(1, 1, 1, 1),
  40. _uint64_set_pi16(F_0_402, F_0_402, F_0_402, F_0_402),
  41. _uint64_set_pi16(-F_0_228, -F_0_228, -F_0_228, -F_0_228),
  42. _uint64_set_pi16(F_0_285, -F_0_344, F_0_285, -F_0_344),
  43. _uint64_set_pi32((int)(1 << (SCALEBITS - 1)), (int)(1 << (SCALEBITS - 1)))
  44. };
  45. #define PW_ONE get_const_value(index_PW_ONE)
  46. #define PW_F0402 get_const_value(index_PW_F0402)
  47. #define PW_MF0228 get_const_value(index_PW_MF0228)
  48. #define PW_MF0344_F0285 get_const_value(index_PW_MF0344_F0285)
  49. #define PD_ONEHALF get_const_value(index_PD_ONEHALF)
  50. #define RGBX_FILLER_0XFF 1
  51. #include "jdmrgext-mmi.c"
  52. #undef RGB_RED
  53. #undef RGB_GREEN
  54. #undef RGB_BLUE
  55. #undef RGB_PIXELSIZE
  56. #define RGB_RED EXT_RGB_RED
  57. #define RGB_GREEN EXT_RGB_GREEN
  58. #define RGB_BLUE EXT_RGB_BLUE
  59. #define RGB_PIXELSIZE EXT_RGB_PIXELSIZE
  60. #define jsimd_h2v1_merged_upsample_mmi jsimd_h2v1_extrgb_merged_upsample_mmi
  61. #define jsimd_h2v2_merged_upsample_mmi jsimd_h2v2_extrgb_merged_upsample_mmi
  62. #include "jdmrgext-mmi.c"
  63. #undef RGB_RED
  64. #undef RGB_GREEN
  65. #undef RGB_BLUE
  66. #undef RGB_PIXELSIZE
  67. #undef jsimd_h2v1_merged_upsample_mmi
  68. #undef jsimd_h2v2_merged_upsample_mmi
  69. #define RGB_RED EXT_RGBX_RED
  70. #define RGB_GREEN EXT_RGBX_GREEN
  71. #define RGB_BLUE EXT_RGBX_BLUE
  72. #define RGB_PIXELSIZE EXT_RGBX_PIXELSIZE
  73. #define jsimd_h2v1_merged_upsample_mmi jsimd_h2v1_extrgbx_merged_upsample_mmi
  74. #define jsimd_h2v2_merged_upsample_mmi jsimd_h2v2_extrgbx_merged_upsample_mmi
  75. #include "jdmrgext-mmi.c"
  76. #undef RGB_RED
  77. #undef RGB_GREEN
  78. #undef RGB_BLUE
  79. #undef RGB_PIXELSIZE
  80. #undef jsimd_h2v1_merged_upsample_mmi
  81. #undef jsimd_h2v2_merged_upsample_mmi
  82. #define RGB_RED EXT_BGR_RED
  83. #define RGB_GREEN EXT_BGR_GREEN
  84. #define RGB_BLUE EXT_BGR_BLUE
  85. #define RGB_PIXELSIZE EXT_BGR_PIXELSIZE
  86. #define jsimd_h2v1_merged_upsample_mmi jsimd_h2v1_extbgr_merged_upsample_mmi
  87. #define jsimd_h2v2_merged_upsample_mmi jsimd_h2v2_extbgr_merged_upsample_mmi
  88. #include "jdmrgext-mmi.c"
  89. #undef RGB_RED
  90. #undef RGB_GREEN
  91. #undef RGB_BLUE
  92. #undef RGB_PIXELSIZE
  93. #undef jsimd_h2v1_merged_upsample_mmi
  94. #undef jsimd_h2v2_merged_upsample_mmi
  95. #define RGB_RED EXT_BGRX_RED
  96. #define RGB_GREEN EXT_BGRX_GREEN
  97. #define RGB_BLUE EXT_BGRX_BLUE
  98. #define RGB_PIXELSIZE EXT_BGRX_PIXELSIZE
  99. #define jsimd_h2v1_merged_upsample_mmi jsimd_h2v1_extbgrx_merged_upsample_mmi
  100. #define jsimd_h2v2_merged_upsample_mmi jsimd_h2v2_extbgrx_merged_upsample_mmi
  101. #include "jdmrgext-mmi.c"
  102. #undef RGB_RED
  103. #undef RGB_GREEN
  104. #undef RGB_BLUE
  105. #undef RGB_PIXELSIZE
  106. #undef jsimd_h2v1_merged_upsample_mmi
  107. #undef jsimd_h2v2_merged_upsample_mmi
  108. #define RGB_RED EXT_XBGR_RED
  109. #define RGB_GREEN EXT_XBGR_GREEN
  110. #define RGB_BLUE EXT_XBGR_BLUE
  111. #define RGB_PIXELSIZE EXT_XBGR_PIXELSIZE
  112. #define jsimd_h2v1_merged_upsample_mmi jsimd_h2v1_extxbgr_merged_upsample_mmi
  113. #define jsimd_h2v2_merged_upsample_mmi jsimd_h2v2_extxbgr_merged_upsample_mmi
  114. #include "jdmrgext-mmi.c"
  115. #undef RGB_RED
  116. #undef RGB_GREEN
  117. #undef RGB_BLUE
  118. #undef RGB_PIXELSIZE
  119. #undef jsimd_h2v1_merged_upsample_mmi
  120. #undef jsimd_h2v2_merged_upsample_mmi
  121. #define RGB_RED EXT_XRGB_RED
  122. #define RGB_GREEN EXT_XRGB_GREEN
  123. #define RGB_BLUE EXT_XRGB_BLUE
  124. #define RGB_PIXELSIZE EXT_XRGB_PIXELSIZE
  125. #define jsimd_h2v1_merged_upsample_mmi jsimd_h2v1_extxrgb_merged_upsample_mmi
  126. #define jsimd_h2v2_merged_upsample_mmi jsimd_h2v2_extxrgb_merged_upsample_mmi
  127. #include "jdmrgext-mmi.c"
  128. #undef RGB_RED
  129. #undef RGB_GREEN
  130. #undef RGB_BLUE
  131. #undef RGB_PIXELSIZE
  132. #undef jsimd_h2v1_merged_upsample_mmi
  133. #undef jsimd_h2v2_merged_upsample_mmi