vf_gblur.c 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /*
  2. * This file is part of FFmpeg.
  3. *
  4. * FFmpeg is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 2 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * FFmpeg 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
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License along
  15. * with FFmpeg; if not, write to the Free Software Foundation, Inc.,
  16. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  17. */
  18. #include <string.h>
  19. #include "checkasm.h"
  20. #include "libavfilter/gblur.h"
  21. #define WIDTH 256
  22. #define HEIGHT 256
  23. #define PIXELS (WIDTH * HEIGHT)
  24. #define BUF_SIZE (PIXELS * 4)
  25. #define randomize_buffers(buf, size) \
  26. do { \
  27. int j; \
  28. float *tmp_buf = (float *)buf; \
  29. for (j = 0; j < size; j++) \
  30. tmp_buf[j] = (float)(rnd() & 0xFF); \
  31. } while (0)
  32. void checkasm_check_vf_gblur(void)
  33. {
  34. float *dst_ref = av_malloc(BUF_SIZE);
  35. float *dst_new = av_malloc(BUF_SIZE);
  36. int w = WIDTH;
  37. int h = HEIGHT;
  38. int steps = 2;
  39. float nu = 0.101f;
  40. float bscale = 1.112f;
  41. GBlurContext s;
  42. declare_func(void, float *dst, int w, int h, int steps, float nu, float bscale);
  43. randomize_buffers(dst_ref, PIXELS);
  44. memcpy(dst_new, dst_ref, BUF_SIZE);
  45. ff_gblur_init(&s);
  46. if (check_func(s.horiz_slice, "horiz_slice")) {
  47. call_ref(dst_ref, w, h, steps, nu, bscale);
  48. call_new(dst_new, w, h, steps, nu, bscale);
  49. if (!float_near_abs_eps_array(dst_ref, dst_new, 0.01f, PIXELS)) {
  50. fail();
  51. }
  52. bench_new(dst_new, w, h, 1, nu, bscale);
  53. }
  54. report("horiz_slice");
  55. av_freep(&dst_ref);
  56. av_freep(&dst_new);
  57. }