utvideodsp.c 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /*
  2. * Copyright (c) 2017 Jokyo Images
  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/utvideodsp.h"
  23. #include "libavutil/intreadwrite.h"
  24. #include "libavutil/mem_internal.h"
  25. #define WIDTH 240
  26. #define HEIGHT 120
  27. #define WIDTH_PADDED (WIDTH + 16) /* padded to 32 */
  28. #define BUFFER_SIZE (WIDTH_PADDED * HEIGHT)
  29. #define randomize_plane(buf, type) \
  30. do { \
  31. int w, h; \
  32. type * tmp = buf; \
  33. for (h = 0; h < HEIGHT; h++) { \
  34. for (w = 0; w < WIDTH; w++) \
  35. tmp[w] = rnd() & 0xFF; \
  36. tmp += WIDTH_PADDED; \
  37. } \
  38. } while (0)
  39. #define cmp_plane(buf0, buf1, s) \
  40. do { \
  41. int h; \
  42. for (h = 0; h < HEIGHT; h++) { \
  43. if (memcmp(buf0 + h*WIDTH_PADDED, \
  44. buf1 + h*WIDTH_PADDED, WIDTH *s)) \
  45. fail();\
  46. } \
  47. } while (0)
  48. #define CHECK_RESTORE(type)\
  49. LOCAL_ALIGNED_32(type, src_r0, [BUFFER_SIZE]); \
  50. LOCAL_ALIGNED_32(type, src_g0, [BUFFER_SIZE]); \
  51. LOCAL_ALIGNED_32(type, src_b0, [BUFFER_SIZE]); \
  52. LOCAL_ALIGNED_32(type, src_r1, [BUFFER_SIZE]); \
  53. LOCAL_ALIGNED_32(type, src_g1, [BUFFER_SIZE]); \
  54. LOCAL_ALIGNED_32(type, src_b1, [BUFFER_SIZE]); \
  55. declare_func(void, type *src_r, type *src_g, type *src_b, \
  56. ptrdiff_t linesize_r, ptrdiff_t linesize_g, \
  57. ptrdiff_t linesize_b, int width, int height); \
  58. memset(src_r0, 0, BUFFER_SIZE * sizeof(type)); \
  59. memset(src_g0, 0, BUFFER_SIZE * sizeof(type)); \
  60. memset(src_b0, 0, BUFFER_SIZE * sizeof(type)); \
  61. randomize_plane(src_r0, type); \
  62. randomize_plane(src_g0, type); \
  63. randomize_plane(src_b0, type); \
  64. memcpy(src_r1, src_r0, BUFFER_SIZE * sizeof(type)); \
  65. memcpy(src_g1, src_g0, BUFFER_SIZE * sizeof(type)); \
  66. memcpy(src_b1, src_b0, BUFFER_SIZE * sizeof(type)); \
  67. call_ref(src_r0, src_g0, src_b0, WIDTH_PADDED, WIDTH_PADDED, WIDTH_PADDED, WIDTH, HEIGHT);\
  68. call_new(src_r1, src_g1, src_b1, WIDTH_PADDED, WIDTH_PADDED, WIDTH_PADDED, WIDTH, HEIGHT);\
  69. cmp_plane(src_r0, src_r1, sizeof(type)); \
  70. cmp_plane(src_g0, src_g1, sizeof(type)); \
  71. cmp_plane(src_b0, src_b1, sizeof(type)); \
  72. bench_new(src_r1, src_g1, src_b1, WIDTH_PADDED, WIDTH_PADDED, WIDTH_PADDED, WIDTH, HEIGHT)
  73. static void check_restore_rgb_planes(void) {
  74. CHECK_RESTORE(uint8_t);
  75. }
  76. static void check_restore_rgb_planes10(void) {
  77. CHECK_RESTORE(uint16_t);
  78. }
  79. void checkasm_check_utvideodsp(void)
  80. {
  81. UTVideoDSPContext h;
  82. ff_utvideodsp_init(&h);
  83. if (check_func(h.restore_rgb_planes, "restore_rgb_planes"))
  84. check_restore_rgb_planes();
  85. report("restore_rgb_planes");
  86. if (check_func(h.restore_rgb_planes10, "restore_rgb_planes10"))
  87. check_restore_rgb_planes10();
  88. report("restore_rgb_planes10");
  89. }