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.

105 lines
3.2KB

  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. size_t matrix_size;
  50. float matrix_y[9];
  51. float matrix_uv[9];
  52. cl_mem cl_matrix_y;
  53. cl_mem cl_matrix_uv;
  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. AVOpenCLKernelEnv kernel_env;
  62. } DeshakeOpenclContext;
  63. #endif
  64. typedef struct {
  65. const AVClass *class;
  66. AVFrame *ref; ///< Previous frame
  67. int rx; ///< Maximum horizontal shift
  68. int ry; ///< Maximum vertical shift
  69. int edge; ///< Edge fill method
  70. int blocksize; ///< Size of blocks to compare
  71. int contrast; ///< Contrast threshold
  72. int search; ///< Motion search method
  73. AVCodecContext *avctx;
  74. DSPContext c; ///< Context providing optimized SAD methods
  75. Transform last; ///< Transform from last frame
  76. int refcount; ///< Number of reference frames (defines averaging window)
  77. FILE *fp;
  78. Transform avg;
  79. int cw; ///< Crop motion search to this box
  80. int ch;
  81. int cx;
  82. int cy;
  83. char *filename; ///< Motion search detailed log filename
  84. int opencl;
  85. #if CONFIG_OPENCL
  86. DeshakeOpenclContext opencl_ctx;
  87. #endif
  88. int (* transform)(AVFilterContext *ctx, int width, int height, int cw, int ch,
  89. const float *matrix_y, const float *matrix_uv, enum InterpolateMethod interpolate,
  90. enum FillMethod fill, AVFrame *in, AVFrame *out);
  91. } DeshakeContext;
  92. #endif /* AVFILTER_DESHAKE_H */