unsharp.h 2.6 KB

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