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.

136 lines
4.6KB

  1. /*
  2. * DSP utils
  3. * Copyright (c) 2000, 2001, 2002 Fabrice Bellard
  4. * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at>
  5. *
  6. * This file is part of FFmpeg.
  7. *
  8. * FFmpeg is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU Lesser General Public
  10. * License as published by the Free Software Foundation; either
  11. * version 2.1 of the License, or (at your option) any later version.
  12. *
  13. * FFmpeg is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. * Lesser General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU Lesser General Public
  19. * License along with FFmpeg; if not, write to the Free Software
  20. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  21. */
  22. /**
  23. * @file
  24. * DSP utils.
  25. * Note, many functions in here may use MMX which trashes the FPU state, it is
  26. * absolutely necessary to call emms_c() between DSP & float/double code.
  27. */
  28. #ifndef AVCODEC_DSPUTIL_H
  29. #define AVCODEC_DSPUTIL_H
  30. #include "avcodec.h"
  31. extern uint32_t ff_square_tab[512];
  32. /* minimum alignment rules ;)
  33. * If you notice errors in the align stuff, need more alignment for some ASM code
  34. * for some CPU or need to use a function with less aligned data then send a mail
  35. * to the ffmpeg-devel mailing list, ...
  36. *
  37. * !warning These alignments might not match reality, (missing attribute((align))
  38. * stuff somewhere possible).
  39. * I (Michael) did not check them, these are just the alignments which I think
  40. * could be reached easily ...
  41. *
  42. * !future video codecs might need functions with less strict alignment
  43. */
  44. struct MpegEncContext;
  45. /* Motion estimation:
  46. * h is limited to { width / 2, width, 2 * width },
  47. * but never larger than 16 and never smaller than 2.
  48. * Although currently h < 4 is not used as functions with
  49. * width < 8 are neither used nor implemented. */
  50. typedef int (*me_cmp_func)(struct MpegEncContext *c,
  51. uint8_t *blk1 /* align width (8 or 16) */,
  52. uint8_t *blk2 /* align 1 */, int line_size, int h);
  53. /**
  54. * DSPContext.
  55. */
  56. typedef struct DSPContext {
  57. /* pixel ops : interface with DCT */
  58. void (*get_pixels)(int16_t *block /* align 16 */,
  59. const uint8_t *pixels /* align 8 */,
  60. int line_size);
  61. void (*diff_pixels)(int16_t *block /* align 16 */,
  62. const uint8_t *s1 /* align 8 */,
  63. const uint8_t *s2 /* align 8 */,
  64. int stride);
  65. int (*sum_abs_dctelem)(int16_t *block /* align 16 */);
  66. int (*pix_sum)(uint8_t *pix, int line_size);
  67. int (*pix_norm1)(uint8_t *pix, int line_size);
  68. me_cmp_func sad[6]; /* identical to pix_absAxA except additional void * */
  69. me_cmp_func sse[6];
  70. me_cmp_func hadamard8_diff[6];
  71. me_cmp_func dct_sad[6];
  72. me_cmp_func quant_psnr[6];
  73. me_cmp_func bit[6];
  74. me_cmp_func rd[6];
  75. me_cmp_func vsad[6];
  76. me_cmp_func vsse[6];
  77. me_cmp_func nsse[6];
  78. me_cmp_func w53[6];
  79. me_cmp_func w97[6];
  80. me_cmp_func dct_max[6];
  81. me_cmp_func dct264_sad[6];
  82. me_cmp_func me_pre_cmp[6];
  83. me_cmp_func me_cmp[6];
  84. me_cmp_func me_sub_cmp[6];
  85. me_cmp_func mb_cmp[6];
  86. me_cmp_func ildct_cmp[6]; // only width 16 used
  87. me_cmp_func frame_skip_cmp[6]; // only width 8 used
  88. me_cmp_func pix_abs[2][4];
  89. /* (I)DCT */
  90. void (*fdct)(int16_t *block /* align 16 */);
  91. void (*fdct248)(int16_t *block /* align 16 */);
  92. void (*draw_edges)(uint8_t *buf, int wrap, int width, int height,
  93. int w, int h, int sides);
  94. #define EDGE_WIDTH 16
  95. #define EDGE_TOP 1
  96. #define EDGE_BOTTOM 2
  97. void (*shrink[4])(uint8_t *dst, int dst_wrap, const uint8_t *src,
  98. int src_wrap, int width, int height);
  99. } DSPContext;
  100. void ff_dsputil_static_init(void);
  101. void ff_dsputil_init(DSPContext *p, AVCodecContext *avctx);
  102. void avpriv_dsputil_init(DSPContext* p, AVCodecContext *avctx);
  103. attribute_deprecated void dsputil_init(DSPContext* c, AVCodecContext *avctx);
  104. int ff_check_alignment(void);
  105. void ff_set_cmp(DSPContext *c, me_cmp_func *cmp, int type);
  106. void ff_dsputil_init_alpha(DSPContext* c, AVCodecContext *avctx);
  107. void ff_dsputil_init_arm(DSPContext *c, AVCodecContext *avctx,
  108. unsigned high_bit_depth);
  109. void ff_dsputil_init_ppc(DSPContext *c, AVCodecContext *avctx,
  110. unsigned high_bit_depth);
  111. void ff_dsputil_init_x86(DSPContext *c, AVCodecContext *avctx,
  112. unsigned high_bit_depth);
  113. void ff_dsputil_init_dwt(DSPContext *c);
  114. #endif /* AVCODEC_DSPUTIL_H */