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.

107 lines
3.3KB

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