You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

80 lines
2.5KB

  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/avfilter.h"
  21. #include "libavfilter/vf_eq.h"
  22. #include "libavutil/intreadwrite.h"
  23. #define WIDTH 256
  24. #define HEIGHT 256
  25. #define SRC_STRIDE 256
  26. #define PIXELS (WIDTH * HEIGHT)
  27. #define RANDOM_RANGE 80000
  28. #define SCALE 10000
  29. #define randomize_buffers(buf, size) \
  30. do { \
  31. int j; \
  32. uint8_t *tmp_buf = (uint8_t *)buf;\
  33. for (j = 0; j< size; j++) \
  34. tmp_buf[j] = rnd() & 0xFF; \
  35. } while (0)
  36. static void check_eq(void)
  37. {
  38. LOCAL_ALIGNED_32(uint8_t, src, [PIXELS]);
  39. LOCAL_ALIGNED_32(uint8_t, dst_ref, [PIXELS]);
  40. LOCAL_ALIGNED_32(uint8_t, dst_new, [PIXELS]);
  41. int w = WIDTH;
  42. int h = HEIGHT;
  43. int src_stride = SRC_STRIDE;
  44. int dst_stride = SRC_STRIDE;
  45. EQParameters pa;
  46. EQContext eq;
  47. declare_func(void, EQParameters *param, uint8_t *dst, int dst_stride,
  48. const uint8_t *src, int src_stride, int w, int h);
  49. double rand_contrast = (int)(rnd() % (RANDOM_RANGE * 2) - RANDOM_RANGE) /
  50. (SCALE * 1.0);
  51. double rand_brightness = (int)(rnd() % (SCALE * 2) - SCALE) /
  52. (SCALE * 1.0);
  53. pa.contrast = rand_contrast;
  54. pa.brightness = rand_brightness;
  55. memset(dst_ref, 0, PIXELS);
  56. memset(dst_new, 0, PIXELS);
  57. randomize_buffers(src, PIXELS);
  58. ff_eq_init(&eq);
  59. if (check_func(eq.process, "process")) {
  60. call_ref(&pa, dst_ref, dst_stride, src, src_stride, w, h);
  61. call_new(&pa, dst_new, dst_stride, src, src_stride, w, h);
  62. if (memcmp(dst_ref, dst_new, PIXELS))
  63. fail();
  64. bench_new(&pa, dst_new, dst_stride, src, src_stride, w, h);
  65. }
  66. }
  67. void checkasm_check_vf_eq(void)
  68. {
  69. check_eq();
  70. report("eq");
  71. }