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.

80 lines
2.4KB

  1. /*
  2. * Copyright (C) 2004-2010 Michael Niedermayer <michaelni@gmx.at>
  3. * Copyright (C) 2008 David Conrad
  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. #include "libavutil/attributes.h"
  22. #include "libavutil/avassert.h"
  23. #include "libavutil/common.h"
  24. #include "dirac_dwt.h"
  25. #define TEMPLATE_8bit
  26. #include "dirac_dwt_template.c"
  27. #define TEMPLATE_10bit
  28. #include "dirac_dwt_template.c"
  29. #define TEMPLATE_12bit
  30. #include "dirac_dwt_template.c"
  31. int ff_spatial_idwt_init(DWTContext *d, DWTPlane *p, enum dwt_type type,
  32. int decomposition_count, int bit_depth)
  33. {
  34. int ret = 0;
  35. d->buffer = p->buf;
  36. d->width = p->width;
  37. d->height = p->height;
  38. d->stride = p->stride;
  39. d->temp = p->tmp;
  40. d->decomposition_count = decomposition_count;
  41. if (bit_depth == 8)
  42. ret = ff_spatial_idwt_init_8bit(d, type);
  43. else if (bit_depth == 10)
  44. ret = ff_spatial_idwt_init_10bit(d, type);
  45. else if (bit_depth == 12)
  46. ret = ff_spatial_idwt_init_12bit(d, type);
  47. else
  48. av_log(NULL, AV_LOG_WARNING, "Unsupported bit depth = %i\n", bit_depth);
  49. if (ret) {
  50. av_log(NULL, AV_LOG_ERROR, "Unknown wavelet type %d\n", type);
  51. return AVERROR_INVALIDDATA;
  52. }
  53. if (ARCH_X86 && bit_depth == 8)
  54. ff_spatial_idwt_init_x86(d, type);
  55. return 0;
  56. }
  57. void ff_spatial_idwt_slice2(DWTContext *d, int y)
  58. {
  59. int level, support = d->support;
  60. for (level = d->decomposition_count-1; level >= 0; level--) {
  61. int wl = d->width >> level;
  62. int hl = d->height >> level;
  63. int stride_l = d->stride << level;
  64. while (d->cs[level].y <= FFMIN((y>>level)+support, hl))
  65. d->spatial_compose(d, level, wl, hl, stride_l);
  66. }
  67. }