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.

148 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. #include "pixels.h"
  22. #define DEF_HPEL(OPNAME, OP) \
  23. static inline void FUNCC(OPNAME ## _pixels2)(uint8_t *block, \
  24. const uint8_t *pixels, \
  25. ptrdiff_t line_size, \
  26. int h) \
  27. { \
  28. int i; \
  29. for (i = 0; i < h; i++) { \
  30. OP(*((pixel2 *) block), AV_RN2P(pixels)); \
  31. pixels += line_size; \
  32. block += line_size; \
  33. } \
  34. } \
  35. \
  36. static inline void FUNCC(OPNAME ## _pixels4)(uint8_t *block, \
  37. const uint8_t *pixels, \
  38. ptrdiff_t line_size, \
  39. int h) \
  40. { \
  41. int i; \
  42. for (i = 0; i < h; i++) { \
  43. OP(*((pixel4 *) block), AV_RN4P(pixels)); \
  44. pixels += line_size; \
  45. block += line_size; \
  46. } \
  47. } \
  48. \
  49. static inline void FUNCC(OPNAME ## _pixels8)(uint8_t *block, \
  50. const uint8_t *pixels, \
  51. ptrdiff_t line_size, \
  52. int h) \
  53. { \
  54. int i; \
  55. for (i = 0; i < h; i++) { \
  56. OP(*((pixel4 *) block), AV_RN4P(pixels)); \
  57. OP(*((pixel4 *) (block + 4 * sizeof(pixel))), \
  58. AV_RN4P(pixels + 4 * sizeof(pixel))); \
  59. pixels += line_size; \
  60. block += line_size; \
  61. } \
  62. } \
  63. \
  64. static inline void FUNC(OPNAME ## _pixels8_l2)(uint8_t *dst, \
  65. const uint8_t *src1, \
  66. const uint8_t *src2, \
  67. int dst_stride, \
  68. int src_stride1, \
  69. int src_stride2, \
  70. int h) \
  71. { \
  72. int i; \
  73. for (i = 0; i < h; i++) { \
  74. pixel4 a, b; \
  75. a = AV_RN4P(&src1[i * src_stride1]); \
  76. b = AV_RN4P(&src2[i * src_stride2]); \
  77. OP(*((pixel4 *) &dst[i * dst_stride]), rnd_avg_pixel4(a, b)); \
  78. a = AV_RN4P(&src1[i * src_stride1 + 4 * sizeof(pixel)]); \
  79. b = AV_RN4P(&src2[i * src_stride2 + 4 * sizeof(pixel)]); \
  80. OP(*((pixel4 *) &dst[i * dst_stride + 4 * sizeof(pixel)]), \
  81. rnd_avg_pixel4(a, b)); \
  82. } \
  83. } \
  84. \
  85. static inline void FUNC(OPNAME ## _pixels4_l2)(uint8_t *dst, \
  86. const uint8_t *src1, \
  87. const uint8_t *src2, \
  88. int dst_stride, \
  89. int src_stride1, \
  90. int src_stride2, \
  91. int h) \
  92. { \
  93. int i; \
  94. for (i = 0; i < h; i++) { \
  95. pixel4 a, b; \
  96. a = AV_RN4P(&src1[i * src_stride1]); \
  97. b = AV_RN4P(&src2[i * src_stride2]); \
  98. OP(*((pixel4 *) &dst[i * dst_stride]), rnd_avg_pixel4(a, b)); \
  99. } \
  100. } \
  101. \
  102. static inline void FUNC(OPNAME ## _pixels2_l2)(uint8_t *dst, \
  103. const uint8_t *src1, \
  104. const uint8_t *src2, \
  105. int dst_stride, \
  106. int src_stride1, \
  107. int src_stride2, \
  108. int h) \
  109. { \
  110. int i; \
  111. for (i = 0; i < h; i++) { \
  112. pixel4 a, b; \
  113. a = AV_RN2P(&src1[i * src_stride1]); \
  114. b = AV_RN2P(&src2[i * src_stride2]); \
  115. OP(*((pixel2 *) &dst[i * dst_stride]), rnd_avg_pixel4(a, b)); \
  116. } \
  117. } \
  118. \
  119. static inline void FUNC(OPNAME ## _pixels16_l2)(uint8_t *dst, \
  120. const uint8_t *src1, \
  121. const uint8_t *src2, \
  122. int dst_stride, \
  123. int src_stride1, \
  124. int src_stride2, \
  125. int h) \
  126. { \
  127. FUNC(OPNAME ## _pixels8_l2)(dst, src1, src2, dst_stride, \
  128. src_stride1, src_stride2, h); \
  129. FUNC(OPNAME ## _pixels8_l2)(dst + 8 * sizeof(pixel), \
  130. src1 + 8 * sizeof(pixel), \
  131. src2 + 8 * sizeof(pixel), \
  132. dst_stride, src_stride1, \
  133. src_stride2, h); \
  134. } \
  135. \
  136. CALL_2X_PIXELS(FUNCC(OPNAME ## _pixels16), \
  137. FUNCC(OPNAME ## _pixels8), \
  138. 8 * sizeof(pixel))
  139. #define op_avg(a, b) a = rnd_avg_pixel4(a, b)
  140. #define op_put(a, b) a = b
  141. DEF_HPEL(avg, op_avg)
  142. DEF_HPEL(put, op_put)
  143. #undef op_avg
  144. #undef op_put