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.

79 lines
2.5KB

  1. /*
  2. * Copyright (C) 2013 Wei Gao <weigao@multicorewareinc.com>
  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 AVFILTER_UNSHARP_H
  21. #define AVFILTER_UNSHARP_H
  22. #include "config.h"
  23. #include "avfilter.h"
  24. #if CONFIG_OPENCL
  25. #include "libavutil/opencl.h"
  26. #endif
  27. #define MIN_MATRIX_SIZE 3
  28. #define MAX_MATRIX_SIZE 63
  29. /* right-shift and round-up */
  30. #define SHIFTUP(x,shift) (-((-(x))>>(shift)))
  31. #if CONFIG_OPENCL
  32. typedef struct {
  33. cl_mem cl_luma_mask;
  34. cl_mem cl_chroma_mask;
  35. int in_plane_size[8];
  36. int out_plane_size[8];
  37. int plane_num;
  38. cl_mem cl_inbuf;
  39. size_t cl_inbuf_size;
  40. cl_mem cl_outbuf;
  41. size_t cl_outbuf_size;
  42. AVOpenCLKernelEnv kernel_env;
  43. } UnsharpOpenclContext;
  44. #endif
  45. typedef struct UnsharpFilterParam {
  46. int msize_x; ///< matrix width
  47. int msize_y; ///< matrix height
  48. int amount; ///< effect amount
  49. int steps_x; ///< horizontal step count
  50. int steps_y; ///< vertical step count
  51. int scalebits; ///< bits to shift pixel
  52. int32_t halfscale; ///< amount to add to pixel
  53. uint32_t *sc[MAX_MATRIX_SIZE - 1]; ///< finite state machine storage
  54. } UnsharpFilterParam;
  55. typedef struct {
  56. const AVClass *class;
  57. int lmsize_x, lmsize_y, cmsize_x, cmsize_y;
  58. float lamount, camount;
  59. UnsharpFilterParam luma; ///< luma parameters (width, height, amount)
  60. UnsharpFilterParam chroma; ///< chroma parameters (width, height, amount)
  61. int hsub, vsub;
  62. int opencl;
  63. #if CONFIG_OPENCL
  64. UnsharpOpenclContext opencl_ctx;
  65. #endif
  66. int (* apply_unsharp)(AVFilterContext *ctx, AVFrame *in, AVFrame *out);
  67. } UnsharpContext;
  68. #endif /* AVFILTER_UNSHARP_H */