v210enc.c 4.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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/v210enc.h"
  23. #include "libavutil/common.h"
  24. #include "libavutil/internal.h"
  25. #include "libavutil/intreadwrite.h"
  26. #define BUF_SIZE 512
  27. #define randomize_buffers(mask) \
  28. do { \
  29. int i, size = sizeof(*y0); \
  30. for (i = 0; i < BUF_SIZE; i += 4 / size) { \
  31. uint32_t r = rnd() & mask; \
  32. AV_WN32A(y0 + i, r); \
  33. AV_WN32A(y1 + i, r); \
  34. } \
  35. for (i = 0; i < BUF_SIZE / 2; i += 4 / size) { \
  36. uint32_t r = rnd() & mask; \
  37. AV_WN32A(u0 + i, r); \
  38. AV_WN32A(u1 + i, r); \
  39. r = rnd() & mask; \
  40. AV_WN32A(v0 + i, r); \
  41. AV_WN32A(v1 + i, r); \
  42. } \
  43. for (i = 0; i < width * 8 / 3; i += 4) { \
  44. uint32_t r = rnd(); \
  45. AV_WN32A(dst0 + i, r); \
  46. AV_WN32A(dst1 + i, r); \
  47. } \
  48. } while (0)
  49. #define check_pack_line(type, mask) \
  50. do { \
  51. LOCAL_ALIGNED_16(type, y0, [BUF_SIZE]); \
  52. LOCAL_ALIGNED_16(type, y1, [BUF_SIZE]); \
  53. LOCAL_ALIGNED_16(type, u0, [BUF_SIZE / 2]); \
  54. LOCAL_ALIGNED_16(type, u1, [BUF_SIZE / 2]); \
  55. LOCAL_ALIGNED_16(type, v0, [BUF_SIZE / 2]); \
  56. LOCAL_ALIGNED_16(type, v1, [BUF_SIZE / 2]); \
  57. LOCAL_ALIGNED_16(uint8_t, dst0, [BUF_SIZE * 8 / 3]); \
  58. LOCAL_ALIGNED_16(uint8_t, dst1, [BUF_SIZE * 8 / 3]); \
  59. \
  60. declare_func(void, const type * y, const type * u, const type * v, \
  61. uint8_t * dst, ptrdiff_t width); \
  62. ptrdiff_t width, step = 12 / sizeof(type); \
  63. \
  64. for (width = step; width < BUF_SIZE - 15; width += step) { \
  65. int y_offset = rnd() & 15; \
  66. int uv_offset = y_offset / 2; \
  67. randomize_buffers(mask); \
  68. call_ref(y0 + y_offset, u0 + uv_offset, v0 + uv_offset, dst0, width); \
  69. call_new(y1 + y_offset, u1 + uv_offset, v1 + uv_offset, dst1, width); \
  70. if (memcmp(y0, y1, BUF_SIZE) || memcmp(u0, u1, BUF_SIZE / 2) || \
  71. memcmp(v0, v1, BUF_SIZE / 2) || memcmp(dst0, dst1, width * 8 / 3)) \
  72. fail(); \
  73. bench_new(y1 + y_offset, u1 + uv_offset, v1 + uv_offset, dst1, width); \
  74. } \
  75. } while (0)
  76. void checkasm_check_v210enc(void)
  77. {
  78. V210EncContext h;
  79. ff_v210enc_init(&h);
  80. if (check_func(h.pack_line_8, "v210_planar_pack_8"))
  81. check_pack_line(uint8_t, 0xffffffff);
  82. if (check_func(h.pack_line_10, "v210_planar_pack_10"))
  83. check_pack_line(uint16_t, 0x03ff03ff);
  84. report("planar_pack");
  85. }