You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

136 lines
3.4KB

  1. /*
  2. * Alpha optimized DSP utils
  3. * Copyright (c) 2002 Falk Hueffner <falk@debian.org>
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 2 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program; if not, write to the Free Software
  17. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18. */
  19. /* This file is intended to be #included with proper definitions of
  20. * PIXOPNAME, BTYPE, AVG2, AVG4 and STORE. */
  21. static void PIXOPNAME(_pixels_axp)(BTYPE *block, const UINT8 *pixels,
  22. int line_size, int h)
  23. {
  24. if ((size_t) pixels & 0x7) {
  25. do {
  26. STORE(uldq(pixels), block);
  27. pixels += line_size;
  28. block += line_size;
  29. } while (--h);
  30. } else {
  31. do {
  32. STORE(ldq(pixels), block);
  33. pixels += line_size;
  34. block += line_size;
  35. } while (--h);
  36. }
  37. }
  38. static void PIXOPNAME(_pixels_x2_axp)(BTYPE *block, const UINT8 *pixels,
  39. int line_size, int h)
  40. {
  41. if ((size_t) pixels & 0x7) {
  42. do {
  43. UINT64 pix1, pix2;
  44. pix1 = uldq(pixels);
  45. pix2 = pix1 >> 8 | ((UINT64) pixels[8] << 56);
  46. STORE(AVG2(pix1, pix2), block);
  47. pixels += line_size;
  48. block += line_size;
  49. } while (--h);
  50. } else {
  51. do {
  52. UINT64 pix1, pix2;
  53. pix1 = ldq(pixels);
  54. pix2 = pix1 >> 8 | ((UINT64) pixels[8] << 56);
  55. STORE(AVG2(pix1, pix2), block);
  56. pixels += line_size;
  57. block += line_size;
  58. } while (--h);
  59. }
  60. }
  61. static void PIXOPNAME(_pixels_y2_axp)(BTYPE *block, const UINT8 *pixels,
  62. int line_size, int h)
  63. {
  64. if ((size_t) pixels & 0x7) {
  65. UINT64 pix = uldq(pixels);
  66. do {
  67. UINT64 next_pix;
  68. pixels += line_size;
  69. next_pix = uldq(pixels);
  70. STORE(AVG2(pix, next_pix), block);
  71. block += line_size;
  72. pix = next_pix;
  73. } while (--h);
  74. } else {
  75. UINT64 pix = ldq(pixels);
  76. do {
  77. UINT64 next_pix;
  78. pixels += line_size;
  79. next_pix = ldq(pixels);
  80. STORE(AVG2(pix, next_pix), block);
  81. block += line_size;
  82. pix = next_pix;
  83. } while (--h);
  84. }
  85. }
  86. /* This could be further sped up by recycling AVG4 intermediate
  87. results from the previous loop pass. */
  88. static void PIXOPNAME(_pixels_xy2_axp)(BTYPE *block, const UINT8 *pixels,
  89. int line_size, int h)
  90. {
  91. if ((size_t) pixels & 0x7) {
  92. UINT64 pix1 = uldq(pixels);
  93. UINT64 pix2 = pix1 >> 8 | ((UINT64) pixels[8] << 56);
  94. do {
  95. UINT64 next_pix1, next_pix2;
  96. pixels += line_size;
  97. next_pix1 = uldq(pixels);
  98. next_pix2 = next_pix1 >> 8 | ((UINT64) pixels[8] << 56);
  99. STORE(AVG4(pix1, pix2, next_pix1, next_pix2), block);
  100. block += line_size;
  101. pix1 = next_pix1;
  102. pix2 = next_pix2;
  103. } while (--h);
  104. } else {
  105. UINT64 pix1 = ldq(pixels);
  106. UINT64 pix2 = pix1 >> 8 | ((UINT64) pixels[8] << 56);
  107. do {
  108. UINT64 next_pix1, next_pix2;
  109. pixels += line_size;
  110. next_pix1 = ldq(pixels);
  111. next_pix2 = next_pix1 >> 8 | ((UINT64) pixels[8] << 56);
  112. STORE(AVG4(pix1, pix2, next_pix1, next_pix2), block);
  113. block += line_size;
  114. pix1 = next_pix1;
  115. pix2 = next_pix2;
  116. } while (--h);
  117. }
  118. }