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.

94 lines
2.5KB

  1. /*
  2. * This file is part of FFmpeg.
  3. *
  4. * FFmpeg is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU Lesser General Public
  6. * License as published by the Free Software Foundation; either
  7. * version 2.1 of the License, or (at your option) any later version.
  8. *
  9. * FFmpeg is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. * Lesser General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU Lesser General Public
  15. * License along with FFmpeg; if not, write to the Free Software
  16. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  17. */
  18. #include "mathops.h"
  19. #include "rnd_avg.h"
  20. #include "libavutil/intreadwrite.h"
  21. #ifndef BIT_DEPTH
  22. #define BIT_DEPTH 8
  23. #endif
  24. #ifdef AVCODEC_BIT_DEPTH_TEMPLATE_C
  25. # undef pixel
  26. # undef pixel2
  27. # undef pixel4
  28. # undef dctcoef
  29. # undef INIT_CLIP
  30. # undef no_rnd_avg_pixel4
  31. # undef rnd_avg_pixel4
  32. # undef AV_RN2P
  33. # undef AV_RN4P
  34. # undef AV_RN4PA
  35. # undef AV_WN2P
  36. # undef AV_WN4P
  37. # undef AV_WN4PA
  38. # undef CLIP
  39. # undef FUNC
  40. # undef FUNCC
  41. # undef av_clip_pixel
  42. # undef PIXEL_SPLAT_X4
  43. #else
  44. # define AVCODEC_BIT_DEPTH_TEMPLATE_C
  45. #endif
  46. #if BIT_DEPTH > 8
  47. # define pixel uint16_t
  48. # define pixel2 uint32_t
  49. # define pixel4 uint64_t
  50. # define dctcoef int32_t
  51. # define INIT_CLIP
  52. # define no_rnd_avg_pixel4 no_rnd_avg64
  53. # define rnd_avg_pixel4 rnd_avg64
  54. # define AV_RN2P AV_RN32
  55. # define AV_RN4P AV_RN64
  56. # define AV_RN4PA AV_RN64A
  57. # define AV_WN2P AV_WN32
  58. # define AV_WN4P AV_WN64
  59. # define AV_WN4PA AV_WN64A
  60. # define PIXEL_SPLAT_X4(x) ((x)*0x0001000100010001ULL)
  61. # define av_clip_pixel(a) av_clip_uintp2(a, BIT_DEPTH)
  62. # define CLIP(a) av_clip_uintp2(a, BIT_DEPTH)
  63. #else
  64. # define pixel uint8_t
  65. # define pixel2 uint16_t
  66. # define pixel4 uint32_t
  67. # define dctcoef int16_t
  68. # define INIT_CLIP
  69. # define no_rnd_avg_pixel4 no_rnd_avg32
  70. # define rnd_avg_pixel4 rnd_avg32
  71. # define AV_RN2P AV_RN16
  72. # define AV_RN4P AV_RN32
  73. # define AV_RN4PA AV_RN32A
  74. # define AV_WN2P AV_WN16
  75. # define AV_WN4P AV_WN32
  76. # define AV_WN4PA AV_WN32A
  77. # define PIXEL_SPLAT_X4(x) ((x)*0x01010101U)
  78. # define av_clip_pixel(a) av_clip_uint8(a)
  79. # define CLIP(a) av_clip_uint8(a)
  80. #endif
  81. #define FUNC3(a, b, c) a ## _ ## b ## c
  82. #define FUNC2(a, b, c) FUNC3(a, b, c)
  83. #define FUNC(a) FUNC2(a, BIT_DEPTH,)
  84. #define FUNCC(a) FUNC2(a, BIT_DEPTH, _c)