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.

77 lines
2.1KB

  1. /*
  2. * Copyright (c) 2016 Alexandra Hájková
  3. *
  4. * This file is part of Libav.
  5. *
  6. * Libav 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. * Libav 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 Libav; 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 "libavutil/common.h"
  22. #include "libavutil/intreadwrite.h"
  23. #include "libavutil/mem.h"
  24. #include "libavcodec/huffyuvdsp.h"
  25. #include "checkasm.h"
  26. #define randomize_buffers(buf, size) \
  27. do { \
  28. int j; \
  29. for (j = 0; j < size; j++) \
  30. buf[j] = rnd() & 0xFF; \
  31. } while (0)
  32. static void check_add_bytes(HuffYUVDSPContext c, int width)
  33. {
  34. uint8_t *src0 = av_mallocz(width);
  35. uint8_t *src1 = av_mallocz(width);
  36. uint8_t *dst0 = av_mallocz(width);
  37. uint8_t *dst1 = av_mallocz(width);
  38. declare_func_emms(AV_CPU_FLAG_MMX, void, uint8_t *dst, uint8_t *src, int w);
  39. if (!src0 || !src1 || !dst0 || !dst1)
  40. fail();
  41. randomize_buffers(src0, width);
  42. memcpy(src1, src0, width);
  43. if (check_func(c.add_bytes, "add_bytes")) {
  44. call_ref(dst0, src0, width);
  45. call_new(dst1, src1, width);
  46. if (memcmp(dst0, dst1, width))
  47. fail();
  48. bench_new(dst1, src1, width);
  49. }
  50. av_free(src0);
  51. av_free(src1);
  52. av_free(dst0);
  53. av_free(dst1);
  54. }
  55. void checkasm_check_huffyuvdsp(void)
  56. {
  57. HuffYUVDSPContext c;
  58. int width = 16 * av_clip(rnd(), 16, 128);
  59. ff_huffyuvdsp_init(&c);
  60. check_add_bytes(c, width);
  61. report("add_bytes");
  62. }