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
3.1KB

  1. /*
  2. * Copyright (c) 2015 Henrik Gramner
  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 "checkasm.h"
  22. #include "libavcodec/h264qpel.h"
  23. #include "libavutil/common.h"
  24. #include "libavutil/intreadwrite.h"
  25. static const uint32_t pixel_mask[3] = { 0xffffffff, 0x01ff01ff, 0x03ff03ff };
  26. #define SIZEOF_PIXEL ((bit_depth + 7) / 8)
  27. #define BUF_SIZE (2 * 16 * (16 + 3 + 4))
  28. #define randomize_buffers() \
  29. do { \
  30. uint32_t mask = pixel_mask[bit_depth - 8]; \
  31. int k; \
  32. for (k = 0; k < BUF_SIZE; k += 4) { \
  33. uint32_t r = rnd() & mask; \
  34. AV_WN32A(buf0 + k, r); \
  35. AV_WN32A(buf1 + k, r); \
  36. r = rnd(); \
  37. AV_WN32A(dst0 + k, r); \
  38. AV_WN32A(dst1 + k, r); \
  39. } \
  40. } while (0)
  41. #define src0 (buf0 + 3 * 2 * 16) /* h264qpel functions read data from negative src pointer offsets */
  42. #define src1 (buf1 + 3 * 2 * 16)
  43. void checkasm_check_h264qpel(void)
  44. {
  45. DECLARE_ALIGNED(16, uint8_t, buf0)[BUF_SIZE];
  46. DECLARE_ALIGNED(16, uint8_t, buf1)[BUF_SIZE];
  47. DECLARE_ALIGNED(16, uint8_t, dst0)[BUF_SIZE];
  48. DECLARE_ALIGNED(16, uint8_t, dst1)[BUF_SIZE];
  49. H264QpelContext h;
  50. int op, bit_depth, i, j;
  51. for (op = 0; op < 2; op++) {
  52. qpel_mc_func (*tab)[16] = op ? h.avg_h264_qpel_pixels_tab : h.put_h264_qpel_pixels_tab;
  53. const char *op_name = op ? "avg" : "put";
  54. for (bit_depth = 8; bit_depth <= 10; bit_depth++) {
  55. ff_h264qpel_init(&h, bit_depth);
  56. for (i = 0; i < (op ? 3 : 4); i++) {
  57. int size = 16 >> i;
  58. for (j = 0; j < 16; j++)
  59. if (check_func(tab[i][j], "%s_h264_qpel_%d_mc%d%d_%d", op_name, size, j & 3, j >> 2, bit_depth)) {
  60. randomize_buffers();
  61. call_ref(dst0, src0, (ptrdiff_t)size * SIZEOF_PIXEL);
  62. call_new(dst1, src1, (ptrdiff_t)size * SIZEOF_PIXEL);
  63. if (memcmp(buf0, buf1, BUF_SIZE) || memcmp(dst0, dst1, BUF_SIZE))
  64. fail();
  65. bench_new(dst1, src1, (ptrdiff_t)size * SIZEOF_PIXEL);
  66. }
  67. }
  68. }
  69. report("%s_h264_qpel", op_name);
  70. }
  71. }