riscv_init.c 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /* riscv_init.c - RISC-V Vector optimized filter functions
  2. *
  3. * Copyright (c) 2023 Google LLC
  4. * Written by Dragoș Tiselice <dtiselice@google.com>, May 2023.
  5. * Filip Wasil <f.wasil@samsung.com>, March 2025.
  6. * This code is released under the libpng license.
  7. * For conditions of distribution and use, see the disclaimer
  8. * and license in png.h
  9. */
  10. #include "../pngpriv.h"
  11. #ifdef PNG_READ_SUPPORTED
  12. #if PNG_RISCV_RVV_IMPLEMENTATION == 1
  13. #include <riscv_vector.h>
  14. #ifndef PNG_ALIGNED_MEMORY_SUPPORTED
  15. # error "ALIGNED_MEMORY is required; set: -DPNG_ALIGNED_MEMORY_SUPPORTED"
  16. #endif
  17. void
  18. png_init_filter_functions_rvv(png_structp pp, unsigned int bpp)
  19. {
  20. png_debug(1, "in png_init_filter_functions_rvv");
  21. pp->read_filter[PNG_FILTER_VALUE_UP-1] = png_read_filter_row_up_rvv;
  22. if (bpp == 3)
  23. {
  24. pp->read_filter[PNG_FILTER_VALUE_AVG-1] = png_read_filter_row_avg3_rvv;
  25. pp->read_filter[PNG_FILTER_VALUE_PAETH-1] = png_read_filter_row_paeth3_rvv;
  26. pp->read_filter[PNG_FILTER_VALUE_SUB-1] = png_read_filter_row_sub3_rvv;
  27. }
  28. else if (bpp == 4)
  29. {
  30. pp->read_filter[PNG_FILTER_VALUE_AVG-1] = png_read_filter_row_avg4_rvv;
  31. pp->read_filter[PNG_FILTER_VALUE_PAETH-1] = png_read_filter_row_paeth4_rvv;
  32. pp->read_filter[PNG_FILTER_VALUE_SUB-1] = png_read_filter_row_sub4_rvv;
  33. }
  34. }
  35. #endif /* PNG_RISCV_RVV_IMPLEMENTATION == 1 */
  36. #endif /* PNG_READ_SUPPORTED */