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.

81 lines
4.2KB

  1. /*
  2. * This file is part of Libav.
  3. *
  4. * Libav is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU Lesser General Public
  6. * License as published by the Free Software Foundation; either
  7. * version 2.1 of the License, or (at your option) any later version.
  8. *
  9. * Libav is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. * Lesser General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU Lesser General Public
  15. * License along with Libav; if not, write to the Free Software
  16. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  17. */
  18. #include <stddef.h>
  19. #include <stdint.h>
  20. #include "libavutil/intreadwrite.h"
  21. #include "pixels.h"
  22. #include "rnd_avg.h"
  23. #include "bit_depth_template.c"
  24. #define DEF_PEL(OPNAME, OP) \
  25. static inline void FUNCC(OPNAME ## _pixels2)(uint8_t *block, \
  26. const uint8_t *pixels, \
  27. ptrdiff_t line_size, \
  28. int h) \
  29. { \
  30. int i; \
  31. for (i = 0; i < h; i++) { \
  32. OP(*((pixel2 *) block), AV_RN2P(pixels)); \
  33. pixels += line_size; \
  34. block += line_size; \
  35. } \
  36. } \
  37. \
  38. static inline void FUNCC(OPNAME ## _pixels4)(uint8_t *block, \
  39. const uint8_t *pixels, \
  40. ptrdiff_t line_size, \
  41. int h) \
  42. { \
  43. int i; \
  44. for (i = 0; i < h; i++) { \
  45. OP(*((pixel4 *) block), AV_RN4P(pixels)); \
  46. pixels += line_size; \
  47. block += line_size; \
  48. } \
  49. } \
  50. \
  51. static inline void FUNCC(OPNAME ## _pixels8)(uint8_t *block, \
  52. const uint8_t *pixels, \
  53. ptrdiff_t line_size, \
  54. int h) \
  55. { \
  56. int i; \
  57. for (i = 0; i < h; i++) { \
  58. OP(*((pixel4 *) block), AV_RN4P(pixels)); \
  59. OP(*((pixel4 *) (block + 4 * sizeof(pixel))), \
  60. AV_RN4P(pixels + 4 * sizeof(pixel))); \
  61. pixels += line_size; \
  62. block += line_size; \
  63. } \
  64. } \
  65. \
  66. CALL_2X_PIXELS(FUNCC(OPNAME ## _pixels16), \
  67. FUNCC(OPNAME ## _pixels8), \
  68. 8 * sizeof(pixel))
  69. #define op_avg(a, b) a = rnd_avg_pixel4(a, b)
  70. #define op_put(a, b) a = b
  71. DEF_PEL(avg, op_avg)
  72. DEF_PEL(put, op_put)
  73. #undef op_avg
  74. #undef op_put