blockdsp.c 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /*
  2. * Copyright (c) 2015 Henrik Gramner
  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/blockdsp.h"
  23. #include "libavutil/common.h"
  24. #include "libavutil/internal.h"
  25. #include "libavutil/intreadwrite.h"
  26. #define randomize_buffers(size) \
  27. do { \
  28. int i; \
  29. for (i = 0; i < size; i++) { \
  30. uint16_t r = rnd(); \
  31. AV_WN16A(buf0 + i, r); \
  32. AV_WN16A(buf1 + i, r); \
  33. } \
  34. } while (0)
  35. #define check_clear(func, size) \
  36. do { \
  37. if (check_func(h.func, "blockdsp." #func)) { \
  38. declare_func_emms(AV_CPU_FLAG_MMX, void, int16_t *block); \
  39. randomize_buffers(size); \
  40. call_ref(buf0); \
  41. call_new(buf1); \
  42. if (memcmp(buf0, buf1, sizeof(*buf0) * size)) \
  43. fail(); \
  44. bench_new(buf0); \
  45. } \
  46. } while (0)
  47. void checkasm_check_blockdsp(void)
  48. {
  49. LOCAL_ALIGNED_16(uint16_t, buf0, [6 * 8 * 8]);
  50. LOCAL_ALIGNED_16(uint16_t, buf1, [6 * 8 * 8]);
  51. AVCodecContext avctx = { 0 };
  52. BlockDSPContext h;
  53. ff_blockdsp_init(&h, &avctx);
  54. check_clear(clear_block, 8 * 8);
  55. check_clear(clear_blocks, 8 * 8 * 6);
  56. report("blockdsp");
  57. }