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.

146 lines
9.4KB

  1. /*
  2. * Copyright (c) 2000, 2001 Fabrice Bellard
  3. * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at>
  4. *
  5. * This file is part of Libav.
  6. *
  7. * Libav is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU Lesser General Public
  9. * License as published by the Free Software Foundation; either
  10. * version 2.1 of the License, or (at your option) any later version.
  11. *
  12. * Libav is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * Lesser General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Lesser General Public
  18. * License along with Libav; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  20. */
  21. #define DEF_HPEL(OPNAME, OP) \
  22. static inline void FUNCC(OPNAME ## _pixels2)(uint8_t *block, \
  23. const uint8_t *pixels, \
  24. ptrdiff_t line_size, \
  25. int h) \
  26. { \
  27. int i; \
  28. for (i = 0; i < h; i++) { \
  29. OP(*((pixel2 *) block), AV_RN2P(pixels)); \
  30. pixels += line_size; \
  31. block += line_size; \
  32. } \
  33. } \
  34. \
  35. static inline void FUNCC(OPNAME ## _pixels4)(uint8_t *block, \
  36. const uint8_t *pixels, \
  37. ptrdiff_t line_size, \
  38. int h) \
  39. { \
  40. int i; \
  41. for (i = 0; i < h; i++) { \
  42. OP(*((pixel4 *) block), AV_RN4P(pixels)); \
  43. pixels += line_size; \
  44. block += line_size; \
  45. } \
  46. } \
  47. \
  48. static inline void FUNCC(OPNAME ## _pixels8)(uint8_t *block, \
  49. const uint8_t *pixels, \
  50. ptrdiff_t line_size, \
  51. int h) \
  52. { \
  53. int i; \
  54. for (i = 0; i < h; i++) { \
  55. OP(*((pixel4 *) block), AV_RN4P(pixels)); \
  56. OP(*((pixel4 *) (block + 4 * sizeof(pixel))), \
  57. AV_RN4P(pixels + 4 * sizeof(pixel))); \
  58. pixels += line_size; \
  59. block += line_size; \
  60. } \
  61. } \
  62. \
  63. static inline void FUNC(OPNAME ## _pixels8_l2)(uint8_t *dst, \
  64. const uint8_t *src1, \
  65. const uint8_t *src2, \
  66. int dst_stride, \
  67. int src_stride1, \
  68. int src_stride2, \
  69. int h) \
  70. { \
  71. int i; \
  72. for (i = 0; i < h; i++) { \
  73. pixel4 a, b; \
  74. a = AV_RN4P(&src1[i * src_stride1]); \
  75. b = AV_RN4P(&src2[i * src_stride2]); \
  76. OP(*((pixel4 *) &dst[i * dst_stride]), rnd_avg_pixel4(a, b)); \
  77. a = AV_RN4P(&src1[i * src_stride1 + 4 * sizeof(pixel)]); \
  78. b = AV_RN4P(&src2[i * src_stride2 + 4 * sizeof(pixel)]); \
  79. OP(*((pixel4 *) &dst[i * dst_stride + 4 * sizeof(pixel)]), \
  80. rnd_avg_pixel4(a, b)); \
  81. } \
  82. } \
  83. \
  84. static inline void FUNC(OPNAME ## _pixels4_l2)(uint8_t *dst, \
  85. const uint8_t *src1, \
  86. const uint8_t *src2, \
  87. int dst_stride, \
  88. int src_stride1, \
  89. int src_stride2, \
  90. int h) \
  91. { \
  92. int i; \
  93. for (i = 0; i < h; i++) { \
  94. pixel4 a, b; \
  95. a = AV_RN4P(&src1[i * src_stride1]); \
  96. b = AV_RN4P(&src2[i * src_stride2]); \
  97. OP(*((pixel4 *) &dst[i * dst_stride]), rnd_avg_pixel4(a, b)); \
  98. } \
  99. } \
  100. \
  101. static inline void FUNC(OPNAME ## _pixels2_l2)(uint8_t *dst, \
  102. const uint8_t *src1, \
  103. const uint8_t *src2, \
  104. int dst_stride, \
  105. int src_stride1, \
  106. int src_stride2, \
  107. int h) \
  108. { \
  109. int i; \
  110. for (i = 0; i < h; i++) { \
  111. pixel4 a, b; \
  112. a = AV_RN2P(&src1[i * src_stride1]); \
  113. b = AV_RN2P(&src2[i * src_stride2]); \
  114. OP(*((pixel2 *) &dst[i * dst_stride]), rnd_avg_pixel4(a, b)); \
  115. } \
  116. } \
  117. \
  118. static inline void FUNC(OPNAME ## _pixels16_l2)(uint8_t *dst, \
  119. const uint8_t *src1, \
  120. const uint8_t *src2, \
  121. int dst_stride, \
  122. int src_stride1, \
  123. int src_stride2, \
  124. int h) \
  125. { \
  126. FUNC(OPNAME ## _pixels8_l2)(dst, src1, src2, dst_stride, \
  127. src_stride1, src_stride2, h); \
  128. FUNC(OPNAME ## _pixels8_l2)(dst + 8 * sizeof(pixel), \
  129. src1 + 8 * sizeof(pixel), \
  130. src2 + 8 * sizeof(pixel), \
  131. dst_stride, src_stride1, \
  132. src_stride2, h); \
  133. } \
  134. \
  135. CALL_2X_PIXELS(FUNCC(OPNAME ## _pixels16), \
  136. FUNCC(OPNAME ## _pixels8), \
  137. 8 * sizeof(pixel))
  138. #define op_avg(a, b) a = rnd_avg_pixel4(a, b)
  139. #define op_put(a, b) a = b
  140. DEF_HPEL(avg, op_avg)
  141. DEF_HPEL(put, op_put)
  142. #undef op_avg
  143. #undef op_put