rv34dsp.c 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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 "libavutil/mem.h"
  21. #include "libavutil/mem_internal.h"
  22. #include "libavcodec/rv34dsp.h"
  23. #include "checkasm.h"
  24. #define BUF_SIZE 1024
  25. #define randomize(buf, len) \
  26. do { \
  27. for (int i = 0; i < len; i++) \
  28. buf[i] = rnd(); \
  29. } while (0)
  30. static void test_rv34_inv_transform_dc(RV34DSPContext *s) {
  31. declare_func_emms(AV_CPU_FLAG_MMX, void, int16_t *block);
  32. if (check_func(s->rv34_inv_transform_dc, "rv34_inv_transform_dc")) {
  33. LOCAL_ALIGNED_16(int16_t, p1, [BUF_SIZE]);
  34. LOCAL_ALIGNED_16(int16_t, p2, [BUF_SIZE]);
  35. randomize(p1, BUF_SIZE);
  36. memcpy(p2, p1, BUF_SIZE * sizeof(*p1));
  37. call_ref(p1);
  38. call_new(p2);
  39. if (memcmp(p1, p2, BUF_SIZE * sizeof (*p1)) != 0) {
  40. fail();
  41. }
  42. bench_new(p1);
  43. }
  44. report("rv34_inv_transform_dc");
  45. }
  46. static void test_rv34_idct_dc_add(RV34DSPContext *s) {
  47. declare_func(void, uint8_t *dst, ptrdiff_t stride, int dc);
  48. if (check_func(s->rv34_idct_dc_add, "rv34_idct_dc_add")) {
  49. LOCAL_ALIGNED_16(uint8_t, p1, [BUF_SIZE]);
  50. LOCAL_ALIGNED_16(uint8_t, p2, [BUF_SIZE]);
  51. randomize(p1, BUF_SIZE);
  52. memcpy(p2, p1, BUF_SIZE * sizeof(*p1));
  53. call_ref(p1, 4, 5);
  54. call_new(p2, 4, 5);
  55. if (memcmp(p1, p2, BUF_SIZE * sizeof (*p1)) != 0) {
  56. fail();
  57. }
  58. bench_new(p1, 4, 5);
  59. }
  60. report("rv34_idct_dc_add");
  61. }
  62. void checkasm_check_rv34dsp(void)
  63. {
  64. RV34DSPContext s = { 0 };
  65. ff_rv34dsp_init(&s);
  66. test_rv34_inv_transform_dc(&s);
  67. test_rv34_idct_dc_add(&s);
  68. }