jpeg2000dwt.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /*
  2. * Discrete wavelet transform
  3. * Copyright (c) 2007 Kamil Nowosad
  4. *
  5. * This file is part of FFmpeg.
  6. *
  7. * FFmpeg is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU Lesser General Public
  9. * License as published by the Free Software Foundation; either
  10. * version 2.1 of the License, or (at your option) any later version.
  11. *
  12. * FFmpeg is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * Lesser General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Lesser General Public
  18. * License along with FFmpeg; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  20. */
  21. #ifndef AVCODEC_JPEG2000DWT_H
  22. #define AVCODEC_JPEG2000DWT_H
  23. /**
  24. * @file
  25. * Discrete wavelet transform
  26. */
  27. #include <stdint.h>
  28. #define FF_DWT_MAX_DECLVLS 32 ///< max number of decomposition levels
  29. #define F_LFTG_K 1.230174104914001f
  30. #define F_LFTG_X 0.812893066115961f
  31. enum DWTType {
  32. FF_DWT97,
  33. FF_DWT53,
  34. FF_DWT97_INT,
  35. FF_DWT_NB
  36. };
  37. typedef struct DWTContext {
  38. /// line lengths { horizontal, vertical } in consecutive decomposition levels
  39. int linelen[FF_DWT_MAX_DECLVLS][2];
  40. uint8_t mod[FF_DWT_MAX_DECLVLS][2]; ///< coordinates (x0, y0) of decomp. levels mod 2
  41. uint8_t ndeclevels; ///< number of decomposition levels
  42. uint8_t type; ///< 0 for 9/7; 1 for 5/3
  43. int32_t *i_linebuf; ///< int buffer used by transform
  44. float *f_linebuf; ///< float buffer used by transform
  45. } DWTContext;
  46. /**
  47. * Initialize DWT.
  48. * @param s DWT context
  49. * @param border coordinates of transformed region {{x0, x1}, {y0, y1}}
  50. * @param decomp_levels number of decomposition levels
  51. * @param type 0 for DWT 9/7; 1 for DWT 5/3
  52. */
  53. int ff_jpeg2000_dwt_init(DWTContext *s, int border[2][2],
  54. int decomp_levels, int type);
  55. int ff_dwt_encode(DWTContext *s, void *t);
  56. int ff_dwt_decode(DWTContext *s, void *t);
  57. void ff_dwt_destroy(DWTContext *s);
  58. #endif /* AVCODEC_JPEG2000DWT_H */