2
0

idctdsp.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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. #ifndef AVCODEC_IDCTDSP_H
  19. #define AVCODEC_IDCTDSP_H
  20. #include <stdint.h>
  21. #include "config.h"
  22. #include "avcodec.h"
  23. /**
  24. * Scantable.
  25. */
  26. typedef struct ScanTable {
  27. const uint8_t *scantable;
  28. uint8_t permutated[64];
  29. uint8_t raster_end[64];
  30. } ScanTable;
  31. enum idct_permutation_type {
  32. FF_IDCT_PERM_NONE,
  33. FF_IDCT_PERM_LIBMPEG2,
  34. FF_IDCT_PERM_SIMPLE,
  35. FF_IDCT_PERM_TRANSPOSE,
  36. FF_IDCT_PERM_PARTTRANS,
  37. FF_IDCT_PERM_SSE2,
  38. };
  39. void ff_init_scantable(uint8_t *permutation, ScanTable *st,
  40. const uint8_t *src_scantable);
  41. void ff_init_scantable_permutation(uint8_t *idct_permutation,
  42. enum idct_permutation_type perm_type);
  43. int ff_init_scantable_permutation_x86(uint8_t *idct_permutation,
  44. enum idct_permutation_type perm_type);
  45. typedef struct IDCTDSPContext {
  46. /* pixel ops : interface with DCT */
  47. void (*put_pixels_clamped)(const int16_t *block /* align 16 */,
  48. uint8_t *av_restrict pixels /* align 8 */,
  49. ptrdiff_t line_size);
  50. void (*put_signed_pixels_clamped)(const int16_t *block /* align 16 */,
  51. uint8_t *av_restrict pixels /* align 8 */,
  52. ptrdiff_t line_size);
  53. void (*add_pixels_clamped)(const int16_t *block /* align 16 */,
  54. uint8_t *av_restrict pixels /* align 8 */,
  55. ptrdiff_t line_size);
  56. void (*idct)(int16_t *block /* align 16 */);
  57. /**
  58. * block -> idct -> clip to unsigned 8 bit -> dest.
  59. * (-1392, 0, 0, ...) -> idct -> (-174, -174, ...) -> put -> (0, 0, ...)
  60. * @param line_size size in bytes of a horizontal line of dest
  61. */
  62. void (*idct_put)(uint8_t *dest /* align 8 */,
  63. ptrdiff_t line_size, int16_t *block /* align 16 */);
  64. /**
  65. * block -> idct -> add dest -> clip to unsigned 8 bit -> dest.
  66. * @param line_size size in bytes of a horizontal line of dest
  67. */
  68. void (*idct_add)(uint8_t *dest /* align 8 */,
  69. ptrdiff_t line_size, int16_t *block /* align 16 */);
  70. /**
  71. * IDCT input permutation.
  72. * Several optimized IDCTs need a permutated input (relative to the
  73. * normal order of the reference IDCT).
  74. * This permutation must be performed before the idct_put/add.
  75. * Note, normally this can be merged with the zigzag/alternate scan<br>
  76. * An example to avoid confusion:
  77. * - (->decode coeffs -> zigzag reorder -> dequant -> reference IDCT -> ...)
  78. * - (x -> reference DCT -> reference IDCT -> x)
  79. * - (x -> reference DCT -> simple_mmx_perm = idct_permutation
  80. * -> simple_idct_mmx -> x)
  81. * - (-> decode coeffs -> zigzag reorder -> simple_mmx_perm -> dequant
  82. * -> simple_idct_mmx -> ...)
  83. */
  84. uint8_t idct_permutation[64];
  85. enum idct_permutation_type perm_type;
  86. int mpeg4_studio_profile;
  87. } IDCTDSPContext;
  88. void ff_put_pixels_clamped_c(const int16_t *block, uint8_t *av_restrict pixels,
  89. ptrdiff_t line_size);
  90. void ff_add_pixels_clamped_c(const int16_t *block, uint8_t *av_restrict pixels,
  91. ptrdiff_t line_size);
  92. void ff_idctdsp_init(IDCTDSPContext *c, AVCodecContext *avctx);
  93. void ff_idctdsp_init_aarch64(IDCTDSPContext *c, AVCodecContext *avctx,
  94. unsigned high_bit_depth);
  95. void ff_idctdsp_init_alpha(IDCTDSPContext *c, AVCodecContext *avctx,
  96. unsigned high_bit_depth);
  97. void ff_idctdsp_init_arm(IDCTDSPContext *c, AVCodecContext *avctx,
  98. unsigned high_bit_depth);
  99. void ff_idctdsp_init_ppc(IDCTDSPContext *c, AVCodecContext *avctx,
  100. unsigned high_bit_depth);
  101. void ff_idctdsp_init_x86(IDCTDSPContext *c, AVCodecContext *avctx,
  102. unsigned high_bit_depth);
  103. void ff_idctdsp_init_mips(IDCTDSPContext *c, AVCodecContext *avctx,
  104. unsigned high_bit_depth);
  105. #endif /* AVCODEC_IDCTDSP_H */