jpeg2000dsp.c 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*
  2. * Copyright (c) 2015 James Almer
  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 "checkasm.h"
  21. #include "libavcodec/jpeg2000dsp.h"
  22. #include "libavutil/common.h"
  23. #include "libavutil/internal.h"
  24. #include "libavutil/intreadwrite.h"
  25. #define BUF_SIZE 512
  26. #define randomize_buffers() \
  27. do { \
  28. int i; \
  29. for (i = 0; i < BUF_SIZE; i += 4) { \
  30. uint32_t r = rnd(); \
  31. AV_WN32A(ref0 + i, r); \
  32. AV_WN32A(new0 + i, r); \
  33. r = rnd(); \
  34. AV_WN32A(ref1 + i, r); \
  35. AV_WN32A(new1 + i, r); \
  36. r = rnd(); \
  37. AV_WN32A(ref2 + i, r); \
  38. AV_WN32A(new2 + i, r); \
  39. } \
  40. } while (0)
  41. static void check_mct(uint8_t *ref0, uint8_t *ref1, uint8_t *ref2,
  42. uint8_t *new0, uint8_t *new1, uint8_t *new2) {
  43. declare_func(void, void *src0, void *src1, void *src2, int csize);
  44. randomize_buffers();
  45. call_ref(ref0, ref1, ref2, BUF_SIZE / sizeof(int32_t));
  46. call_new(new0, new1, new2, BUF_SIZE / sizeof(int32_t));
  47. if (memcmp(ref0, new0, BUF_SIZE) || memcmp(ref1, new1, BUF_SIZE) ||
  48. memcmp(ref2, new2, BUF_SIZE))
  49. fail();
  50. bench_new(new0, new1, new2, BUF_SIZE / sizeof(int32_t));
  51. }
  52. void checkasm_check_jpeg2000dsp(void)
  53. {
  54. LOCAL_ALIGNED_32(uint8_t, ref, [BUF_SIZE*3]);
  55. LOCAL_ALIGNED_32(uint8_t, new, [BUF_SIZE*3]);
  56. Jpeg2000DSPContext h;
  57. ff_jpeg2000dsp_init(&h);
  58. if (check_func(h.mct_decode[FF_DWT53], "jpeg2000_rct_int"))
  59. check_mct(&ref[BUF_SIZE*0], &ref[BUF_SIZE*1], &ref[BUF_SIZE*2],
  60. &new[BUF_SIZE*0], &new[BUF_SIZE*1], &new[BUF_SIZE*2]);
  61. report("mct_decode");
  62. }