h263dsp.c 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /*
  2. * Copyright (c) 2024 Rémi Denis-Courmont
  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 "checkasm.h"
  22. #include "libavcodec/h263dsp.h"
  23. #include "libavutil/mem.h"
  24. #include "libavutil/mem_internal.h"
  25. typedef void (*filter)(uint8_t *src, int stride, int qscale);
  26. static void check_loop_filter(char dim, filter func)
  27. {
  28. LOCAL_ALIGNED_16(uint8_t, buf0, [32 * 32]);
  29. LOCAL_ALIGNED_16(uint8_t, buf1, [32 * 32]);
  30. int qscale = rnd() % 32;
  31. declare_func_emms(AV_CPU_FLAG_MMX, void, uint8_t *, int, int);
  32. for (size_t y = 0; y < 32; y++)
  33. for (size_t x = 0; x < 32; x++)
  34. buf0[y * 32 + x] = buf1[y * 32 + x] = rnd();
  35. if (check_func(func, "h263dsp.%c_loop_filter", dim)) {
  36. call_ref(buf0 + 8 * 33, 32, qscale);
  37. call_new(buf1 + 8 * 33, 32, qscale);
  38. if (memcmp(buf0, buf1, 32 * 32))
  39. fail();
  40. bench_new(buf1 + 8 * 33, 32, 1);
  41. }
  42. }
  43. void checkasm_check_h263dsp(void)
  44. {
  45. H263DSPContext ctx;
  46. ff_h263dsp_init(&ctx);
  47. check_loop_filter('h', ctx.h263_h_loop_filter);
  48. check_loop_filter('v', ctx.h263_v_loop_filter);
  49. report("loop_filter");
  50. }