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.

107 lines
2.9KB

  1. /*
  2. * This file is part of Libav.
  3. *
  4. * Libav 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. * Libav 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 Libav; if not, write to the Free Software
  16. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  17. */
  18. #include "dsputil.h"
  19. #ifndef BIT_DEPTH
  20. #define BIT_DEPTH 8
  21. #endif
  22. #ifdef AVCODEC_H264_HIGH_DEPTH_H
  23. # undef pixel
  24. # undef pixel2
  25. # undef pixel4
  26. # undef dctcoef
  27. # undef INIT_CLIP
  28. # undef no_rnd_avg_pixel4
  29. # undef rnd_avg_pixel4
  30. # undef AV_RN2P
  31. # undef AV_RN4P
  32. # undef AV_RN4PA
  33. # undef AV_WN2P
  34. # undef AV_WN4P
  35. # undef AV_WN4PA
  36. # undef CLIP
  37. # undef FUNC
  38. # undef FUNCC
  39. # undef av_clip_pixel
  40. # undef PIXEL_SPLAT_X4
  41. #else
  42. # define AVCODEC_H264_HIGH_DEPTH_H
  43. # define CLIP_PIXEL(depth)\
  44. static inline uint16_t av_clip_pixel_ ## depth (int p)\
  45. {\
  46. const int pixel_max = (1 << depth)-1;\
  47. return (p & ~pixel_max) ? (-p)>>31 & pixel_max : p;\
  48. }
  49. CLIP_PIXEL( 9)
  50. CLIP_PIXEL(10)
  51. #endif
  52. #if BIT_DEPTH > 8
  53. # define pixel uint16_t
  54. # define pixel2 uint32_t
  55. # define pixel4 uint64_t
  56. # define dctcoef int32_t
  57. # define INIT_CLIP
  58. # define no_rnd_avg_pixel4 no_rnd_avg64
  59. # define rnd_avg_pixel4 rnd_avg64
  60. # define AV_RN2P AV_RN32
  61. # define AV_RN4P AV_RN64
  62. # define AV_RN4PA AV_RN64A
  63. # define AV_WN2P AV_WN32
  64. # define AV_WN4P AV_WN64
  65. # define AV_WN4PA AV_WN64A
  66. # define PIXEL_SPLAT_X4(x) ((x)*0x0001000100010001ULL)
  67. #else
  68. # define pixel uint8_t
  69. # define pixel2 uint16_t
  70. # define pixel4 uint32_t
  71. # define dctcoef int16_t
  72. # define INIT_CLIP uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
  73. # define no_rnd_avg_pixel4 no_rnd_avg32
  74. # define rnd_avg_pixel4 rnd_avg32
  75. # define AV_RN2P AV_RN16
  76. # define AV_RN4P AV_RN32
  77. # define AV_RN4PA AV_RN32A
  78. # define AV_WN2P AV_WN16
  79. # define AV_WN4P AV_WN32
  80. # define AV_WN4PA AV_WN32A
  81. # define PIXEL_SPLAT_X4(x) ((x)*0x01010101U)
  82. #endif
  83. #if BIT_DEPTH == 8
  84. # define av_clip_pixel(a) av_clip_uint8(a)
  85. # define CLIP(a) cm[a]
  86. # define FUNC(a) a ## _8
  87. # define FUNCC(a) a ## _8_c
  88. #elif BIT_DEPTH == 9
  89. # define av_clip_pixel(a) av_clip_pixel_9(a)
  90. # define CLIP(a) av_clip_pixel_9(a)
  91. # define FUNC(a) a ## _9
  92. # define FUNCC(a) a ## _9_c
  93. #elif BIT_DEPTH == 10
  94. # define av_clip_pixel(a) av_clip_pixel_10(a)
  95. # define CLIP(a) av_clip_pixel_10(a)
  96. # define FUNC(a) a ## _10
  97. # define FUNCC(a) a ## _10_c
  98. #endif