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.

109 lines
2.9KB

  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 idctin
  30. # undef INIT_CLIP
  31. # undef no_rnd_avg_pixel4
  32. # undef rnd_avg_pixel4
  33. # undef AV_RN2P
  34. # undef AV_RN4P
  35. # undef AV_RN4PA
  36. # undef AV_WN2P
  37. # undef AV_WN4P
  38. # undef AV_WN4PA
  39. # undef CLIP
  40. # undef FUNC
  41. # undef FUNCC
  42. # undef av_clip_pixel
  43. # undef PIXEL_SPLAT_X4
  44. #else
  45. # define AVCODEC_BIT_DEPTH_TEMPLATE_C
  46. #endif
  47. #if BIT_DEPTH > 8
  48. # define pixel uint16_t
  49. # define pixel2 uint32_t
  50. # define pixel4 uint64_t
  51. # define dctcoef int32_t
  52. #ifdef IN_IDCT_DEPTH
  53. #if IN_IDCT_DEPTH == 32
  54. # define idctin int32_t
  55. #else
  56. # define idctin int16_t
  57. #endif
  58. #else
  59. # define idctin int16_t
  60. #endif
  61. # define INIT_CLIP
  62. # define no_rnd_avg_pixel4 no_rnd_avg64
  63. # define rnd_avg_pixel4 rnd_avg64
  64. # define AV_RN2P AV_RN32
  65. # define AV_RN4P AV_RN64
  66. # define AV_RN4PA AV_RN64A
  67. # define AV_WN2P AV_WN32
  68. # define AV_WN4P AV_WN64
  69. # define AV_WN4PA AV_WN64A
  70. # define PIXEL_SPLAT_X4(x) ((x)*0x0001000100010001ULL)
  71. # define av_clip_pixel(a) av_clip_uintp2(a, BIT_DEPTH)
  72. # define CLIP(a) av_clip_uintp2(a, BIT_DEPTH)
  73. #else
  74. # define pixel uint8_t
  75. # define pixel2 uint16_t
  76. # define pixel4 uint32_t
  77. # define dctcoef int16_t
  78. # define idctin int16_t
  79. # define INIT_CLIP
  80. # define no_rnd_avg_pixel4 no_rnd_avg32
  81. # define rnd_avg_pixel4 rnd_avg32
  82. # define AV_RN2P AV_RN16
  83. # define AV_RN4P AV_RN32
  84. # define AV_RN4PA AV_RN32A
  85. # define AV_WN2P AV_WN16
  86. # define AV_WN4P AV_WN32
  87. # define AV_WN4PA AV_WN32A
  88. # define PIXEL_SPLAT_X4(x) ((x)*0x01010101U)
  89. # define av_clip_pixel(a) av_clip_uint8(a)
  90. # define CLIP(a) av_clip_uint8(a)
  91. #endif
  92. #define FUNC3(a, b, c) a ## _ ## b ## c
  93. #define FUNC2(a, b, c) FUNC3(a, b, c)
  94. #define FUNC(a) FUNC2(a, BIT_DEPTH,)
  95. #define FUNCC(a) FUNC2(a, BIT_DEPTH, _c)
  96. #define FUNC4(a, b, c) a ## _int ## b ## _ ## c ## bit
  97. #define FUNC5(a, b, c) FUNC4(a, b, c)
  98. #define FUNC6(a) FUNC5(a, IN_IDCT_DEPTH, BIT_DEPTH)