deshake.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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_DESHAKE_H
  22. #define AVFILTER_DESHAKE_H
  23. #include "config.h"
  24. #include "avfilter.h"
  25. #include "libavcodec/dsputil.h"
  26. #include "transform.h"
  27. #if CONFIG_OPENCL
  28. #include "libavutil/opencl.h"
  29. #endif
  30. enum SearchMethod {
  31. EXHAUSTIVE, ///< Search all possible positions
  32. SMART_EXHAUSTIVE, ///< Search most possible positions (faster)
  33. SEARCH_COUNT
  34. };
  35. typedef struct {
  36. int x; ///< Horizontal shift
  37. int y; ///< Vertical shift
  38. } IntMotionVector;
  39. typedef struct {
  40. double x; ///< Horizontal shift
  41. double y; ///< Vertical shift
  42. } MotionVector;
  43. typedef struct {
  44. MotionVector vector; ///< Motion vector
  45. double angle; ///< Angle of rotation
  46. double zoom; ///< Zoom percentage
  47. } Transform;
  48. #if CONFIG_OPENCL
  49. typedef struct {
  50. cl_command_queue command_queue;
  51. cl_program program;
  52. cl_kernel kernel_luma;
  53. cl_kernel kernel_chroma;
  54. int in_plane_size[8];
  55. int out_plane_size[8];
  56. int plane_num;
  57. cl_mem cl_inbuf;
  58. size_t cl_inbuf_size;
  59. cl_mem cl_outbuf;
  60. size_t cl_outbuf_size;
  61. } DeshakeOpenclContext;
  62. #endif
  63. typedef struct {
  64. const AVClass *class;
  65. AVFrame *ref; ///< Previous frame
  66. int rx; ///< Maximum horizontal shift
  67. int ry; ///< Maximum vertical shift
  68. int edge; ///< Edge fill method
  69. int blocksize; ///< Size of blocks to compare
  70. int contrast; ///< Contrast threshold
  71. int search; ///< Motion search method
  72. AVCodecContext *avctx;
  73. DSPContext c; ///< Context providing optimized SAD methods
  74. Transform last; ///< Transform from last frame
  75. int refcount; ///< Number of reference frames (defines averaging window)
  76. FILE *fp;
  77. Transform avg;
  78. int cw; ///< Crop motion search to this box
  79. int ch;
  80. int cx;
  81. int cy;
  82. char *filename; ///< Motion search detailed log filename
  83. int opencl;
  84. #if CONFIG_OPENCL
  85. DeshakeOpenclContext opencl_ctx;
  86. #endif
  87. int (* transform)(AVFilterContext *ctx, int width, int height, int cw, int ch,
  88. const float *matrix_y, const float *matrix_uv, enum InterpolateMethod interpolate,
  89. enum FillMethod fill, AVFrame *in, AVFrame *out);
  90. } DeshakeContext;
  91. #endif /* AVFILTER_DESHAKE_H */