unsharp.h 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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. cl_mem cl_luma_mask_x;
  40. cl_mem cl_chroma_mask_x;
  41. cl_mem cl_luma_mask_y;
  42. cl_mem cl_chroma_mask_y;
  43. int in_plane_size[8];
  44. int out_plane_size[8];
  45. int plane_num;
  46. cl_mem cl_inbuf;
  47. size_t cl_inbuf_size;
  48. cl_mem cl_outbuf;
  49. size_t cl_outbuf_size;
  50. int use_fast_kernels;
  51. } UnsharpOpenclContext;
  52. #endif
  53. typedef struct UnsharpFilterParam {
  54. int msize_x; ///< matrix width
  55. int msize_y; ///< matrix height
  56. int amount; ///< effect amount
  57. int steps_x; ///< horizontal step count
  58. int steps_y; ///< vertical step count
  59. int scalebits; ///< bits to shift pixel
  60. int32_t halfscale; ///< amount to add to pixel
  61. uint32_t *sc[MAX_MATRIX_SIZE - 1]; ///< finite state machine storage
  62. } UnsharpFilterParam;
  63. typedef struct UnsharpContext {
  64. const AVClass *class;
  65. int lmsize_x, lmsize_y, cmsize_x, cmsize_y;
  66. float lamount, camount;
  67. UnsharpFilterParam luma; ///< luma parameters (width, height, amount)
  68. UnsharpFilterParam chroma; ///< chroma parameters (width, height, amount)
  69. int hsub, vsub;
  70. int opencl;
  71. #if CONFIG_OPENCL
  72. UnsharpOpenclContext opencl_ctx;
  73. #endif
  74. int (* apply_unsharp)(AVFilterContext *ctx, AVFrame *in, AVFrame *out);
  75. } UnsharpContext;
  76. #endif /* AVFILTER_UNSHARP_H */