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.

79 lines
2.4KB

  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/hflip.h"
  21. #include "libavutil/intreadwrite.h"
  22. #include "libavutil/mem_internal.h"
  23. #define WIDTH 256
  24. #define WIDTH_PADDED 256 + 32
  25. #define randomize_buffers(buf, size) \
  26. do { \
  27. int j; \
  28. uint8_t *tmp_buf = (uint8_t *)buf;\
  29. for (j = 0; j < size; j++) \
  30. tmp_buf[j] = rnd() & 0xFF; \
  31. } while (0)
  32. static void check_hflip(int step, const char * report_name){
  33. LOCAL_ALIGNED_32(uint8_t, src, [WIDTH_PADDED]);
  34. LOCAL_ALIGNED_32(uint8_t, dst_ref, [WIDTH_PADDED]);
  35. LOCAL_ALIGNED_32(uint8_t, dst_new, [WIDTH_PADDED]);
  36. int w = WIDTH;
  37. int i;
  38. int step_array[4] = {1, 1, 1, 1};
  39. FlipContext s;
  40. declare_func(void, const uint8_t *src, uint8_t *dst, int w);
  41. s.bayer_plus1 = 1;
  42. memset(src, 0, WIDTH_PADDED);
  43. memset(dst_ref, 0, WIDTH_PADDED);
  44. memset(dst_new, 0, WIDTH_PADDED);
  45. randomize_buffers(src, WIDTH_PADDED);
  46. if (step == 2) {
  47. w /= 2;
  48. for (i = 0; i < 4; i++)
  49. step_array[i] = step;
  50. }
  51. ff_hflip_init(&s, step_array, 4);
  52. if (check_func(s.flip_line[0], "hflip_%s", report_name)) {
  53. for (i = 1; i < w; i++) {
  54. call_ref(src + (w - 1) * step, dst_ref, i);
  55. call_new(src + (w - 1) * step, dst_new, i);
  56. if (memcmp(dst_ref, dst_new, i * step))
  57. fail();
  58. }
  59. bench_new(src + (w - 1) * step, dst_new, w);
  60. }
  61. }
  62. void checkasm_check_vf_hflip(void)
  63. {
  64. check_hflip(1, "byte");
  65. report("hflip_byte");
  66. check_hflip(2, "short");
  67. report("hflip_short");
  68. }