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.

127 lines
3.9KB

  1. /*
  2. * Copyright (C) 2004-2010 Michael Niedermayer <michaelni@gmx.at>
  3. *
  4. * This file is part of FFmpeg.
  5. *
  6. * FFmpeg is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 2.1 of the License, or (at your option) any later version.
  10. *
  11. * FFmpeg is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public
  17. * License along with FFmpeg; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  19. */
  20. #ifndef AVCODEC_DIRAC_DWT_H
  21. #define AVCODEC_DIRAC_DWT_H
  22. #include <stdint.h>
  23. typedef int DWTELEM;
  24. typedef short IDWTELEM;
  25. #define MAX_DWT_SUPPORT 8
  26. #define MAX_DECOMPOSITIONS 8
  27. typedef struct DWTCompose {
  28. IDWTELEM *b[MAX_DWT_SUPPORT];
  29. int y;
  30. } DWTCompose;
  31. struct DWTContext;
  32. // Possible prototypes for vertical_compose functions
  33. typedef void (*vertical_compose_2tap)(IDWTELEM *b0, IDWTELEM *b1, int width);
  34. typedef void (*vertical_compose_3tap)(IDWTELEM *b0, IDWTELEM *b1, IDWTELEM *b2, int width);
  35. typedef void (*vertical_compose_5tap)(IDWTELEM *b0, IDWTELEM *b1, IDWTELEM *b2, IDWTELEM *b3, IDWTELEM *b4, int width);
  36. typedef void (*vertical_compose_9tap)(IDWTELEM *dst, IDWTELEM *b[8], int width);
  37. typedef struct DWTContext {
  38. IDWTELEM *buffer;
  39. IDWTELEM *temp;
  40. int width;
  41. int height;
  42. int stride;
  43. int decomposition_count;
  44. int support;
  45. void (*spatial_compose)(struct DWTContext *cs, int level, int width, int height, int stride);
  46. void (*vertical_compose_l0)(void);
  47. void (*vertical_compose_h0)(void);
  48. void (*vertical_compose_l1)(void);
  49. void (*vertical_compose_h1)(void);
  50. void (*vertical_compose)(void); ///< one set of lowpass and highpass combined
  51. void (*horizontal_compose)(IDWTELEM *b, IDWTELEM *tmp, int width);
  52. DWTCompose cs[MAX_DECOMPOSITIONS];
  53. } DWTContext;
  54. enum dwt_type {
  55. DWT_SNOW_DAUB9_7,
  56. DWT_SNOW_LEGALL5_3,
  57. DWT_DIRAC_DD9_7,
  58. DWT_DIRAC_LEGALL5_3,
  59. DWT_DIRAC_DD13_7,
  60. DWT_DIRAC_HAAR0,
  61. DWT_DIRAC_HAAR1,
  62. DWT_DIRAC_FIDELITY,
  63. DWT_DIRAC_DAUB9_7,
  64. DWT_NUM_TYPES
  65. };
  66. // -1 if an error occurred, e.g. the dwt_type isn't recognized
  67. int ff_spatial_idwt_init2(DWTContext *d, IDWTELEM *buffer, int width, int height,
  68. int stride, enum dwt_type type, int decomposition_count,
  69. IDWTELEM *temp);
  70. int ff_spatial_idwt2(IDWTELEM *buffer, int width, int height, int stride,
  71. enum dwt_type type, int decomposition_count, IDWTELEM *temp);
  72. void ff_spatial_idwt_slice2(DWTContext *d, int y);
  73. // shared stuff for simd optimiztions
  74. #define COMPOSE_53iL0(b0, b1, b2)\
  75. (b1 - ((b0 + b2 + 2) >> 2))
  76. #define COMPOSE_DIRAC53iH0(b0, b1, b2)\
  77. (b1 + ((b0 + b2 + 1) >> 1))
  78. #define COMPOSE_DD97iH0(b0, b1, b2, b3, b4)\
  79. (b2 + ((-b0 + 9*b1 + 9*b3 - b4 + 8) >> 4))
  80. #define COMPOSE_DD137iL0(b0, b1, b2, b3, b4)\
  81. (b2 - ((-b0 + 9*b1 + 9*b3 - b4 + 16) >> 5))
  82. #define COMPOSE_HAARiL0(b0, b1)\
  83. (b0 - ((b1 + 1) >> 1))
  84. #define COMPOSE_HAARiH0(b0, b1)\
  85. (b0 + b1)
  86. #define COMPOSE_FIDELITYiL0(b0, b1, b2, b3, b4, b5, b6, b7, b8)\
  87. (b4 - ((-8*(b0+b8) + 21*(b1+b7) - 46*(b2+b6) + 161*(b3+b5) + 128) >> 8))
  88. #define COMPOSE_FIDELITYiH0(b0, b1, b2, b3, b4, b5, b6, b7, b8)\
  89. (b4 + ((-2*(b0+b8) + 10*(b1+b7) - 25*(b2+b6) + 81*(b3+b5) + 128) >> 8))
  90. #define COMPOSE_DAUB97iL1(b0, b1, b2)\
  91. (b1 - ((1817*(b0 + b2) + 2048) >> 12))
  92. #define COMPOSE_DAUB97iH1(b0, b1, b2)\
  93. (b1 - (( 113*(b0 + b2) + 64) >> 7))
  94. #define COMPOSE_DAUB97iL0(b0, b1, b2)\
  95. (b1 + (( 217*(b0 + b2) + 2048) >> 12))
  96. #define COMPOSE_DAUB97iH0(b0, b1, b2)\
  97. (b1 + ((6497*(b0 + b2) + 2048) >> 12))
  98. #endif /* AVCODEC_DWT_H */