deshake.h 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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 "transform.h"
  26. #include "libavutil/pixelutils.h"
  27. enum SearchMethod {
  28. EXHAUSTIVE, ///< Search all possible positions
  29. SMART_EXHAUSTIVE, ///< Search most possible positions (faster)
  30. SEARCH_COUNT
  31. };
  32. typedef struct IntMotionVector {
  33. int x; ///< Horizontal shift
  34. int y; ///< Vertical shift
  35. } IntMotionVector;
  36. typedef struct MotionVector {
  37. double x; ///< Horizontal shift
  38. double y; ///< Vertical shift
  39. } MotionVector;
  40. typedef struct Transform {
  41. MotionVector vec; ///< Motion vector
  42. double angle; ///< Angle of rotation
  43. double zoom; ///< Zoom percentage
  44. } Transform;
  45. #define MAX_R 64
  46. typedef struct DeshakeContext {
  47. const AVClass *class;
  48. int counts[2*MAX_R+1][2*MAX_R+1]; /// < Scratch buffer for motion search
  49. double *angles; ///< Scratch buffer for block angles
  50. unsigned angles_size;
  51. AVFrame *ref; ///< Previous frame
  52. int rx; ///< Maximum horizontal shift
  53. int ry; ///< Maximum vertical shift
  54. int edge; ///< Edge fill method
  55. int blocksize; ///< Size of blocks to compare
  56. int contrast; ///< Contrast threshold
  57. int search; ///< Motion search method
  58. av_pixelutils_sad_fn sad; ///< Sum of the absolute difference function
  59. Transform last; ///< Transform from last frame
  60. int refcount; ///< Number of reference frames (defines averaging window)
  61. FILE *fp;
  62. Transform avg;
  63. int cw; ///< Crop motion search to this box
  64. int ch;
  65. int cx;
  66. int cy;
  67. char *filename; ///< Motion search detailed log filename
  68. int opencl;
  69. int (* transform)(AVFilterContext *ctx, int width, int height, int cw, int ch,
  70. const float *matrix_y, const float *matrix_uv, enum InterpolateMethod interpolate,
  71. enum FillMethod fill, AVFrame *in, AVFrame *out);
  72. } DeshakeContext;
  73. #endif /* AVFILTER_DESHAKE_H */