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.

103 lines
6.2KB

  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 FUNC(OPNAME ## _pixels8_l2)(uint8_t *dst, \
  24. const uint8_t *src1, \
  25. const uint8_t *src2, \
  26. int dst_stride, \
  27. int src_stride1, \
  28. int src_stride2, \
  29. int h) \
  30. { \
  31. int i; \
  32. for (i = 0; i < h; i++) { \
  33. pixel4 a, b; \
  34. a = AV_RN4P(&src1[i * src_stride1]); \
  35. b = AV_RN4P(&src2[i * src_stride2]); \
  36. OP(*((pixel4 *) &dst[i * dst_stride]), rnd_avg_pixel4(a, b)); \
  37. a = AV_RN4P(&src1[i * src_stride1 + 4 * sizeof(pixel)]); \
  38. b = AV_RN4P(&src2[i * src_stride2 + 4 * sizeof(pixel)]); \
  39. OP(*((pixel4 *) &dst[i * dst_stride + 4 * sizeof(pixel)]), \
  40. rnd_avg_pixel4(a, b)); \
  41. } \
  42. } \
  43. \
  44. static inline void FUNC(OPNAME ## _pixels4_l2)(uint8_t *dst, \
  45. const uint8_t *src1, \
  46. const uint8_t *src2, \
  47. int dst_stride, \
  48. int src_stride1, \
  49. int src_stride2, \
  50. int h) \
  51. { \
  52. int i; \
  53. for (i = 0; i < h; i++) { \
  54. pixel4 a, b; \
  55. a = AV_RN4P(&src1[i * src_stride1]); \
  56. b = AV_RN4P(&src2[i * src_stride2]); \
  57. OP(*((pixel4 *) &dst[i * dst_stride]), rnd_avg_pixel4(a, b)); \
  58. } \
  59. } \
  60. \
  61. static inline void FUNC(OPNAME ## _pixels2_l2)(uint8_t *dst, \
  62. const uint8_t *src1, \
  63. const uint8_t *src2, \
  64. int dst_stride, \
  65. int src_stride1, \
  66. int src_stride2, \
  67. int h) \
  68. { \
  69. int i; \
  70. for (i = 0; i < h; i++) { \
  71. pixel4 a, b; \
  72. a = AV_RN2P(&src1[i * src_stride1]); \
  73. b = AV_RN2P(&src2[i * src_stride2]); \
  74. OP(*((pixel2 *) &dst[i * dst_stride]), rnd_avg_pixel4(a, b)); \
  75. } \
  76. } \
  77. \
  78. static inline void FUNC(OPNAME ## _pixels16_l2)(uint8_t *dst, \
  79. const uint8_t *src1, \
  80. const uint8_t *src2, \
  81. int dst_stride, \
  82. int src_stride1, \
  83. int src_stride2, \
  84. int h) \
  85. { \
  86. FUNC(OPNAME ## _pixels8_l2)(dst, src1, src2, dst_stride, \
  87. src_stride1, src_stride2, h); \
  88. FUNC(OPNAME ## _pixels8_l2)(dst + 8 * sizeof(pixel), \
  89. src1 + 8 * sizeof(pixel), \
  90. src2 + 8 * sizeof(pixel), \
  91. dst_stride, src_stride1, \
  92. src_stride2, h); \
  93. } \
  94. #define op_avg(a, b) a = rnd_avg_pixel4(a, b)
  95. #define op_put(a, b) a = b
  96. DEF_HPEL(avg, op_avg)
  97. DEF_HPEL(put, op_put)
  98. #undef op_avg
  99. #undef op_put