jsimd_mmi.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /*
  2. * Loongson MMI optimizations for libjpeg-turbo
  3. *
  4. * Copyright (C) 2016-2018, Loongson Technology Corporation Limited, BeiJing.
  5. * All Rights Reserved.
  6. * Authors: ZhuChen <zhuchen@loongson.cn>
  7. * CaiWanwei <caiwanwei@loongson.cn>
  8. * SunZhangzhi <sunzhangzhi-cq@loongson.cn>
  9. * QingfaLiu <liuqingfa-hf@loongson.cn>
  10. * Copyright (C) 2024, D. R. Commander. All Rights Reserved.
  11. *
  12. * This software is provided 'as-is', without any express or implied
  13. * warranty. In no event will the authors be held liable for any damages
  14. * arising from the use of this software.
  15. *
  16. * Permission is granted to anyone to use this software for any purpose,
  17. * including commercial applications, and to alter it and redistribute it
  18. * freely, subject to the following restrictions:
  19. *
  20. * 1. The origin of this software must not be misrepresented; you must not
  21. * claim that you wrote the original software. If you use this software
  22. * in a product, an acknowledgment in the product documentation would be
  23. * appreciated but is not required.
  24. * 2. Altered source versions must be plainly marked as such, and must not be
  25. * misrepresented as being the original software.
  26. * 3. This notice may not be removed or altered from any source distribution.
  27. */
  28. #define JPEG_INTERNALS
  29. #include "../../src/jinclude.h"
  30. #include "../../src/jpeglib.h"
  31. #include "../../src/jdct.h"
  32. #include "loongson-mmintrin.h"
  33. /* Common code */
  34. #if defined(_ABI64) && _MIPS_SIM == _ABI64
  35. # define PTR_ADDU "daddu "
  36. # define PTR_SLL "dsll "
  37. #else
  38. # define PTR_ADDU "addu "
  39. # define PTR_SLL "sll "
  40. #endif
  41. #define SIZEOF_MMWORD 8
  42. #define BYTE_BIT 8
  43. #define WORD_BIT 16
  44. #define SCALEBITS 16
  45. #define _uint64_set_pi8(a, b, c, d, e, f, g, h) \
  46. (((uint64_t)(uint8_t)a << 56) | \
  47. ((uint64_t)(uint8_t)b << 48) | \
  48. ((uint64_t)(uint8_t)c << 40) | \
  49. ((uint64_t)(uint8_t)d << 32) | \
  50. ((uint64_t)(uint8_t)e << 24) | \
  51. ((uint64_t)(uint8_t)f << 16) | \
  52. ((uint64_t)(uint8_t)g << 8) | \
  53. ((uint64_t)(uint8_t)h))
  54. #define _uint64_set1_pi8(a) _uint64_set_pi8(a, a, a, a, a, a, a, a)
  55. #define _uint64_set_pi16(a, b, c, d) \
  56. (((uint64_t)(uint16_t)a << 48) | \
  57. ((uint64_t)(uint16_t)b << 32) | \
  58. ((uint64_t)(uint16_t)c << 16) | \
  59. ((uint64_t)(uint16_t)d))
  60. #define _uint64_set1_pi16(a) _uint64_set_pi16(a, a, a, a)
  61. #define _uint64_set_pi32(a, b) \
  62. (((uint64_t)(uint32_t)a << 32) | \
  63. ((uint64_t)(uint32_t)b))
  64. #define get_const_value(index) (*(__m64 *)&const_value[index])