rv40dsp.c 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /*
  2. * Copyright (c) 2024 Institue of Software Chinese Academy of Sciences (ISCAS).
  3. *
  4. * This file is part of FFmpeg.
  5. *
  6. * FFmpeg is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * FFmpeg is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License along
  17. * with FFmpeg; if not, write to the Free Software Foundation, Inc.,
  18. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  19. */
  20. #include <string.h>
  21. #include <stdint.h>
  22. #include "checkasm.h"
  23. #include "libavcodec/rv40dsp.c"
  24. #include "libavutil/mem_internal.h"
  25. #define randomize_buffers() \
  26. do { \
  27. for (int i = 0; i < 16*18*2; i++) \
  28. src[i] = rnd() & 0x3; \
  29. } while (0)
  30. static void check_chroma_mc(void)
  31. {
  32. RV34DSPContext h;
  33. LOCAL_ALIGNED_32(uint8_t, src, [16 * 18 * 2]);
  34. LOCAL_ALIGNED_32(uint8_t, dst0, [16 * 18 * 2]);
  35. LOCAL_ALIGNED_32(uint8_t, dst1, [16 * 18 * 2]);
  36. declare_func_emms(AV_CPU_FLAG_MMX, void, uint8_t *dst, const uint8_t *src,
  37. ptrdiff_t stride, int h, int x, int y);
  38. ff_rv40dsp_init(&h);
  39. randomize_buffers();
  40. for (int size = 0; size < 2; size++) {
  41. #define CHECK_CHROMA_MC(name) \
  42. do { \
  43. if (check_func(h.name## _pixels_tab[size], #name "_mc%d", 1 << (3 - size))) { \
  44. for (int x = 0; x < 2; x++) { \
  45. for (int y = 0; y < 2; y++) { \
  46. memcpy(dst0, src, 16 * 18); \
  47. memcpy(dst1, src, 16 * 18); \
  48. call_ref(dst0, src, 16, 16, x, y); \
  49. call_new(dst1, src, 16, 16, x, y); \
  50. if (memcmp(dst0, dst1, 16 * 16)) { \
  51. fprintf(stderr, #name ": x:%i, y:%i\n", x, y); \
  52. fail(); \
  53. } \
  54. bench_new(dst1, src, 16, 16, x, y); \
  55. } \
  56. } \
  57. } \
  58. } while (0)
  59. CHECK_CHROMA_MC(put_chroma);
  60. CHECK_CHROMA_MC(avg_chroma);
  61. }
  62. }
  63. void checkasm_check_rv40dsp(void)
  64. {
  65. check_chroma_mc();
  66. report("chroma_mc");
  67. }